Skip to content

Commit

Permalink
Removing form method will break routing.
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicdreams committed May 17, 2018
1 parent 8c88bfb commit 0b69f2b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion hax.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ hax.node_form:
defaults:
op: update
_title_callback: '\Drupal\hax\Controller\HaxController::title'
_controller: '\Drupal\hax\Controller\HaxController::haxNodeForm'
_controller: '\Drupal\hax\Controller\HaxController::form'
requirements:
_custom_access: '\Drupal\hax\Controller\HaxController::access'
hax.settings:
Expand Down
28 changes: 28 additions & 0 deletions src/Controller/HaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,34 @@ public function title(EntityInterface $node) {
]);
}

/**
* Hax node edit form.
*
* @param \Drupal\Core\Entity\EntityInterface $node
* The node.
* @param string $view_mode
* The node's view mode.
* @param null $langcode
* The node's langcode.
*
* @return array
* The node's view render array.
*
* @todo: There's a good chance this logic isn't invoked.
*/
public function form(EntityInterface $node, $view_mode = 'full', $langcode = NULL) {
// Based on NodeViewController's view() method.
$build = parent::view($node, $view_mode, $langcode);

// This method only seems useful for adding attachments, but not for
// altering. Much of the contents of $build['#node'] are protected
// Is hax_node_view() a better place for altering the node field output?
// Or are there other hooks we're missing?
// TODO maybe just route to the canonical if we end up not actually using
// this controller.
return $build;
}

/**
* Permission + Node access check.
*
Expand Down

0 comments on commit 0b69f2b

Please sign in to comment.