/** * @param ModelSaveEvent $event */ public function execute(ModelSaveEvent $event) { if (!$event->isDeleteStatement()) { return; } $upload = new Upload($this->applicationPath, Schema::MODULE_NAME); foreach ($event->getEntryId() as $entryId) { $upload->removeUploadedFile($this->emoticonRepository->getOneImageById($entryId)); } }
/** * Caches the emoticons * * @return boolean */ public function saveCache() { $emoticons = $this->emoticonRepository->getAll(); $cEmoticons = count($emoticons); $data = []; for ($i = 0; $i < $cEmoticons; ++$i) { $picInfos = getimagesize($this->appPath->getUploadsDir() . 'emoticons/' . $emoticons[$i]['img']); $code = $emoticons[$i]['code']; $description = $emoticons[$i]['description']; $data[$code] = '<img src="' . $this->appPath->getWebRoot() . 'uploads/emoticons/' . $emoticons[$i]['img'] . '" width="' . $picInfos[0] . '" height="' . $picInfos[1] . '" alt="' . $description . '" title="' . $description . '" />'; } return $this->cache->save(static::CACHE_ID, $data); }
private function applyEmoticons() { $this->config['smiley_path'] = $this->appPath->getWebRoot() . 'uploads/emoticons/'; $this->config['smiley_images'] = $this->config['smiley_descriptions'] = ''; $emoticons = $this->emoticonRepository->getAll(); $cEmoticons = count($emoticons); $images = $descriptions = []; for ($i = 0; $i < $cEmoticons; ++$i) { $images[] = $emoticons[$i]['img']; $descriptions[] = $emoticons[$i]['description']; } $this->config['smiley_images'] = $images; $this->config['smiley_descriptions'] = $descriptions; }