public function YamlFormBreadcrumbBuilder::applies in YAML Form 8
Whether this breadcrumb builder should be used to build the breadcrumb.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
Return value
bool TRUE if this builder should be used or FALSE to let other builders decide.
Overrides BreadcrumbBuilderInterface::applies
File
- src/
BreadCrumb/ YamlFormBreadcrumbBuilder.php, line 30
Class
- YamlFormBreadcrumbBuilder
- Provides a form breadcrumb builder.
Namespace
Drupal\yamlform\BreadCrumbCode
public function applies(RouteMatchInterface $route_match) {
$route_name = $route_match
->getRouteName();
// All routes must begin or contain 'yamlform.
if (strpos($route_name, 'yamlform') === FALSE) {
return FALSE;
}
$args = explode('.', $route_name);
// Skip all config_translation routes except the overview
// and allow Drupal to use the path as the breadcrumb.
if (strpos($route_name, 'config_translation') !== FALSE && $route_name != 'entity.yamlform.config_translation_overview') {
return FALSE;
}
if ($args[0] == 'entity' && ($args[2] == 'yamlform' || $args[2] == 'yamlform_submission')) {
$this->type = 'yamlform_source_entity';
}
elseif (strpos($route_name, 'entity.yamlform.handler.') === 0) {
$this->type = 'yamlform_handler';
}
elseif (strpos($route_name, 'entity.yamlform_ui.element') === 0) {
$this->type = 'yamlform_element';
}
elseif (strpos($route_match
->getRouteName(), 'yamlform.user.submissions') !== FALSE) {
$this->type = 'yamlform_user_submissions';
}
elseif ($route_match
->getParameter('yamlform_submission') instanceof YamlFormSubmissionInterface && strpos($route_name, 'yamlform.user.submission') !== FALSE) {
$this->type = 'yamlform_user_submission';
}
elseif ($route_match
->getParameter('yamlform_submission') instanceof YamlFormSubmissionInterface && $route_match
->getParameter('yamlform_submission')
->access('admin')) {
$this->type = 'yamlform_submission';
}
elseif ($route_match
->getParameter('yamlform') instanceof YamlFormInterface && $route_match
->getParameter('yamlform')
->access('admin')) {
/** @var \Drupal\yamlform\YamlFormInterface $yamlform */
$yamlform = $route_match
->getParameter('yamlform');
$this->type = $yamlform
->isTemplate() && \Drupal::moduleHandler()
->moduleExists('yamlform_templates') ? 'yamlform_template' : 'yamlform';
}
else {
$this->type = NULL;
}
return $this->type ? TRUE : FALSE;
}