From 0b69f2b9fec9a3a4b1c1e462ab67278a71b2f577 Mon Sep 17 00:00:00 2001 From: Chris Weber Date: Wed, 16 May 2018 20:33:29 -0500 Subject: [PATCH] Removing form method will break routing. --- hax.routing.yml | 2 +- src/Controller/HaxController.php | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/hax.routing.yml b/hax.routing.yml index c5f280f..7849c4e 100644 --- a/hax.routing.yml +++ b/hax.routing.yml @@ -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: diff --git a/src/Controller/HaxController.php b/src/Controller/HaxController.php index dc22475..fb78b1b 100644 --- a/src/Controller/HaxController.php +++ b/src/Controller/HaxController.php @@ -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. *