コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function registerFoundResource($bundleClass, $bundleDir, CumulativeResource $resource)
 {
     $path = $bundleDir . $this->relativeFilePath;
     if (is_file($path)) {
         $resource->addFound($bundleClass, $path);
     }
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 /**
  * {@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());
         }
     }
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 /**
  * {@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);
         }
     }
 }
コード例 #6
0
 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]);
 }
コード例 #7
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);
     }
 }