public function ViewRevisionsRequest::isValidSourceEntity in Config Entity Revisions 8
Same name and namespace in other branches
- 1.x modules/views_revisions/src/ViewsRevisionsRequest.php \Drupal\views_revisions\ViewRevisionsRequest::isValidSourceEntity()
2 calls to ViewRevisionsRequest::isValidSourceEntity()
- ViewRevisionsRequest::getBaseRouteName in modules/
views_revisions/ src/ ViewsRevisionsRequest.php - ViewRevisionsRequest::getRouteParameters in modules/
views_revisions/ src/ ViewsRevisionsRequest.php
File
- modules/
views_revisions/ src/ ViewsRevisionsRequest.php, line 323
Class
- ViewRevisionsRequest
- Handles view requests.
Namespace
Drupal\views_revisionsCode
public function isValidSourceEntity(EntityInterface $view_entity, EntityInterface $source_entity = NULL) {
// Validate that source entity exists and can be linked to.
if (!$source_entity || !$source_entity
->hasLinkTemplate('canonical')) {
return FALSE;
}
// Get the view.
if ($view_entity instanceof ViewSubmissionInterface) {
$view = $view_entity
->getView();
}
elseif ($view_entity instanceof ViewInterface) {
$view = $view_entity;
}
else {
throw new \InvalidArgumentException('View entity');
}
// Validate that source entity's field target id is the correct view.
$view_target = $this->viewEntityReferenceManager
->getView($source_entity);
if ($view_target && $view_target
->id() == $view
->id()) {
return TRUE;
}
else {
return FALSE;
}
}