protected function setUp()
 {
     AnnotationRegistry::registerLoader('class_exists');
     $conn = DriverManager::getConnection(array('driver' => 'pdo_sqlite', 'memory' => true));
     $this->em = $this->_getTestEntityManager($conn);
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Bazinga\\Bundle\\GeocoderBundle\\Mapping\\Annotations');
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $driver = new AnnotationDriver($reader);
     $geocoder = new GoogleMaps(new CurlHttpAdapter());
     $this->listener = new GeocoderListener($geocoder, $driver);
     $this->em->getEventManager()->addEventSubscriber($this->listener);
     $sm = new SchemaTool($this->em);
     $sm->createSchema(array($this->em->getClassMetadata('Bazinga\\Bundle\\GeocoderBundle\\Tests\\Doctrine\\ORM\\Dummy')));
 }
 /**
  * @param type $class
  * @return \Nucleus\Annotation\IParsingResult
  */
 public function parse($className)
 {
     $reflectionClass = new \ReflectionClass($className);
     $result = new ParsingResult($reflectionClass->getName());
     $result->setClassAnnotations($this->reader->getClassAnnotations($reflectionClass));
     foreach ($reflectionClass->getMethods() as $reflectionMethod) {
         $result->setMethodAnnotations($reflectionMethod->getName(), $this->reader->getMethodAnnotations($reflectionMethod));
     }
     foreach ($reflectionClass->getMethods() as $reflectionMethod) {
         $result->setMethodAnnotations($reflectionMethod->getName(), $this->reader->getMethodAnnotations($reflectionMethod));
     }
     foreach ($reflectionClass->getProperties() as $reflectionProperty) {
         $result->setPropertyAnnotations($reflectionProperty->getName(), $this->reader->getPropertyAnnotations($reflectionProperty));
     }
     $parentClass = $reflectionClass->getParentClass();
     if ($parentClass) {
         $parentResult = $this->parse($parentClass->getName());
         $result->mergeParentClass($parentResult);
     }
     $interfaceClasses = $reflectionClass->getInterfaces();
     foreach ($interfaceClasses as $interfaceClass) {
         /* @var $interfaceClass \ReflectionClass  */
         $interfaceResult = $this->parse($interfaceClass->getName());
         $result->mergeParentClass($interfaceResult);
     }
     return $result;
 }
 /**
  * @param array $paths
  * @return \Doctrine\Common\Annotations\AnnotationReader
  */
 protected function createAnnotationDriver($paths = array(), $alias = null)
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '2.2.0-DEV', '>=')) {
         // Register the ORM Annotations in the AnnotationRegistry
         AnnotationRegistry::registerFile(__DIR__ . '/../../../lib/Doctrine/ORM//Mapping/Driver/DoctrineAnnotations.php');
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ORM\\Mapping');
         $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new ArrayCache());
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-BETA3-DEV', '>=')) {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             $reader->setIgnoreNotImportedAnnotations(true);
             $reader->setEnableParsePhpImports(false);
             if ($alias) {
                 $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias);
             } else {
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             }
             $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache());
         } else {
             $reader = new \Doctrine\Common\Annotations\AnnotationReader();
             if ($alias) {
                 $reader->setAnnotationNamespaceAlias('Doctrine\\ORM\\Mapping\\', $alias);
             } else {
                 $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
             }
         }
     }
     return new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, (array) $paths);
 }
示例#4
0
 /**
  * Generate documentation with the name and version.
  *
  * @param string $name
  * @param string $version
  *
  * @return bool
  */
 public function generate(Collection $controllers, $name, $version)
 {
     $resources = $controllers->map(function ($controller) use($version) {
         $controller = $controller instanceof ReflectionClass ? $controller : new ReflectionClass($controller);
         $actions = new Collection();
         // Spin through all the methods on the controller and compare the version
         // annotation (if supplied) with the version given for the generation.
         // We'll also build up an array of actions on each resource.
         foreach ($controller->getMethods() as $method) {
             if ($versionAnnotation = $this->reader->getMethodAnnotation($method, Annotation\Versions::class)) {
                 if (!in_array($version, $versionAnnotation->value)) {
                     continue;
                 }
             }
             if ($annotations = $this->reader->getMethodAnnotations($method)) {
                 if (!$actions->contains($method)) {
                     $actions->push(new Action($method, new Collection($annotations)));
                 }
             }
         }
         $annotations = new Collection($this->reader->getClassAnnotations($controller));
         return new Resource($controller->getName(), $controller, $annotations, $actions);
     });
     return $this->generateContentsFromResources($resources, $name);
 }
