/** * */ 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); } }