You are here

class PathProcessorFront in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php \Drupal\Core\PathProcessor\PathProcessorFront

Processes the inbound path by resolving it to the front page if empty.

@todo - remove ::processOutbound() when we remove UrlGenerator::fromPath().

Hierarchy

Expanded class hierarchy of PathProcessorFront

1 file declares its use of PathProcessorFront
PathProcessorTest.php in core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
Contains \Drupal\Tests\Core\PathProcessor\PathProcessorTest.
1 string reference to 'PathProcessorFront'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses PathProcessorFront
path_processor_front in core/core.services.yml
Drupal\Core\PathProcessor\PathProcessorFront

File

core/lib/Drupal/Core/PathProcessor/PathProcessorFront.php, line 19
Contains \Drupal\Core\PathProcessor\PathProcessorFront.

Namespace

Drupal\Core\PathProcessor
View source
class PathProcessorFront implements InboundPathProcessorInterface, OutboundPathProcessorInterface {

  /**
   * A config factory for retrieving required config settings.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $config;

  /**
   * Constructs a PathProcessorFront object.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config
   *   A config factory for retrieving the site front page configuration.
   */
  public function __construct(ConfigFactoryInterface $config) {
    $this->config = $config;
  }

  /**
   * {@inheritdoc}
   */
  public function processInbound($path, Request $request) {
    if ($path === '/') {
      $path = $this->config
        ->get('system.site')
        ->get('page.front');
    }
    return $path;
  }

  /**
   * {@inheritdoc}
   */
  public function processOutbound($path, &$options = array(), Request $request = NULL, BubbleableMetadata $bubbleable_metadata = NULL) {

    // The special path '<front>' links to the default front page.
    if ($path === '/<front>') {
      $path = '/';
    }
    return $path;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PathProcessorFront::$config protected property A config factory for retrieving required config settings.
PathProcessorFront::processInbound public function Processes the inbound path. Overrides InboundPathProcessorInterface::processInbound
PathProcessorFront::processOutbound public function Processes the outbound path. Overrides OutboundPathProcessorInterface::processOutbound
PathProcessorFront::__construct public function Constructs a PathProcessorFront object.