getPath() public méthode

get the path
Since: 3.0.0
public getPath ( mixed $bundle = null ) : string
$bundle mixed key or collection of the bundle
Résultat string
Exemple #1
0
 /**
  * concat the collection
  *
  * @since 3.0.0
  *
  * @param array $optionArray
  * @param array $rewriteArray
  *
  * @return Loader
  */
 public function concat($optionArray = [], $rewriteArray = [])
 {
     $bundleArray = [];
     $restArray = [];
     /* prevent as needed */
     if ($this->_registry->get('noCache')) {
         return $this;
     }
     /* process collection */
     foreach ($this->_collectionArray as $collectionKey => $attributeArray) {
         $path = $attributeArray[$optionArray['attribute']];
         $fileArray = pathinfo($path);
         if (is_file($path) && $fileArray['extension'] === $optionArray['extension']) {
             $bundleArray[] = $attributeArray[$optionArray['attribute']];
         } else {
             $restArray[] = $attributeArray;
         }
     }
     /* cache as needed */
     $cache = new Cache();
     $cache->init($optionArray['directory'], $optionArray['extension']);
     /* load from cache */
     if ($cache->validate($bundleArray, $optionArray['lifetime'])) {
         $this->_collectionArray = $restArray;
         $this->_collectionArray['bundle'] = [$optionArray['attribute'] => $cache->getPath($bundleArray)];
         if ($optionArray['extension'] === 'css') {
             $this->_collectionArray['bundle']['rel'] = 'stylesheet';
         }
     } else {
         $content = $this->_getContent($bundleArray, $rewriteArray);
         $cache->store($bundleArray, $content);
     }
     return $this;
 }
Exemple #2
0
 /**
  * testClearInvalid
  *
  * @since 3.0.0
  */
 public function testClearInvalid()
 {
     /* setup */
     $cache = new Cache();
     $cache->init(Stream::url('root'), 'cache')->store('test1', 'test')->store('test2', 'test')->store('test3', 'test')->store('test4', 'test');
     touch($cache->getPath('test1'), time() - 3600);
     touch($cache->getPath('test2'), time() - 3600);
     touch($cache->getPath('test3'), time() - 3600);
     $cache->clearInvalid();
     /* compare */
     $this->assertFalse(is_file($cache->getPath('test1')));
     $this->assertFalse(is_file($cache->getPath('test2')));
     $this->assertFalse(is_file($cache->getPath('test3')));
     $this->assertTrue(is_file($cache->getPath('test4')));
 }