Example #1
0
 public function __construct($noContainerCache = false)
 {
     $this->environment();
     $this->errors();
     $this->root = $this->root();
     $this->apiToken = $this->apiTokenFromRequest();
     $items = [$this->root . '-collections' => false, $this->root . '-forms' => false, $this->root . '-bundles' => false, $this->root . '-topics' => false, $this->root . '-routes' => false, $this->root . '-container' => false, $this->root . '-languages' => false, $this->root . '-config' => false];
     if (!empty($this->apiToken)) {
         $items['person-' . $this->apiToken] = false;
     }
     $cache = new Cache();
     $cacheResult = $cache->getBatch($items);
     $containerCache = [];
     if ($noContainerCache === false && isset($items[$this->root . '-container'])) {
         $containerCache = json_decode($items[$this->root . '-container'], true);
     }
     if ($items[$this->root . '-routes'] != false) {
         $this->routeCached = true;
     }
     $config = new Config($this->root);
     if ($items[$this->root . '-config'] !== false) {
         $configData = json_decode($items[$this->root . '-config'], true);
         if (isset($configData[$this->environment])) {
             $config->cacheSet($configData[$this->environment]);
         } elseif (isset($configData['default'])) {
             $config->cacheSet($configData['default']);
         }
     } else {
         $config->cacheSet();
     }
     $this->container = Container::instance($this->root, $config, $this->root . '/../config/containers/container.yml', $noContainerCache, $containerCache);
     $this->container->set('cache', $cache);
     $this->cache($items);
 }
Example #2
0
 public function testGetBatch()
 {
     $cache = new Cache(self::ROOT);
     $items = ['phpunit-test' => function () {
         return 'C';
     }, 'phpunit-test2' => function () {
         return 'D';
     }];
     $this->assertTrue($cache->getBatch($items, 0));
     $this->assertTrue('B' === $items['phpunit-test']);
     $this->assertTrue('D' === $items['phpunit-test2']);
 }