예제 #1
0
 /**
  * Get template content
  *
  * @param string $template
  * @return string
  * @throws \Exception
  */
 public function getTemplate($template)
 {
     $hash = sprintf('%x', crc32($template));
     if (isset($this->cachedTemplates[$hash])) {
         return $this->cachedTemplates[$hash];
     }
     $this->cachedTemplates[$hash] = $this->readerFactory->create(['fileCollector' => $this->aggregatedFileCollectorFactory->create(['searchPattern' => $template]), 'domMerger' => $this->domMerger])->getContent();
     $this->cache->save(serialize($this->cachedTemplates), static::CACHE_ID);
     return $this->cachedTemplates[$hash];
 }
예제 #2
0
 /**
  * Get UIReader and collect base files configuration
  *
  * @param string $name
  * @return UiReaderInterface
  */
 public function getReader($name)
 {
     if (!isset($this->uiReader[$name])) {
         $this->domMerger->unsetDom();
         $this->uiReader[$name] = $this->readerFactory->create(['fileCollector' => $this->aggregatedFileCollectorFactory->create(['searchPattern' => sprintf(ManagerInterface::SEARCH_PATTERN, $name)]), 'domMerger' => $this->domMerger]);
     }
     return $this->uiReader[$name];
 }
예제 #3
0
 /**
  * @dataProvider getComponentData()
  */
 public function testPrepareGetData($componentName, $componentData, $isCached, $readerData, $expectedResult)
 {
     $this->readerFactory->expects($this->any())->method('create')->with(['fileCollector' => $this->aggregatedFileCollector, 'domMerger' => $this->domMerger])->willReturn($this->uiReader);
     $this->aggregatedFileCollectorFactory->expects($this->any())->method('create')->willReturn($this->aggregatedFileCollector);
     $this->argumentInterpreter->expects($this->any())->method('evaluate')->willReturnCallback(function ($argument) {
         return ['argument' => $argument['value']];
     });
     $this->arrayObjectFactory->expects($this->any())->method('create')->willReturn($componentData);
     $this->cacheConfig->expects($this->any())->method('load')->with(Manager::CACHE_ID . '_' . $componentName)->willReturn($isCached);
     $this->uiReader->expects($this->any())->method('read')->willReturn($readerData);
     $this->assertEquals($expectedResult, $this->manager->prepareData($componentName)->getData($componentName));
 }