/**
  * returns classes that are taged with all of the specified tags
  *
  * @param string $tags
  * @return void
  * @author Marc Neuhaus
  */
 public function getClassesAnnotatedWith($tags)
 {
     $cache = $this->cacheManager->getCache('Admin_ImplementationCache');
     $identifier = "ClassesTaggedWith-" . implode("_", $tags);
     if (!$cache->has($identifier)) {
         $classes = array();
         $activePackages = $this->packageManager->getActivePackages();
         foreach ($activePackages as $packageName => $package) {
             if (substr($packageName, 0, 8) === "Doctrine") {
                 continue;
             }
             foreach ($package->getClassFiles() as $class => $file) {
                 $annotations = $this->getClassConfiguration($class);
                 $tagged = true;
                 foreach ($tags as $tag) {
                     if (!isset($annotations[$tag])) {
                         $tagged = false;
                     }
                 }
                 if ($tagged) {
                     $classes[$class] = $packageName;
                 }
             }
         }
         $cache->set($identifier, $classes);
     } elseif (isset($this->runtimeCache[$identifier])) {
         $classes = $this->runtimeCache[$identifier];
     } else {
         $this->runtimeCache[$identifier] = $classes = $cache->get($identifier);
     }
     return $classes;
 }
예제 #2
0
 public function renderPartial($variant = "Default")
 {
     $replacements = array("@partial" => "Field", "@package" => \Admin\Core\API::get("package"), "@being" => \Admin\Core\Helper::getShortName(\Admin\Core\API::get("being")), "@action" => "Field", "@variant" => $variant);
     $cache = $this->cacheManager->getCache('Admin_TemplateCache');
     $identifier = str_replace("\\", "_", implode("-", $replacements));
     $identifier = str_replace(".", "_", $identifier);
     if (!$cache->has($identifier)) {
         $template = $this->helper->getPathByPatternFallbacks("Partials", $replacements);
         $cache->set($identifier, $template);
     } else {
         $template = $cache->get($identifier);
     }
     $this->view = $this->viewHelperVariableContainer->getView();
     $this->view->setTemplatePathAndFilename($template);
     return $this->view->render();
 }
예제 #3
0
 /**
  *
  * @param object $value
  * @param string $partial
  * @param string $fallbacks
  * @param array $vars
  * @param string $section
  * @param mixed $optional
  * @param string $variant
  * @return string Rendered string
  * @author Marc Neuhaus <*****@*****.**>
  * @api
  */
 public function render($value = '', $partial = '', $fallbacks = '', $vars = array(), $section = null, $optional = false, $variant = "Default")
 {
     if ($value !== '') {
         return $value;
     }
     if ($partial !== '') {
         if ($fallbacks !== '') {
             $replacements = array("@partial" => $partial, "@package" => \Admin\Core\API::get("package"), "@being" => \Admin\Core\Helper::getShortName(\Admin\Core\API::get("being")), "@action" => $partial, "@variant" => $variant);
             $cache = $this->cacheManager->getCache('Admin_TemplateCache');
             $identifier = str_replace("\\", "_", implode("-", $replacements));
             $identifier = str_replace(".", "_", $identifier);
             $identifier = str_replace("/", "_", $identifier);
             if (!$cache->has($identifier)) {
                 $template = $this->helper->getPathByPatternFallbacks($fallbacks, $replacements);
                 $cache->set($identifier, $template);
             } else {
                 $template = $cache->get($identifier);
             }
             if (empty($vars)) {
                 $this->view = $this->viewHelperVariableContainer->getView();
                 $this->view->setTemplatePathAndFilename($template);
                 if (!empty($template)) {
                     return $this->view->render();
                 }
             } else {
                 $partial = $this->parseTemplate($template);
                 $variableContainer = $this->objectManager->create('TYPO3\\Fluid\\Core\\ViewHelper\\TemplateVariableContainer', $vars);
                 $renderingContext = $this->buildRenderingContext($variableContainer);
                 return $partial->render($renderingContext);
             }
         }
     }
     if ($section !== null) {
         $output = $this->viewHelperVariableContainer->getView()->renderSection($section, $vars, $optional);
         if (strlen($output) < 1) {
             $output = $this->renderChildren();
         }
         return $output;
     }
 }
예제 #4
0
 /**
  * returns all active groups
  *
  * @return $groups Array
  * @author Marc Neuhaus
  */
 public function getGroups()
 {
     $this->adapters = $this->getAdapters();
     $cache = $this->cacheManager->getCache('Admin_Cache');
     $identifier = "Groups-" . sha1(implode("-", $this->adapters));
     if (!$cache->has($identifier)) {
         $groups = array();
         $adapters = array();
         foreach ($this->adapters as $adapter) {
             $adapters[$adapter] = $this->objectManager->get($adapter);
             foreach ($adapters[$adapter]->getGroups() as $group => $beings) {
                 foreach ($beings as $conf) {
                     $being = $conf["being"];
                     $conf["adapter"] = $adapter;
                     $groups[$group]["beings"][$being] = $conf;
                 }
             }
         }
         $cache->set($identifier, $groups);
     } else {
         $groups = $cache->get($identifier);
     }
     return $groups;
 }
예제 #5
0
 public function getCache($cache)
 {
     return $this->cacheManager->getCache($cache);
 }
예제 #6
0
 /**
  * @test
  */
 public function flushCachesCallsTheFlushMethodOfAllRegisteredCaches()
 {
     $manager = new \TYPO3\FLOW3\Cache\CacheManager();
     $cache1 = $this->getMock('TYPO3\\FLOW3\\Cache\\Frontend\\AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', FALSE);
     $cache1->expects($this->atLeastOnce())->method('getIdentifier')->will($this->returnValue('cache1'));
     $cache1->expects($this->once())->method('flush');
     $manager->registerCache($cache1);
     $cache2 = $this->getMock('TYPO3\\FLOW3\\Cache\\Frontend\\AbstractFrontend', array('getIdentifier', 'set', 'get', 'getByTag', 'has', 'remove', 'flush', 'flushByTag'), array(), '', FALSE);
     $cache2->expects($this->once())->method('flush');
     $manager->registerCache($cache2);
     $manager->flushCaches();
 }
예제 #7
0
파일: Scripts.php 프로젝트: nxpthx/FLOW3
 /**
  * Initializes the cache framework
  *
  * @param \TYPO3\FLOW3\Core\Bootstrap $bootstrap
  * @return void
  */
 public static function initializeCacheManagement(Bootstrap $bootstrap)
 {
     $configurationManager = $bootstrap->getEarlyInstance('TYPO3\\FLOW3\\Configuration\\ConfigurationManager');
     $environment = $bootstrap->getEarlyInstance('TYPO3\\FLOW3\\Utility\\Environment');
     $cacheManager = new \TYPO3\FLOW3\Cache\CacheManager();
     $cacheManager->setCacheConfigurations($configurationManager->getConfiguration(\TYPO3\FLOW3\Configuration\ConfigurationManager::CONFIGURATION_TYPE_CACHES));
     $cacheManager->injectSystemLogger($bootstrap->getEarlyInstance('TYPO3\\FLOW3\\Log\\SystemLoggerInterface'));
     $cacheFactory = new \TYPO3\FLOW3\Cache\CacheFactory($bootstrap->getContext(), $cacheManager, $environment);
     $bootstrap->setEarlyInstance('TYPO3\\FLOW3\\Cache\\CacheManager', $cacheManager);
     $bootstrap->setEarlyInstance('TYPO3\\FLOW3\\Cache\\CacheFactory', $cacheFactory);
 }