Example #1
0
 /**
  * Sets preset.
  *
  * Preset can be set in several ways:
  * - preset name to get one of presets defined in Imagine
  * - preset name and preset data to create preset on the fly
  * - instance of SystemPlugin_Imagine_Preset with custom preset
  * - only with data as "anonymous" preset (it name will be set to width + x + height)
  *
  * @param SystemPlugin_Imagine_Preset|string|array  $preset Preset instance, preset name or preset data as array.
  * @param array                                     $data   Preset data.
  *
  * @return SystemPlugin_Imagine_Manager
  */
 public function setPreset($preset = null, $data = null)
 {
     if ($preset instanceof SystemPlugin_Imagine_Preset) {
         $this->preset = $preset;
     } else {
         if (is_null($preset)) {
             $preset = 'default';
         }
         $this->preset = $this->plugin->getPreset($preset, $data);
     }
     if (!is_null($this->preset['__module'])) {
         $this->setModule($this->preset['__module']);
     }
     if (!is_null($this->preset['__imagine']) && $this->preset['__imagine'] instanceof \Imagine\Image\ImagineInterface) {
         $this->setImagine($this->preset['__imagine']);
     }
     if (!is_null($this->preset['__transformation']) && $this->preset['__transformation'] instanceof \Imagine\Filter\Transformation) {
         $this->setTransformation($this->preset['__transformation']);
     }
     return $this;
 }