/** * {@inheritdoc} */ public function registerFoundResource($bundleClass, $bundleDir, CumulativeResource $resource) { $path = $bundleDir . $this->relativeFilePath; if (is_file($path)) { $resource->addFound($bundleClass, $path); } }
public function testSetialization() { $resource = new CumulativeResource('test', new CumulativeResourceLoaderCollection([new FolderingCumulativeFileLoader('{folder}', '\\w+', [new YamlCumulativeFileLoader('Resources/config/res1.yml'), new YamlCumulativeFileLoader('Resources/config/res2.yml')])])); $resource->addFound('bundle', 'path'); $serializedData = $resource->serialize(); $unserializedResource = new CumulativeResource('test1', new CumulativeResourceLoaderCollection()); $unserializedResource->unserialize($serializedData); $this->assertEquals($resource, $unserializedResource); }
/** * {@inheritdoc} */ public function registerFoundResource($bundleClass, $bundleDir, CumulativeResource $resource) { $finder = $this->getFileFinder($bundleDir); if ($finder) { /** @var \SplFileInfo $file */ foreach ($finder as $file) { $resource->addFound($bundleClass, $file->getRealPath()); } } }
public function testRegisterFoundResource() { $relativeFilePath = 'Resources/config/test.yml'; $bundle = new TestBundle1(); $bundleClass = get_class($bundle); $bundleDir = dirname((new \ReflectionClass($bundle))->getFileName()); $loader = $this->createLoader($relativeFilePath); $resource = new CumulativeResource('test_group', new CumulativeResourceLoaderCollection()); $loader->registerFoundResource($bundleClass, $bundleDir, '', $resource); $expectedResource = new CumulativeResource('test_group', new CumulativeResourceLoaderCollection()); $expectedResource->addFound($bundleClass, str_replace('/', DIRECTORY_SEPARATOR, $bundleDir . '/' . $relativeFilePath)); $this->assertEquals($expectedResource, $resource); }
/** * {@inheritdoc} */ public function registerFoundResource($bundleClass, $bundleDir, $bundleAppDir, CumulativeResource $resource) { $path = $this->getBundleAppResourcePath($bundleAppDir); if (is_file($path)) { $resource->addFound($bundleClass, $path); } else { $path = $this->getBundleResourcePath($bundleDir); if (is_file($path)) { $resource->addFound($bundleClass, $path); } } }
public function testLoad() { $resourceRelativePath = 'Resources/config/test.yml'; $bundle = new TestBundle1(); $bundleDir = dirname((new \ReflectionClass($bundle))->getFileName()); $resourceLoader = new YamlCumulativeFileLoader($resourceRelativePath); CumulativeResourceManager::getInstance()->clear()->setBundles(['TestBundle1' => get_class($bundle)]); $container = new ContainerBuilder(); $loader = new CumulativeConfigLoader('test', $resourceLoader); $result = $loader->load($container); $this->assertEquals([new CumulativeResourceInfo(get_class($bundle), 'test', str_replace('/', DIRECTORY_SEPARATOR, $bundleDir . '/' . $resourceRelativePath), ['test' => 123])], $result); $expectedResource = new CumulativeResource('test', new CumulativeResourceLoaderCollection([$resourceLoader])); $expectedResource->addFound(get_class($bundle), str_replace('/', DIRECTORY_SEPARATOR, $bundleDir . '/Resources/config/test.yml')); $this->assertCount(1, $container->getResources()); $this->assertEquals($expectedResource, $container->getResources()[0]); }
/** * {@inheritdoc} */ public function registerFoundResource($bundleClass, $bundleDir, $bundleAppDir, CumulativeResource $resource) { $dir = $this->getResourcesDirectoryAbsolutePath($bundleAppDir); $realPath = realpath($dir); $bundleAppData = []; if (is_dir($realPath)) { $bundleAppData = $this->getDirectoryContentsArray($realPath); } $dir = $this->getDirectoryAbsolutePath($bundleDir); $realPath = realpath($dir); $bundleData = []; if (is_dir($realPath)) { $bundleData = $this->getDirectoryContentsArray($realPath); } foreach ($this->mergeArray($bundleAppData, $bundleData, $bundleAppDir, $bundleDir) as $filename) { $resource->addFound($bundleClass, $filename); } }