Example #1
0
 /**
  * Factory for cache implementations.
  *
  * @param array $options Cache options.
  *
  * @throws CacheException
  * @return ICache
  */
 private static function _returnCacheFromImpl($options)
 {
     switch ($options['impl']) {
         case 'file':
             return FileCacheImpl::getInstance($options);
         case 'apc':
             return ApcCacheImpl::getInstance($options);
         case 'dummy':
             return DummyCacheImpl::getInstance($options);
         case 'zend':
             return ZendCacheImpl::getInstance($options['zend']);
         case 'memcached':
             return MemcachedCacheImpl::getInstance($options['memcached']);
         default:
             throw new CacheException('Invalid cache impl requested');
     }
 }
Example #2
0
 /**
  * Constructor.
  *
  * @param array $options options.
  *
  * @return void
  */
 protected function __construct(array $options)
 {
     // Setup logger.
     $this->_logger = \Logger::getLogger(get_class($this));
     $this->_logDebugEnabled = $this->_logger->isDebugEnabled();
     $soullessArray = array();
     $this->_beanAliases = $soullessArray;
     $this->_beanDefs = $soullessArray;
     $this->_beans = $soullessArray;
     $this->_shutdowners = $soullessArray;
     $this->_resources = $soullessArray;
     $this->_eventListeners = $soullessArray;
     $this->_properties = $soullessArray;
     // Merge options with our defaults.
     self::$_options = array_replace_recursive(self::$_options, $options);
     $this->registerProperties(self::$_options['properties']);
     $sapi = php_sapi_name();
     if (function_exists('pcntl_signal')) {
         if ($sapi == 'cgi' || $sapi == 'cli') {
             $signals = array(SIGQUIT, SIGHUP, SIGINT, SIGCHLD, SIGTERM, SIGUSR1, SIGUSR2);
             $handler = array($this, 'signalHandler');
             foreach ($signals as $signal) {
                 pcntl_signal($signal, $handler);
             }
             pcntl_sigprocmask(SIG_UNBLOCK, $signals);
         }
     }
     set_error_handler(array($this, 'errorHandler'));
     register_shutdown_function(array($this, 'shutdownHandler'));
     $this->_lifecycleManager = new BeanLifecycleManager();
     $this->_dispatcherTemplate = new DispatcherImpl();
     $this->_aspectManager = new AspectManager();
     $this->_aspectManager->setCache(DummyCacheImpl::getInstance());
     $this->_beanDefCache = DummyCacheImpl::getInstance();
     $this->_beanCache = DummyCacheImpl::getInstance();
     $this->registerBeanDefinitionProvider(new Core(self::$_options));
     $this->_reflectionFactory = $this;
     $this->_reflectionFactory = $this->getBean('dingReflectionFactory');
     $this->_proxyFactory = $this->getBean('dingProxyFactory');
     $this->_beanDefCache = $this->getBean('dingDefinitionsCache');
     $this->_beanCache = $this->getBean('dingBeanCache');
     $this->_lifecycleManager = $this->getBean('dingLifecycleManager');
     $this->_aspectManager = $this->getBean('dingAspectManager');
     $this->_dispatcherTemplate = $this->getBean('dingAspectCallDispatcher');
     // Set drivers
     if (isset(self::$_options['bdef']['xml'])) {
         $xmlDriver = $this->getBean('dingXmlBeanDefinitionProvider');
     }
     if (isset(self::$_options['bdef']['yaml'])) {
         $yamlDriver = $this->getBean('dingYamlBeanDefinitionProvider');
     }
     $this->getBean('dingPropertiesDriver');
     $this->getBean('dingMessageSourceDriver');
     $this->getBean('dingMethodInjectionDriver');
     // All set, continue.
     if (isset(self::$_options['bdef']['annotation'])) {
         $this->getBean('dingAnnotationDiscovererDriver');
         $this->getBean('dingAnnotationBeanDefinitionProvider');
         $this->getBean('dingAnnotationValueDriver');
         $this->getBean('dingAnnotationResourceDriver');
         $this->getBean('dingAnnotationInjectDriver');
         $this->getBean('dingAnnotationInitDestroyMethodDriver');
         $this->getBean('dingAnnotationRequiredDriver');
         $this->getBean('dingMvcAnnotationDriver');
     }
     $this->_lifecycleManager->afterConfig();
 }