Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot extend 'edit' action with custom action - "Call to a member function all() on array" #6531

Open
Adrriii opened this issue Nov 11, 2024 · 0 comments

Comments

@Adrriii
Copy link

Adrriii commented Nov 11, 2024

Describe the bug
Extending (at least) the edit crud action doesn't seem to work in an AbstractCrudController.

To Reproduce
EasyAdmin v4.15.5

Following the documentation, configure a custom 'linkToCrudAction'

public function configureActions(Actions $actions): Actions
{
	$manageAction = Action::new('manage', 'Manage', 'fa fa-pen')
		 ->linkToCrudAction('manage')
	;

	return $actions
		->add(Crud::PAGE_INDEX, $manageAction)
	;
}

And declare the custom action to simply reuse the 'edit' action, even before making any changes

public function manage(AdminContext $context)
{
	return $this->edit($context);
}

This triggers the error

in vendor/easycorp/easyadmin-bundle/src/Factory/ActionFactory.php (line 44)
in vendor/easycorp/easyadmin-bundle/src/Factory/EntityFactory.php -> processEntityActions (line 56)
in vendor/easycorp/easyadmin-bundle/src/Controller/AbstractCrudController.php -> processActions (line 220)

Expected behavior
Since the class has direct inheritance, and here both the manage and edit methods are triggered in the same way by HttpKernel, passing the AdminContext should also work with minimal side effects.

Rewriting the edit method and its dependencies could ultimately work but is not a good solution.
Maybe something else is wrong and the section about linkToCrudAction could deserve more indications in the docs in how to correctly extend the base behavior of Crud Actions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant