/** * Load custom defined transformations. * * @param Transformer $transformer * * @todo this is an ugly implementation done for speed of development, should be refactored * * @return void */ public function loadTransformations(Transformer $transformer) { $received = array(); $transformations = $this->getConfigValueFromPath('transformations/transformation'); if (is_array($transformations)) { if (isset($transformations['writer'])) { $received[] = new Transformation(isset($transformations['query']) ? $transformations['query'] : '', $transformations['writer'], isset($transformations['source']) ? $transformations['source'] : '', isset($transformations['artifact']) ? $transformations['artifact'] : ''); } else { foreach ($transformations as $transformation) { if (is_array($transformation)) { $received[] = new Transformation(isset($transformations['query']) ? $transformations['query'] : '', $transformations['writer'], isset($transformations['source']) ? $transformations['source'] : '', isset($transformations['artifact']) ? $transformations['artifact'] : ''); } } } } if (!empty($received)) { $template = new Template('__'); foreach ($received as $transformation) { $template[] = $transformation; } $transformer->getTemplates()->append($template); } }
/** * Append received transformations. * * @param Transformer $transformer * @param array $received * * @return void */ protected function appendReceivedTransformations(Transformer $transformer, $received) { if (!empty($received)) { $template = new Template('__'); foreach ($received as $transformation) { $template[] = $transformation; } $transformer->getTemplates()->append($template); } }
/** * @covers phpDocumentor\Transformer\Transformer::getTemplates */ public function testRetrieveTemplateCollection() { $templateCollectionMock = m::mock('phpDocumentor\\Transformer\\Template\\Collection'); $templateCollectionMock->shouldIgnoreMissing(); $writerCollectionMock = m::mock('phpDocumentor\\Transformer\\Writer\\Collection'); $writerCollectionMock->shouldIgnoreMissing(); $fixture = new Transformer($templateCollectionMock, $writerCollectionMock); $this->assertEquals($templateCollectionMock, $fixture->getTemplates()); }