コード例 #1
0
ファイル: ImageBehave.php プロジェクト: rocketyang/yii2-cms
 /**
  *
  * removes concrete model's image
  * @param Image $img
  * @throws \Exception
  */
 public function removeImage(\rico\yii2images\models\Image $img)
 {
     if (!$img->isNewRecord) {
         $imgInfoweb = Image::findOne(['id' => $img->id]);
         $imgInfoweb->clearCache();
         $storePath = $this->getModule()->getStorePath();
         $fileToRemove = $storePath . DIRECTORY_SEPARATOR . $img->filePath;
         if (preg_match('@\\.@', $fileToRemove) and is_file($fileToRemove)) {
             unlink($fileToRemove);
         }
         $img->delete();
     }
 }
コード例 #2
0
 /**
  *
  * removes concrete model's image
  * @param Image $img
  * @throws \Exception
  */
 public function removeImage(Image $img)
 {
     $img->clearCache();
     $storePath = $this->getModule()->getStorePath();
     $fileToRemove = $storePath . DIRECTORY_SEPARATOR . $img->filePath;
     if (preg_match('@\\.@', $fileToRemove) and is_file($fileToRemove)) {
         unlink($fileToRemove);
     }
     $img->delete();
 }