You are here

class RouteProcessor in Ubercart 8.4

Processes the outbound path by resolving it to the catalog page.

Hierarchy

Expanded class hierarchy of RouteProcessor

1 string reference to 'RouteProcessor'
uc_catalog.services.yml in uc_catalog/uc_catalog.services.yml
uc_catalog/uc_catalog.services.yml
1 service uses RouteProcessor
uc_catalog.route_processor in uc_catalog/uc_catalog.services.yml
Drupal\uc_catalog\Access\RouteProcessor

File

uc_catalog/src/Access/RouteProcessor.php, line 14

Namespace

Drupal\uc_catalog\Access
View source
class RouteProcessor implements OutboundRouteProcessorInterface {

  /**
   * The config factory.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * The entity type manager service.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a RouteProcessor object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager service.
   */
  public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager) {
    $this->configFactory = $config_factory;
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function processOutbound($route_name, Route $route, array &$parameters, BubbleableMetadata $bubbleable_metadata = NULL) {
    if ($route_name == 'entity.taxonomy_term.canonical' && !empty($parameters['taxonomy_term'])) {
      if ($vid = $this->configFactory
        ->get('uc_catalog.settings')
        ->get('vocabulary')) {
        if ($this->entityTypeManager
          ->getStorage('taxonomy_term')
          ->load($parameters['taxonomy_term'])
          ->bundle() == $vid) {
          $route
            ->setPath('/catalog/{taxonomy_term}');
        }
      }
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RouteProcessor::$configFactory protected property The config factory.
RouteProcessor::$entityTypeManager protected property The entity type manager service.
RouteProcessor::processOutbound public function Processes the outbound route. Overrides OutboundRouteProcessorInterface::processOutbound
RouteProcessor::__construct public function Constructs a RouteProcessor object.