Пример #1
0
 /**
  * Ensures there we have validation rules restricting file types to valid image filetypes and
  * that the paths for any thumbnails exist and are writable.
  *
  * @param  array  $options
  */
 public function __construct($options = array())
 {
     parent::__construct($options);
     // Check that all thumbnail directories are writable...
     foreach ($this->thumbnails as $key => $thumbnail) {
         if (!isset($thumbnail['quality'])) {
             // Use default quality
             $thumbnail['quality'] = $this->quality;
         }
         if (isset($thumbnail['path'])) {
             // Ensure the path is normalized and writable if set
             $thumbnail['path'] = $this->_check_path($thumbnail['path']);
         }
         if (!isset($thumbnail['prefix'])) {
             // Force the thumbnail prefix to NULL if not set
             $thumbnail['prefix'] = NULL;
         }
         if (!isset($thumbnail['transformations'])) {
             // Create an empty array for thumbnail tranformations if not set
             $thumbnail['transformations'] = array();
         }
         if (!$thumbnail['prefix'] and (!isset($thumbnail['path']) or $thumbnail['path'] === $this->path)) {
             // If no prefix is set and the thumbnail path is the same as the original path throw exception
             throw new Kohana_Exception(':class must have a different `path` or a defined `prefix` property for thumbnails', array(':class' => get_class($this)));
         }
         // Merge back in
         $this->thumbnails[$key] = $thumbnail;
     }
 }