Collections are strictly checked by mime-type, and added to an AssetCollection when all checks passed.
Inheritance: implements AssetManager\Resolver\ResolverInterface, implements AssetManager\Resolver\AggregateResolverAwareInterface, implements AssetManager\Service\AssetFilterManagerAwareInterface
Exemplo n.º 1
0
 public function getCollectionResolver()
 {
     $aggregateResolver = new AggregateResolver();
     $mockedResolver = $this->getResolver(__DIR__ . '/../../_files/require-jquery.js');
     $collArr = array('blah.js' => array('asset-path'));
     $resolver = new CollectionResolver($collArr);
     $resolver->setAggregateResolver($aggregateResolver);
     $aggregateResolver->attach($mockedResolver, 500);
     $aggregateResolver->attach($resolver, 1000);
     return $resolver;
 }
 /**
  * Test Collect returns valid list of assets
  *
  * @covers \AssetManager\Resolver\CollectionResolver::collect
  */
 public function testCollect()
 {
     $collections = array('myCollection' => array('bacon', 'eggs', 'mud'), 'my/collect.ion' => array('bacon', 'eggs', 'mud'));
     $resolver = new CollectionResolver($collections);
     $this->assertEquals(array_keys($collections), $resolver->collect());
 }
Exemplo n.º 3
0
 public function testSuccessResolve()
 {
     $callbackInvocationCount = 0;
     $callback = function () use(&$callbackInvocationCount) {
         $asset1 = new Asset\StringAsset('bacon');
         $asset2 = new Asset\StringAsset('eggs');
         $asset3 = new Asset\StringAsset('Mud');
         $asset1->mimetype = 'text/plain';
         $asset2->mimetype = 'text/plain';
         $asset3->mimetype = 'text/plain';
         $callbackInvocationCount += 1;
         $assetName = "asset{$callbackInvocationCount}";
         return ${$assetName};
     };
     $aggregateResolver = $this->getMock('AssetManager\\Resolver\\ResolverInterface');
     $aggregateResolver->expects($this->exactly(3))->method('resolve')->will($this->returnCallback($callback));
     $resolver = new CollectionResolver(array('myCollection' => array('bacon', 'eggs', 'mud')));
     $mimeResolver = new MimeResolver();
     $assetFilterManager = new AssetFilterManager();
     $assetFilterManager->setMimeResolver($mimeResolver);
     $resolver->setAggregateResolver($aggregateResolver);
     $resolver->setAssetFilterManager($assetFilterManager);
     $collectionResolved = $resolver->resolve('myCollection');
     $this->assertEquals($collectionResolved->mimetype, 'text/plain');
     $this->assertTrue($collectionResolved instanceof Asset\AssetCollection);
 }
 /**
  * {@inheritDoc}
  */
 public function resolve($name)
 {
     // Check if we are resolving an asset defined with an absolute path
     if ($name === realpath($name)) {
         return $this->resolveAbsolutePath($name);
     } elseif ($this->isGlobalAsset($name)) {
         $this->loadGlobalCollection($name);
     } elseif ($this->isTemplateAsset($name)) {
         $this->loadTemplateCollection($name);
     }
     $resolve = parent::resolve($name);
     if ($resolve instanceof AssetCollection) {
         $resolve->setTargetPath($this->getPublicPath() . $resolve->getTargetPath());
         if (empty($resolve->mimetype)) {
             $resolve->mimetype = $this->getMimeResolver()->getMimeType($name);
         }
     }
     return $resolve;
 }