Ejemplo n.º 1
0
 /**
  * Transforms the given project into a series of artifacts as provided by the templates.
  *
  * @param ProjectDescriptor $project
  *
  * @return void
  */
 public function execute(ProjectDescriptor $project)
 {
     Dispatcher::getInstance()->dispatch('transformer.transform.pre', PreTransformEvent::createInstance($this));
     if ($this->getBehaviours() instanceof Behaviour\Collection) {
         $this->log(sprintf('Applying %d behaviours', count($this->getBehaviours())));
         $this->getBehaviours()->process($project);
     }
     $transformations = $this->getTemplates()->getTransformations();
     $this->log(sprintf('Applying %d transformations', count($transformations)));
     foreach ($transformations as $transformation) {
         $this->log('  Writer ' . $transformation->getWriter() . ($transformation->getQuery() ? ' using query "' . $transformation->getQuery() . '"' : '') . ' on ' . $transformation->getArtifact());
         $transformation->setTransformer($this);
         /** @var Writer\WriterAbstract $writer  */
         $writer = $this->writers[$transformation->getWriter()];
         Dispatcher::getInstance()->dispatch('transformer.transformation.pre', PreTransformationEvent::createInstance($this));
         $writer->transform($project, $transformation);
         Dispatcher::getInstance()->dispatch('transformer.transformation.post', PostTransformationEvent::createInstance($this));
     }
     Dispatcher::getInstance()->dispatch('transformer.transform.post', PostTransformEvent::createInstance($this));
     $this->log('Finished transformation process');
 }
Ejemplo n.º 2
0
 /**
  * Executes each transformation.
  *
  * @return void
  */
 public function execute()
 {
     $source = $this->getSource();
     if (!$source) {
         throw new Exception('Unable to process transformations; the source was not set ' . 'correctly');
     }
     // invoke pre-transform actions (i.e. enhance source file with additional
     // meta-data)
     \phpDocumentor\Event\Dispatcher::getInstance()->dispatch('transformer.transform.pre', \phpDocumentor\Transformer\Event\PreTransformEvent::createInstance($this)->setSource($source));
     foreach ($this->getTransformations() as $transformation) {
         \phpDocumentor\Event\Dispatcher::getInstance()->dispatch('transformer.transformation.pre', \phpDocumentor\Transformer\Event\PreTransformationEvent::createInstance($this)->setSource($source));
         $this->log('Applying transformation' . ($transformation->getQuery() ? ' query "' . $transformation->getQuery() . '"' : '') . ' using writer ' . get_class($transformation->getWriter()) . ' on ' . $transformation->getArtifact());
         $transformation->execute($source);
         \phpDocumentor\Event\Dispatcher::getInstance()->dispatch('transformer.transformation.post', \phpDocumentor\Transformer\Event\PostTransformationEvent::createInstance($this)->setSource($source));
     }
     \phpDocumentor\Event\Dispatcher::getInstance()->dispatch('transformer.transform.post', \phpDocumentor\Transformer\Event\PostTransformEvent::createInstance($this)->setSource($source));
 }
Ejemplo n.º 3
0
 /**
  * Transforms the given project into a series of artifacts as provided by the templates.
  *
  * @param ProjectDescriptor $project
  *
  * @return void
  */
 public function execute(ProjectDescriptor $project)
 {
     Dispatcher::getInstance()->dispatch(self::EVENT_PRE_TRANSFORM, PreTransformEvent::createInstance($this)->setProject($project));
     $transformations = $this->getTemplates()->getTransformations();
     $this->initializeWriters($project, $transformations);
     $this->transformProject($project, $transformations);
     Dispatcher::getInstance()->dispatch(self::EVENT_POST_TRANSFORM, PostTransformEvent::createInstance($this));
     $this->log('Finished transformation process');
 }