public function testGetAllClassNames() { AnnotationRegistry::registerFile(__DIR__ . '/../../../Annotation/Resource.php'); $reader = new AnnotationReader(); $driver = new AnnotationDriver($reader, array('Conjecto\\Nemrod\\ResourceManager\\Tests\\Fixtures\\TestBundle' => __DIR__ . '/../../Fixtures/TestBundle/RdfResource')); $classes = $driver->getAllClassNames(); $this->assertEquals(array('Conjecto\\Nemrod\\ResourceManager\\Tests\\Fixtures\\TestBundle\\RdfResource\\TestResource'), $classes); }
/** * Parses active bundles for resources to map. * * @param ContainerBuilder $container */ private function registerResourceMappings(array $config, ContainerBuilder $container) { // registering all annotation mappings. $service = $container->getDefinition('nemrod.type_mapper'); //setting default resource $service->addMethodCall('setDefaultResourceClass', array($container->getParameter('nemrod.resource.class'))); // get bundles and classes $finder = new Finder(); $classes = array(); $paths = array(); foreach ($container->getParameter('kernel.bundles') as $bundle => $class) { // in bundle $reflection = new \ReflectionClass($class); if (is_dir($dir = dirname($reflection->getFilename()) . DIRECTORY_SEPARATOR . 'RdfResource')) { $paths[$bundle] = dirname($reflection->getFilename()) . DIRECTORY_SEPARATOR . 'RdfResource'; foreach ($finder->in($dir) as $file) { if (is_file($file)) { $classes[] = $this->getClassRelativePath($file->getPathName()); } } } } $driver = new AnnotationDriver(new AnnotationReader(), $paths); //adding paths to annotation driver $annDriver = $container->getDefinition('nemrod.metadata_annotation_driver'); $annDriver->replaceArgument(1, $paths); foreach ($classes as $class) { $metadata = $driver->loadMetadataForClass(new \ReflectionClass($class)); foreach ($metadata->types as $type) { $service->addMethodCall('set', array($type, $class)); } } // guess class filiation $registry = $container->getDefinition('nemrod.filiation.builder'); $registry->addMethodCall('guessRdfClassFiliation', array($classes)); }