Esempio n. 1
0
 /**
  * @return array
  */
 public function list() : array
 {
     $services = $this->repo->list();
     /** @var $service Service */
     foreach ($this->services as $service) {
         $services[] = $service->name();
     }
     return $services;
 }
Esempio n. 2
0
 /**
  * @param string $key
  * @param $object
  * @return bool
  */
 public function set(string $key, $object) : bool
 {
     if (!is_object($object)) {
         return false;
     }
     $this->repo->push($object, $key);
     if ($this->cache) {
         try {
             $this->cache->set($key, clone $object);
         } catch (CacheException $e) {
             trigger_error($e->getParsed(), E_USER_WARNING);
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Register Translator (i18n) Component
  * @param string $lang
  * @return Translator\Language
  */
 protected function getCachedLanguage(string $lang) : Translator\Language
 {
     // Get cache Disk instance
     $cache = $this->disks->pull("cache");
     // Cached language file
     $langFile = sprintf("bootstrap.lang_%s.php.cache", strtolower($lang));
     try {
         $lang = unserialize($cache->read($langFile));
     } catch (DiskException $e) {
     }
     // Got language?
     if (!isset($lang) || !$lang instanceof Translator\Language) {
         $lang = $this->translator->language($lang);
         // Write to cache
         $cache->write($langFile, serialize($lang), Disk::WRITE_FLOCK);
     }
     // Return Language instance
     return $lang;
 }