Part of #1971384: [META] Convert page callbacks to controllers

For instructions on how to convert a page callback into a controller, see the WSCCI Conversion Guide.

CommentFileSizeAuthor
#109 1987762-node-add-page-108.patch8.6 KBvijaycs85
#109 1987762-diff-107-108.txt1.63 KBvijaycs85
#107 1987762-node-add-page-107.patch8.58 KBvijaycs85
#107 1987762-diff-105-107.txt2.01 KBvijaycs85
#105 1987762-node-add-page-105.patch8.56 KBkim.pepper
#101 1987762-diff-99-101.txt901 bytesvijaycs85
#101 1987762-node-add-page-101.patch8.57 KBvijaycs85
#99 1987762-diff-94-99.txt1.72 KBvijaycs85
#99 1987762-node-add-page-99.patch8.33 KBvijaycs85
#95 1987762-node-add-page-94.patch8.96 KBvijaycs85
#92 drupal8.node-module.1987762-92.patch10.02 KBgoogletorp
#88 drupal8.node-module.1987762-88.patch15.7 KBdisasm
#83 drupal8.node-module.1987762-83.patch16.16 KBdisasm
#83 interdiff.txt2.17 KBdisasm
#81 drupal8.node-module.1987762-combined.patch23.03 KBdisasm
#75 node-1987762-75.patch16.16 KBtim.plunkett
#75 interdiff.txt4.98 KBtim.plunkett
#74 drupal8.node-module.1987762-74.patch16.53 KBdisasm
#74 interdiff.txt5.7 KBdisasm
#71 drupal8.node-module.1987762-71.patch18.06 KBdisasm
#71 interdiff.txt4.16 KBdisasm
#70 drupal8.node-module.1987762-70.patch19.63 KBdisasm
#68 drupal8.node-module.1987762-67.patch19.65 KBbecw
#68 drupal8.node-module.1987762-67.interdiff.txt1.44 KBbecw
#67 1987762-67-fix.patch19.64 KBwamilton
#67 1987762-67-reroll.patch19.64 KBwamilton
#67 1987762-67-interdiff.txt777 byteswamilton
#61 1987762-61.patch19.66 KBdamiankloip
#61 interdiff-1987762-61.txt3.93 KBdamiankloip
#58 1987762-58.patch19.2 KBdamiankloip
#58 interdiff-1987762-58.txt4.74 KBdamiankloip
#53 1987762-51.patch17.68 KBdamiankloip
#53 interdiff-1987762-51.txt5.23 KBdamiankloip
#47 1987762-47.patch15.1 KBdamiankloip
#47 interdiff-1987762-47.txt2 KBdamiankloip
#45 1987762-45.patch12.84 KBdamiankloip
#45 interdiff-1987762-45.txt5.38 KBdamiankloip
#41 1987762-41.patch10.79 KBdamiankloip
#41 interdiff-1987762-41.txt731 bytesdamiankloip
#35 1987762-35.patch10.79 KBdamiankloip
#35 interdiff-1987762-35.txt3.99 KBdamiankloip
#34 node-1987762-34.patch10.36 KBtim.plunkett
#34 interdiff.txt7.43 KBtim.plunkett
#29 1987762-29.patch7.8 KBdamiankloip
#25 1987762-25.patch7.74 KBdamiankloip
#20 1987762-node_add_page-routing-20.patch7.99 KBvijaycs85
#12 drupal-1987762-12.patch7.85 KBdawehner
#12 interdiff.txt1.09 KBdawehner
#8 drupal-1987762-8.patch8.09 KBdawehner
#8 interdiff.txt1.33 KBdawehner
#6 drupal-1987762-6.patch6.76 KBdawehner
#6 interdiff.txt2.85 KBdawehner
#4 1987762-4.patch7.07 KBdamiankloip
#4 interdiff-1987762-4.txt372 bytesdamiankloip
#2 1987762.patch6.67 KBdamiankloip
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

damiankloip’s picture

Assigned: Unassigned » damiankloip

I'll grab this one too.

damiankloip’s picture

Assigned: damiankloip » Unassigned
Status: Active » Needs review
FileSize
6.67 KB

Status: Needs review » Needs work

The last submitted patch, 1987762.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
372 bytes
7.07 KB

Adding the actual services file, and adding the controller to use helper ALOT.

Status: Needs review » Needs work

