Beispiel #1
0
 /**
  * Attach rule validation
  * @param qio\Cache $cache
  */
 function execute(qio\Cache $cache)
 {
     $sourcePath = $this->source->getPath();
     if (empty($this->target)) {
         return;
     }
     $cachePath = $this->target->getPath();
     if (!is_file($sourcePath) || !is_file($cachePath)) {
         return;
     }
     $sourceLastModified = $this->source->getLastModified();
     $targetLastModified = $this->target->getLastModified();
     $cache->attach('has', function ($sender, $e) use($sourceLastModified, $targetLastModified) {
         if ($sourceLastModified > $targetLastModified) {
             $e->cancel();
             return false;
         }
         return true;
     });
 }
Beispiel #2
0
 /**
  * Retrieves cache destination of specific source asset
  * @param \qio\Asset $asset
  * @return \qio\File\Asset
  */
 public function getTarget(qio\Asset $asset)
 {
     $path = qtil\StringUtil::flipDS($asset->getPath());
     $nfo = pathinfo($path);
     $basename = $nfo['basename'];
     $targetPath = $this->getDestination()->getPath() . DIRECTORY_SEPARATOR . $basename;
     return new \qio\File\Asset($this, $targetPath);
 }