/**
  * Creates a filename from title, prefixed with date if required.
  *
  * @param string The title to use e.g. IMG-1234.jpg
  * @return string The filename
  */
 protected function buildFilename($title)
 {
     $ext = pathinfo($title, PATHINFO_EXTENSION);
     $filename = str_replace('.' . $ext, '', $title);
     $datePrefix = '/';
     if ($this->mediaOrganizeByDate) {
         $now = $this->DateFactory->newStorageDate();
         $datePrefix = $now->format('/Y/m/d/');
     }
     return $datePrefix . SlugUtils::createSlug($filename) . '.' . strtolower($ext);
 }
 /**
  * Performs a fetch of our data from the filecache without logging in the logger.
  * That allows this method to be used in other locations.
  *
  * @param string $key The key to fetch
  *
  * @return mixed Data in this->storageFormat format or FALSE if data is invalid
  */
 protected function getData($key)
 {
     $filename = $this->file($key);
     if (!file_exists($filename)) {
         return false;
     } else {
         $data = $this->readFile($filename);
         if ($this->isExpired(null, $data)) {
             return false;
         } else {
             // if going to expire in 10 seconds, extend the cache and let this request refresh it
             $expire = $data['expires'];
             $value = $data['value'];
             $duration = $data['duration'];
             $now = $this->DateFactory->newStorageDate();
             if (!empty($value) && $duration > 0 && $now->toUnix() > $expire - 10) {
                 $this->put($key, $value, $duration);
                 return false;
             }
             return $data;
         }
     }
 }