Updated: Comment #0



function hook_entity_operation_alter(array &$operations, \Drupal\Core\Entity\EntityInterface $entity) {}
was added in
#2004408-34: Allow modules to alter the result of EntityListController::getOperations
(there were some followups for random fails, so the history there is a bit confusing)

That hook was useful in #2004428: Less ugly operations altering

But, the hook did not effect some of the entities.
See #17-#24 in #2004428-17: Less ugly operations altering

#2019647: Use EntityListController for menus was opened because initially the thought was the menu operation was not added because it was not using a List Controller. It is using a list controller, it's injected through, not put in the annotations on the menu entity. (See comment #4 there.)

Proposed resolution

Make the hook work/ change something about Menus so the hook works.

Remaining tasks

User interface changes


API changes


#7 drupal8.menu-system.2023739-7.patch3.58 KBYesCT
PASSED: [[SimpleTest]]: [MySQL] 58,504 pass(es). View
#3 drupal8.menu-system.2023739-3.patch3.56 KBYesCT
FAILED: [[SimpleTest]]: [MySQL] 58,040 pass(es), 1 fail(s), and 0 exception(s). View
Members fund testing for the Drupal project. Drupal Association Learn more


YesCT’s picture

Title: hook_entity_operation_alter() does not work with menu EntityListController » menu: hook_entity_operation_alter() does not work with EntityListController
Gábor Hojtsy’s picture

Issue tags: +D8MI, +language-config

The code in Drupal\menu\MenuListController does not override buildOperations(), where this is implemented in the parent and it extends from Drupal\Core\Config\Entity\ConfigEntityListController as expected. Not sure what is going on here.

Gábor Hojtsy’s picture

Issue summary: View changes

makeing more obvious this is regarding menus, adding related views issue

YesCT’s picture

Status: Active » Needs review
3.56 KB
FAILED: [[SimpleTest]]: [MySQL] 58,040 pass(es), 1 fail(s), and 0 exception(s). View

just a first go to see if this approach of writing a test is even close, and also to get feedback as to the location of the test files.

kfritsche’s picture

Status: Needs review » Active

This works in Core. I tested it with the config_translation module and we could clean up some code there.

$this->buildOperations($entity) is used to create the operations array in the Menu List Controller which issn't used in all Controllers yet.

The test still is useful to not loose this functionality in core.

kfritsche’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, drupal8.menu-system.2023739-3.patch, failed testing.

YesCT’s picture

Status: Needs work » Needs review
3.58 KB
PASSED: [[SimpleTest]]: [MySQL] 58,504 pass(es). View

oops. posted the block patch here with the wrong patch name.

here is the right menu tests.
these should pass as the hook is working with menus now, as @kfritsche says in #4.

No interdiff since this in the right patch this time. It does have some cleanups noticed though.

tim.plunkett’s picture

As I said in #2027857: Blocks operations cannot be altered, this can just be a single test checking all entities with a list controller.

YesCT’s picture

Status: Needs review » Closed (duplicate)

So menus is not failing, and the tests are being added in the other issue. So this is a duplicate of #2027857: Blocks operations cannot be altered.

YesCT’s picture

Issue summary: View changes

added blocks issues