Пример #1
0
 /**
  * Factory method which creates the specified cache along with the specified kind of backend.
  * After creating the cache, it will be registered at the cache manager.
  *
  * @param string $cacheIdentifier The name / identifier of the cache to create
  * @param string $cacheObjectName Object name of the cache frontend
  * @param string $backendObjectName Object name of the cache backend
  * @param array $backendOptions (optional) Array of backend options
  * @return \TYPO3\FLOW3\Cache\Frontend\FrontendInterface The created cache frontend
  * @throws \TYPO3\FLOW3\Cache\Exception\InvalidBackendException
  * @throws \TYPO3\FLOW3\Cache\Exception\InvalidCacheException
  * @api
  */
 public function create($cacheIdentifier, $cacheObjectName, $backendObjectName, array $backendOptions = array())
 {
     $backend = new $backendObjectName($this->context, $backendOptions);
     if (!$backend instanceof \TYPO3\FLOW3\Cache\Backend\BackendInterface) {
         throw new \TYPO3\FLOW3\Cache\Exception\InvalidBackendException('"' . $backendObjectName . '" is not a valid cache backend object.', 1216304301);
     }
     $backend->injectEnvironment($this->environment);
     if (is_callable(array($backend, 'initializeObject'))) {
         $backend->initializeObject(\TYPO3\FLOW3\Object\ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
     }
     $cache = new $cacheObjectName($cacheIdentifier, $backend);
     if (!$cache instanceof \TYPO3\FLOW3\Cache\Frontend\FrontendInterface) {
         throw new \TYPO3\FLOW3\Cache\Exception\InvalidCacheException('"' . $cacheObjectName . '" is not a valid cache frontend object.', 1216304300);
     }
     if (is_callable(array($cache, 'initializeObject'))) {
         $cache->initializeObject(\TYPO3\FLOW3\Object\ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED);
     }
     $this->cacheManager->registerCache($cache);
     return $cache;
 }