/** * @param array $files * * @return AssetInfo */ public function compressFiles(array $files) { $md5String = ''; foreach ($files as $file) { $path = $this->getAssetPath($file); $md5String .= '.' . filemtime($path); } $fileUpToDate = false; $md5Line = '/* ' . md5($md5String) . " */\n"; $oFile = 'cache/compressed-css/' . md5($md5String) . '.css'; $handle = @fopen($this->getJarves()->getRootDir() . '/../web/' . $oFile, 'r'); if ($handle) { $line = fgets($handle); fclose($handle); if ($line == $md5Line) { $fileUpToDate = true; } } if (!$fileUpToDate) { $content = $this->utils->compressCss($files, 'cache/compressed-css/'); $content = $md5Line . $content; $this->webFilesystem->write($oFile, $content); } $assetInfo = new AssetInfo(); $assetInfo->setPath($oFile); return $assetInfo; }
/** * @ApiDoc( * section="Bundle Editor", * description="Saves the composer config" * ) * * @Rest\QueryParam(name="bundle", requirements=".*", strict=true, description="The bundle name") * * @Rest\Post("/admin/system/bundle/editor/config") * * @param string $bundle * * @return array */ public function saveConfigAction($bundle) { if ($this->jarves->getBundleDir($bundle)) { $config = $this->utils->getComposerArray($bundle); $config['_path'] = $this->jarves->getBundleDir($bundle); return $config; } return "#todo"; }
/** * @param string|File $path * @param string $verb * @param string $message */ protected function newFeed($path, $verb, $message = '') { $file = $path; if (!$path instanceof File) { $file = $this->webFilesystem->getFile($path); } if ($file instanceof File) { $this->utils->newNewsFeed($this->objects, 'jarves/file', $file->toArray(), $verb, $message); } }
/** * @ApiDoc( * section="Bundle/Package Manager", * description="Checks for updates in composer packages" * ) * * @Rest\Get("/admin/system/bundle/manager/check-updates") * * @return array */ public function check4UpdatesAction() { $res = []; foreach ($this->jarves->getBundles() as $bundleName => $bundle) { $composer = $this->utils->getComposerArray($bundleName) ?: []; $version = @$composer['version']; if ($version && $version != '' && self::versionCompareToServer($version, $version['content']) == '<') { $temp = array(); $temp['newVersion'] = $version; $temp['bundle'] = $bundleName; $res[] = $temp; } } return $res; }
/** * Patches a object entry. This means, only defined fields will be saved. Fields which are not defined will * not be overwritten. * * @param array $pk * * @param Request|array $requestOrData * @return bool * * @throws AccessDeniedException * @throws ObjectNotFoundException * @throws \Exception */ public function patch($pk, $requestOrData) { $storageController = $this->objects->getStorageController($this->getObject()); $pk = $storageController->normalizePrimaryKey($pk); $this->primaryKey = $pk; $values = $this->collectData($requestOrData); $args = ['pk' => $pk, 'values' => &$values, 'controller' => $this, 'mode' => 'update']; $eventPre = new GenericEvent($this->getObject(), $args); $this->eventDispatcher->dispatch('core/object/modify-pre', $eventPre); $this->eventDispatcher->dispatch('core/object/patch-pre', $eventPre); $item = $this->getItem($pk); if ($this->getPermissionCheck()) { if (!$item) { return null; } if (!$this->acl->check(ACLRequest::create($this->getObject(), $pk)->onlyUpdateMode())) { return null; } foreach ($values as $fieldName => $value) { $aclRequest = ACLRequest::create($this->getObject(), $pk)->setField([$fieldName => $value])->onlyUpdateMode(); if (!$this->acl->check($aclRequest)) { throw new AccessDeniedException(sprintf('Not allowed to change `%s`', $fieldName)); } } } if (($condition = $this->getCondition()) && $condition->hasRules()) { if (!$this->conditionOperator->satisfy($condition, $item, $this->getObject())) { return null; } } $incomingFields = $requestOrData instanceof Request ? array_keys($requestOrData->request->all()) : array_keys($requestOrData); if (!$incomingFields) { return false; } $changedData = $this->mapData($values, $incomingFields, $item); if ($this->getWithNewsFeed()) { $this->utils->newNewsFeed($this->objects, $this->getObject(), array_merge($values, $pk), 'updated'); } $result = $storageController->patch($pk, $changedData); $args['result'] = $result; $event = new GenericEvent($this->getObject(), $args); $this->eventDispatcher->dispatch('core/object/modify', $event); $this->eventDispatcher->dispatch('core/object/patch', $event); return $result; }