You are here

class BoostCacheRoute in Boost 8

BoostCacheRoute class.

@todo, allow admin to set uri scheme location.

Hierarchy

Expanded class hierarchy of BoostCacheRoute

1 file declares its use of BoostCacheRoute
BoostCache.php in src/BoostCache.php
Contains Drupal\boost\BoostCache
1 string reference to 'BoostCacheRoute'
boost.services.yml in ./boost.services.yml
boost.services.yml
1 service uses BoostCacheRoute
boost.route in ./boost.services.yml
Drupal\boost\BoostCacheRoute

File

src/BoostCacheRoute.php, line 18
Contains Drupal\boost\BoostCacheRoute

Namespace

Drupal\boost
View source
class BoostCacheRoute {

  /**
   * File system schema.
   */
  protected $schema;

  /**
   * File extension.
   */
  protected $extension;

  /**
   * The normalized current path.
   */
  protected $filePath;

  /**
   * The current path.
   * @var \Drupal\Core\Path\CurrentPathStack
   */
  protected $currentPath;

  /**
   * The alias manager.
   * @var \Drupal\Core\Path\AliasManager
   */
  protected $aliasManager;

  /**
   * @param \Drupal\Core\Path\CurrentPathStack $current_path
   *    The current path.
   * @param \Drupal\Core\Path\AliasManager $aliasManager
   *    The alias manager.
   */
  public function __construct(CurrentPathStack $current_path, AliasManager $alias_manager) {
    $this->currentPath = $current_path;
    $this->aliasManager = $alias_manager;
    $this->schema = file_default_scheme() . '://boost';
    $this->extension = '.html';
  }

  /**
   * Return the current file uri.
   */
  public function getUri() {
    return $this->schema . $this
      ->getPath() . $this->extension;
  }

  /**
   * Return the current path.
   */
  public function getPath() {
    return $this->aliasManager
      ->getAliasByPath($this->currentPath
      ->getPath());
  }

  /**
   * Return the converted file path.
   */
  public function getFilePath() {
    if (!$this->filePath) {
      $this->filePath = array_filter($this
        ->convertPath());
    }
    return $this->filePath;
  }

  /**
   * Convert the path into a file path.
   */
  private function convertPath() {
    return explode('/', $this
      ->getPath());
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BoostCacheRoute::$aliasManager protected property The alias manager.
BoostCacheRoute::$currentPath protected property The current path.
BoostCacheRoute::$extension protected property File extension.
BoostCacheRoute::$filePath protected property The normalized current path.
BoostCacheRoute::$schema protected property File system schema.
BoostCacheRoute::convertPath private function Convert the path into a file path.
BoostCacheRoute::getFilePath public function Return the converted file path.
BoostCacheRoute::getPath public function Return the current path.
BoostCacheRoute::getUri public function Return the current file uri.
BoostCacheRoute::__construct public function