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

[4.x] RouteEntity Producer doesn't support views which have a path #1270

Open
ekrokowski opened this issue Mar 21, 2022 · 0 comments
Open

[4.x] RouteEntity Producer doesn't support views which have a path #1270

ekrokowski opened this issue Mar 21, 2022 · 0 comments

Comments

@ekrokowski
Copy link

The RouteEntity producer currently only works with entities with route name of format anything.TYPE_NAME.anything.
Code which shows that (RouteEntity.php):

[, $type] = explode('.', $url->getRouteName());
$parameters = $url->getRouteParameters();
$id = $parameters[$type];
$resolver = $this->entityBuffer->add($type, $id);

This does not work with views which have a path assigned, because views have the following routename format: view.VIEW_ID.PAGE_ID.
When you use the RouteEntity producer on a path which translates to a view, it will throw an error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "__SOME_VIEW_ID__" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (Line 143 in /docroot/core/lib/Drupal/Core/Entity/EntityTypeManager.php).

There should be a check implemented for entity / view. Something like this:

[$baseType, $type] = explode('.', $url->getRouteName());

if ($baseType === 'entity') {
    $parameters = $url->getRouteParameters();
    $id = $parameters[$type];
} else if ($baseType === 'view') {
    // View routeNames have format 'view.VIEW_ID.PAGE_ID'
    $id = $type;
    $type = 'view';
} else {
    return NULL;
}

$resolver = $this->entityBuffer->add($type, $id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants