protected function processResourceUrlFunction(Twig_Node $node)
 {
     if (!$this->urlGenerator) {
         throw new RuntimeException('The resource_url() function is only available if ' . 'puli/url-generator is installed.');
     }
     $argsNode = $node->getNode('arguments');
     if (!$argsNode->hasNode(0)) {
         return null;
     }
     $exprNode = $argsNode->getNode(0);
     if (!$exprNode instanceof Twig_Node_Expression_Constant) {
         return null;
     }
     // The paths passed to the resource_url() function must always be Puli
     // paths, so disable path checking
     $this->processConstantNode($exprNode, false);
     // Optimize away function call
     $exprNode->setAttribute('value', $this->urlGenerator->generateUrl($exprNode->getAttribute('value')));
     return $exprNode;
 }
Beispiel #2
0
 /**
  * Prints the URL of a Puli path.
  *
  * @param string $path A Puli path.
  * @param IO     $io   The I/O.
  */
 private function printUrl($path, IO $io)
 {
     $path = Path::makeAbsolute($path, $this->currentPath);
     $io->writeLine($this->urlGenerator->generateUrl($path));
 }