/** * Applies the given transformation to the provided project. * * This method will attempt to find an appropriate writer for the given transformation and invoke that with the * transformation and project so that an artifact can be generated that matches the intended transformation. * * In addition this method will emit the following events: * * - transformer.transformation.pre, before the project has been transformed with this transformation. * - transformer.transformation.post, after the project has been transformed with this transformation * * @param Transformation $transformation * @param ProjectDescriptor $project * * @uses Dispatcher to emit the events surrounding a transformation. * * @return void */ private function applyTransformationToProject(Transformation $transformation, ProjectDescriptor $project) { $this->log(sprintf(' Writer %s %s on %s', $transformation->getWriter(), $transformation->getQuery() ? ' using query "' . $transformation->getQuery() . '"' : '', $transformation->getArtifact())); $preTransformationEvent = PreTransformationEvent::createInstance($this)->setTransformation($transformation); Dispatcher::getInstance()->dispatch(self::EVENT_PRE_TRANSFORMATION, $preTransformationEvent); $writer = $this->writers[$transformation->getWriter()]; $writer->transform($project, $transformation); $postTransformationEvent = PostTransformationEvent::createInstance($this); Dispatcher::getInstance()->dispatch(self::EVENT_POST_TRANSFORMATION, $postTransformationEvent); }