The last submitted patch, 1987762-4.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
2.85 KB
6.76 KB
+++ b/core/modules/node/lib/Drupal/node/NodeAddController.phpundefined
@@ -0,0 +1,66 @@
+      return new RedirectResponse('node/add/' . $type->type);

Don't you actually need url('node/add' . $type->type, array('absolute' => TRUE)); on there?

removing the hook_menu entry also feels wrong.

Status: Needs review » Needs work

The last submitted patch, drupal-1987762-6.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.33 KB
8.09 KB

I guess it's sort of okay to reuse this access checker.

damiankloip’s picture

#8: drupal-1987762-8.patch queued for re-testing.

InternetDevels’s picture

@dawehner Maybe it would be better to move from NodeAddAccessCheck contoller to routing.yml requirements param:

+    if (user_access('administer content types')) {
+      // There are no content types defined that the user has permission to create,
+      // but the user does have the permission to administer the content types, so
+      // grant them access to the page anyway.
+      return TRUE;
+    }
requirements:
  _permissions: 'administer content types'

Status: Needs review » Needs work

The last submitted patch, drupal-1987762-8.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
FileSize
1.09 KB
7.85 KB

Good idea. This works fine here, as the access system uses an OR conjunction at the moment.

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, drupal-1987762-12.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#12: drupal-1987762-12.patch queued for re-testing.

Meh, seems random.

Status: Needs review » Needs work

The last submitted patch, drupal-1987762-12.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#12: drupal-1987762-12.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, drupal-1987762-12.patch, failed testing.

damiankloip’s picture

Yeah, sorry, that is an actual legit failure.

dawehner’s picture

Wow, I can't really debug the failure, but I guess once this is a real route this might work out better.

vijaycs85’s picture

Status: Needs work » Needs review
FileSize
7.99 KB

Re-rolling...

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, 1987762-node_add_page-routing-20.patch, failed testing.

The last submitted patch, 1987762-node_add_page-routing-20.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, 1987762-node_add_page-routing-20.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
7.74 KB

Rerolled, and remove ControllerInterface implementation for NodeAddController. We don't need that if we have no deps atm. Or did you put it there in preparation? even so, if we don't need it yet, let's not use it.

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, 1987762-25.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#25: 1987762-25.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, 1987762-25.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
7.8 KB

Rerolled after the RedirectResponse patch.

dawehner’s picture

