Example #1
0
 /**
  * @param $key
  * @return Lock
  */
 public static function get($key)
 {
     $lock = new self();
     $lock->getById($key);
     return $lock;
 }
Example #2
0
 /**
  * @param $id
  * @return null|TmpStore
  */
 public static function get($id)
 {
     $item = new self();
     if ($item->getById($id)) {
         if ($item->getExpiryDate() < time()) {
             self::delete($id);
         } else {
             return $item;
         }
     }
     return null;
 }
Example #3
0
 /**
  * Remove a library
  *
  * @param  array $fields
  * @return void
  */
 public function process(array $fields)
 {
     if (isset($fields['rm_media_libraries'])) {
         foreach ($fields['rm_media_libraries'] as $id) {
             $library = Table\MediaLibraries::findById((int) $id);
             if (isset($library->id)) {
                 $dir = new Dir($_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . '/' . $library->folder);
                 $dir->emptyDir(true);
                 $library->delete();
             }
         }
     } else {
         if (isset($fields['process_media_libraries'])) {
             foreach ($fields['process_media_libraries'] as $id) {
                 $library = new self();
                 $library->getById((int) $id);
                 if (isset($library->id)) {
                     $class = 'Pop\\Image\\' . $library->adapter;
                     $formats = array_keys($class::getFormats());
                     $media = Table\Media::findBy(['library_id' => $library->id]);
                     if ($media->count() > 0) {
                         $med = new Media();
                         foreach ($media->rows() as $m) {
                             $fileParts = pathinfo($m->file);
                             if (!empty($fileParts['extension']) && in_array($fileParts['extension'], $formats)) {
                                 $med->processImage($m->file, $library);
                             }
                         }
                     }
                 }
             }
         }
     }
 }