class TwigResource

A Twig template resource.

@author Kris Wallsmith <kris.wallsmith@gmail.com>

Hierarchy

Expanded class hierarchy of TwigResource

1 file declares its use of TwigResource
TwigResourceTest.php in drupal/core/vendor/kriswallsmith/assetic/tests/Assetic/Test/Extension/Twig/TwigResourceTest.php

File

drupal/core/vendor/kriswallsmith/assetic/src/Assetic/Extension/Twig/TwigResource.php, line 21

Namespace

Assetic\Extension\Twig
View source
class TwigResource implements ResourceInterface {
  private $loader;
  private $name;
  public function __construct(\Twig_LoaderInterface $loader, $name) {
    $this->loader = $loader;
    $this->name = $name;
  }
  public function getContent() {
    try {
      return $this->loader
        ->getSource($this->name);
    } catch (\Twig_Error_Loader $e) {
      return '';
    }
  }
  public function isFresh($timestamp) {
    try {
      return $this->loader
        ->isFresh($this->name, $timestamp);
    } catch (\Twig_Error_Loader $e) {
      return false;
    }
  }
  public function __toString() {
    return $this->name;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TwigResource::$loader private property
TwigResource::$name private property
TwigResource::getContent public function Returns the content of the resource. Overrides ResourceInterface::getContent
TwigResource::isFresh public function Checks if a timestamp represents the latest resource. Overrides ResourceInterface::isFresh
TwigResource::__construct public function
TwigResource::__toString public function Returns a unique string for the current resource. Overrides ResourceInterface::__toString