public function updateResponse(Response $response, StructureInterface $structure) { $tags = [$this->getBanKey($structure->getUuid())]; foreach ($structure->getProperties(true) as $property) { foreach ($this->getReferencedUuids($property) as $uuid) { $tags[] = $this->getBanKey($uuid); } } $response->headers->set(self::TAGS_HEADER, implode(',', $tags)); }
/** * {@inheritDoc} */ public function resolve(StructureInterface $structure) { $data = ['view' => [], 'content' => [], 'uuid' => $structure->getUuid(), 'creator' => $structure->getCreator(), 'changer' => $structure->getChanger(), 'created' => $structure->getCreated(), 'changed' => $structure->getChanged(), 'template' => $structure->getKey(), 'path' => $structure->getPath()]; if ($structure instanceof PageBridge) { $data['extension'] = $structure->getExt()->toArray(); $data['urls'] = $structure->getUrls(); $data['published'] = $structure->getPublished(); $data['shadowBaseLocale'] = $structure->getShadowBaseLanguage(); foreach ($data['extension'] as $name => $value) { $extension = $this->structureManager->getExtension($structure->getKey(), $name); $data['extension'][$name] = $extension->getContentData($value); } } foreach ($structure->getProperties(true) as $property) { $contentType = $this->contentTypeManager->get($property->getContentTypeName()); $data['view'][$property->getName()] = $contentType->getViewData($property); $data['content'][$property->getName()] = $contentType->getContentData($property); } return $data; }
/** * returns finished Node (with _links and _embedded). * * @param StructureInterface $structure * @param string $webspaceKey * @param string $languageCode * @param int $depth * @param bool $complete * @param bool $excludeGhosts * @param string|null $extension * * @return array * * @deprecated This part should be split into a serialization handler and using the hateoas bundle */ protected function prepareNode(StructureInterface $structure, $webspaceKey, $languageCode, $depth = 1, $complete = true, $excludeGhosts = false, $extension = null) { $result = $structure->toArray($complete); // add default embedded property with empty nodes array $result['_embedded'] = []; $result['_embedded']['nodes'] = []; // add api links $result['_links'] = ['self' => ['href' => $this->apiBasePath . '/' . $structure->getUuid() . ($extension !== null ? '/' . $extension : '')], 'children' => ['href' => $this->apiBasePath . '?parent=' . $structure->getUuid() . '&depth=' . $depth . '&webspace=' . $webspaceKey . '&language=' . $languageCode . ($excludeGhosts === true ? '&exclude-ghosts=true' : '')]]; if ($this->tokenStorage && ($token = $this->tokenStorage->getToken())) { $result['_permissions'] = $this->accessControlManager->getUserPermissions(new SecurityCondition('sulu.webspaces.' . $webspaceKey, $languageCode, SecurityBehavior::class, $structure->getUuid()), $token->getUser()); } return $result; }
private function copyNode($srcLocale, $destLocale, StructureInterface $structure, $overwrite = false) { if (!$overwrite) { $destStructure = $this->contentMapper->load($structure->getUuid(), null, $destLocale, true); if (!($destStructure->getType() && $destStructure->getType()->getName() === 'ghost')) { $this->output->writeln('<info>Processing aborted: </info>' . $structure->getNodeName() . ' <comment>(use overwrite option to force)</comment>'); return; } } $this->contentMapper->copyLanguage($structure->getUuid(), $structure->getChanger(), null, $srcLocale, $destLocale, Structure::TYPE_SNIPPET); $this->output->writeln('<info>Processing: </info>' . $structure->getNodeName()); }
private function copyNode($webspaceKey, $srcLocale, $destLocale, StructureInterface $structure, $overwrite = false) { if (!$overwrite) { $destStructure = $this->contentMapper->load($structure->getUuid(), $webspaceKey, $destLocale, true); if (!($destStructure->getType() && $destStructure->getType()->getName() === 'ghost')) { $this->output->writeln('<info>Processing aborted: </info>' . $structure->getPath() . ' <comment>(use overwrite option to force)</comment>'); return; } } if ($structure->getType() && $structure->getType()->getName() === 'ghost') { $this->output->writeln('<info>Processing aborted: </info>' . $structure->getPath() . ' <comment>(source language does not exist)</comment>'); return; } try { $this->contentMapper->copyLanguage($structure->getUuid(), $structure->getChanger(), $webspaceKey, $srcLocale, $destLocale); $this->output->writeln('<info>Processing: </info>' . $structure->getPath()); } catch (ResourceLocatorAlreadyExistsException $e) { $this->output->writeln(sprintf('<info>Processing aborted: </info> %s <comment>Resource Locator "%s" already exists', $structure->getPath(), $structure->getResourceLocator())); } }
/** * {@inheritdoc} */ public function copyFrom(StructureInterface $structure) { $this->setWebspaceKey($structure->getWebspaceKey()); $this->setLanguageCode($structure->getLanguageCode()); $this->setUuid($structure->getUuid()); $this->setChanged($structure->getChanged()); $this->setChanger($structure->getChanger()); $this->setCreated($structure->getCreated()); $this->setCreator($structure->getCreator()); $this->setPublished($structure->getPublished()); $this->setPath($structure->getPath()); $this->setNodeType($structure->getNodeType()); $this->setHasTranslation($structure->getHasTranslation()); }
/** * returns finished Node (with _links and _embedded). * * @param StructureInterface $structure * @param string $webspaceKey * @param string $languageCode * @param int $depth * @param bool $complete * @param bool $excludeGhosts * @param string|null $extension * * @return array */ protected function prepareNode(StructureInterface $structure, $webspaceKey, $languageCode, $depth = 1, $complete = true, $excludeGhosts = false, $extension = null) { $result = $structure->toArray($complete); // add default embedded property with empty nodes array $result['_embedded'] = []; $result['_embedded']['nodes'] = []; // add api links $result['_links'] = ['self' => ['href' => $this->apiBasePath . '/' . $structure->getUuid() . ($extension !== null ? '/' . $extension : '')], 'children' => ['href' => $this->apiBasePath . '?parent=' . $structure->getUuid() . '&depth=' . $depth . '&webspace=' . $webspaceKey . '&language=' . $languageCode . ($excludeGhosts === true ? '&exclude-ghosts=true' : '')]]; return $result; }