示例#5
0
 public function testIssueSimpleAnnotationReader()
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Doctrine\\Tests\\Common\\Annotations\\Ticket\\Doctrine\\ORM\\Mapping');
     $annots = $reader->getClassAnnotations(new \ReflectionClass(__NAMESPACE__ . "\\MappedClass"));
     $this->assertEquals(1, count($annots));
     $this->assertInstanceOf("Doctrine\\Tests\\Common\\Annotations\\Ticket\\Doctrine\\ORM\\Mapping\\Entity", $annots[0]);
 }
 protected function getReader()
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace(__NAMESPACE__);
     $reader->addNamespace(__NAMESPACE__ . '\\Fixtures');
     $reader->addNamespace(__NAMESPACE__ . '\\Fixtures\\Annotation');
     return $reader;
 }
 public function test_get_all_class_names_considers_class_paths_from_config()
 {
     Kohana::$config->load('doctrine')->set('entity_paths', array('Some/Entity/Path' => TRUE, 'Other/Entities' => TRUE));
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $driver = new Doctrine_KohanaAnnotationDriver(new CachedReader($reader, new ArrayCache()), Kohana::include_paths());
     $this->assertEquals(array('Some_Entity_Path_Entity', 'Other_Entities_Entity'), $driver->getAllClassNames());
 }
 /**
  * @return Reader
  */
 public function getAnnotationReader()
 {
     if (!$this->annotationReader) {
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Oow\\Plugin\\Annotations');
         $this->annotationReader = $reader;
     }
     return $this->annotationReader;
 }
 /**
  * Get the method annotations for a given class.
  *
  * @param  \ReflectionClass  $class
  * @param  \Doctrine\Common\Annotations\SimpleAnnotationReader  $reader
  * @return array
  */
 protected function getMethodAnnotations(ReflectionClass $class, SimpleAnnotationReader $reader)
 {
     $annotations = [];
     foreach ($class->getMethods() as $method) {
         $results = $reader->getMethodAnnotations($method);
         if (count($results) > 0) {
             $annotations[$method->name] = $results;
         }
     }
     return $annotations;
 }
