/** * [onDelete description] * @param [type] $block [description] * @param [type] $page_id [description] * @return [type] [description] */ public function onDelete($block, $page_id) { // Delete block if not attached to other zones if (count($block->pages) == 0) { $block->delete(); } }
/** * Safely remove the image entity and all its presets * The physical image files are only removed after making sure that the same file is not used in other records * @param \Cake\ORM\Entity $imageEntity [description] * @return bool */ public function deleteImageEntity($imageEntity) { $shared = $this->_imagesTable->find()->where(['id !=' => $imageEntity->id, 'field_index !=' => $imageEntity->field_index, 'model' => $imageEntity->model, 'filename' => $imageEntity->filename]); if (!$shared->count()) { $basePath = $this->basePath(); (new File($basePath . DS . $imageEntity->filename))->delete(); foreach ($this->config('presets') as $preset => $options) { (new File($basePath . DS . $preset . '_' . $imageEntity->filename))->delete(); } } return $this->_imagesTable->delete($imageEntity); }