protected function prepareImage($path) { $metadata = $this->adapter->getMetadata($path); $path = implode(DIRECTORY_SEPARATOR, [trim($metadata['dirname'], DIRECTORY_SEPARATOR), "{$this->width}x{$this->height}", $metadata['basename']]); $this->src = $this->srcCache . '/' . ltrim($path, '/'); if ($this->adapterCache->has($path)) { return; } if ($this->handler instanceof \Closure) { call_user_func($this->handler, $path, $this); return; } $string = Image::thumbnail($this->image, $this->width, $this->height)->get('jpg'); if (!$this->adapterCache->write($path, $string)) { if (class_exists('\\rock\\log\\Log')) { $message = BaseException::convertExceptionToString(new ImageException(ImageException::NOT_CREATE_FILE, ['path' => $path])); Log::warn($message); } } }
public function init() { if (!is_object($this->adapter)) { if (class_exists('\\rock\\di\\Container')) { $this->adapter = Container::load($this->adapter); return; } throw new FileException(FileException::NOT_OBJECT, ['name' => FileManager::className()]); } }