示例#10
0
 /**
  * Constructor
  *
  * @param EntityManagerInterface $em
  * @param ReaderInterface $reader
  * @param array $namespaces
  * @param CacheProvider $cacheProvider
  */
 public function __construct(EntityManagerInterface $em, ReaderInterface $reader = null, array $namespaces = array('Doctrine\\ORM\\Mapping', 'Mindgruve\\Gordo\\Domain'), CacheProvider $cacheProvider = null)
 {
     $this->em = $em;
     if (!$reader) {
         $reader = new SimpleAnnotationReader();
     }
     foreach ($namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     if ($cacheProvider) {
         $reader = new CachedReader($reader, $cacheProvider);
     }
     $this->reader = $reader;
 }
示例#11
0
 /**
  * @return null
  */
 public function init()
 {
     parent::init();
     $this->annotReader = new SimpleAnnotationReader();
     $this->annotReader->addNamespace(__NAMESPACE__ . '\\Annotation\\Action');
     $this->annotReader->addNamespace(__NAMESPACE__ . '\\Annotation\\Common');
 }
 /**
  * @return SimpleAnnotationReader
  */
 protected function getAnnotationReader()
 {
     if ($this->annotationReader === null) {
         $this->annotationReader = new SimpleAnnotationReader();
         $this->annotationReader->addNamespace('Supra\\Core\\Doctrine\\Annotation');
     }
     return $this->annotationReader;
 }
示例#13
0
 /**
  * @return \Doctrine\ORM\Configuration
  */
 protected function getDoctrine_ConfigService()
 {
     $this->services['doctrine.config'] = $instance = new Configuration();
     $baseDir = $this->getParameter('app.baseDir');
     $cache = $this->get('app.cache');
     $instance->setMetadataCacheImpl($cache);
     $instance->setQueryCacheImpl($cache);
     $instance->setResultCacheImpl($cache);
     $instance->setProxyDir($baseDir . $this->getParameter('doctrine.proxy.dir'));
     $instance->setProxyNamespace($this->getParameter('doctrine.proxy.namespace'));
     $instance->setAutoGenerateProxyClasses($this->getParameter('app.devmode'));
     AnnotationRegistry::registerFile($baseDir . 'vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Doctrine\\ORM\\Mapping');
     $instance->setMetadataDriverImpl(new AnnotationDriver(new CachedReader($reader, $cache), array($baseDir . $this->getParameter('doctrine.entity.dir'))));
     return $instance;
 }
示例#14
0
 /**
  * @param ObjectManager $objectManager
  * @param DoctrineProxyResolver $doctrineProxyResolver
  * @param ReaderInterface $reader
  * @param array $namespaces
  * @param CacheProvider $cacheProvider
  */
 public function __construct(ObjectManager $objectManager, DoctrineProxyResolver $doctrineProxyResolver = null, ReaderInterface $reader = null, array $namespaces = array('Doctrine\\ORM\\Mapping', 'Mindgruve\\Gordo\\Annotations'), CacheProvider $cacheProvider = null)
 {
     $this->objectManager = $objectManager;
     if (!$doctrineProxyResolver) {
         $doctrineProxyResolver = new DoctrineProxyResolver();
     }
     $this->doctrineProxyResolver = $doctrineProxyResolver;
     if (!$reader) {
         $reader = new SimpleAnnotationReader();
     }
     foreach ($namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     if ($cacheProvider) {
         $reader = new CachedReader($reader, $cacheProvider);
     }
     $this->reader = $reader;
 }
示例#15
0
 /**
  * Testing specific server scenario configured in Job annotations as a simple server
  */
 public function testCombinationServers()
 {
     $this->reflectionClass->expects($this->once())->method('getNamespaceName')->will($this->returnValue($this->classNamespace));
     $this->reflectionClass->expects($this->exactly(2))->method('getName')->will($this->returnValue($this->className));
     $this->reflectionClass->expects($this->once())->method('getFileName')->will($this->returnValue($this->fileName));
     $this->reflectionClass->expects($this->once())->method('getMethods')->will($this->returnValue(array()));
     $this->reader->expects($this->never())->method('getMethodAnnotations');
     $this->workAnnotation->servers = array('host' => '10.0.0.2', 'port' => '80');
     $workerClass = new WorkerClass($this->workAnnotation, $this->reflectionClass, $this->reader, $this->servers, $this->defaultSettings);
     $this->assertEquals($workerClass->toArray(), array('namespace' => $this->classNamespace, 'className' => $this->className, 'fileName' => $this->fileName, 'callableName' => $this->className, 'description' => $workerClass::DEFAULT_DESCRIPTION, 'service' => null, 'servers' => array($this->workAnnotation->servers), 'iterations' => $this->defaultSettings['iterations'], 'minimumExecutionTime' => $this->defaultSettings['minimum_execution_time'], 'timeout' => $this->defaultSettings['timeout'], 'jobs' => array()));
 }
示例#16
0
 public function createContextFromFilename($filename)
 {
     $tokens = $this->getFileTokens($filename);
     $class = $this->getNamespaceFromToken($tokens);
     $reader = new SimpleAnnotationReader();
     $reflClass = new \ReflectionClass($class);
     $entityAnnotation = $reader->getClassAnnotation($reflClass, Entity::class);
     if (!$entityAnnotation) {
         return;
     }
     $context = new Context();
     $context->setFile($filename);
     $context->setEntity($entityAnnotation);
     $propertyAnnotations = [];
     foreach ($reflClass->getProperties() as $property) {
         $annotation = $reader->getPropertyAnnotation($property, Property::class);
         if ($annotation && !$annotation->name) {
             $annotation->name = $property->getName();
             $context->addProperty($annotation);
         }
     }
     return $context;
 }
 /**
  * Gets an annotation.
  *
  * @param  mixed  $from
  * @param  string $name
  * @return Annotation
  */
 protected function getAnnotation($from, $name)
 {
     if (!$this->reader) {
         $this->reader = new SimpleAnnotationReader();
         $this->reader->addNamespace($this->namespace);
     }
     $name = "{$this->namespace}\\{$name}";
     if ($from instanceof \ReflectionClass) {
         $annotation = $this->reader->getClassAnnotation($from, $name);
     } elseif ($from instanceof \ReflectionMethod) {
         $annotation = $this->reader->getMethodAnnotation($from, $name);
     } elseif ($from instanceof \ReflectionProperty) {
         $annotation = $this->reader->getPropertyAnnotation($from, $name);
     }
     return $annotation;
 }
示例#18
0
 /**
  * @param \Doctrine\Common\Cache\Cache|NULL
  * @param bool
  * @return \Doctrine\Common\Annotations\Reader
  */
 public static function createAnnotationReader(Cache $cache = NULL, $useSimple = FALSE)
 {
     // force load doctrine annotations
     AnnotationRegistry::registerFile(dirname(ClassType::from('Doctrine\\ORM\\Version')->getFileName()) . '/Mapping/Driver/DoctrineAnnotations.php');
     AnnotationRegistry::registerFile(__DIR__ . '/../Mapping/DiscriminatorEntry.php');
     if ($useSimple) {
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ORM\\Mapping');
     } else {
         $reader = new AnnotationReader();
     }
     if (!$cache) {
         return $reader;
     }
     return new CachedReader($reader, $cache);
 }
示例#19
0
 /**
  * Discovers all available tests in all extensions.
  *
  * @param string $extension
  *   (optional) The name of an extension to limit discovery to; e.g., 'node'.
  *
  * @return array
  *   An array of tests keyed by the first @group specified in each test's
  *   PHPDoc comment block, and then keyed by class names. For example:
  *   @code
  *     $groups['block'] => array(
  *       'Drupal\block\Tests\BlockTest' => array(
  *         'name' => 'Drupal\block\Tests\BlockTest',
  *         'description' => 'Tests block UI CRUD functionality.',
  *         'group' => 'block',
  *       ),
  *     );
  *   @endcode
  *
  * @throws \ReflectionException
  *   If a discovered test class does not match the expected class name.
  *
  * @todo Remove singular grouping; retain list of groups in 'group' key.
  * @see https://www.drupal.org/node/2296615
  * @todo Add base class groups 'Kernel' + 'Web', complementing 'PHPUnit'.
  */
 public function getTestClasses($extension = NULL)
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Drupal\\simpletest\\Annotation');
     if (!isset($extension)) {
         if ($this->cacheBackend && ($cache = $this->cacheBackend->get('simpletest:discovery:classes'))) {
             return $cache->data;
         }
     }
     $list = array();
     $classmap = $this->findAllClassFiles($extension);
     // Prevent expensive class loader lookups for each reflected test class by
     // registering the complete classmap of test classes to the class loader.
     // This also ensures that test classes are loaded from the discovered
     // pathnames; a namespace/classname mismatch will throw an exception.
     $this->classLoader->addClassMap($classmap);
     foreach ($classmap as $classname => $pathname) {
         $finder = MockFileFinder::create($pathname);
         $parser = new StaticReflectionParser($classname, $finder, TRUE);
         try {
             $info = static::getTestInfo($classname, $parser->getDocComment());
         } catch (MissingGroupException $e) {
             // If the class name ends in Test and is not a migrate table dump.
             if (preg_match('/Test$/', $classname) && strpos($classname, 'migrate_drupal\\Tests\\Table') === FALSE) {
                 throw $e;
             }
             // If the class is @group annotation just skip it. Most likely it is an
             // abstract class, trait or test fixture.
             continue;
         }
         // Skip this test class if it requires unavailable modules.
         // @todo PHPUnit skips tests with unmet requirements when executing a test
         //   (instead of excluding them upfront). Refactor test runner to follow
         //   that approach.
         // @see https://www.drupal.org/node/1273478
         if (!empty($info['requires']['module'])) {
             if (array_diff($info['requires']['module'], $this->availableExtensions['module'])) {
                 continue;
             }
         }
         $list[$info['group']][$classname] = $info;
     }
     // Sort the groups and tests within the groups by name.
     uksort($list, 'strnatcasecmp');
     foreach ($list as &$tests) {
         uksort($tests, 'strnatcasecmp');
     }
     // Allow modules extending core tests to disable originals.
     \Drupal::moduleHandler()->alter('simpletest', $list);
     if (!isset($extension)) {
         if ($this->cacheBackend) {
             $this->cacheBackend->set('simpletest:discovery:classes', $list);
         }
     }
     return $list;
 }
 public static function newInstance($paths = array(), $excludePaths = array())
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('SlimAnnotation\\Mapping\\Annotation');
     $cachedReader = new CachedReader($reader, new ArrayCache());
     AnnotationRegistry::registerFile(__DIR__ . '/SlimAnnotations.php');
     return new SlimAnnotationDriver($cachedReader, $paths, $excludePaths);
 }
