- Issue created by @VladimirAus
- Status changed to Needs review
about 2 years ago 12:05am 2 November 2023 - last update
about 2 years ago 297 pass - last update
about 2 years ago 297 pass - Status changed to Needs work
almost 2 years ago 8:30am 28 November 2023 - 🇩🇪Germany jurgenhaas Gottmadingen
This looks like a great improvement, thanks @VladimirAus for the contribution. The tests are reporting 3 issues, 2 of which a caused by the merge request. The third one is from a different code fraction and should be gone after you've rebased the fork.
- last update
almost 2 years ago 297 pass - last update
almost 2 years ago 297 pass - 🇦🇺Australia jannakha Brisbane!
@VladimirAus:
Weird local vs prod environment issue:
Local works, production throws warnings/errors and crashes out:Error: Call to a member function replaceClear() on null in Drupal\eca_base\Plugin\Action\Title->execute() (line 44 of /app/web/modules/contrib/eca/modules/base/src/Plugin/Action/Title.php).
Warning: Undefined property: Drupal\eca_base\Plugin\Action\Title::$tokenService in Drupal\eca_base\Plugin\Action\Title->execute() (line 44 of /app/web/modules/contrib/eca/modules/base/src/Plugin/Action/Title.php)
#0 /app/web/core/includes/bootstrap.inc(164): _drupal_error_handler_real(2, 'Undefined prope...', '/app/web/module...', 44)
#1 /app/web/modules/contrib/eca/modules/base/src/Plugin/Action/Title.php(44): _drupal_error_handler(2, 'Undefined prope...', '/app/web/module...', 44)
#2 /app/web/modules/contrib/eca/src/Entity/Objects/EcaAction.php(102): Drupal\eca_base\Plugin\Action\Title->execute(NULL)
#3 /app/web/modules/contrib/eca/src/Processor.php(188): Drupal\eca\Entity\Objects\EcaAction->execute(Object(Drupal\eca\Entity\Objects\EcaAction), Object(Drupal\eca_form\Event\FormBuild), Array)
#4 /app/web/modules/contrib/eca/src/Processor.php(190): Drupal\eca\Processor->executeSuccessors(Object(Drupal\eca\Entity\Eca), Object(Drupal\eca\Entity\Objects\EcaAction), Object(Drupal\eca_form\Event\FormBuild), Array)
#5 /app/web/modules/contrib/eca/src/Processor.php(146): Drupal\eca\Processor->executeSuccessors(Object(Drupal\eca\Entity\Eca), Object(Drupal\eca\Entity\Objects\EcaEvent), Object(Drupal\eca_form\Event\FormBuild), Array)
#6 /app/web/modules/contrib/eca/src/EventSubscriber/EcaBase.php(76): Drupal\eca\Processor->execute(Object(Drupal\eca_form\Event\FormBuild), 'eca.form.build')
#7 [internal function]: Drupal\eca\EventSubscriber\EcaBase->onEvent(Object(Drupal\eca_form\Event\FormBuild), 'eca.form.build', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#8 /app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array, Object(Drupal\eca_form\Event\FormBuild), 'eca.form.build', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))
#9 /app/web/modules/contrib/eca/src/Event/TriggerEvent.php(73): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object(Drupal\eca_form\Event\FormBuild), 'eca.form.build')
#10 /app/web/modules/contrib/eca/modules/form/src/HookHandler.php(47): Drupal\eca\Event\TriggerEvent->dispatchFromPlugin('form:form_build', Array, Object(Drupal\Core\Form\FormState))
#11 /app/web/modules/contrib/eca/modules/form/eca_form.module(25): Drupal\eca_form\HookHandler->alter(Array, Object(Drupal\Core\Form\FormState))
#12 /app/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(545): eca_form_form_alter(Array, Object(Drupal\Core\Form\FormState), 'taxonomy_term_r...')
#13 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(840): Drupal\Core\Extension\ModuleHandler->alter('form', Array, Object(Drupal\Core\Form\FormState), 'taxonomy_term_r...')
#14 /app/web/core/lib/Drupal/Core/Form/FormBuilder.php(284): Drupal\Core\Form\FormBuilder->prepareForm('taxonomy_term_r...', Array, Object(Drupal\Core\Form\FormState))
#15 /app/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\taxonomy\TermForm), Object(Drupal\Core\Form\FormState))
#16 /app/web/core/modules/taxonomy/src/Controller/TaxonomyController.php(26): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\taxonomy\Entity\Term))
#17 [internal function]: Drupal\taxonomy\Controller\TaxonomyController->addForm(Object(Drupal\taxonomy\Entity\Vocabulary))
#18 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#19 /app/web/core/lib/Drupal/Core/Render/Renderer.php(592): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#20 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#21 /app/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#22 /app/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#23 /app/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#24 /app/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#26 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#27 /app/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#28 /app/web/core/modules/ban/src/BanMiddleware.php(50): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#29 /app/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\ban\BanMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#30 /app/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#31 /app/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#32 /app/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#33 /app/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#34 {main} - 🇩🇪Germany jurgenhaas Gottmadingen
That sounds like you're using ECA 1.1 on production, while this patch only works with the 2.0.x release.
- 🇩🇪Germany jurgenhaas Gottmadingen
@VladimirAus Any chance to address my questions in #6?
- 🇦🇺Australia VladimirAus Brisbane, Australia
@jurgenhaas Yep, I'm planning to address it in the coming weeks.
No ETA though, sorry. - 🇩🇪Germany jurgenhaas Gottmadingen
@VladimirAus are you coming to DrupalCon Portland? We could then probably address this there.
- 🇩🇪Germany jurgenhaas Gottmadingen
@VladimirAus hope you don't mind a friendly ping.
- 🇦🇺Australia VladimirAus Brisbane, Australia
Still here. Stuck in a rut of Drupal 11 and then jumping on this guy.
@jurgenhaas feel free to ping me. - 🇩🇪Germany jurgenhaas Gottmadingen
I've rebased the MR to the latest dev branch. @VladimirAus maybe this is an issue to be addressed in Singapor?
- 🇩🇪Germany mxh Offenburg
There is a "hidden" layer of how a page title can be set.
There is an anoymous function in
Drupal\Core\Render\MainContent\HtmlRenderer::prepare:<?php $get_title = function (array $main_content) use ($request, $route_match) { return $main_content['#title'] ?? $this->titleResolver->getTitle($request, $route_match->getRouteObject()); }; ?>It fetches the
#titlekey from the main page content render array and uses it when set.
For example, withinDrupal\node\NodeForm::formthe page title of the node edit page is being set as follows:<?php if ($this->operation == 'edit') { $form['#title'] = $this->t('<em>Edit @type</em> @title', [ '@type' => node_get_type_label($node), '@title' => $node->label(), ]); } ?>We could make use of this mechanism, by implementing "Set Title" as a render action so that it is able to get the current render array. Then we are probably able to set the title for example on a "Build form" event.
- 🇩🇪Germany jurgenhaas Gottmadingen
@mxh that sounds interesting, I just wonder where we get the render array from. Does that require an extra event for when the page gets rendered?
Would it otherwise be possible to decorate the
\Drupal\Core\Block\Plugin\Block\PageTitleBlockplugin? - 🇩🇪Germany mxh Offenburg
There is a listener
Drupal\Core\EventSubscriber\MainContentViewSubscriber::onViewRenderArrayon eventSymfony\Component\HttpKernel\KernelEvents::VIEW. Within that listener method, following happens:// For main page content controller methods, this can (but is not forced to be) returning a renderable array. $result = $event->getControllerResult(); // ... $renderer = $this->classResolver->getInstanceFromDefinition($this->mainContentRenderers[$wrapper]); // $wrapper == 'html' -> will be calling \Drupal\Core\Render\MainContent\HtmlRenderer::renderResponse $response = $renderer->renderResponse($result, $request, $this->routeMatch); // ...There is an already existing
"kernel:view"event plugin ineca_misc. It could be extended to reckognize$result = $event->getControllerResult();so in case of a renderable array, it could be instantiated as aDrupal\eca\Event\RenderEventInterface. - 🇩🇪Germany jurgenhaas Gottmadingen
This is a real mess. I've played with the
ViewEventand it looked really promising.There is an already existing "kernel:view" event plugin in eca_misc. It could be extended to reckognize $result = $event->getControllerResult(); so in case of a renderable array, it could be instantiated as a Drupal\eca\Event\RenderEventInterface.
I did something similar by overriding the
#titleproperty in the controller result, if that was a render array. That seemed to work, until I ended up on e.g. a views page which also contains a#pre_renderelement which generates the#titlein the render array at a later stage.The same with nodes: they have a pre render callback to build the title. Whereas user entities use the
#titlerender element, which could be used with this approach.We may have to add our own pre render callback to the end of the list instead and trigger a render event in there?