+++ b/core/modules/node/lib/Drupal/node/Plugin/views/area/ListingEmpty.phpundefined
@@ -23,6 +25,8 @@ class ListingEmpty extends AreaPluginBase {
+    $node_access_checker = new NodeAddAccessCheck();

@@ -32,7 +36,8 @@ public function render($empty = FALSE) {
+        '#access' => $node_access_checker->access(new Route('/node'), \Drupal::request()),

Just wondering whether we should better inject the node add access service/request object?

Status: Needs review » Needs work

The last submitted patch, 1987762-29.patch, failed testing.

dawehner’s picture

Maybe the failure is related with #2021779: Decouple shortcuts from menu links but honestly no idea.

tim.plunkett’s picture

Assigned: Unassigned » tim.plunkett

Stealing this, I have a couple thoughts.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
7.43 KB
10.36 KB

Okay, injected all the things.

damiankloip’s picture

FileSize
3.99 KB
10.79 KB

I think we could remove the last of the procedural functions there and use the url generator. Also Since #1979094: Separate create access operation entity access controllers to avoid costly EntityNG instantiation happened, the createAccess just wants the bundle type I think.

Sorry, I had the patch applied, so this seems easier!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Nice!

Status: Reviewed & tested by the community » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, 1987762-35.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#35: 1987762-35.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, 1987762-35.patch, failed testing.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned

My patch was clearly inferior!
@damiankloip++

damiankloip’s picture

Status: Needs work » Needs review
FileSize
731 bytes
10.79 KB

Ha, I just got lucky this time... :)

Anyway, looks like a schoolboy error in my patch. I guess that's the source of all failures.

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, 1987762-41.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review

#41: 1987762-41.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, 1987762-41.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
5.38 KB
12.84 KB

ok, I found #1987760: Convert node_add() to a new style controller which is for the node_add conversion but was closed as a dupe of this. I think it now makes sense to roll what that patch was meant to be into here too, as they will conflict quite a bit anyway, and adding node_add to this patch isn't massive.

Status: Needs review » Needs work

The last submitted patch, 1987762-45.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
2 KB
15.1 KB

We could extend the NodeAddAccessCheck to check if a node type is present in the request? Then we don;t need another access checker. It would be cool to be able to use _entity_access: 'node.create' but this isn't possible as we wouldn't have a node slug in the path to get upcasted... or can we do some other trickery on the route config like adding 'node: something' or whatever we would need, I doubt that is a. good and b. would work though.

Status: Needs review » Needs work

The last submitted patch, 1987762-47.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review

The EntityCreateAccessCheck was added specifically because we can't use _entity_access: 'foo.create'

dawehner’s picture

+++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.phpundefined
@@ -0,0 +1,154 @@
+    $node = entity_create('node', array(

Let's also use the storage controller.

jibran’s picture

+++ b/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.phpundefined
@@ -0,0 +1,41 @@
+    foreach (node_permissions_get_configured_types() as $type) {

Somehow we can inject this or convert to some helper function in nodeManger. This is just a thought. It is out of scope obviously.

jibran’s picture

+++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.phpundefined
@@ -0,0 +1,153 @@
+      return new RedirectResponse($this->urlGenerator->generate('node_add'));

Why not $this->urlGenerator->generate('node_add', array('node_type' => $type))? Am I missing something?

damiankloip’s picture

FileSize
5.23 KB
17.68 KB

Thanks, made those changes. @jibran, sorry I missed your suggestion form the interdiff, but the actual patch has it in. You're totally right, it needs the node_type.

Also we have a bunch of failing forum tests as forum alters the node form for paths like 'node/add/forum/1' etc... by using arg(3) to set a default forum ID. We can't really use arbitrary arguments on the path anymore so I've converted this to use a forum_id parameter in the query string instead. This should fix those tests again.

jibran’s picture

What about creating nodeTypeManger and move node_permissions_get_configured_types and other helper functions to it? If someone agrees to the idea I can create an issue for this.

damiankloip’s picture

@jibran, having these helpers contained in a class sounds like a good idea to me. It will have to be done at some point anyway. +1

Status: Needs review » Needs work

The last submitted patch, 1987762-51.patch, failed testing.

damiankloip’s picture

Oops, that needed to be $type->type... :?

damiankloip’s picture

Status: Needs work » Needs review
FileSize
4.74 KB
19.2 KB

Hopefully this fixes those fails.

Status: Needs review » Needs work

The last submitted patch, 1987762-58.patch, failed testing.

jibran’s picture

+++ b/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.phpundefined
@@ -0,0 +1,41 @@
+   * {@inheritdoc}

Hmmm I don't know. Can we use @inheritdoc for attributes as well?

+++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.phpundefined
@@ -0,0 +1,169 @@
+    drupal_set_title(t('Create @name', array('@name' => $node_type->name)), PASS_THROUGH);

Let's inject stringTranslationManger as well.

damiankloip’s picture

Status: Needs work » Needs review
FileSize
3.93 KB
19.66 KB

thanks, here are those changes. I think that just leaves the one fail in ShortcutLinksTest, which I'm not sure about the cause of atm.

Status: Needs review » Needs work

The last submitted patch, 1987762-61.patch, failed testing.

tim.plunkett’s picture

Debugging this, the menu_link for node/add is being built wrong:

Drupal\menu_link\Plugin\Core\Entity\MenuLink::__set_state(array(
   'menu_name' => 'shortcut-default',
   'bundle' => 'shortcut',
   'mlid' => '110',
   'uuid' => '60b03dbe-bc79-411f-ad30-48cde382d896',
   'plid' => '0',
   'link_path' => 'admin/config',
   'router_path' => 'admin/config',
   'link_title' => 'Add content',
   'options' => 
  array (
  ),
   'module' => 'menu',
   'hidden' => '0',
   'external' => '0',
   'has_children' => '0',
   'expanded' => '0',
   'weight' => '-20',
   'depth' => '1',
   'customized' => '0',
   'p1' => '110',
   'p2' => '0',
   'p3' => '0',
   'p4' => '0',
   'p5' => '0',
   'p6' => '0',
   'p7' => '0',
   'p8' => '0',
   'p9' => '0',
   'updated' => '0',
   'route_name' => 'node_add_page',
   'routeObject' => 
  Symfony\Component\Routing\Route::__set_state(array(
     'path' => '/node/add',
     'host' => '',
     'schemes' => 
    array (
    ),
     'methods' => 
    array (
    ),
     'defaults' => 
    array (
      '_controller' => '\\Drupal\\node\\Controller\\NodeController::addPage',
    ),
     'requirements' => 
    array (
      '_permission' => 'administer content types',
      '_node_add_access' => 'TRUE',
    ),
     'options' => 
    array (
      'compiler_class' => '\\Drupal\\Core\\Routing\\RouteCompiler',
      '_access_checks' => 
      array (
        0 => 'access_check.permission',
        1 => 'access_check.node.add',
      ),
    ),
     'compiled' => NULL,
  )),
   'langcode' => 'und',
   'entityType' => 'menu_link',
   'enforceIsNew' => NULL,
   'newRevision' => false,
   'isDefaultRevision' => true,
   'path' => 'admin/config',
   'load_functions' => '',
   'to_arg_functions' => '',
   'access_callback' => 'user_access',
   'access_arguments' => 'a:1:{i:0;s:27:"access administration pages";}',
   'page_callback' => 'system_admin_config_page',
   'page_arguments' => 'a:0:{}',
   'fit' => '3',
   'number_parts' => '2',
   'context' => '0',
   'tab_parent' => '',
   'tab_root' => 'admin/config',
   'title' => 'Configuration',
   'title_callback' => 't',
   'title_arguments' => '',
   'theme_callback' => '',
   'theme_arguments' => 'a:0:{}',
   'type' => '6',
   'description' => 'Administer settings.',
   'description_callback' => 't',
   'description_arguments' => '',
   'position' => '',
   'include_file' => 'core/modules/system/system.admin.inc',
   'm_route_name' => '',
   'router_item' => 
  array (
    'weight' => '-20',
  ),
   'in_active_trail' => false,
   'href' => 'admin/config',
))

#2045453: menu_item_route_access() does not catch ResourceNotFoundException helps a bit.

tim.plunkett’s picture

This probably isn't 100% related to #2021779: Decouple shortcuts from menu links, but I bet it would fix this.

damiankloip’s picture

Status: Needs work » Needs review
Issue tags: -WSCCI-conversion

#61: 1987762-61.patch queued for re-testing.

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, 1987762-61.patch, failed testing.

wamilton’s picture

Status: Needs work » Needs review
FileSize
777 bytes
19.64 KB
19.64 KB

Here's a trivial reroll with a trivial fix on top for the account vs _account change that was upsetting the node test cases. Fixes some things, probably not all.

becw’s picture

The _node_add_access property in the route needed some minor tweaks.

[edit: oops, I failed to reload the page before posting this patch]

Status: Needs review » Needs work

The last submitted patch, drupal8.node-module.1987762-67.patch, failed testing.

disasm’s picture

Status: Needs work » Needs review
FileSize
19.63 KB

reroll

disasm’s picture

Cleaning up the NodeController.

Status: Needs review » Needs work

The last submitted patch, drupal8.node-module.1987762-71.patch, failed testing.

tim.plunkett’s picture

  1. +++ b/core/modules/node/lib/Drupal/node/Access/NodeAddAccessCheck.php
    @@ -0,0 +1,43 @@
    +      return $access_controller->createAccess($request->attributes->get('node_type')->type);
    ...
    +        return TRUE;
    ...
    +    }
    +  }
    +
    +}
    

    This needs to return either static::ALLOW or static::DENY

  2. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -0,0 +1,142 @@
    +  protected $urlGenerator;
    ...
    +  protected $entityManager;
    ...
    +  protected $languageManager;
    ...
    +  protected $moduleHandler;
    ...
    +    $this->entityManager = $this->container->get('plugin.manager.entity');
    ...
    +    $this->urlGenerator = $this->container->get('url_generator');
    +    $this->languageManager = $this->container->get('language_manager');
    +    $this->moduleHandler = $this->container->get('module_handler');
    

    These are all on ControllerBase, remove them

  3. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -0,0 +1,142 @@
    +    $this->nodeAccess = $this->entityManager->getAccessController('node');
    +    $this->nodeTypeStorage = $this->entityManager->getStorageController('node_type');
    

    I'm not sure if this will work since setContainer won't have been called.
    Either use create(), put them in protected methods, or just make the calls to entityManager inline.

  4. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -0,0 +1,142 @@
    +      return new RedirectResponse($this->urlGenerator->generate('node_add', array('node_type' => $type->type), TRUE));
    

    $this->redirect()

  5. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -0,0 +1,142 @@
    +    $node = $this->entityManager->getStorageController('node')->create(array(
    

    Either inject this like the rest, or don't

  6. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -0,0 +1,142 @@
    +    drupal_set_title($this->t('Create @name', array('@name' => $node_type->name)), PASS_THROUGH);
    

    use ['#title']

  7. +++ b/core/modules/node/lib/Drupal/node/Plugin/views/area/ListingEmpty.php
    @@ -20,6 +24,52 @@
    +   * @param array $configuration
    

    Missing oneliner

  8. +++ b/core/modules/node/lib/Drupal/node/Plugin/views/area/ListingEmpty.php
    @@ -32,7 +82,8 @@ public function render($empty = FALSE) {
    +        '#access' => $this->nodeAccessChecker->access(new Route('/node'), $this->request),
    

    Use AccessManager::checkNamedRoute() please

  9. +++ b/core/modules/node/node.routing.yml
    @@ -12,6 +12,21 @@ node_page_edit:
    +  requirements:
    +    _permission: 'administer content types'
    +    _node_add_access: 'node'
    

    This needs _access_mode: 'ALL'

disasm’s picture

Status: Needs work » Needs review
FileSize
5.7 KB
16.53 KB

addressing everything but checkNamedRoute. Couldn't find an example of this being done elsewhere, and too late to dig into it now.

tim.plunkett’s picture

FileSize
4.98 KB
16.16 KB

Manually testing helps :)

tim.plunkett’s picture

damiankloip’s picture

+++ b/core/modules/node/node.routing.yml
@@ -12,6 +12,23 @@ node_page_edit:
+    _node_add_access: 'node'
...
+    _node_add_access: 'node:{node_type}'

Not sure about this change, the node add access checker doesn't care about the values of these?

tim.plunkett’s picture

Oh, I didn't even see that added already. That is the syntax for the issue I just mentioned in #76.

damiankloip’s picture

Fair, makes sense. thanks!

Status: Needs review » Needs work

The last submitted patch, node-1987762-75.patch, failed testing.

disasm’s picture

Status: Needs work » Needs review
FileSize
23.03 KB

Since we're using code syntax from that patch, here's a combined to see if it improves tests at all. Future developers, DO NOT use this patch for development. Patch in #75 is the correct one.

Status: Needs review » Needs work

The last submitted patch, drupal8.node-module.1987762-combined.patch, failed testing.

disasm’s picture

Status: Needs work » Needs review
FileSize
2.17 KB
16.16 KB

fixing some issues introduced when I converted this to ControllerBase (incorrectly). Manual testing of creating nodes locally works, so this should pass, or at least be close. It may still need #2068287: Support bundle names provided in the request arguments in EntityCreateAccessCheck to pass all tests.

Status: Needs review » Needs work

The last submitted patch, drupal8.node-module.1987762-83.patch, failed testing.

xjm’s picture

Thanks for your work on this issue! Please see #1971384-43: [META] Convert page callbacks to controllers for an update on the routing system conversion process.

disasm’s picture

Status: Needs work » Needs review
FileSize
15.7 KB

reroll!

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, drupal8.node-module.1987762-88.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: +WSCCI-conversion

The last submitted patch, drupal8.node-module.1987762-88.patch, failed testing.

googletorp’s picture

Status: Needs work » Needs review
FileSize
10.02 KB

Rerolled the patch, but didn't actually fix anything

Status: Needs review » Needs work
Issue tags: -WSCCI-conversion

The last submitted patch, drupal8.node-module.1987762-92.patch, failed testing.

andypost’s picture

  1. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -7,44 +7,74 @@
    +    $account = $request->attributes->get('_account');
    

    use currentUser() here

  2. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -7,44 +7,74 @@
    +    $langcode = $this->moduleHandler()->invoke('language', 'get_default_langcode', array('node', $node_type->type));
    ...
    +      'langcode' => $langcode ? $langcode : $this->languageManager()->getLanguage()->id,
    

    seems better to use language manager, related #1966436: Default *content* entity languages are not set for entities created with the API

  3. +++ b/core/modules/node/lib/Drupal/node/Plugin/views/area/ListingEmpty.php
    @@ -32,7 +71,7 @@ public function render($empty = FALSE) {
    -        '#access' => _node_add_access()
    +        '#access' => $this->accessManager->checkNamedRoute('node_add_page'),
    
    +++ b/core/modules/node/node.module
    @@ -940,21 +940,6 @@ function _node_revision_access(EntityInterface $node, $op = 'view', $account = N
    -function _node_add_access() {
    -  return \Drupal::service('access_manager')->checkNamedRoute('node.add_page');
    

    dot was lost

  4. +++ b/core/modules/node/node.routing.yml
    @@ -39,9 +40,11 @@ node.view:
    -    _entity_form: 'node.delete'
    +    _title: 'Add page'
    +    _content: '\Drupal\node\Controller\NodeController::addPage'
    ...
    -    _entity_access: 'node.delete'
    +    _permission: 'administer content types'
    +    _node_add_access: 'node'
    

    any reason for?

vijaycs85’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
8.96 KB

Thanks for the review @andypost. Just rerolled with fixes for your comments:

#94.1 - Fixed
#94.2 - not sure what we need to change as it is still it progress
#94.3 - Fixed
#94.4 - Not fixed - seems it is changed as part of review(in #73). will leave if for now until hear from @tim.plunkett

Status: Needs review » Needs work

The last submitted patch, 95: 1987762-node-add-page-94.patch, failed testing.

damiankloip’s picture

  1. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -27,19 +28,65 @@ public function contentOverview() {
    +      return $this->redirect($this->urlGenerator()->generate('node_add', array('node_type' => $type->type), TRUE));
    

    redirect() will call generate() so this will not work. You just need to pass route name, and params into redirect.

  2. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -27,19 +28,65 @@ public function contentOverview() {
    +    $account = \Drupal::currentUser();
    +    $langcode = $this->moduleHandler()->invoke('language', 'get_default_langcode', array('node', $node_type->type));
    ...
    +    $form = $this->entityManager()->getForm($node);
    

    This is still mixing how the services are used.

damiankloip’s picture

vijaycs85’s picture

Status: Needs work » Needs review
FileSize
8.33 KB
1.72 KB

#97.1 - Fixed
#97.2 - Fixed - updated to use ControllerBase::currentUser() instead of Drupal::currentUser() (thanks to @damiankloip for clarifying it on IRC)
#94.4 - Fixed - looks like that was a unintended change on #73

Status: Needs review » Needs work

The last submitted patch, 99: 1987762-node-add-page-99.patch, failed testing.

vijaycs85’s picture

Status: Needs work » Needs review
FileSize
8.57 KB
901 bytes

Seems setting title in add form overriding title set by other places like preview. Removing it and updating title callback to use node_type->name instead of node_type->type.

kim.pepper’s picture

The last submitted patch, 101: 1987762-node-add-page-101.patch, failed testing.

kim.pepper’s picture

kim.pepper’s picture

Issue tags: -Needs reroll
FileSize
8.56 KB

Re-roll. Cleaned up a couple of code style issues.

dawehner’s picture

  1. +++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
    @@ -19,19 +20,63 @@
    +   * @param \Drupal\Core\Entity\EntityInterface $node_type
    ...
       public function add(EntityInterface $node_type) {
    

    In a perfect world (a follow up) we could typehint for the node type interface.

  2. +++ b/core/modules/node/lib/Drupal/node/Plugin/views/area/ListingEmpty.php
    @@ -19,19 +21,57 @@
    +            'title' => t('Add new content'),
    

    We should have $this->t() available.

vijaycs85’s picture

Addressing both issues in #106

andypost’s picture

+++ b/core/modules/node/lib/Drupal/node/Controller/NodeController.php
@@ -57,20 +57,20 @@ public function addPage() {
-  public function add(EntityInterface $node_type) {
+  public function add(NodeInterface $node) {

This change is wrong, should be NodeTypeInterface

vijaycs85’s picture

Updating node_type

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thank you!

The last submitted patch, 107: 1987762-node-add-page-107.patch, failed testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 109: 1987762-node-add-page-108.patch, failed testing.

kim.pepper’s picture

Test failures seem unrelated:

Drupal\rest\Tests\Views\StyleSerializerTest	109	1	0
Drupal\views\Tests\Plugin\DisplayTest	53	1	0
Drupal\views\Tests\Plugin\PagerTest	70	1	0
Drupal\views_ui\Tests\CachedDataUITest	59	1	0
vijaycs85’s picture

Status: Needs work » Needs review
andypost’s picture

Status: Needs review » Reviewed & tested by the community

back to rtbc

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

xjm’s picture

Component: node.module » node system

(Merging "node system" and "node.module" components for 8.x; disregard.)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.