/**
  * @param string $code
  * @param WebLoader\Compiler $loader
  * @param string $file
  * @return string
  */
 public function __invoke($code, WebLoader\Compiler $loader, $file)
 {
     $ree = '~\\/~';
     $root = $loader->getFileCollection()->getRoot();
     $rootSegments = preg_split($ree, $root);
     $pathInfo = pathinfo($file);
     $pathInfoSegments = preg_split($ree, $pathInfo['dirname']);
     $fileRelativePath = array_diff($pathInfoSegments, $rootSegments);
     $fileRelativePath[] = $pathInfo['basename'];
     $fileRelativePath = join(DIRECTORY_SEPARATOR, $fileRelativePath);
     $this->lilo->appendLoadPath($root);
     $this->lilo->scan($fileRelativePath);
     $fileDeps = $this->lilo->getFileChain($fileRelativePath);
     $code = array_reduce($fileDeps, function ($memo, $dep) {
         return $memo . $dep['content'];
     }, '');
     return $code;
 }
Exemple #2
0
 /**
  * Constructor
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->_lilo = new Lilo(array('js', 'coffee'));
     $this->_lilo->appendLoadPath('../etc/assets');
 }