/** * Метод сохраняет картинку в файл */ public function saveToFile(DirItem $path) { $path->assertExtension(PsConst::EXT_GIF); $fp = fopen($path->getAbsPath(), 'w'); fwrite($fp, $this->getAnimation()); fclose($fp); }
protected function onInit(DirItem $di) { $this->info = getimagesize($di->getAbsPath()); check_condition($this->info, "В ImageAdapter передана невалидная картинка [{$di->getRelPath()}]."); $this->width = $this->info[0]; $this->height = $this->info[1]; }
/** @return DirItem */ public function moveUploadedFileTo(DirItem $di) { $this->assertIsValid(); check_condition(move_uploaded_file($this->getTmpFilePath(), $di->getAbsPath()), 'Не удаётся переместить временный файл'); return $di; }
/** * Выполняет команды в переданном файле в shell интерпретаторе */ public function execureShell(DirItem $sql) { check_condition($sql->isFile(), 'Файл с sql инструкциями не существут: ' . $sql->getAbsPath()); $LOGGER = PsLogger::inst(__CLASS__); $command = 'mysql' . ' --default-character-set=utf8' . ' --host=' . $this->host() . ' --user='******' --password='******' --database=' . $this->database() : '') . ' < ' . $sql->getAbsPath(); $LOGGER->info('Executing sql shell script: {}', $command); $output = shell_exec($command); $LOGGER->info($output ? 'Output: ' . $output : 'No output'); }