public function testHasResourceInAnnotationReturnFalseIfOnlyOneControllerDefined() { $tmpDir = sys_get_temp_dir() . '/sf2'; $file = tempnam($tmpDir, 'routing'); $routing = <<<DATA acme_demo_post: resource: "@AcmeDemoBundle/Controller/PostController.php" type: annotation DATA; file_put_contents($file, $routing); $manipulator = new RoutingManipulator($file); $this->assertFalse($manipulator->hasResourceInAnnotation('AcmeDemoBundle')); }
protected function updateAnnotationRouting(BundleInterface $bundle, $entity, $prefix) { $rootDir = $this->getContainer()->getParameter('kernel.root_dir'); $routing = new RoutingManipulator($rootDir . '/config/routing.yml'); if (!$routing->hasResourceInAnnotation($bundle->getName())) { $parts = explode('\\', $entity); $controller = array_pop($parts); $ret = $routing->addAnnotationController($bundle->getName(), $controller); } }