/** * {@inheritDoc} * * @return PrioritizedPathsResolver */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('config'); $prioritizedPathsResolver = new PrioritizedPathsResolver(); $paths = isset($config['asset_manager']['resolver_configs']['prioritized_paths']) ? $config['asset_manager']['resolver_configs']['prioritized_paths'] : array(); $prioritizedPathsResolver->addPaths($paths); return $prioritizedPathsResolver; }
/** * @inheritDoc */ public function __invoke(ContainerInterface $container, $requestedName, array $options = null) { $config = $container->get('config'); $prioritizedPathsResolver = new PrioritizedPathsResolver(); $paths = isset($config['asset_manager']['resolver_configs']['prioritized_paths']) ? $config['asset_manager']['resolver_configs']['prioritized_paths'] : array(); $prioritizedPathsResolver->addPaths($paths); return $prioritizedPathsResolver; }
public function testAddPaths() { $resolver = new PrioritizedPathsResolver(); $resolver->setPaths(array(array('path' => 'dir3', 'priority' => 750), array('path' => 'dir2', 'priority' => 1000), array('path' => 'dir1', 'priority' => 500))); $resolver->addPaths(array('dir4', array('path' => 'dir5', 'priority' => -5))); $fetched = array(); foreach ($resolver->getPaths() as $path) { $fetched[] = $path; } // order inverted because of how a stack is traversed $this->assertSame(array('dir2' . DIRECTORY_SEPARATOR, 'dir3' . DIRECTORY_SEPARATOR, 'dir1' . DIRECTORY_SEPARATOR, 'dir4' . DIRECTORY_SEPARATOR, 'dir5' . DIRECTORY_SEPARATOR), $fetched); }