Ejemplo n.º 1
0
 public static function resolveBuildPage($page, FileStackInterface $result)
 {
     if (!self::isTree()) {
         self::loadTree();
     }
     $pageName = self::createPkgName($page);
     $pagePkg = self::getPkg($pageName);
     if (false === $pagePkg) {
         $err = "-({$page}) manifest was not found ";
         throw new DomainException($err);
     }
     $layers = $pagePkg->getLayers();
     foreach ($layers as $layerName) {
         $factory = self::loadFactory($layerName->getVendor());
         $stack = $factory->createFileStack();
         $layer = self::loadLayer($layerName, $stack);
         if ($layer->isJs()) {
             $result->add('js', $layer->getJsFile());
         }
         if ($layer->isCss()) {
             $result->add('css', $layer->getCssFile());
         }
     }
     $layer = self::createPageLayer($pageName);
     if ($layer->isJs()) {
         $result->add('js', $layer->getJsFile());
     }
     if ($layer->isCss()) {
         $result->add('css', $layer->getCssFile());
     }
     $htmlPkg = self::getPkg($pagePkg->getHtmlDocName());
     $themePkgName = $pagePkg->getThemeName();
     if (!$themePkgName) {
         return $htmlPkg;
     }
     $themeName = $themePkgName->getName();
     $vendorName = $pageName->getVendor();
     $vendor = self::loadVendor($vendorName);
     $version = $vendor->getVersion();
     $themeFile = "build/{$vendorName}/{$version}/theme" . "/{$themeName}/css/{$themeName}.css";
     $result->add('css', $themeFile);
     return $htmlPkg;
 }
Ejemplo n.º 2
0
 /**
  * @param	FileStackInterface $stack
  * @return	FileStack
  */
 public function loadStack(FileStackInterface $stack)
 {
     $types = $stack->getTypes();
     foreach ($types as $type) {
         $files = $stack->get($type);
         if (empty($files)) {
             continue;
         }
         foreach ($files as $file) {
             $this->add($type, $file);
         }
     }
     return $this;
 }
Ejemplo n.º 3
0
 protected function makeString($type, array $list, FileReaderInterface $reader, FileStackInterface $pageStack)
 {
     if ('css' !== $type && 'js' !== $type) {
         $err = 'can only convert js or css files';
         throw new LogicException($err);
     }
     $content = new ContentStack();
     foreach ($list as $file) {
         $text = $reader->getContent($file);
         if (false === $text) {
             $err = "could not read contents of file -({$file})";
             throw new RunTimeException($err);
         }
         $content->add($text);
         $pageStack->add($type, $file);
     }
     if ($content->count() > 0) {
         $result = '';
         foreach ($content as $data) {
             $result .= $data . PHP_EOL;
         }
     }
     return $result;
 }