示例#1
0
 public function testSetIspackage()
 {
     $asset = new Asset('myfile.js');
     $this->assertFalse($asset->isPackage());
     $asset->setIsPackage(true);
     $this->assertTrue($asset->isPackage());
     $asset->setIsPackage(false);
     $this->assertFalse($asset->isPackage());
     $asset->setIsPackage(0);
     $this->assertFalse($asset->isPackage());
     $asset->setIsPackage(1);
     $this->assertTrue($asset->isPackage());
 }
示例#2
0
文件: Loader.php 项目: eberhm/phoenix
 /**
  * @return \Phoenix\Container\ContainerInterface
  */
 public function buildContainer()
 {
     $container = new Container();
     $i = 0;
     $sections = array();
     foreach ($this->files as $file) {
         $jsPackageName = $this->getJsPackageName($file);
         if ($jsPackageName && !$this->config['debug']) {
             $file = 'packages/' . $jsPackageName . '.js';
             $asset = new Asset($this->getFinalPath($file));
             $asset->setIsPackage(true);
             $container->add($asset);
             continue;
         }
         if (!$this->useBatches()) {
             $container->add(new Asset($this->getFinalPath($file)));
         } else {
             $sections[intval($i++ / $this->getBatchSize())][] = $file;
         }
     }
     if (count($sections)) {
         foreach ($sections as $aSection) {
             $container->add(new Asset($this->config['batchController'] . base64_encode(implode(',', $aSection)) . '.js'));
         }
     }
     return $container;
 }