Ejemplo n.º 1
0
 /**
  * 
  * @param UiComposer $composer
  * @param DomElement $incElement
  * @return UiComponent
  */
 public static function factory(UiComposer $composer, $incElement)
 {
     $services = $composer->getServiceLocator();
     $context = self::getContextDescription($incElement, $composer->getContextData());
     $xpath = new DOMXpath($context);
     $class = $xpath->getFirstMatchingXpath(self::getRules($services));
     if (!class_exists($class)) {
         $services->get('log')->warn('Unknown UiComponent: ' . $class);
         $class = '\\BaseXMS\\UiComposer\\UiComponent\\UiComponent';
     }
     $services->get('log')->info('Loading UiComponent: ' . $class);
     $component = new $class();
     $component->setUiComposer($composer);
     $component->setContext($context);
     return $component;
 }
Ejemplo n.º 2
0
 /**
  * @return \BaseXMS\UiComposer\UiComponent\mixed
  */
 protected function getRenderResult()
 {
     if (!$this->isRendered()) {
         // Let's check the cache first
         if ($this instanceof Cacheable && $this->uiComposer->getServiceLocator()->has('cache')) {
             $cache = $this->uiComposer->getServiceLocator()->get('cache');
             $key = $this->getCacheKey();
             if ($cache->hasItem($key)) {
                 $this->uiComposer->getServiceLocator()->get('log')->debug('RenderResult cache hit.');
                 $this->renderResult = $cache->getItem($key);
             } else {
                 $this->uiComposer->getServiceLocator()->get('log')->debug('RenderResult cache miss.');
                 $this->render();
                 // Add to cache
                 $cache->setItem($key, $this->renderResult);
                 $cache->setXml($key, $this->getContext());
             }
         } else {
             $this->render();
         }
     }
     return $this->renderResult;
 }