Beispiel #1
0
 /**
  * Remove entity. If entity has been removed, delete related file.
  *
  * @access     public
  * @return    boolean
  * @since      1.0.0-alpha
  * @version    1.0.0-alpha
  */
 public function remove()
 {
     $bRemoved = parent::remove();
     if ($bRemoved) {
         // set path to file
         $sPath = $this->getPath() . DS . $this->getNameWithExt();
         // if it's an image, remove all its styles
         if (in_array($this->getExt(), ['jpg', 'jpeg', 'gif', 'png', 'tiff'])) {
             ImageStyles::removeStyledImgCache($sPath);
         }
         // remove file
         \FileManager::delete($sPath);
     }
     return $bRemoved;
 }
Beispiel #2
0
 /**
  * Make some operations related to this field before Model Entity will be
  * completely removed.
  *
  * @access   public
  * @param    ModelCore $oModel
  * @param    mixed     $mValue
  * @return   boolean
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 public function whenRemovingEntity(ModelCore $oModel, $mValue)
 {
     parent::whenRemovingEntity($oModel, $mValue);
     if (empty($mValue)) {
         return FALSE;
     }
     $aValues = [];
     if (!is_array($mValue)) {
         $aValues[] = $mValue;
     }
     foreach ($aValues as $oFileBroker) {
         /* @var $oFileBroker \Plethora\ModelCore\FileBroker */
         $oFile = $oFileBroker->getFile();
         /* @var $oFile \Model\File */
         \Plethora\ImageStyles::removeStyledImgCache($oFile->getPath() . DS . $oFile->getNameWithExt());
     }
 }