Пример #1
0
 protected function parseFile($file)
 {
     $tokens = token_get_all(file_get_contents($file));
     //  var_dump($tokens);die();
     $count = count($tokens) - 1;
     for ($i = 0; $i < $count; $i++) {
         $token = $tokens[$i];
         if ($token[0] == 307) {
             $method = $token[1];
             if ($method === 'getCss') {
                 $type = 'css';
             } elseif ($method === 'getJs') {
                 $type = 'js';
             } else {
                 $type = null;
             }
             if ($type !== null) {
                 $arg = $this->getArgument($tokens, $i);
                 $sourcePath = AssetResolver::resolveSourcePath($arg, \eBuildy\Helper\ResolverHelper::getModulePathFromView($file));
                 if ($sourcePath === null) {
                     // var_dump(array('file' => $file, 'type' => $type, 'source' => $arg));
                 } else {
                     $this->assets[$sourcePath] = $type;
                 }
             }
         }
     }
 }
Пример #2
0
 public function getAssetPath($source)
 {
     $sourcePath = AssetResolver::resolveSourcePath($source, $this->templatingService->getContext());
     if ($sourcePath === null || $sourcePath === false) {
         throw new \Exception("The asset " . $source . " is not found !");
     }
     return $sourcePath;
 }