You are here

class BusinessRulesBreadcrumb in Business Rules 8

Same name and namespace in other branches
  1. 2.x src/BusinessRulesBreadcrumb.php \Drupal\business_rules\BusinessRulesBreadcrumb

Adjust the breadcrumbs for the Business Rules module.

@package Drupal\business_rules

Hierarchy

Expanded class hierarchy of BusinessRulesBreadcrumb

1 string reference to 'BusinessRulesBreadcrumb'
business_rules.services.yml in ./business_rules.services.yml
business_rules.services.yml
1 service uses BusinessRulesBreadcrumb
business_rules.breadcrumb in ./business_rules.services.yml
Drupal\business_rules\BusinessRulesBreadcrumb

File

src/BusinessRulesBreadcrumb.php, line 14

Namespace

Drupal\business_rules
View source
class BusinessRulesBreadcrumb extends PathBasedBreadcrumbBuilder {

  /**
   * {@inheritdoc}
   */
  public function applies(RouteMatchInterface $route_match) {
    $route_name = $route_match
      ->getRouteName();
    if (stristr($route_name, 'entity.business_rule')) {
      return TRUE;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function build(RouteMatchInterface $route_match) {

    /** @var \Drupal\Core\Breadcrumb\Breadcrumb $breadcrumb */
    $breadcrumb = parent::build($route_match);
    $route_name = $route_match
      ->getRouteName();
    $breadcrumb
      ->addLink(Link::createFromRoute($this
      ->t('Business Rules'), 'entity.business_rule.collection'));
    if (stristr($route_name, 'entity.business_rules_action')) {
      $breadcrumb
        ->addLink(Link::createFromRoute($this
        ->t('Actions'), 'entity.business_rules_action.collection'));
    }
    elseif (stristr($route_name, 'entity.business_rules_condition')) {
      $breadcrumb
        ->addLink(Link::createFromRoute($this
        ->t('Conditions'), 'entity.business_rules_condition.collection'));
    }
    elseif (stristr($route_name, 'entity.business_rules_variable')) {
      $breadcrumb
        ->addLink(Link::createFromRoute($this
        ->t('Variables'), 'entity.business_rules_variable.collection'));
    }
    return $breadcrumb;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BusinessRulesBreadcrumb::applies public function Whether this breadcrumb builder should be used to build the breadcrumb. Overrides PathBasedBreadcrumbBuilder::applies
BusinessRulesBreadcrumb::build public function Builds the breadcrumb. Overrides PathBasedBreadcrumbBuilder::build
PathBasedBreadcrumbBuilder::$accessManager protected property The menu link access service.
PathBasedBreadcrumbBuilder::$config protected property Site config object.
PathBasedBreadcrumbBuilder::$context protected property The router request context.
PathBasedBreadcrumbBuilder::$currentPath protected property The current path service.
PathBasedBreadcrumbBuilder::$currentUser protected property The current user object.
PathBasedBreadcrumbBuilder::$pathMatcher protected property The patch matcher service.
PathBasedBreadcrumbBuilder::$pathProcessor protected property The inbound path processor.
PathBasedBreadcrumbBuilder::$router protected property The dynamic router service.
PathBasedBreadcrumbBuilder::$titleResolver protected property The title resolver.
PathBasedBreadcrumbBuilder::getRequestForPath protected function Matches a path in the router.
PathBasedBreadcrumbBuilder::__construct public function Constructs the PathBasedBreadcrumbBuilder.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.