示例#21
0
 /**
  * Add a new default annotation driver with a correctly configured annotation reader. If $useSimpleAnnotationReader
  * is true, the notation `@Document` will work, otherwise, the notation `@ODM\Document` will be supported.
  *
  * @param array $paths
  * @param bool  $useSimpleAnnotationReader
  *
  * @return AnnotationDriver
  */
 public function newDefaultAnnotationDriver($paths = [], $useSimpleAnnotationReader = true)
 {
     AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Annotations/DoctrineAnnotations.php');
     if ($useSimpleAnnotationReader) {
         // Register the ORM Annotations in the AnnotationRegistry
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ODM\\OrientDB\\Mapping\\Annotations');
         $cachedReader = new CachedReader($reader, new ArrayCache());
         return new AnnotationDriver($cachedReader, (array) $paths);
     }
     return new AnnotationDriver(new CachedReader(new AnnotationReader(), new ArrayCache()), (array) $paths);
 }
 /**
  * Add a new default annotation driver with a correctly configured annotation reader.
  * 
  * @param array $paths
  * @return Mapping\Driver\AnnotationDriver
  */
 public function newDefaultAnnotationDriver($paths = array())
 {
     if (version_compare(\Doctrine\Common\Version::VERSION, '3.0.0-DEV', '>=')) {
         // Register the ORM Annotations in the AnnotationRegistry
         AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
         $reader = new AnnotationReader();
         $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ApcCache());
     } else {
         if (version_compare(\Doctrine\Common\Version::VERSION, '2.3.0-DEV', '>=')) {
             // Register the ORM Annotations in the AnnotationRegistry
             // Done manually according to MongoDB ODM but that breaks existing code quickly
             AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
             $reader = new SimpleAnnotationReader();
             $reader->addNamespace('Doctrine\\OXM\\Mapping');
             $reader = new \Doctrine\Common\Annotations\CachedReader($reader, new \Doctrine\Common\Cache\ApcCache());
         } else {
             if (version_compare(\Doctrine\Common\Version::VERSION, '2.1.0-DEV', '>=')) {
                 // Register the ORM Annotations in the AnnotationRegistry
                 AnnotationRegistry::registerFile(__DIR__ . '/Mapping/Driver/DoctrineAnnotations.php');
                 $reader = new AnnotationReader();
                 $reader->setDefaultAnnotationNamespace('Doctrine\\OXM\\Mapping\\');
                 $reader->setIgnoreNotImportedAnnotations(true);
                 $reader->setEnableParsePhpImports(false);
                 $reader = new \Doctrine\Common\Annotations\CachedReader(new \Doctrine\Common\Annotations\IndexedReader($reader), new \Doctrine\Common\Cache\ApcCache());
             } else {
                 $reader = new AnnotationReader();
                 $reader->setDefaultAnnotationNamespace('Doctrine\\OXM\\Mapping\\');
             }
         }
     }
     return new AnnotationDriver($reader, (array) $paths);
 }
