Esempio n. 1
0
 public function testGetBundleFolderFromPath()
 {
     /** @var AppKernel|\PHPUnit_Framework_MockObject_MockObject $mockKernel */
     $mockKernel = $this->getMockBuilder(AppKernel::class)->disableOriginalConstructor()->getMock();
     $bundleHelper = new BundleHelper($mockKernel);
     $path = '/path/to/project/src/YourNamespace/Bundles/YourBundle/YourNamespaceYourBundle.php';
     $this->assertEquals('YourBundle', $bundleHelper->getBundleFolderFromPath($path));
 }
Esempio n. 2
0
 /**
  * @param $configFilePath
  * @return null|\ReflectionClass
  */
 private function getReflectionClassForConfig($configFilePath)
 {
     $bundleName = $this->bundleHelper->getBundleFolderFromPath($configFilePath);
     $endOfPath = substr($configFilePath, strpos($configFilePath, self::PATH_IN_BUNDLE));
     $configClassShortName = str_replace([self::PATH_IN_BUNDLE, self::CONFIG_PATH_SUFFIX], '', $endOfPath);
     if (!isset($this->entityClassesByBundle[$bundleName])) {
         return null;
     }
     /** @var \ReflectionClass $reflectionClass */
     foreach ($this->entityClassesByBundle[$bundleName] as $reflectionClass) {
         if ($configClassShortName === $reflectionClass->getShortName()) {
             return $reflectionClass;
         }
     }
     return null;
 }