/** * @param SourceItem $sourceItem * * @return null|string */ protected function getPreviewImageUrl(SourceItem $sourceItem) { $imageFileName = 'pageType.' . self::PREVIEW_IMAGE_EXTENSION; $imageFilePath = FS::joinPath($sourceItem->getDirectory(), self::PREVIEW_IMAGE_SUBDIRECTORY, $imageFileName); if (!file_exists($imageFilePath)) { return null; } return $sourceItem->getUrl() . '/' . self::PREVIEW_IMAGE_SUBDIRECTORY . '/' . $imageFileName; }
/** * @param SourceItem $sourceItem * * @throws ModuleNotWritable */ protected function checkIfModuleIsWritable(SourceItem $sourceItem) { if ($sourceItem->isReadonly()) { throw new ModuleNotWritable(114, __METHOD__, __LINE__, array('id' => $sourceItem->getId(), 'type' => $sourceItem->getType(), 'directory' => $sourceItem->getDirectory())); } }
/** * @param string $websiteId * @param string $id * @param SourceItem $sourceItem * @param array $additionalData * * @return object */ protected function loadCachedEntity($websiteId, $id, SourceItem $sourceItem, array $additionalData) { $cacheKey = self::CACHE_PREFIX_ENTITY . $websiteId . $sourceItem->getCacheKey(); $cachedEntity = $this->getCacheValue($cacheKey, null); if (!is_null($cachedEntity)) { return $cachedEntity; } $entity = $this->loadEntity($websiteId, $id, $sourceItem, $additionalData); $this->setCacheValue($cacheKey, $entity); return $entity; }
/** * @param SourceItem $sourceItem * @param string $newId * @param string $subdirectory * * @return SourceItem */ public function createSubdirSourceItem(SourceItem $sourceItem, $newId, $subdirectory) { return new SourceItem($newId, FS::joinPath($sourceItem->getDirectory(), $subdirectory, $newId), $sourceItem->getUrl() . '/' . $subdirectory . '/' . $newId, $sourceItem->getType(), $sourceItem->isReadonly(), false); }
/** * @param string $websiteId * @param string $id * @param SourceItem $sourceItem * @param \stdClass $manifest * * @return DataWebsiteSettings */ protected function loadDataObject($websiteId, $id, SourceItem $sourceItem, \stdClass $manifest) { $websiteSettings = new DataWebsiteSettings(); $websiteSettings->setWebsiteid($websiteId); $websiteSettings->setId($id); $websiteSettings->setReadonly($sourceItem->isReadonly()); $websiteSettings->setSource($sourceItem); $websiteSettings->setSourceType($sourceItem->getType()); if (property_exists($manifest, 'name') && is_object($manifest->name)) { $websiteSettings->setName($manifest->name); } if (property_exists($manifest, 'description') && is_object($manifest->description)) { $websiteSettings->setDescription($manifest->description); } if (property_exists($manifest, 'version')) { $websiteSettings->setVersion($manifest->version); } if (property_exists($manifest, 'form')) { $websiteSettings->setForm($manifest->form); } if (property_exists($manifest, 'formValues')) { $websiteSettings->setFormValues($manifest->formValues); } return $websiteSettings; }