示例#23
0
 /**
  * Create an instance of the Kohana annotation driver, which supports loading model files from across the CFS. Also
  * handles registering the Doctrine annotations in the Annotation registry - which would normally be handled by
  * Doctrine\ORM\Configuration::newDefaultAnnotationDriver.
  *
  * @return Doctrine_KohanaAnnotationDriver
  * @see Doctrine\ORM\Configuration::newDefaultAnnotationDriver
  */
 protected function create_annotation_driver()
 {
     $config = $this->config->load('doctrine');
     // Register the Doctrine annotations
     $vendor_path = $config->get('composer_vendor_path');
     AnnotationRegistry::registerFile($vendor_path . 'doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     if ($config->get('use_simple_annotation_reader')) {
         // Register the ORM Annotations in the AnnotationReader
         $reader = new SimpleAnnotationReader();
         $reader->addNamespace('Doctrine\\ORM\\Mapping');
     } else {
         $reader = new AnnotationReader();
     }
     $cachedReader = new CachedReader($reader, new ArrayCache());
     return new Doctrine_KohanaAnnotationDriver($cachedReader, Kohana::include_paths());
 }
 /**
  * Get an annotation reader instance.
  *
  * @return \Doctrine\Common\Annotations\SimpleAnnotationReader
  */
 protected function getReader()
 {
     $reader = new SimpleAnnotationReader();
     foreach ($this->namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     return $reader;
 }
示例#25
0
 /**
  * @param array $namespaces
  * @return \Doctrine\Common\Annotations\Reader
  */
 protected function newDoctrineAnnotationImpl(array $namespaces)
 {
     $this->registerAnnotationLoader($namespaces);
     $reader = new Annotations\SimpleAnnotationReader();
     foreach ($namespaces as $namespace) {
         $reader->addNamespace($namespace);
     }
     return $reader;
 }
示例#26
0
 /**
  * Generate the documentation contents from the resources collection.
  *
  * @param \Illuminate\Support\Collection $resources
  * @param string $name
  *
  * @return string
  */
 protected function generateContentsFromResources(Collection $resources, $name)
 {
     $contents = '';
     $contents .= $this->getFormat();
     $contents .= $this->line(2);
     $contents .= sprintf('# %s', $name);
     $contents .= $this->line(2);
     $content = ' [Home](' . $this->baseUrl . $this->homeUrl . ')' . "\n";
     $resources->each(function ($resource) use(&$contents, $content) {
         if ($resource->getActions()->isEmpty()) {
             return;
         }
         $contents .= $this->line(2);
         $contents .= $resource->getDefinition();
         $contents .= "\n" . '| Name: | Method: | Route: |' . "\n";
         $contents .= '| :-------- | :-------- | :-------- |' . "\n";
         $content .= "\n" . $resource->getDefinition();
         if ($description = $resource->getDescription()) {
             $content .= $this->line();
             $content .= $description;
         }
         if (($parameters = $resource->getParameters()) && !$parameters->isEmpty()) {
             $this->appendParameters($content, $parameters);
         }
         $resource->getActions()->each(function ($action) use(&$contents, $content, $resource) {
             $content .= "\n" . $action->getDefinition();
             if ($description = $action->getDescription()) {
                 $content .= $this->line();
                 $content .= $description;
             }
             if (($attributes = $action->getAttributes()) && !$attributes->isEmpty()) {
                 $this->appendAttributes($content, $attributes);
             }
             if (($parameters = $action->getParameters()) && !$parameters->isEmpty()) {
                 $this->appendParameters($content, $parameters);
             }
             if ($request = $action->getRequest()) {
                 $this->appendRequest($content, $request, $resource);
             }
             if ($response = $action->getResponse()) {
                 $this->appendResponse($content, $response, $resource);
             }
             if ($transaction = $action->getTransaction()) {
                 foreach ($transaction->value as $value) {
                     if ($value instanceof Annotation\Request) {
                         $this->appendRequest($content, $value, $resource);
                     } elseif ($value instanceof Annotation\Response) {
                         $this->appendResponse($content, $value, $resource);
                     } else {
                         throw new RuntimeException('Unsupported annotation type given in transaction.');
                     }
                 }
             }
             $baseUrl = substr($action->getRoute(), 1);
             $fileUrl = $this->getFileUrl($baseUrl, $action->getIdentifier());
             $file = strtolower($action->getMethod()) . '-' . $fileUrl . '.md';
             $this->writer->write(stripslashes(trim($content)), $this->includePath . '/' . $file);
             $contents .= $this->generateLink($action->getMethod(), $fileUrl, $action->getHttpVerb(), $action->getRoute());
         });
     });
     return stripslashes($contents);
 }
 public static function getService(ArrayObject $config, Loops $loops)
 {
     if (@$config->simple) {
         $annotation_reader = new SimpleAnnotationReader();
         $annotation_reader->addNamespace("Loops\\Annotations");
         $annotation_reader->addNamespace("Loops\\Annotations\\Access");
         $annotation_reader->addNamespace("Loops\\Annotations\\Admin");
         $annotation_reader->addNamespace("Loops\\Annotations\\Element");
         $annotation_reader->addNamespace("Loops\\Annotations\\Element\\Doctrine");
         $annotation_reader->addNamespace("Loops\\Annotations\\Event\\Form");
         $annotation_reader->addNamespace("Loops\\Annotations\\Event\\Renderer");
         $annotation_reader->addNamespace("Loops\\Annotations\\Event\\Session");
         $annotation_reader->addNamespace("Loops\\Annotations\\Form");
         $annotation_reader->addNamespace("Loops\\Annotations\\Form\\Element");
         $annotation_reader->addNamespace("Loops\\Annotations\\Navigation");
         $annotation_reader->addNamespace("Loops\\Annotations\\Session");
         return $annotation_reader;
     } else {
         return new AnnotationReader();
     }
 }
示例#28
0
 protected function getDomainObjectAnnotations()
 {
     $reader = new SimpleAnnotationReader();
     $reader->addNamespace('Oneup\\AclBundle\\Mapping\\Annotation');
     $object = new \ReflectionClass('Oneup\\AclBundle\\Tests\\Model\\SomeObject');
     return $reader->getClassAnnotations($object);
 }