/** * @see \Zend\Mvc\Application#init() * @param array $configuration * @return RealZendApplication */ public static function init($configuration = array()) { Exception\ErrorException::$oldErrorHandler = set_error_handler("\\Netis\\Exception\\ErrorException::errorHandler"); Environment::setEnv(isset($configuration['env']) ? $configuration['env'] : Environment::ENV_PRODUCTION); self::detectLoader($configuration); return parent::init($configuration); }
/** * */ protected function preToString() { $logger = $this->getServiceLocator()->getServiceLocator()->get('Athcore\\Log\\Logger'); try { // obtain Zend\Storage instance $cache = $this->getServiceLocator()->getServiceLocator()->get('Athcore\\Cache\\Cache'); // generate key based on url $caheKey = md5(preg_replace('/[^\\d\\w]/', '-', $this->view->url())) . '-css'; // load the cache if possible, or generate it $itemSet = $cache->getItem($caheKey, $success); // current resource $self = $this; // new container $container = Placeholder\Container::factoryCloneFromContainer($this->getContainer()); $container->setCacheKey($caheKey); if (!$success) { // convert CSS3 preprocessors to CSS3 language $container->filter(function ($item) use($self) { return $self->detectPreprocessors($item); }); // minify code if ($this->config->canMinify()) { $container->organizeForMinify(function ($item) use($self) { return $self->isValid($item); }, function ($o1, $o2) use($self) { return $self->compare($o1, $o2); }); } $itemSet = array_filter($container->getArrayCopy(), function ($item) use($self) { return $self->isValid($item); }); $cache->setItem($caheKey, $itemSet); } // get container $container->exchangeArray($itemSet); // set the new item urls if ($this->config->canMinify()) { $container->addaptUrlsForMinify($this->view, $this->config, function ($item) use($self) { return $self->isValid($item); }); } // add versioning if ($this->config->hasVersion()) { $container->attachVersionToUrl($this->config->getVersion()); } // update container $this->setContainer($container); } catch (\Exception $e) { if (Environment::isDev()) { echo sprintf('<!-- Exception : (type %s) :: %s. Please check logs for more info! -->', get_class($e), $e->getMessage()); } $logger->exception($e); } }
/** * */ protected function preToString() { $logger = $this->getServiceLocator()->getServiceLocator()->get('Athcore\\Log\\Logger'); try { // obtain Zend\Storage instance $cache = $this->getServiceLocator()->getServiceLocator()->get('Athcore\\Cache\\Cache'); // generate key based on url $caheKey = $this->head . '-' . md5(preg_replace('/[^\\d\\w]/', '-', $this->view->url())) . '-js'; // load the cache if possible, or generate it $itemSet = $cache->getItem($caheKey, $success); // current resource $self = $this; // new container $container = Placeholder\Container::factoryCloneFromContainer($this->getContainer()); $container->setCacheKey($caheKey); if (!$success) { // minify code if ($this->config->canMinify()) { $container->organizeForMinify(function ($item) use($self) { return $self->isValid($item); }, function ($o1, $o2) use($self) { return $self->compare($o1, $o2); }, Placeholder\Container::CODE_JS); } $itemSet = array_filter($container->getArrayCopy(), function ($item) use($self) { return $self->isValid($item); }); $cache->setItem($caheKey, $itemSet); } // get container $container->exchangeArray($itemSet); // set the new item urls if ($this->config->canMinify()) { $container->addaptUrlsForMinify($this->view, $this->config, function ($item) use($self) { return $self->isValid($item); }, Placeholder\Container::CODE_JS); } // add versioning if ($this->config->hasVersion()) { $container->attachVersionToUrl($this->config->getVersion(), Placeholder\Container::CODE_JS); } // update container $this->setContainer($container); } catch (\Exception $e) { if (Environment::isDev()) { $container = $this->getContainer(); $item = ArrayUtils::arrayToObject(array('type' => 'text/javascript', 'source' => sprintf('throw new Error(\'(type %s) :: %s. See logs for more details.\')', get_class($e), str_replace('\'', '\\\'', $e->getMessage())))); $container[] = $item; $this->setContainer($container); } $logger->exception($e); } }
/** * @param null|array $options * @return Configuration */ protected function renderConfig($options = null) { if (null == $options) { return $this->getConfiguration(); } $config = new Configuration(); $isDev = Environment::isDev(); if (!empty($options['cache'])) { $config->setMetadataCacheImpl($this->renderCacheClass($options['cache'], $isDev)); } // $driver = $config->newDefaultAnnotationDriver($options['modelsPath']); $driver = $this->renderAnnotationDriver($options['modelsPath'], $config); $config->setMetadataDriverImpl($driver); if (!empty($options['queryCache'])) { $config->setQueryCacheImpl($this->renderCacheClass($options['queryCache'], $isDev)); } $config->setProxyDir($options['modelsProxiesPath']); $config->setProxyNamespace($options['modelsProxiesNamespace']); $config->setAutoGenerateProxyClasses(!empty($options['modelsProxiesAutogenerate'])); return $config; }
/** * Returns a string containing a banner text, that describes the module and/or the application. * The banner is shown in the console window, when the user supplies invalid command-line parameters or invokes * the application with no parameters. * * The method is called with active Zend\Console\Adapter\AdapterInterface that can be used to directly access Console and send * output. * * @param Console $console * @return string|null */ public function getConsoleBanner(Console $console) { if (Environment::isDev()) { $versionClass = $this->getInspector()->getNamespaceName() . '\\Version'; $version = class_exists($versionClass) ? $versionClass::VERSION : ''; return $this->getName() . ' ' . $version; } else { return null; } }