repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php | ResourceSegmentSubscriber.persistRoute | private function persistRoute(ResourceSegmentBehavior $document)
{
$resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey(
$this->documentInspector->getWebspace($document)
);
$resourceLocatorStrategy->save($document, null);
} | php | private function persistRoute(ResourceSegmentBehavior $document)
{
$resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey(
$this->documentInspector->getWebspace($document)
);
$resourceLocatorStrategy->save($document, null);
} | [
"private",
"function",
"persistRoute",
"(",
"ResourceSegmentBehavior",
"$",
"document",
")",
"{",
"$",
"resourceLocatorStrategy",
"=",
"$",
"this",
"->",
"resourceLocatorStrategyPool",
"->",
"getStrategyByWebspaceKey",
"(",
"$",
"this",
"->",
"documentInspector",
"->",
"getWebspace",
"(",
"$",
"document",
")",
")",
";",
"$",
"resourceLocatorStrategy",
"->",
"save",
"(",
"$",
"document",
",",
"null",
")",
";",
"}"
] | Creates or updates the route of the document using the RlpStrategy.
@param ResourceSegmentBehavior $document | [
"Creates",
"or",
"updates",
"the",
"route",
"of",
"the",
"document",
"using",
"the",
"RlpStrategy",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L304-L311 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php | ResourceSegmentSubscriber.updateRoute | private function updateRoute($document, $generateRoutes)
{
$locales = $this->documentInspector->getLocales($document);
$webspaceKey = $this->documentInspector->getWebspace($document);
$uuid = $this->documentInspector->getUuid($document);
$path = $this->documentInspector->getPath($document);
$parentUuid = $this->documentInspector->getUuid($this->documentInspector->getParent($document));
$defaultNode = $this->defaultSession->getNode($path);
$liveNode = $this->liveSession->getNode($path);
$resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
foreach ($locales as $locale) {
$localizedDocument = $this->documentManager->find($uuid, $locale);
if (RedirectType::NONE !== $localizedDocument->getRedirectType()) {
continue;
}
$resourceSegmentPropertyName = $this->encoder->localizedSystemName(
$this->getResourceSegmentProperty($localizedDocument)->getName(),
$locale
);
$this->updateResourceSegmentProperty(
$defaultNode,
$resourceSegmentPropertyName,
$parentUuid,
$webspaceKey,
$locale
);
if ($liveNode->hasProperty($resourceSegmentPropertyName)) {
$this->updateResourceSegmentProperty(
$liveNode,
$resourceSegmentPropertyName,
$parentUuid,
$webspaceKey,
$locale
);
// if the method is called with the generateRoutes flag it will create a new route
// this happens on a move, but not on copy, because copy results in a draft page without url
if ($generateRoutes) {
$localizedDocument->setResourceSegment($liveNode->getPropertyValue($resourceSegmentPropertyName));
$resourceLocatorStrategy->save($localizedDocument, null);
$localizedDocument->setResourceSegment($defaultNode->getPropertyValue($resourceSegmentPropertyName));
}
}
}
} | php | private function updateRoute($document, $generateRoutes)
{
$locales = $this->documentInspector->getLocales($document);
$webspaceKey = $this->documentInspector->getWebspace($document);
$uuid = $this->documentInspector->getUuid($document);
$path = $this->documentInspector->getPath($document);
$parentUuid = $this->documentInspector->getUuid($this->documentInspector->getParent($document));
$defaultNode = $this->defaultSession->getNode($path);
$liveNode = $this->liveSession->getNode($path);
$resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
foreach ($locales as $locale) {
$localizedDocument = $this->documentManager->find($uuid, $locale);
if (RedirectType::NONE !== $localizedDocument->getRedirectType()) {
continue;
}
$resourceSegmentPropertyName = $this->encoder->localizedSystemName(
$this->getResourceSegmentProperty($localizedDocument)->getName(),
$locale
);
$this->updateResourceSegmentProperty(
$defaultNode,
$resourceSegmentPropertyName,
$parentUuid,
$webspaceKey,
$locale
);
if ($liveNode->hasProperty($resourceSegmentPropertyName)) {
$this->updateResourceSegmentProperty(
$liveNode,
$resourceSegmentPropertyName,
$parentUuid,
$webspaceKey,
$locale
);
// if the method is called with the generateRoutes flag it will create a new route
// this happens on a move, but not on copy, because copy results in a draft page without url
if ($generateRoutes) {
$localizedDocument->setResourceSegment($liveNode->getPropertyValue($resourceSegmentPropertyName));
$resourceLocatorStrategy->save($localizedDocument, null);
$localizedDocument->setResourceSegment($defaultNode->getPropertyValue($resourceSegmentPropertyName));
}
}
}
} | [
"private",
"function",
"updateRoute",
"(",
"$",
"document",
",",
"$",
"generateRoutes",
")",
"{",
"$",
"locales",
"=",
"$",
"this",
"->",
"documentInspector",
"->",
"getLocales",
"(",
"$",
"document",
")",
";",
"$",
"webspaceKey",
"=",
"$",
"this",
"->",
"documentInspector",
"->",
"getWebspace",
"(",
"$",
"document",
")",
";",
"$",
"uuid",
"=",
"$",
"this",
"->",
"documentInspector",
"->",
"getUuid",
"(",
"$",
"document",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"documentInspector",
"->",
"getPath",
"(",
"$",
"document",
")",
";",
"$",
"parentUuid",
"=",
"$",
"this",
"->",
"documentInspector",
"->",
"getUuid",
"(",
"$",
"this",
"->",
"documentInspector",
"->",
"getParent",
"(",
"$",
"document",
")",
")",
";",
"$",
"defaultNode",
"=",
"$",
"this",
"->",
"defaultSession",
"->",
"getNode",
"(",
"$",
"path",
")",
";",
"$",
"liveNode",
"=",
"$",
"this",
"->",
"liveSession",
"->",
"getNode",
"(",
"$",
"path",
")",
";",
"$",
"resourceLocatorStrategy",
"=",
"$",
"this",
"->",
"resourceLocatorStrategyPool",
"->",
"getStrategyByWebspaceKey",
"(",
"$",
"webspaceKey",
")",
";",
"foreach",
"(",
"$",
"locales",
"as",
"$",
"locale",
")",
"{",
"$",
"localizedDocument",
"=",
"$",
"this",
"->",
"documentManager",
"->",
"find",
"(",
"$",
"uuid",
",",
"$",
"locale",
")",
";",
"if",
"(",
"RedirectType",
"::",
"NONE",
"!==",
"$",
"localizedDocument",
"->",
"getRedirectType",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"resourceSegmentPropertyName",
"=",
"$",
"this",
"->",
"encoder",
"->",
"localizedSystemName",
"(",
"$",
"this",
"->",
"getResourceSegmentProperty",
"(",
"$",
"localizedDocument",
")",
"->",
"getName",
"(",
")",
",",
"$",
"locale",
")",
";",
"$",
"this",
"->",
"updateResourceSegmentProperty",
"(",
"$",
"defaultNode",
",",
"$",
"resourceSegmentPropertyName",
",",
"$",
"parentUuid",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
";",
"if",
"(",
"$",
"liveNode",
"->",
"hasProperty",
"(",
"$",
"resourceSegmentPropertyName",
")",
")",
"{",
"$",
"this",
"->",
"updateResourceSegmentProperty",
"(",
"$",
"liveNode",
",",
"$",
"resourceSegmentPropertyName",
",",
"$",
"parentUuid",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
";",
"// if the method is called with the generateRoutes flag it will create a new route",
"// this happens on a move, but not on copy, because copy results in a draft page without url",
"if",
"(",
"$",
"generateRoutes",
")",
"{",
"$",
"localizedDocument",
"->",
"setResourceSegment",
"(",
"$",
"liveNode",
"->",
"getPropertyValue",
"(",
"$",
"resourceSegmentPropertyName",
")",
")",
";",
"$",
"resourceLocatorStrategy",
"->",
"save",
"(",
"$",
"localizedDocument",
",",
"null",
")",
";",
"$",
"localizedDocument",
"->",
"setResourceSegment",
"(",
"$",
"defaultNode",
"->",
"getPropertyValue",
"(",
"$",
"resourceSegmentPropertyName",
")",
")",
";",
"}",
"}",
"}",
"}"
] | Updates the route for the given document after a move or copy.
@param object $document
@param bool $generateRoutes If set to true a route in the routing tree will also be created | [
"Updates",
"the",
"route",
"for",
"the",
"given",
"document",
"after",
"a",
"move",
"or",
"copy",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L319-L370 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php | ResourceSegmentSubscriber.updateResourceSegmentProperty | private function updateResourceSegmentProperty(
NodeInterface $node,
$resourceSegmentPropertyName,
$parentUuid,
$webspaceKey,
$locale
) {
$resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
$childPart = $resourceLocatorStrategy->getChildPart($node->getPropertyValue($resourceSegmentPropertyName));
$node->setProperty(
$resourceSegmentPropertyName,
$resourceLocatorStrategy->generate($childPart, $parentUuid, $webspaceKey, $locale)
);
} | php | private function updateResourceSegmentProperty(
NodeInterface $node,
$resourceSegmentPropertyName,
$parentUuid,
$webspaceKey,
$locale
) {
$resourceLocatorStrategy = $this->resourceLocatorStrategyPool->getStrategyByWebspaceKey($webspaceKey);
$childPart = $resourceLocatorStrategy->getChildPart($node->getPropertyValue($resourceSegmentPropertyName));
$node->setProperty(
$resourceSegmentPropertyName,
$resourceLocatorStrategy->generate($childPart, $parentUuid, $webspaceKey, $locale)
);
} | [
"private",
"function",
"updateResourceSegmentProperty",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"resourceSegmentPropertyName",
",",
"$",
"parentUuid",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
"{",
"$",
"resourceLocatorStrategy",
"=",
"$",
"this",
"->",
"resourceLocatorStrategyPool",
"->",
"getStrategyByWebspaceKey",
"(",
"$",
"webspaceKey",
")",
";",
"$",
"childPart",
"=",
"$",
"resourceLocatorStrategy",
"->",
"getChildPart",
"(",
"$",
"node",
"->",
"getPropertyValue",
"(",
"$",
"resourceSegmentPropertyName",
")",
")",
";",
"$",
"node",
"->",
"setProperty",
"(",
"$",
"resourceSegmentPropertyName",
",",
"$",
"resourceLocatorStrategy",
"->",
"generate",
"(",
"$",
"childPart",
",",
"$",
"parentUuid",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
")",
";",
"}"
] | Updates the property for the resource segment on the given node.
@param NodeInterface $node
@param string $resourceSegmentPropertyName
@param string $parentUuid
@param string $webspaceKey
@param string $locale | [
"Updates",
"the",
"property",
"for",
"the",
"resource",
"segment",
"on",
"the",
"given",
"node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/ResourceSegmentSubscriber.php#L381-L395 | train |
sulu/sulu | src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php | PreviewRenderer.handle | private function handle(Request $request)
{
$kernel = $this->kernelFactory->create($this->environment);
try {
return $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, false);
} catch (HttpException $e) {
if ($e->getPrevious()) {
throw $e->getPrevious();
}
throw $e;
}
} | php | private function handle(Request $request)
{
$kernel = $this->kernelFactory->create($this->environment);
try {
return $kernel->handle($request, HttpKernelInterface::MASTER_REQUEST, false);
} catch (HttpException $e) {
if ($e->getPrevious()) {
throw $e->getPrevious();
}
throw $e;
}
} | [
"private",
"function",
"handle",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"kernel",
"=",
"$",
"this",
"->",
"kernelFactory",
"->",
"create",
"(",
"$",
"this",
"->",
"environment",
")",
";",
"try",
"{",
"return",
"$",
"kernel",
"->",
"handle",
"(",
"$",
"request",
",",
"HttpKernelInterface",
"::",
"MASTER_REQUEST",
",",
"false",
")",
";",
"}",
"catch",
"(",
"HttpException",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getPrevious",
"(",
")",
")",
"{",
"throw",
"$",
"e",
"->",
"getPrevious",
"(",
")",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"}"
] | Handles given request and returns response.
@param Request $request
@return Response
@throws \Exception | [
"Handles",
"given",
"request",
"and",
"returns",
"response",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php#L217-L230 | train |
sulu/sulu | src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php | PreviewRenderer.createServerAttributes | private function createServerAttributes(PortalInformation $portalInformation, Request $currentRequest = null)
{
// get server parameters
$server = [];
$host = null;
// FIXME default scheme and port should be configurable.
$scheme = 'http';
$port = 80;
if ($currentRequest) {
$server = $currentRequest->server->all();
$scheme = $currentRequest->getScheme();
$host = $currentRequest->getHost();
$port = $currentRequest->getPort();
}
$portalUrl = $scheme . '://' . $this->replacer->replaceHost($portalInformation->getUrl(), $host);
$portalUrlParts = parse_url($portalUrl);
$prefixPath = isset($portalUrlParts['path']) ? $portalUrlParts['path'] : '';
$httpHost = $portalUrlParts['host'];
if (!in_array($port, [80, 443])) {
$httpHost .= ':' . $port;
}
$server['SERVER_NAME'] = $portalUrlParts['host'];
$server['SERVER_PORT'] = $port;
$server['HTTP_HOST'] = $httpHost;
$server['REQUEST_URI'] = $prefixPath . '/_sulu_preview';
unset($server['HTTP_X_REQUESTED_WITH']); // subrequest should not be detected as ajax
return $server;
} | php | private function createServerAttributes(PortalInformation $portalInformation, Request $currentRequest = null)
{
// get server parameters
$server = [];
$host = null;
// FIXME default scheme and port should be configurable.
$scheme = 'http';
$port = 80;
if ($currentRequest) {
$server = $currentRequest->server->all();
$scheme = $currentRequest->getScheme();
$host = $currentRequest->getHost();
$port = $currentRequest->getPort();
}
$portalUrl = $scheme . '://' . $this->replacer->replaceHost($portalInformation->getUrl(), $host);
$portalUrlParts = parse_url($portalUrl);
$prefixPath = isset($portalUrlParts['path']) ? $portalUrlParts['path'] : '';
$httpHost = $portalUrlParts['host'];
if (!in_array($port, [80, 443])) {
$httpHost .= ':' . $port;
}
$server['SERVER_NAME'] = $portalUrlParts['host'];
$server['SERVER_PORT'] = $port;
$server['HTTP_HOST'] = $httpHost;
$server['REQUEST_URI'] = $prefixPath . '/_sulu_preview';
unset($server['HTTP_X_REQUESTED_WITH']); // subrequest should not be detected as ajax
return $server;
} | [
"private",
"function",
"createServerAttributes",
"(",
"PortalInformation",
"$",
"portalInformation",
",",
"Request",
"$",
"currentRequest",
"=",
"null",
")",
"{",
"// get server parameters",
"$",
"server",
"=",
"[",
"]",
";",
"$",
"host",
"=",
"null",
";",
"// FIXME default scheme and port should be configurable.",
"$",
"scheme",
"=",
"'http'",
";",
"$",
"port",
"=",
"80",
";",
"if",
"(",
"$",
"currentRequest",
")",
"{",
"$",
"server",
"=",
"$",
"currentRequest",
"->",
"server",
"->",
"all",
"(",
")",
";",
"$",
"scheme",
"=",
"$",
"currentRequest",
"->",
"getScheme",
"(",
")",
";",
"$",
"host",
"=",
"$",
"currentRequest",
"->",
"getHost",
"(",
")",
";",
"$",
"port",
"=",
"$",
"currentRequest",
"->",
"getPort",
"(",
")",
";",
"}",
"$",
"portalUrl",
"=",
"$",
"scheme",
".",
"'://'",
".",
"$",
"this",
"->",
"replacer",
"->",
"replaceHost",
"(",
"$",
"portalInformation",
"->",
"getUrl",
"(",
")",
",",
"$",
"host",
")",
";",
"$",
"portalUrlParts",
"=",
"parse_url",
"(",
"$",
"portalUrl",
")",
";",
"$",
"prefixPath",
"=",
"isset",
"(",
"$",
"portalUrlParts",
"[",
"'path'",
"]",
")",
"?",
"$",
"portalUrlParts",
"[",
"'path'",
"]",
":",
"''",
";",
"$",
"httpHost",
"=",
"$",
"portalUrlParts",
"[",
"'host'",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"port",
",",
"[",
"80",
",",
"443",
"]",
")",
")",
"{",
"$",
"httpHost",
".=",
"':'",
".",
"$",
"port",
";",
"}",
"$",
"server",
"[",
"'SERVER_NAME'",
"]",
"=",
"$",
"portalUrlParts",
"[",
"'host'",
"]",
";",
"$",
"server",
"[",
"'SERVER_PORT'",
"]",
"=",
"$",
"port",
";",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
"=",
"$",
"httpHost",
";",
"$",
"server",
"[",
"'REQUEST_URI'",
"]",
"=",
"$",
"prefixPath",
".",
"'/_sulu_preview'",
";",
"unset",
"(",
"$",
"server",
"[",
"'HTTP_X_REQUESTED_WITH'",
"]",
")",
";",
"// subrequest should not be detected as ajax",
"return",
"$",
"server",
";",
"}"
] | Create server attributes.
@param PortalInformation $portalInformation
@param Request|null $currentRequest
@return array | [
"Create",
"server",
"attributes",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php#L240-L272 | train |
sulu/sulu | src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php | PreviewRenderer.createPortalInformation | private function createPortalInformation($object, $id, $webspaceKey, $locale)
{
$webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey);
$domain = $this->requestStack->getCurrentRequest()->getHost();
if (!$webspace) {
throw new WebspaceNotFoundException($object, $id, $webspaceKey, $locale);
}
$webspace = clone $webspace;
$localization = $webspace->getLocalization($locale);
if (!$localization) {
throw new WebspaceLocalizationNotFoundException($object, $id, $webspaceKey, $locale);
}
$localization = clone $localization;
$localization->setXDefault(true);
$portal = new Portal();
$portal->setName($webspace->getName());
$portal->setKey($webspace->getKey());
$portal->setWebspace($webspace);
$portal->setXDefaultLocalization($localization);
$portal->setLocalizations([$localization]);
$portal->setDefaultLocalization($localization);
$environment = new Environment();
$url = new Url($domain, $this->environment);
$environment->setUrls([$url]);
$portal->setEnvironments([$environment]);
$webspace->setPortals([$portal]);
return new PortalInformation(RequestAnalyzer::MATCH_TYPE_FULL, $webspace, $portal, $localization, $domain);
} | php | private function createPortalInformation($object, $id, $webspaceKey, $locale)
{
$webspace = $this->webspaceManager->findWebspaceByKey($webspaceKey);
$domain = $this->requestStack->getCurrentRequest()->getHost();
if (!$webspace) {
throw new WebspaceNotFoundException($object, $id, $webspaceKey, $locale);
}
$webspace = clone $webspace;
$localization = $webspace->getLocalization($locale);
if (!$localization) {
throw new WebspaceLocalizationNotFoundException($object, $id, $webspaceKey, $locale);
}
$localization = clone $localization;
$localization->setXDefault(true);
$portal = new Portal();
$portal->setName($webspace->getName());
$portal->setKey($webspace->getKey());
$portal->setWebspace($webspace);
$portal->setXDefaultLocalization($localization);
$portal->setLocalizations([$localization]);
$portal->setDefaultLocalization($localization);
$environment = new Environment();
$url = new Url($domain, $this->environment);
$environment->setUrls([$url]);
$portal->setEnvironments([$environment]);
$webspace->setPortals([$portal]);
return new PortalInformation(RequestAnalyzer::MATCH_TYPE_FULL, $webspace, $portal, $localization, $domain);
} | [
"private",
"function",
"createPortalInformation",
"(",
"$",
"object",
",",
"$",
"id",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
"{",
"$",
"webspace",
"=",
"$",
"this",
"->",
"webspaceManager",
"->",
"findWebspaceByKey",
"(",
"$",
"webspaceKey",
")",
";",
"$",
"domain",
"=",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
"->",
"getHost",
"(",
")",
";",
"if",
"(",
"!",
"$",
"webspace",
")",
"{",
"throw",
"new",
"WebspaceNotFoundException",
"(",
"$",
"object",
",",
"$",
"id",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
";",
"}",
"$",
"webspace",
"=",
"clone",
"$",
"webspace",
";",
"$",
"localization",
"=",
"$",
"webspace",
"->",
"getLocalization",
"(",
"$",
"locale",
")",
";",
"if",
"(",
"!",
"$",
"localization",
")",
"{",
"throw",
"new",
"WebspaceLocalizationNotFoundException",
"(",
"$",
"object",
",",
"$",
"id",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
";",
"}",
"$",
"localization",
"=",
"clone",
"$",
"localization",
";",
"$",
"localization",
"->",
"setXDefault",
"(",
"true",
")",
";",
"$",
"portal",
"=",
"new",
"Portal",
"(",
")",
";",
"$",
"portal",
"->",
"setName",
"(",
"$",
"webspace",
"->",
"getName",
"(",
")",
")",
";",
"$",
"portal",
"->",
"setKey",
"(",
"$",
"webspace",
"->",
"getKey",
"(",
")",
")",
";",
"$",
"portal",
"->",
"setWebspace",
"(",
"$",
"webspace",
")",
";",
"$",
"portal",
"->",
"setXDefaultLocalization",
"(",
"$",
"localization",
")",
";",
"$",
"portal",
"->",
"setLocalizations",
"(",
"[",
"$",
"localization",
"]",
")",
";",
"$",
"portal",
"->",
"setDefaultLocalization",
"(",
"$",
"localization",
")",
";",
"$",
"environment",
"=",
"new",
"Environment",
"(",
")",
";",
"$",
"url",
"=",
"new",
"Url",
"(",
"$",
"domain",
",",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"environment",
"->",
"setUrls",
"(",
"[",
"$",
"url",
"]",
")",
";",
"$",
"portal",
"->",
"setEnvironments",
"(",
"[",
"$",
"environment",
"]",
")",
";",
"$",
"webspace",
"->",
"setPortals",
"(",
"[",
"$",
"portal",
"]",
")",
";",
"return",
"new",
"PortalInformation",
"(",
"RequestAnalyzer",
"::",
"MATCH_TYPE_FULL",
",",
"$",
"webspace",
",",
"$",
"portal",
",",
"$",
"localization",
",",
"$",
"domain",
")",
";",
"}"
] | This creates a new portal information based on the given information. This is necessary because it is possible
that a webspace defines a language, which is not used in any portal. For this case we have to define our own
fake PortalInformation object.
@param object $object
@param int $id
@param string $webspaceKey
@param string $locale
@return PortalInformation
@throws WebspaceLocalizationNotFoundException
@throws WebspaceNotFoundException | [
"This",
"creates",
"a",
"new",
"portal",
"information",
"based",
"on",
"the",
"given",
"information",
".",
"This",
"is",
"necessary",
"because",
"it",
"is",
"possible",
"that",
"a",
"webspace",
"defines",
"a",
"language",
"which",
"is",
"not",
"used",
"in",
"any",
"portal",
".",
"For",
"this",
"case",
"we",
"have",
"to",
"define",
"our",
"own",
"fake",
"PortalInformation",
"object",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PreviewBundle/Preview/Renderer/PreviewRenderer.php#L289-L321 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.createNodeInPublicWorkspace | public function createNodeInPublicWorkspace(PersistEvent $event)
{
$node = $event->getNode();
if ($node->isNew()) {
$this->createNodesWithUuid($node);
return;
}
$liveNode = $this->getLiveNode($event->getDocument());
$nodeName = $node->getName();
if ($liveNode->getName() !== $nodeName) {
$liveNode->rename($nodeName);
}
} | php | public function createNodeInPublicWorkspace(PersistEvent $event)
{
$node = $event->getNode();
if ($node->isNew()) {
$this->createNodesWithUuid($node);
return;
}
$liveNode = $this->getLiveNode($event->getDocument());
$nodeName = $node->getName();
if ($liveNode->getName() !== $nodeName) {
$liveNode->rename($nodeName);
}
} | [
"public",
"function",
"createNodeInPublicWorkspace",
"(",
"PersistEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"if",
"(",
"$",
"node",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"createNodesWithUuid",
"(",
"$",
"node",
")",
";",
"return",
";",
"}",
"$",
"liveNode",
"=",
"$",
"this",
"->",
"getLiveNode",
"(",
"$",
"event",
"->",
"getDocument",
"(",
")",
")",
";",
"$",
"nodeName",
"=",
"$",
"node",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"liveNode",
"->",
"getName",
"(",
")",
"!==",
"$",
"nodeName",
")",
"{",
"$",
"liveNode",
"->",
"rename",
"(",
"$",
"nodeName",
")",
";",
"}",
"}"
] | Creates the node with the same UUID in the public workspace if it does not exist yet. In case it does it will
be renamed if necessary.
@param PersistEvent $event | [
"Creates",
"the",
"node",
"with",
"the",
"same",
"UUID",
"in",
"the",
"public",
"workspace",
"if",
"it",
"does",
"not",
"exist",
"yet",
".",
"In",
"case",
"it",
"does",
"it",
"will",
"be",
"renamed",
"if",
"necessary",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L96-L112 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.removeNodeFromPublicWorkspace | public function removeNodeFromPublicWorkspace(RemoveEvent $event)
{
$document = $event->getDocument();
$metadata = $this->metadataFactory->getMetadataForClass(get_class($document));
if (!$metadata->getSyncRemoveLive()) {
return;
}
$this->getLiveNode($document)->remove();
} | php | public function removeNodeFromPublicWorkspace(RemoveEvent $event)
{
$document = $event->getDocument();
$metadata = $this->metadataFactory->getMetadataForClass(get_class($document));
if (!$metadata->getSyncRemoveLive()) {
return;
}
$this->getLiveNode($document)->remove();
} | [
"public",
"function",
"removeNodeFromPublicWorkspace",
"(",
"RemoveEvent",
"$",
"event",
")",
"{",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"metadataFactory",
"->",
"getMetadataForClass",
"(",
"get_class",
"(",
"$",
"document",
")",
")",
";",
"if",
"(",
"!",
"$",
"metadata",
"->",
"getSyncRemoveLive",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"getLiveNode",
"(",
"$",
"document",
")",
"->",
"remove",
"(",
")",
";",
"}"
] | Since deleting is not draftable the node will be deleted in the live session as soon as it is deleted in the
default session.
@param RemoveEvent $event | [
"Since",
"deleting",
"is",
"not",
"draftable",
"the",
"node",
"will",
"be",
"deleted",
"in",
"the",
"live",
"session",
"as",
"soon",
"as",
"it",
"is",
"deleted",
"in",
"the",
"default",
"session",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L120-L129 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.moveNodeInPublicWorkspace | public function moveNodeInPublicWorkspace(MoveEvent $event)
{
$liveNode = $this->getLiveNode($event->getDocument());
$this->nodeHelper->move($liveNode, $event->getDestId(), $event->getDestName());
} | php | public function moveNodeInPublicWorkspace(MoveEvent $event)
{
$liveNode = $this->getLiveNode($event->getDocument());
$this->nodeHelper->move($liveNode, $event->getDestId(), $event->getDestName());
} | [
"public",
"function",
"moveNodeInPublicWorkspace",
"(",
"MoveEvent",
"$",
"event",
")",
"{",
"$",
"liveNode",
"=",
"$",
"this",
"->",
"getLiveNode",
"(",
"$",
"event",
"->",
"getDocument",
"(",
")",
")",
";",
"$",
"this",
"->",
"nodeHelper",
"->",
"move",
"(",
"$",
"liveNode",
",",
"$",
"event",
"->",
"getDestId",
"(",
")",
",",
"$",
"event",
"->",
"getDestName",
"(",
")",
")",
";",
"}"
] | Since moving is not draftable the node will also be moved in the live session immediately.
@param MoveEvent $event | [
"Since",
"moving",
"is",
"not",
"draftable",
"the",
"node",
"will",
"also",
"be",
"moved",
"in",
"the",
"live",
"session",
"immediately",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L136-L140 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.reorderNodeInPublicWorkspace | public function reorderNodeInPublicWorkspace(ReorderEvent $event)
{
$node = $this->getLiveNode($event->getDocument());
$this->nodeHelper->reorder($node, $event->getDestId());
// FIXME duplicating logic of OrderSubscriber, maybe move to NodeHelper?
$count = 1;
foreach ($node->getParent()->getNodes() as $childNode) {
$childNode->setProperty($this->propertyEncoder->systemName('order'), $count * 10);
++$count;
}
} | php | public function reorderNodeInPublicWorkspace(ReorderEvent $event)
{
$node = $this->getLiveNode($event->getDocument());
$this->nodeHelper->reorder($node, $event->getDestId());
// FIXME duplicating logic of OrderSubscriber, maybe move to NodeHelper?
$count = 1;
foreach ($node->getParent()->getNodes() as $childNode) {
$childNode->setProperty($this->propertyEncoder->systemName('order'), $count * 10);
++$count;
}
} | [
"public",
"function",
"reorderNodeInPublicWorkspace",
"(",
"ReorderEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getLiveNode",
"(",
"$",
"event",
"->",
"getDocument",
"(",
")",
")",
";",
"$",
"this",
"->",
"nodeHelper",
"->",
"reorder",
"(",
"$",
"node",
",",
"$",
"event",
"->",
"getDestId",
"(",
")",
")",
";",
"// FIXME duplicating logic of OrderSubscriber, maybe move to NodeHelper?",
"$",
"count",
"=",
"1",
";",
"foreach",
"(",
"$",
"node",
"->",
"getParent",
"(",
")",
"->",
"getNodes",
"(",
")",
"as",
"$",
"childNode",
")",
"{",
"$",
"childNode",
"->",
"setProperty",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"systemName",
"(",
"'order'",
")",
",",
"$",
"count",
"*",
"10",
")",
";",
"++",
"$",
"count",
";",
"}",
"}"
] | Reordering is also not draftable, and therefore also immediately applied to the live session.
@param ReorderEvent $event | [
"Reordering",
"is",
"also",
"not",
"draftable",
"and",
"therefore",
"also",
"immediately",
"applied",
"to",
"the",
"live",
"session",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L157-L169 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.removePropertiesFromPublicWorkspace | public function removePropertiesFromPublicWorkspace(UnpublishEvent $event)
{
$node = $event->getNode();
$locale = $event->getLocale();
$this->removeLocalizedNodeProperties($node, $locale);
} | php | public function removePropertiesFromPublicWorkspace(UnpublishEvent $event)
{
$node = $event->getNode();
$locale = $event->getLocale();
$this->removeLocalizedNodeProperties($node, $locale);
} | [
"public",
"function",
"removePropertiesFromPublicWorkspace",
"(",
"UnpublishEvent",
"$",
"event",
")",
"{",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"$",
"locale",
"=",
"$",
"event",
"->",
"getLocale",
"(",
")",
";",
"$",
"this",
"->",
"removeLocalizedNodeProperties",
"(",
"$",
"node",
",",
"$",
"locale",
")",
";",
"}"
] | Removes all the properties for the given locale from the node, so that the content is not accessible anymore from
the live workspace.
@param UnpublishEvent $event | [
"Removes",
"all",
"the",
"properties",
"for",
"the",
"given",
"locale",
"from",
"the",
"node",
"so",
"that",
"the",
"content",
"is",
"not",
"accessible",
"anymore",
"from",
"the",
"live",
"workspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L197-L203 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.createNodesWithUuid | private function createNodesWithUuid(NodeInterface $node)
{
$path = $node->getPath();
if ($this->liveSession->itemExists($path)) {
return;
}
$currentDefaultNode = $node->getSession()->getRootNode();
$currentLiveNode = $this->liveSession->getRootNode();
$pathSegments = explode('/', ltrim($path, '/'));
foreach ($pathSegments as $pathSegment) {
$currentDefaultNode = $currentDefaultNode->getNode($pathSegment);
if ($currentLiveNode->hasNode($pathSegment)) {
$currentLiveNode = $currentLiveNode->getNode($pathSegment);
continue;
}
$currentLiveNode = $currentLiveNode->addNode($pathSegment);
$currentLiveNode->setMixins(['mix:referenceable']);
$currentLiveNode->setProperty('jcr:uuid', $currentDefaultNode->getIdentifier());
}
} | php | private function createNodesWithUuid(NodeInterface $node)
{
$path = $node->getPath();
if ($this->liveSession->itemExists($path)) {
return;
}
$currentDefaultNode = $node->getSession()->getRootNode();
$currentLiveNode = $this->liveSession->getRootNode();
$pathSegments = explode('/', ltrim($path, '/'));
foreach ($pathSegments as $pathSegment) {
$currentDefaultNode = $currentDefaultNode->getNode($pathSegment);
if ($currentLiveNode->hasNode($pathSegment)) {
$currentLiveNode = $currentLiveNode->getNode($pathSegment);
continue;
}
$currentLiveNode = $currentLiveNode->addNode($pathSegment);
$currentLiveNode->setMixins(['mix:referenceable']);
$currentLiveNode->setProperty('jcr:uuid', $currentDefaultNode->getIdentifier());
}
} | [
"private",
"function",
"createNodesWithUuid",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"path",
"=",
"$",
"node",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"liveSession",
"->",
"itemExists",
"(",
"$",
"path",
")",
")",
"{",
"return",
";",
"}",
"$",
"currentDefaultNode",
"=",
"$",
"node",
"->",
"getSession",
"(",
")",
"->",
"getRootNode",
"(",
")",
";",
"$",
"currentLiveNode",
"=",
"$",
"this",
"->",
"liveSession",
"->",
"getRootNode",
"(",
")",
";",
"$",
"pathSegments",
"=",
"explode",
"(",
"'/'",
",",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
")",
";",
"foreach",
"(",
"$",
"pathSegments",
"as",
"$",
"pathSegment",
")",
"{",
"$",
"currentDefaultNode",
"=",
"$",
"currentDefaultNode",
"->",
"getNode",
"(",
"$",
"pathSegment",
")",
";",
"if",
"(",
"$",
"currentLiveNode",
"->",
"hasNode",
"(",
"$",
"pathSegment",
")",
")",
"{",
"$",
"currentLiveNode",
"=",
"$",
"currentLiveNode",
"->",
"getNode",
"(",
"$",
"pathSegment",
")",
";",
"continue",
";",
"}",
"$",
"currentLiveNode",
"=",
"$",
"currentLiveNode",
"->",
"addNode",
"(",
"$",
"pathSegment",
")",
";",
"$",
"currentLiveNode",
"->",
"setMixins",
"(",
"[",
"'mix:referenceable'",
"]",
")",
";",
"$",
"currentLiveNode",
"->",
"setProperty",
"(",
"'jcr:uuid'",
",",
"$",
"currentDefaultNode",
"->",
"getIdentifier",
"(",
")",
")",
";",
"}",
"}"
] | Creates every node on the path to the given node. Also uses the same UUIDs for these nodes.
@param NodeInterface $node | [
"Creates",
"every",
"node",
"on",
"the",
"path",
"to",
"the",
"given",
"node",
".",
"Also",
"uses",
"the",
"same",
"UUIDs",
"for",
"these",
"nodes",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L254-L279 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php | PublishSubscriber.removeLocalizedNodeProperties | private function removeLocalizedNodeProperties(NodeInterface $node, $locale)
{
// remove all localized system properties from the node
foreach ($node->getProperties($this->propertyEncoder->localizedSystemName('', $locale) . '*') as $property) {
$property->remove();
}
// remove all localized content properties from the node
foreach ($node->getProperties($this->propertyEncoder->localizedContentName('', $locale) . '*') as $property) {
$property->remove();
}
} | php | private function removeLocalizedNodeProperties(NodeInterface $node, $locale)
{
// remove all localized system properties from the node
foreach ($node->getProperties($this->propertyEncoder->localizedSystemName('', $locale) . '*') as $property) {
$property->remove();
}
// remove all localized content properties from the node
foreach ($node->getProperties($this->propertyEncoder->localizedContentName('', $locale) . '*') as $property) {
$property->remove();
}
} | [
"private",
"function",
"removeLocalizedNodeProperties",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"locale",
")",
"{",
"// remove all localized system properties from the node",
"foreach",
"(",
"$",
"node",
"->",
"getProperties",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"localizedSystemName",
"(",
"''",
",",
"$",
"locale",
")",
".",
"'*'",
")",
"as",
"$",
"property",
")",
"{",
"$",
"property",
"->",
"remove",
"(",
")",
";",
"}",
"// remove all localized content properties from the node",
"foreach",
"(",
"$",
"node",
"->",
"getProperties",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"localizedContentName",
"(",
"''",
",",
"$",
"locale",
")",
".",
"'*'",
")",
"as",
"$",
"property",
")",
"{",
"$",
"property",
"->",
"remove",
"(",
")",
";",
"}",
"}"
] | Removes all localized properties in the given locale from the given node.
@param NodeInterface $node
@param string $locale | [
"Removes",
"all",
"localized",
"properties",
"in",
"the",
"given",
"locale",
"from",
"the",
"given",
"node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Document/Subscriber/PublishSubscriber.php#L309-L320 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadProperties | private function loadProperties(&$tags, \DOMXPath $xpath, \DOMNode $context): array
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query('x:*', $context) as $node) {
if ('property' === $node->tagName) {
$value = $this->loadProperty($xpath, $node, $tags);
$result[$value['name']] = $value;
} elseif ('block' === $node->tagName) {
$value = $this->loadBlock($xpath, $node, $tags);
$result[$value['name']] = $value;
} elseif ('section' === $node->tagName) {
$value = $this->loadSection($xpath, $node, $tags);
$result[$value['name']] = $value;
}
}
return $result;
} | php | private function loadProperties(&$tags, \DOMXPath $xpath, \DOMNode $context): array
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query('x:*', $context) as $node) {
if ('property' === $node->tagName) {
$value = $this->loadProperty($xpath, $node, $tags);
$result[$value['name']] = $value;
} elseif ('block' === $node->tagName) {
$value = $this->loadBlock($xpath, $node, $tags);
$result[$value['name']] = $value;
} elseif ('section' === $node->tagName) {
$value = $this->loadSection($xpath, $node, $tags);
$result[$value['name']] = $value;
}
}
return $result;
} | [
"private",
"function",
"loadProperties",
"(",
"&",
"$",
"tags",
",",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"context",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var \\DOMElement $node */",
"foreach",
"(",
"$",
"xpath",
"->",
"query",
"(",
"'x:*'",
",",
"$",
"context",
")",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"'property'",
"===",
"$",
"node",
"->",
"tagName",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"loadProperty",
"(",
"$",
"xpath",
",",
"$",
"node",
",",
"$",
"tags",
")",
";",
"$",
"result",
"[",
"$",
"value",
"[",
"'name'",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"'block'",
"===",
"$",
"node",
"->",
"tagName",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"loadBlock",
"(",
"$",
"xpath",
",",
"$",
"node",
",",
"$",
"tags",
")",
";",
"$",
"result",
"[",
"$",
"value",
"[",
"'name'",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"elseif",
"(",
"'section'",
"===",
"$",
"node",
"->",
"tagName",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"loadSection",
"(",
"$",
"xpath",
",",
"$",
"node",
",",
"$",
"tags",
")",
";",
"$",
"result",
"[",
"$",
"value",
"[",
"'name'",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | load properties from given context. | [
"load",
"properties",
"from",
"given",
"context",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L57-L76 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadProperty | private function loadProperty(\DOMXPath $xpath, \DOMNode $node, &$tags)
{
$result = $this->loadValues(
$xpath,
$node,
[
'name',
'type',
'minOccurs',
'maxOccurs',
'colspan',
'cssClass',
'spaceAfter',
'disabledCondition',
'visibleCondition',
]
);
$result['mandatory'] = $this->getValueFromXPath('@mandatory', $xpath, $node, false);
$result['multilingual'] = $this->getValueFromXPath('@multilingual', $xpath, $node, true);
$result['onInvalid'] = $this->getValueFromXPath('@onInvalid', $xpath, $node);
$result['tags'] = $this->loadTags($tags, $xpath, $node);
$result['params'] = $this->loadParams('x:params/x:param', $xpath, $node);
$result['meta'] = $this->loadMeta($xpath, $node);
return $result;
} | php | private function loadProperty(\DOMXPath $xpath, \DOMNode $node, &$tags)
{
$result = $this->loadValues(
$xpath,
$node,
[
'name',
'type',
'minOccurs',
'maxOccurs',
'colspan',
'cssClass',
'spaceAfter',
'disabledCondition',
'visibleCondition',
]
);
$result['mandatory'] = $this->getValueFromXPath('@mandatory', $xpath, $node, false);
$result['multilingual'] = $this->getValueFromXPath('@multilingual', $xpath, $node, true);
$result['onInvalid'] = $this->getValueFromXPath('@onInvalid', $xpath, $node);
$result['tags'] = $this->loadTags($tags, $xpath, $node);
$result['params'] = $this->loadParams('x:params/x:param', $xpath, $node);
$result['meta'] = $this->loadMeta($xpath, $node);
return $result;
} | [
"private",
"function",
"loadProperty",
"(",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"node",
",",
"&",
"$",
"tags",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"loadValues",
"(",
"$",
"xpath",
",",
"$",
"node",
",",
"[",
"'name'",
",",
"'type'",
",",
"'minOccurs'",
",",
"'maxOccurs'",
",",
"'colspan'",
",",
"'cssClass'",
",",
"'spaceAfter'",
",",
"'disabledCondition'",
",",
"'visibleCondition'",
",",
"]",
")",
";",
"$",
"result",
"[",
"'mandatory'",
"]",
"=",
"$",
"this",
"->",
"getValueFromXPath",
"(",
"'@mandatory'",
",",
"$",
"xpath",
",",
"$",
"node",
",",
"false",
")",
";",
"$",
"result",
"[",
"'multilingual'",
"]",
"=",
"$",
"this",
"->",
"getValueFromXPath",
"(",
"'@multilingual'",
",",
"$",
"xpath",
",",
"$",
"node",
",",
"true",
")",
";",
"$",
"result",
"[",
"'onInvalid'",
"]",
"=",
"$",
"this",
"->",
"getValueFromXPath",
"(",
"'@onInvalid'",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"result",
"[",
"'tags'",
"]",
"=",
"$",
"this",
"->",
"loadTags",
"(",
"$",
"tags",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"result",
"[",
"'params'",
"]",
"=",
"$",
"this",
"->",
"loadParams",
"(",
"'x:params/x:param'",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"result",
"[",
"'meta'",
"]",
"=",
"$",
"this",
"->",
"loadMeta",
"(",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"return",
"$",
"result",
";",
"}"
] | load single property. | [
"load",
"single",
"property",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L81-L107 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.validateTag | private function validateTag($tag, &$tags)
{
if (!isset($tags[$tag['name']])) {
$tags[$tag['name']] = [];
}
$tags[$tag['name']][] = $tag['priority'];
} | php | private function validateTag($tag, &$tags)
{
if (!isset($tags[$tag['name']])) {
$tags[$tag['name']] = [];
}
$tags[$tag['name']][] = $tag['priority'];
} | [
"private",
"function",
"validateTag",
"(",
"$",
"tag",
",",
"&",
"$",
"tags",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"tags",
"[",
"$",
"tag",
"[",
"'name'",
"]",
"]",
")",
")",
"{",
"$",
"tags",
"[",
"$",
"tag",
"[",
"'name'",
"]",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"tags",
"[",
"$",
"tag",
"[",
"'name'",
"]",
"]",
"[",
"]",
"=",
"$",
"tag",
"[",
"'priority'",
"]",
";",
"}"
] | validates a single tag. | [
"validates",
"a",
"single",
"tag",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L112-L119 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadTag | private function loadTag(\DOMXPath $xpath, \DOMNode $node)
{
$tag = [
'name' => null,
'priority' => null,
'attributes' => [],
];
foreach ($node->attributes as $key => $attr) {
if (in_array($key, ['name', 'priority'])) {
$tag[$key] = $attr->value;
} else {
$tag['attributes'][$key] = $attr->value;
}
}
return $tag;
} | php | private function loadTag(\DOMXPath $xpath, \DOMNode $node)
{
$tag = [
'name' => null,
'priority' => null,
'attributes' => [],
];
foreach ($node->attributes as $key => $attr) {
if (in_array($key, ['name', 'priority'])) {
$tag[$key] = $attr->value;
} else {
$tag['attributes'][$key] = $attr->value;
}
}
return $tag;
} | [
"private",
"function",
"loadTag",
"(",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"node",
")",
"{",
"$",
"tag",
"=",
"[",
"'name'",
"=>",
"null",
",",
"'priority'",
"=>",
"null",
",",
"'attributes'",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"node",
"->",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"attr",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"[",
"'name'",
",",
"'priority'",
"]",
")",
")",
"{",
"$",
"tag",
"[",
"$",
"key",
"]",
"=",
"$",
"attr",
"->",
"value",
";",
"}",
"else",
"{",
"$",
"tag",
"[",
"'attributes'",
"]",
"[",
"$",
"key",
"]",
"=",
"$",
"attr",
"->",
"value",
";",
"}",
"}",
"return",
"$",
"tag",
";",
"}"
] | load single tag. | [
"load",
"single",
"tag",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L124-L141 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadBlock | private function loadBlock(\DOMXPath $xpath, \DOMNode $node, &$tags)
{
$result = $this->loadValues(
$xpath,
$node,
[
'name',
'default-type',
'minOccurs',
'maxOccurs',
'colspan',
'cssClass',
'disabledCondition',
'visibleCondition',
]
);
$result['mandatory'] = $this->getValueFromXPath('@mandatory', $xpath, $node, false);
$result['type'] = 'block';
$result['tags'] = $this->loadTags($tags, $xpath, $node);
$result['params'] = $this->loadParams('x:params/x:param', $xpath, $node);
$result['meta'] = $this->loadMeta($xpath, $node);
$result['types'] = $this->loadTypes($tags, $xpath, $node);
return $result;
} | php | private function loadBlock(\DOMXPath $xpath, \DOMNode $node, &$tags)
{
$result = $this->loadValues(
$xpath,
$node,
[
'name',
'default-type',
'minOccurs',
'maxOccurs',
'colspan',
'cssClass',
'disabledCondition',
'visibleCondition',
]
);
$result['mandatory'] = $this->getValueFromXPath('@mandatory', $xpath, $node, false);
$result['type'] = 'block';
$result['tags'] = $this->loadTags($tags, $xpath, $node);
$result['params'] = $this->loadParams('x:params/x:param', $xpath, $node);
$result['meta'] = $this->loadMeta($xpath, $node);
$result['types'] = $this->loadTypes($tags, $xpath, $node);
return $result;
} | [
"private",
"function",
"loadBlock",
"(",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"node",
",",
"&",
"$",
"tags",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"loadValues",
"(",
"$",
"xpath",
",",
"$",
"node",
",",
"[",
"'name'",
",",
"'default-type'",
",",
"'minOccurs'",
",",
"'maxOccurs'",
",",
"'colspan'",
",",
"'cssClass'",
",",
"'disabledCondition'",
",",
"'visibleCondition'",
",",
"]",
")",
";",
"$",
"result",
"[",
"'mandatory'",
"]",
"=",
"$",
"this",
"->",
"getValueFromXPath",
"(",
"'@mandatory'",
",",
"$",
"xpath",
",",
"$",
"node",
",",
"false",
")",
";",
"$",
"result",
"[",
"'type'",
"]",
"=",
"'block'",
";",
"$",
"result",
"[",
"'tags'",
"]",
"=",
"$",
"this",
"->",
"loadTags",
"(",
"$",
"tags",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"result",
"[",
"'params'",
"]",
"=",
"$",
"this",
"->",
"loadParams",
"(",
"'x:params/x:param'",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"result",
"[",
"'meta'",
"]",
"=",
"$",
"this",
"->",
"loadMeta",
"(",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"result",
"[",
"'types'",
"]",
"=",
"$",
"this",
"->",
"loadTypes",
"(",
"$",
"tags",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"return",
"$",
"result",
";",
"}"
] | load single block. | [
"load",
"single",
"block",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L146-L171 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadTags | private function loadTags(&$tags, \DOMXPath $xpath, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query('x:tag', $context) as $node) {
$tag = $this->loadTag($xpath, $node);
$this->validateTag($tag, $tags);
$result[] = $tag;
}
return $result;
} | php | private function loadTags(&$tags, \DOMXPath $xpath, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query('x:tag', $context) as $node) {
$tag = $this->loadTag($xpath, $node);
$this->validateTag($tag, $tags);
$result[] = $tag;
}
return $result;
} | [
"private",
"function",
"loadTags",
"(",
"&",
"$",
"tags",
",",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var \\DOMElement $node */",
"foreach",
"(",
"$",
"xpath",
"->",
"query",
"(",
"'x:tag'",
",",
"$",
"context",
")",
"as",
"$",
"node",
")",
"{",
"$",
"tag",
"=",
"$",
"this",
"->",
"loadTag",
"(",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"$",
"this",
"->",
"validateTag",
"(",
"$",
"tag",
",",
"$",
"tags",
")",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"tag",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | load tags from given tag and validates them. | [
"load",
"tags",
"from",
"given",
"tag",
"and",
"validates",
"them",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L197-L210 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadTypes | private function loadTypes(&$tags, \DOMXPath $xpath, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query('x:types/x:type', $context) as $node) {
$value = $this->loadType($xpath, $node, $tags);
$result[$value['name']] = $value;
}
return $result;
} | php | private function loadTypes(&$tags, \DOMXPath $xpath, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query('x:types/x:type', $context) as $node) {
$value = $this->loadType($xpath, $node, $tags);
$result[$value['name']] = $value;
}
return $result;
} | [
"private",
"function",
"loadTypes",
"(",
"&",
"$",
"tags",
",",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var \\DOMElement $node */",
"foreach",
"(",
"$",
"xpath",
"->",
"query",
"(",
"'x:types/x:type'",
",",
"$",
"context",
")",
"as",
"$",
"node",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"loadType",
"(",
"$",
"xpath",
",",
"$",
"node",
",",
"$",
"tags",
")",
";",
"$",
"result",
"[",
"$",
"value",
"[",
"'name'",
"]",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | load types from given node. | [
"load",
"types",
"from",
"given",
"node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L215-L226 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadValues | private function loadValues(\DOMXPath $xpath, \DOMNode $node, $keys, $prefix = '@')
{
$result = [];
foreach ($keys as $key) {
$result[$key] = $this->getValueFromXPath($prefix . $key, $xpath, $node);
}
return $result;
} | php | private function loadValues(\DOMXPath $xpath, \DOMNode $node, $keys, $prefix = '@')
{
$result = [];
foreach ($keys as $key) {
$result[$key] = $this->getValueFromXPath($prefix . $key, $xpath, $node);
}
return $result;
} | [
"private",
"function",
"loadValues",
"(",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"keys",
",",
"$",
"prefix",
"=",
"'@'",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"getValueFromXPath",
"(",
"$",
"prefix",
".",
"$",
"key",
",",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | load values defined by key from given node. | [
"load",
"values",
"defined",
"by",
"key",
"from",
"given",
"node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L246-L255 | train |
sulu/sulu | src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php | PropertiesXmlParser.loadParams | private function loadParams($path, \DOMXPath $xpath, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query($path, $context) as $node) {
$result[] = $this->loadParam($xpath, $node);
}
return $result;
} | php | private function loadParams($path, \DOMXPath $xpath, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($xpath->query($path, $context) as $node) {
$result[] = $this->loadParam($xpath, $node);
}
return $result;
} | [
"private",
"function",
"loadParams",
"(",
"$",
"path",
",",
"\\",
"DOMXPath",
"$",
"xpath",
",",
"\\",
"DOMNode",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var \\DOMElement $node */",
"foreach",
"(",
"$",
"xpath",
"->",
"query",
"(",
"$",
"path",
",",
"$",
"context",
")",
"as",
"$",
"node",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"loadParam",
"(",
"$",
"xpath",
",",
"$",
"node",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | load params from given node. | [
"load",
"params",
"from",
"given",
"node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Metadata/Parser/PropertiesXmlParser.php#L307-L317 | train |
sulu/sulu | src/Sulu/Bundle/ContactBundle/Entity/ContactAddress.php | ContactAddress.setAddress | public function setAddress(\Sulu\Bundle\ContactBundle\Entity\Address $address)
{
$this->address = $address;
return $this;
} | php | public function setAddress(\Sulu\Bundle\ContactBundle\Entity\Address $address)
{
$this->address = $address;
return $this;
} | [
"public",
"function",
"setAddress",
"(",
"\\",
"Sulu",
"\\",
"Bundle",
"\\",
"ContactBundle",
"\\",
"Entity",
"\\",
"Address",
"$",
"address",
")",
"{",
"$",
"this",
"->",
"address",
"=",
"$",
"address",
";",
"return",
"$",
"this",
";",
"}"
] | Set address.
@param \Sulu\Bundle\ContactBundle\Entity\Address $address
@return ContactAddress | [
"Set",
"address",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ContactBundle/Entity/ContactAddress.php#L83-L88 | train |
sulu/sulu | src/Sulu/Bundle/RouteBundle/Manager/RouteManager.php | RouteManager.isUnique | private function isUnique(RouteInterface $route)
{
$persistedRoute = $this->routeRepository->findByPath($route->getPath(), $route->getLocale());
return !$persistedRoute;
} | php | private function isUnique(RouteInterface $route)
{
$persistedRoute = $this->routeRepository->findByPath($route->getPath(), $route->getLocale());
return !$persistedRoute;
} | [
"private",
"function",
"isUnique",
"(",
"RouteInterface",
"$",
"route",
")",
"{",
"$",
"persistedRoute",
"=",
"$",
"this",
"->",
"routeRepository",
"->",
"findByPath",
"(",
"$",
"route",
"->",
"getPath",
"(",
")",
",",
"$",
"route",
"->",
"getLocale",
"(",
")",
")",
";",
"return",
"!",
"$",
"persistedRoute",
";",
"}"
] | Returns true if route is unique.
@param RouteInterface $route
@return bool | [
"Returns",
"true",
"if",
"route",
"is",
"unique",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/RouteBundle/Manager/RouteManager.php#L128-L133 | train |
sulu/sulu | src/Sulu/Bundle/RouteBundle/Manager/RouteManager.php | RouteManager.resolve | private function resolve(RouteInterface $route, RoutableInterface $entity)
{
$persistedRoute = $this->routeRepository->findByPath($route->getPath(), $route->getLocale());
if (!$persistedRoute) {
return $route;
}
if ($persistedRoute->getEntityClass() === $route->getEntityClass()
&& $persistedRoute->getEntityId() === $route->getEntityId()
) {
return $persistedRoute;
}
throw new RouteIsNotUniqueException($route, $entity);
} | php | private function resolve(RouteInterface $route, RoutableInterface $entity)
{
$persistedRoute = $this->routeRepository->findByPath($route->getPath(), $route->getLocale());
if (!$persistedRoute) {
return $route;
}
if ($persistedRoute->getEntityClass() === $route->getEntityClass()
&& $persistedRoute->getEntityId() === $route->getEntityId()
) {
return $persistedRoute;
}
throw new RouteIsNotUniqueException($route, $entity);
} | [
"private",
"function",
"resolve",
"(",
"RouteInterface",
"$",
"route",
",",
"RoutableInterface",
"$",
"entity",
")",
"{",
"$",
"persistedRoute",
"=",
"$",
"this",
"->",
"routeRepository",
"->",
"findByPath",
"(",
"$",
"route",
"->",
"getPath",
"(",
")",
",",
"$",
"route",
"->",
"getLocale",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"persistedRoute",
")",
"{",
"return",
"$",
"route",
";",
"}",
"if",
"(",
"$",
"persistedRoute",
"->",
"getEntityClass",
"(",
")",
"===",
"$",
"route",
"->",
"getEntityClass",
"(",
")",
"&&",
"$",
"persistedRoute",
"->",
"getEntityId",
"(",
")",
"===",
"$",
"route",
"->",
"getEntityId",
"(",
")",
")",
"{",
"return",
"$",
"persistedRoute",
";",
"}",
"throw",
"new",
"RouteIsNotUniqueException",
"(",
"$",
"route",
",",
"$",
"entity",
")",
";",
"}"
] | Looks for the same route in the database.
If no route was found the method returns the newly created route.
If the route is a history route for given entity the history route will be returned.
Else a RouteIsNotUniqueException will be thrown.
@param RouteInterface $route
@param RoutableInterface $entity
@return RouteInterface
@throws RouteIsNotUniqueException | [
"Looks",
"for",
"the",
"same",
"route",
"in",
"the",
"database",
".",
"If",
"no",
"route",
"was",
"found",
"the",
"method",
"returns",
"the",
"newly",
"created",
"route",
".",
"If",
"the",
"route",
"is",
"a",
"history",
"route",
"for",
"given",
"entity",
"the",
"history",
"route",
"will",
"be",
"returned",
".",
"Else",
"a",
"RouteIsNotUniqueException",
"will",
"be",
"thrown",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/RouteBundle/Manager/RouteManager.php#L148-L163 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php | BlameSubscriber.setBlamesOnDocument | public function setBlamesOnDocument(HydrateEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($document)) {
return;
}
$node = $event->getNode();
$locale = $event->getLocale();
$encoding = $this->getPropertyEncoding($document);
$accessor = $event->getAccessor();
$accessor->set(
static::CHANGER,
$node->getPropertyValueWithDefault(
$this->propertyEncoder->encode($encoding, static::CHANGER, $locale),
null
)
);
$accessor->set(
static::CREATOR,
$node->getPropertyValueWithDefault(
$this->propertyEncoder->encode($encoding, static::CREATOR, $locale),
null
)
);
} | php | public function setBlamesOnDocument(HydrateEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($document)) {
return;
}
$node = $event->getNode();
$locale = $event->getLocale();
$encoding = $this->getPropertyEncoding($document);
$accessor = $event->getAccessor();
$accessor->set(
static::CHANGER,
$node->getPropertyValueWithDefault(
$this->propertyEncoder->encode($encoding, static::CHANGER, $locale),
null
)
);
$accessor->set(
static::CREATOR,
$node->getPropertyValueWithDefault(
$this->propertyEncoder->encode($encoding, static::CREATOR, $locale),
null
)
);
} | [
"public",
"function",
"setBlamesOnDocument",
"(",
"HydrateEvent",
"$",
"event",
")",
"{",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"document",
")",
")",
"{",
"return",
";",
"}",
"$",
"node",
"=",
"$",
"event",
"->",
"getNode",
"(",
")",
";",
"$",
"locale",
"=",
"$",
"event",
"->",
"getLocale",
"(",
")",
";",
"$",
"encoding",
"=",
"$",
"this",
"->",
"getPropertyEncoding",
"(",
"$",
"document",
")",
";",
"$",
"accessor",
"=",
"$",
"event",
"->",
"getAccessor",
"(",
")",
";",
"$",
"accessor",
"->",
"set",
"(",
"static",
"::",
"CHANGER",
",",
"$",
"node",
"->",
"getPropertyValueWithDefault",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"encode",
"(",
"$",
"encoding",
",",
"static",
"::",
"CHANGER",
",",
"$",
"locale",
")",
",",
"null",
")",
")",
";",
"$",
"accessor",
"->",
"set",
"(",
"static",
"::",
"CREATOR",
",",
"$",
"node",
"->",
"getPropertyValueWithDefault",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"encode",
"(",
"$",
"encoding",
",",
"static",
"::",
"CREATOR",
",",
"$",
"locale",
")",
",",
"null",
")",
")",
";",
"}"
] | Sets the changer and creator of the document.
@param HydrateEvent $event | [
"Sets",
"the",
"changer",
"and",
"creator",
"of",
"the",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php#L63-L92 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php | BlameSubscriber.setBlamesOnNodeForPersist | public function setBlamesOnNodeForPersist(PersistEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($document)) {
return;
}
$this->setBlamesOnNode(
$document,
$event->getNode(),
$event->getLocale(),
$event->getAccessor(),
$event->getOption('user')
);
} | php | public function setBlamesOnNodeForPersist(PersistEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($document)) {
return;
}
$this->setBlamesOnNode(
$document,
$event->getNode(),
$event->getLocale(),
$event->getAccessor(),
$event->getOption('user')
);
} | [
"public",
"function",
"setBlamesOnNodeForPersist",
"(",
"PersistEvent",
"$",
"event",
")",
"{",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"document",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"setBlamesOnNode",
"(",
"$",
"document",
",",
"$",
"event",
"->",
"getNode",
"(",
")",
",",
"$",
"event",
"->",
"getLocale",
"(",
")",
",",
"$",
"event",
"->",
"getAccessor",
"(",
")",
",",
"$",
"event",
"->",
"getOption",
"(",
"'user'",
")",
")",
";",
"}"
] | Sets the creator and changer for the persist event.
@param PersistEvent $event | [
"Sets",
"the",
"creator",
"and",
"changer",
"for",
"the",
"persist",
"event",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php#L99-L114 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php | BlameSubscriber.setBlamesOnNodeForPublish | public function setBlamesOnNodeForPublish(PublishEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($document)) {
return;
}
$this->setBlamesOnNode(
$document,
$event->getNode(),
$event->getLocale(),
$event->getAccessor(),
$document->getChanger()
);
} | php | public function setBlamesOnNodeForPublish(PublishEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($document)) {
return;
}
$this->setBlamesOnNode(
$document,
$event->getNode(),
$event->getLocale(),
$event->getAccessor(),
$document->getChanger()
);
} | [
"public",
"function",
"setBlamesOnNodeForPublish",
"(",
"PublishEvent",
"$",
"event",
")",
"{",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"document",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"setBlamesOnNode",
"(",
"$",
"document",
",",
"$",
"event",
"->",
"getNode",
"(",
")",
",",
"$",
"event",
"->",
"getLocale",
"(",
")",
",",
"$",
"event",
"->",
"getAccessor",
"(",
")",
",",
"$",
"document",
"->",
"getChanger",
"(",
")",
")",
";",
"}"
] | Sets the creator and changer for the publish event.
@param PublishEvent $event | [
"Sets",
"the",
"creator",
"and",
"changer",
"for",
"the",
"publish",
"event",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php#L121-L136 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php | BlameSubscriber.setBlamesOnNode | public function setBlamesOnNode(
LocalizedBlameBehavior $document,
NodeInterface $node,
$locale,
DocumentAccessor $accessor,
$userId
) {
if (!$document instanceof BlameBehavior && !$locale) {
return;
}
$encoding = $this->getPropertyEncoding($document);
$creatorPropertyName = $this->propertyEncoder->encode($encoding, static::CREATOR, $locale);
if (!$node->hasProperty($creatorPropertyName)) {
$accessor->set(self::CREATOR, $userId);
$node->setProperty(
$creatorPropertyName,
$document->getCreator()
);
}
$accessor->set(self::CHANGER, $userId);
$node->setProperty(
$this->propertyEncoder->encode($encoding, static::CHANGER, $locale),
$userId
);
} | php | public function setBlamesOnNode(
LocalizedBlameBehavior $document,
NodeInterface $node,
$locale,
DocumentAccessor $accessor,
$userId
) {
if (!$document instanceof BlameBehavior && !$locale) {
return;
}
$encoding = $this->getPropertyEncoding($document);
$creatorPropertyName = $this->propertyEncoder->encode($encoding, static::CREATOR, $locale);
if (!$node->hasProperty($creatorPropertyName)) {
$accessor->set(self::CREATOR, $userId);
$node->setProperty(
$creatorPropertyName,
$document->getCreator()
);
}
$accessor->set(self::CHANGER, $userId);
$node->setProperty(
$this->propertyEncoder->encode($encoding, static::CHANGER, $locale),
$userId
);
} | [
"public",
"function",
"setBlamesOnNode",
"(",
"LocalizedBlameBehavior",
"$",
"document",
",",
"NodeInterface",
"$",
"node",
",",
"$",
"locale",
",",
"DocumentAccessor",
"$",
"accessor",
",",
"$",
"userId",
")",
"{",
"if",
"(",
"!",
"$",
"document",
"instanceof",
"BlameBehavior",
"&&",
"!",
"$",
"locale",
")",
"{",
"return",
";",
"}",
"$",
"encoding",
"=",
"$",
"this",
"->",
"getPropertyEncoding",
"(",
"$",
"document",
")",
";",
"$",
"creatorPropertyName",
"=",
"$",
"this",
"->",
"propertyEncoder",
"->",
"encode",
"(",
"$",
"encoding",
",",
"static",
"::",
"CREATOR",
",",
"$",
"locale",
")",
";",
"if",
"(",
"!",
"$",
"node",
"->",
"hasProperty",
"(",
"$",
"creatorPropertyName",
")",
")",
"{",
"$",
"accessor",
"->",
"set",
"(",
"self",
"::",
"CREATOR",
",",
"$",
"userId",
")",
";",
"$",
"node",
"->",
"setProperty",
"(",
"$",
"creatorPropertyName",
",",
"$",
"document",
"->",
"getCreator",
"(",
")",
")",
";",
"}",
"$",
"accessor",
"->",
"set",
"(",
"self",
"::",
"CHANGER",
",",
"$",
"userId",
")",
";",
"$",
"node",
"->",
"setProperty",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"encode",
"(",
"$",
"encoding",
",",
"static",
"::",
"CHANGER",
",",
"$",
"locale",
")",
",",
"$",
"userId",
")",
";",
"}"
] | Persists the data of creator and changer to the Node.
@param LocalizedBlameBehavior $document
@param NodeInterface $node
@param string $locale string
@param DocumentAccessor $accessor
@param int $userId | [
"Persists",
"the",
"data",
"of",
"creator",
"and",
"changer",
"to",
"the",
"Node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php#L147-L174 | train |
sulu/sulu | src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php | BlameSubscriber.setChangerForRestore | public function setChangerForRestore(RestoreEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($event->getDocument())) {
return;
}
$encoding = $this->getPropertyEncoding($document);
$event->getNode()->setProperty(
$this->propertyEncoder->encode($encoding, self::CHANGER, $event->getLocale()),
$event->getOption('user')
);
} | php | public function setChangerForRestore(RestoreEvent $event)
{
$document = $event->getDocument();
if (!$this->supports($event->getDocument())) {
return;
}
$encoding = $this->getPropertyEncoding($document);
$event->getNode()->setProperty(
$this->propertyEncoder->encode($encoding, self::CHANGER, $event->getLocale()),
$event->getOption('user')
);
} | [
"public",
"function",
"setChangerForRestore",
"(",
"RestoreEvent",
"$",
"event",
")",
"{",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"$",
"event",
"->",
"getDocument",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"encoding",
"=",
"$",
"this",
"->",
"getPropertyEncoding",
"(",
"$",
"document",
")",
";",
"$",
"event",
"->",
"getNode",
"(",
")",
"->",
"setProperty",
"(",
"$",
"this",
"->",
"propertyEncoder",
"->",
"encode",
"(",
"$",
"encoding",
",",
"self",
"::",
"CHANGER",
",",
"$",
"event",
"->",
"getLocale",
"(",
")",
")",
",",
"$",
"event",
"->",
"getOption",
"(",
"'user'",
")",
")",
";",
"}"
] | Sets the changer for the restore event.
@param RestoreEvent $event | [
"Sets",
"the",
"changer",
"for",
"the",
"restore",
"event",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Document/Subscriber/BlameSubscriber.php#L181-L194 | train |
sulu/sulu | src/Sulu/Bundle/AudienceTargetingBundle/TargetGroup/TargetGroupEvaluator.php | TargetGroupEvaluator.evaluateTargetGroup | private function evaluateTargetGroup(TargetGroupInterface $targetGroup)
{
foreach ($targetGroup->getRules() as $targetGroupRule) {
if ($this->evaluateTargetGroupRule($targetGroupRule)) {
return true;
}
}
return false;
} | php | private function evaluateTargetGroup(TargetGroupInterface $targetGroup)
{
foreach ($targetGroup->getRules() as $targetGroupRule) {
if ($this->evaluateTargetGroupRule($targetGroupRule)) {
return true;
}
}
return false;
} | [
"private",
"function",
"evaluateTargetGroup",
"(",
"TargetGroupInterface",
"$",
"targetGroup",
")",
"{",
"foreach",
"(",
"$",
"targetGroup",
"->",
"getRules",
"(",
")",
"as",
"$",
"targetGroupRule",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"evaluateTargetGroupRule",
"(",
"$",
"targetGroupRule",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Evaluates if one of the rules of the given TargetGroup match. If one of these rules are matching the entire
target group is matching.
@param TargetGroupInterface $targetGroup
@return bool | [
"Evaluates",
"if",
"one",
"of",
"the",
"rules",
"of",
"the",
"given",
"TargetGroup",
"match",
".",
"If",
"one",
"of",
"these",
"rules",
"are",
"matching",
"the",
"entire",
"target",
"group",
"is",
"matching",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/TargetGroup/TargetGroupEvaluator.php#L85-L94 | train |
sulu/sulu | src/Sulu/Bundle/AudienceTargetingBundle/TargetGroup/TargetGroupEvaluator.php | TargetGroupEvaluator.evaluateTargetGroupRule | private function evaluateTargetGroupRule(TargetGroupRuleInterface $targetGroupRule)
{
foreach ($targetGroupRule->getConditions() as $targetGroupCondition) {
$rule = $this->ruleCollection->getRule($targetGroupCondition->getType());
if (!$rule->evaluate($targetGroupCondition->getCondition())) {
return false;
}
}
return true;
} | php | private function evaluateTargetGroupRule(TargetGroupRuleInterface $targetGroupRule)
{
foreach ($targetGroupRule->getConditions() as $targetGroupCondition) {
$rule = $this->ruleCollection->getRule($targetGroupCondition->getType());
if (!$rule->evaluate($targetGroupCondition->getCondition())) {
return false;
}
}
return true;
} | [
"private",
"function",
"evaluateTargetGroupRule",
"(",
"TargetGroupRuleInterface",
"$",
"targetGroupRule",
")",
"{",
"foreach",
"(",
"$",
"targetGroupRule",
"->",
"getConditions",
"(",
")",
"as",
"$",
"targetGroupCondition",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"ruleCollection",
"->",
"getRule",
"(",
"$",
"targetGroupCondition",
"->",
"getType",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"rule",
"->",
"evaluate",
"(",
"$",
"targetGroupCondition",
"->",
"getCondition",
"(",
")",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Evaluates if the given rule is matching. Only returns true if all of the conditions are matching.
@param TargetGroupRuleInterface $targetGroupRule
@return bool | [
"Evaluates",
"if",
"the",
"given",
"rule",
"is",
"matching",
".",
"Only",
"returns",
"true",
"if",
"all",
"of",
"the",
"conditions",
"are",
"matching",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/TargetGroup/TargetGroupEvaluator.php#L103-L114 | train |
sulu/sulu | src/Sulu/Bundle/AdminBundle/Admin/JsConfig.php | JsConfig.addParameters | public function addParameters(array $params)
{
if (!is_array($params)) {
throw new \InvalidArgumentException('$params has to be an array');
}
$this->parameters = array_merge($this->parameters, $params);
} | php | public function addParameters(array $params)
{
if (!is_array($params)) {
throw new \InvalidArgumentException('$params has to be an array');
}
$this->parameters = array_merge($this->parameters, $params);
} | [
"public",
"function",
"addParameters",
"(",
"array",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'$params has to be an array'",
")",
";",
"}",
"$",
"this",
"->",
"parameters",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"parameters",
",",
"$",
"params",
")",
";",
"}"
] | adds array of parameters.
@param array $params
@throws \InvalidArgumentException | [
"adds",
"array",
"of",
"parameters",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AdminBundle/Admin/JsConfig.php#L64-L70 | train |
sulu/sulu | src/Sulu/Bundle/AdminBundle/Admin/NavigationRegistry.php | NavigationRegistry.processNavigationItem | private function processNavigationItem(NavigationItem $navigationItem): void
{
// create label from name when no label is set
if (!$navigationItem->getLabel()) {
$navigationItem->setLabel($this->translator->trans($navigationItem->getName(), [], 'admin'));
}
// add child routes
if ($navigationItem->getMainRoute()) {
$mainPath = $this->routeRegistry->findRouteByName($navigationItem->getMainRoute())->getPath();
foreach ($this->routeRegistry->getRoutes() as $route) {
if (false !== strpos($route->getPath(), $mainPath)) {
$navigationItem->addChildRoute($route->getName());
}
}
}
// process all children
foreach ($navigationItem->getChildren() as $child) {
$this->processNavigationItem($child);
}
} | php | private function processNavigationItem(NavigationItem $navigationItem): void
{
// create label from name when no label is set
if (!$navigationItem->getLabel()) {
$navigationItem->setLabel($this->translator->trans($navigationItem->getName(), [], 'admin'));
}
// add child routes
if ($navigationItem->getMainRoute()) {
$mainPath = $this->routeRegistry->findRouteByName($navigationItem->getMainRoute())->getPath();
foreach ($this->routeRegistry->getRoutes() as $route) {
if (false !== strpos($route->getPath(), $mainPath)) {
$navigationItem->addChildRoute($route->getName());
}
}
}
// process all children
foreach ($navigationItem->getChildren() as $child) {
$this->processNavigationItem($child);
}
} | [
"private",
"function",
"processNavigationItem",
"(",
"NavigationItem",
"$",
"navigationItem",
")",
":",
"void",
"{",
"// create label from name when no label is set",
"if",
"(",
"!",
"$",
"navigationItem",
"->",
"getLabel",
"(",
")",
")",
"{",
"$",
"navigationItem",
"->",
"setLabel",
"(",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"$",
"navigationItem",
"->",
"getName",
"(",
")",
",",
"[",
"]",
",",
"'admin'",
")",
")",
";",
"}",
"// add child routes",
"if",
"(",
"$",
"navigationItem",
"->",
"getMainRoute",
"(",
")",
")",
"{",
"$",
"mainPath",
"=",
"$",
"this",
"->",
"routeRegistry",
"->",
"findRouteByName",
"(",
"$",
"navigationItem",
"->",
"getMainRoute",
"(",
")",
")",
"->",
"getPath",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"routeRegistry",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"route",
"->",
"getPath",
"(",
")",
",",
"$",
"mainPath",
")",
")",
"{",
"$",
"navigationItem",
"->",
"addChildRoute",
"(",
"$",
"route",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"}",
"// process all children",
"foreach",
"(",
"$",
"navigationItem",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"processNavigationItem",
"(",
"$",
"child",
")",
";",
"}",
"}"
] | Adds the translation and the child routes to the given navigation item. | [
"Adds",
"the",
"translation",
"and",
"the",
"child",
"routes",
"to",
"the",
"given",
"navigation",
"item",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AdminBundle/Admin/NavigationRegistry.php#L87-L108 | train |
sulu/sulu | src/Sulu/Bundle/WebsiteBundle/Twig/Meta/MetaTwigExtension.php | MetaTwigExtension.getAlternateLinks | public function getAlternateLinks($urls)
{
// determine default and current values
$webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
$currentPortal = $this->requestAnalyzer->getPortal();
$defaultLocale = null;
if (null !== $currentPortal && null !== ($defaultLocale = $currentPortal->getXDefaultLocalization())) {
$defaultLocale = $defaultLocale->getLocale();
}
$result = [];
foreach ($urls as $locale => $url) {
// url = '/' means that there is no translation for this page
// the only exception is the homepage where the requested resource-locator is '/'
if ('/' !== $url || '/' === $this->requestAnalyzer->getResourceLocator()) {
if ($locale === $defaultLocale) {
$result[] = $this->getAlternate($url, $webspaceKey, $locale, true);
}
$result[] = $this->getAlternate($url, $webspaceKey, $locale);
}
}
return implode(PHP_EOL, $result);
} | php | public function getAlternateLinks($urls)
{
// determine default and current values
$webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
$currentPortal = $this->requestAnalyzer->getPortal();
$defaultLocale = null;
if (null !== $currentPortal && null !== ($defaultLocale = $currentPortal->getXDefaultLocalization())) {
$defaultLocale = $defaultLocale->getLocale();
}
$result = [];
foreach ($urls as $locale => $url) {
// url = '/' means that there is no translation for this page
// the only exception is the homepage where the requested resource-locator is '/'
if ('/' !== $url || '/' === $this->requestAnalyzer->getResourceLocator()) {
if ($locale === $defaultLocale) {
$result[] = $this->getAlternate($url, $webspaceKey, $locale, true);
}
$result[] = $this->getAlternate($url, $webspaceKey, $locale);
}
}
return implode(PHP_EOL, $result);
} | [
"public",
"function",
"getAlternateLinks",
"(",
"$",
"urls",
")",
"{",
"// determine default and current values",
"$",
"webspaceKey",
"=",
"$",
"this",
"->",
"requestAnalyzer",
"->",
"getWebspace",
"(",
")",
"->",
"getKey",
"(",
")",
";",
"$",
"currentPortal",
"=",
"$",
"this",
"->",
"requestAnalyzer",
"->",
"getPortal",
"(",
")",
";",
"$",
"defaultLocale",
"=",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"currentPortal",
"&&",
"null",
"!==",
"(",
"$",
"defaultLocale",
"=",
"$",
"currentPortal",
"->",
"getXDefaultLocalization",
"(",
")",
")",
")",
"{",
"$",
"defaultLocale",
"=",
"$",
"defaultLocale",
"->",
"getLocale",
"(",
")",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"locale",
"=>",
"$",
"url",
")",
"{",
"// url = '/' means that there is no translation for this page",
"// the only exception is the homepage where the requested resource-locator is '/'",
"if",
"(",
"'/'",
"!==",
"$",
"url",
"||",
"'/'",
"===",
"$",
"this",
"->",
"requestAnalyzer",
"->",
"getResourceLocator",
"(",
")",
")",
"{",
"if",
"(",
"$",
"locale",
"===",
"$",
"defaultLocale",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getAlternate",
"(",
"$",
"url",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
",",
"true",
")",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getAlternate",
"(",
"$",
"url",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"result",
")",
";",
"}"
] | Returns alternate link HTML tags with href-lang attributes.
@param array $urls
@return string
@deprecated since 1.1 use SeoTwigExtension::renderSeoTags - sulu_seo | [
"Returns",
"alternate",
"link",
"HTML",
"tags",
"with",
"href",
"-",
"lang",
"attributes",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Twig/Meta/MetaTwigExtension.php#L71-L95 | train |
sulu/sulu | src/Sulu/Bundle/WebsiteBundle/Twig/Meta/MetaTwigExtension.php | MetaTwigExtension.getSeoMetaTags | public function getSeoMetaTags($extension, $content)
{
$seo = [];
if (array_key_exists('seo', $extension)) {
$seo = $extension['seo'];
}
$excerpt = [];
if (array_key_exists('excerpt', $extension)) {
$excerpt = $extension['excerpt'];
}
// fallback for seo description
if (
(!array_key_exists('description', $seo) || '' === $seo['description']) &&
array_key_exists('description', $excerpt) && '' !== $excerpt['description']
) {
$seo['description'] = strip_tags($excerpt['description']);
}
$seo['description'] = substr($seo['description'], 0, 155);
// generate robots content
$robots = [];
$robots[] = (array_key_exists('noIndex', $seo) && true === $seo['noIndex']) ? 'noIndex' : 'index';
$robots[] = (array_key_exists('noFollow', $seo) && true === $seo['noFollow']) ? 'noFollow' : 'follow';
// build meta tags
$result = [];
$result[] = $this->getMeta('description', $seo['description']);
$result[] = $this->getMeta('keywords', $seo['keywords']);
$result[] = $this->getMeta('robots', strtoupper(implode(', ', $robots)));
return implode(PHP_EOL, $result);
} | php | public function getSeoMetaTags($extension, $content)
{
$seo = [];
if (array_key_exists('seo', $extension)) {
$seo = $extension['seo'];
}
$excerpt = [];
if (array_key_exists('excerpt', $extension)) {
$excerpt = $extension['excerpt'];
}
// fallback for seo description
if (
(!array_key_exists('description', $seo) || '' === $seo['description']) &&
array_key_exists('description', $excerpt) && '' !== $excerpt['description']
) {
$seo['description'] = strip_tags($excerpt['description']);
}
$seo['description'] = substr($seo['description'], 0, 155);
// generate robots content
$robots = [];
$robots[] = (array_key_exists('noIndex', $seo) && true === $seo['noIndex']) ? 'noIndex' : 'index';
$robots[] = (array_key_exists('noFollow', $seo) && true === $seo['noFollow']) ? 'noFollow' : 'follow';
// build meta tags
$result = [];
$result[] = $this->getMeta('description', $seo['description']);
$result[] = $this->getMeta('keywords', $seo['keywords']);
$result[] = $this->getMeta('robots', strtoupper(implode(', ', $robots)));
return implode(PHP_EOL, $result);
} | [
"public",
"function",
"getSeoMetaTags",
"(",
"$",
"extension",
",",
"$",
"content",
")",
"{",
"$",
"seo",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'seo'",
",",
"$",
"extension",
")",
")",
"{",
"$",
"seo",
"=",
"$",
"extension",
"[",
"'seo'",
"]",
";",
"}",
"$",
"excerpt",
"=",
"[",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'excerpt'",
",",
"$",
"extension",
")",
")",
"{",
"$",
"excerpt",
"=",
"$",
"extension",
"[",
"'excerpt'",
"]",
";",
"}",
"// fallback for seo description",
"if",
"(",
"(",
"!",
"array_key_exists",
"(",
"'description'",
",",
"$",
"seo",
")",
"||",
"''",
"===",
"$",
"seo",
"[",
"'description'",
"]",
")",
"&&",
"array_key_exists",
"(",
"'description'",
",",
"$",
"excerpt",
")",
"&&",
"''",
"!==",
"$",
"excerpt",
"[",
"'description'",
"]",
")",
"{",
"$",
"seo",
"[",
"'description'",
"]",
"=",
"strip_tags",
"(",
"$",
"excerpt",
"[",
"'description'",
"]",
")",
";",
"}",
"$",
"seo",
"[",
"'description'",
"]",
"=",
"substr",
"(",
"$",
"seo",
"[",
"'description'",
"]",
",",
"0",
",",
"155",
")",
";",
"// generate robots content",
"$",
"robots",
"=",
"[",
"]",
";",
"$",
"robots",
"[",
"]",
"=",
"(",
"array_key_exists",
"(",
"'noIndex'",
",",
"$",
"seo",
")",
"&&",
"true",
"===",
"$",
"seo",
"[",
"'noIndex'",
"]",
")",
"?",
"'noIndex'",
":",
"'index'",
";",
"$",
"robots",
"[",
"]",
"=",
"(",
"array_key_exists",
"(",
"'noFollow'",
",",
"$",
"seo",
")",
"&&",
"true",
"===",
"$",
"seo",
"[",
"'noFollow'",
"]",
")",
"?",
"'noFollow'",
":",
"'follow'",
";",
"// build meta tags",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getMeta",
"(",
"'description'",
",",
"$",
"seo",
"[",
"'description'",
"]",
")",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getMeta",
"(",
"'keywords'",
",",
"$",
"seo",
"[",
"'keywords'",
"]",
")",
";",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"getMeta",
"(",
"'robots'",
",",
"strtoupper",
"(",
"implode",
"(",
"', '",
",",
"$",
"robots",
")",
")",
")",
";",
"return",
"implode",
"(",
"PHP_EOL",
",",
"$",
"result",
")",
";",
"}"
] | Returns seo meta tags with fallbacks.
@param array $extension
@param array $content
@return string
@deprecated since 1.1 use SeoTwigExtension::renderSeoTags - sulu_seo | [
"Returns",
"seo",
"meta",
"tags",
"with",
"fallbacks",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/WebsiteBundle/Twig/Meta/MetaTwigExtension.php#L107-L140 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php | BaseXmlFormatLoader.addFormatFromFormatNode | private function addFormatFromFormatNode(\DOMNode $formatNode, &$formats)
{
$key = $this->getKeyFromFormatNode($formatNode);
$internal = $this->getInternalFlagFromFormatNode($formatNode);
$meta = $this->getMetaFromFormatNode($formatNode);
$scale = $this->getScaleFromFormatNode($formatNode);
$transformations = $this->getTransformationsFromFormatNode($formatNode);
$options = $this->getOptionsFromFormatNode($formatNode);
$formats[$key] = [
'key' => $key,
'internal' => $internal,
'meta' => $meta,
'scale' => $scale,
'transformations' => $transformations,
'options' => array_merge($this->globalOptions, $options),
];
} | php | private function addFormatFromFormatNode(\DOMNode $formatNode, &$formats)
{
$key = $this->getKeyFromFormatNode($formatNode);
$internal = $this->getInternalFlagFromFormatNode($formatNode);
$meta = $this->getMetaFromFormatNode($formatNode);
$scale = $this->getScaleFromFormatNode($formatNode);
$transformations = $this->getTransformationsFromFormatNode($formatNode);
$options = $this->getOptionsFromFormatNode($formatNode);
$formats[$key] = [
'key' => $key,
'internal' => $internal,
'meta' => $meta,
'scale' => $scale,
'transformations' => $transformations,
'options' => array_merge($this->globalOptions, $options),
];
} | [
"private",
"function",
"addFormatFromFormatNode",
"(",
"\\",
"DOMNode",
"$",
"formatNode",
",",
"&",
"$",
"formats",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getKeyFromFormatNode",
"(",
"$",
"formatNode",
")",
";",
"$",
"internal",
"=",
"$",
"this",
"->",
"getInternalFlagFromFormatNode",
"(",
"$",
"formatNode",
")",
";",
"$",
"meta",
"=",
"$",
"this",
"->",
"getMetaFromFormatNode",
"(",
"$",
"formatNode",
")",
";",
"$",
"scale",
"=",
"$",
"this",
"->",
"getScaleFromFormatNode",
"(",
"$",
"formatNode",
")",
";",
"$",
"transformations",
"=",
"$",
"this",
"->",
"getTransformationsFromFormatNode",
"(",
"$",
"formatNode",
")",
";",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptionsFromFormatNode",
"(",
"$",
"formatNode",
")",
";",
"$",
"formats",
"[",
"$",
"key",
"]",
"=",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'internal'",
"=>",
"$",
"internal",
",",
"'meta'",
"=>",
"$",
"meta",
",",
"'scale'",
"=>",
"$",
"scale",
",",
"'transformations'",
"=>",
"$",
"transformations",
",",
"'options'",
"=>",
"array_merge",
"(",
"$",
"this",
"->",
"globalOptions",
",",
"$",
"options",
")",
",",
"]",
";",
"}"
] | For a given format node and a given array of formats, this method parses the
format node to an array and adds it to the formats array.
@param \DOMNode $formatNode
@param $formats | [
"For",
"a",
"given",
"format",
"node",
"and",
"a",
"given",
"array",
"of",
"formats",
"this",
"method",
"parses",
"the",
"format",
"node",
"to",
"an",
"array",
"and",
"adds",
"it",
"to",
"the",
"formats",
"array",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php#L135-L153 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php | BaseXmlFormatLoader.tryLoad | private function tryLoad($file)
{
try {
return XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH);
} catch (\InvalidArgumentException $e) {
throw new InvalidMediaFormatException(
sprintf('Could not parse image formats XML file "%s"', $file),
null,
$e
);
}
} | php | private function tryLoad($file)
{
try {
return XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH);
} catch (\InvalidArgumentException $e) {
throw new InvalidMediaFormatException(
sprintf('Could not parse image formats XML file "%s"', $file),
null,
$e
);
}
} | [
"private",
"function",
"tryLoad",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"return",
"XmlUtils",
"::",
"loadFile",
"(",
"$",
"file",
",",
"__DIR__",
".",
"static",
"::",
"SCHEME_PATH",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidMediaFormatException",
"(",
"sprintf",
"(",
"'Could not parse image formats XML file \"%s\"'",
",",
"$",
"file",
")",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Tries to load the DOM Document of a given image formats xml.
@param $file string The path to the xml file
@return \DOMDocument
@throws InvalidMediaFormatException | [
"Tries",
"to",
"load",
"the",
"DOM",
"Document",
"of",
"a",
"given",
"image",
"formats",
"xml",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php#L164-L175 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php | BaseXmlFormatLoader.getParametersFromNode | protected function getParametersFromNode($node, $parameterName = 'parameter')
{
if (null === $node) {
return [];
}
$parameters = [];
foreach ($this->xpath->query('x:' . $parameterName, $node) as $parameterNode) {
$name = $this->xpath->query('@name', $parameterNode)->item(0)->nodeValue;
$parameters[$name] = $parameterNode->nodeValue;
}
return $parameters;
} | php | protected function getParametersFromNode($node, $parameterName = 'parameter')
{
if (null === $node) {
return [];
}
$parameters = [];
foreach ($this->xpath->query('x:' . $parameterName, $node) as $parameterNode) {
$name = $this->xpath->query('@name', $parameterNode)->item(0)->nodeValue;
$parameters[$name] = $parameterNode->nodeValue;
}
return $parameters;
} | [
"protected",
"function",
"getParametersFromNode",
"(",
"$",
"node",
",",
"$",
"parameterName",
"=",
"'parameter'",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"node",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"parameters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:'",
".",
"$",
"parameterName",
",",
"$",
"node",
")",
"as",
"$",
"parameterNode",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'@name'",
",",
"$",
"parameterNode",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
";",
"$",
"parameters",
"[",
"$",
"name",
"]",
"=",
"$",
"parameterNode",
"->",
"nodeValue",
";",
"}",
"return",
"$",
"parameters",
";",
"}"
] | For a given dom node returns an array of parameters. The xml name of the parameter
tag can be passed as an argument.
@param \DOMNode $node
@param string $parameterName
@return array | [
"For",
"a",
"given",
"dom",
"node",
"returns",
"an",
"array",
"of",
"parameters",
".",
"The",
"xml",
"name",
"of",
"the",
"parameter",
"tag",
"can",
"be",
"passed",
"as",
"an",
"argument",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php#L208-L221 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php | BaseXmlFormatLoader.getOptionsFromFormatNode | private function getOptionsFromFormatNode(\DOMNode $formatNode)
{
$optionsNode = $this->xpath->query('x:options', $formatNode)->item(0);
return $this->getParametersFromNode($optionsNode, 'option');
} | php | private function getOptionsFromFormatNode(\DOMNode $formatNode)
{
$optionsNode = $this->xpath->query('x:options', $formatNode)->item(0);
return $this->getParametersFromNode($optionsNode, 'option');
} | [
"private",
"function",
"getOptionsFromFormatNode",
"(",
"\\",
"DOMNode",
"$",
"formatNode",
")",
"{",
"$",
"optionsNode",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:options'",
",",
"$",
"formatNode",
")",
"->",
"item",
"(",
"0",
")",
";",
"return",
"$",
"this",
"->",
"getParametersFromNode",
"(",
"$",
"optionsNode",
",",
"'option'",
")",
";",
"}"
] | For a given format node returns the options for it.
@param \DOMNode $formatNode
@return array | [
"For",
"a",
"given",
"format",
"node",
"returns",
"the",
"options",
"for",
"it",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/FormatLoader/BaseXmlFormatLoader.php#L275-L280 | train |
sulu/sulu | src/Sulu/Component/Content/Compat/LocalizationFinder.php | LocalizationFinder.findAvailableParentLocalization | private function findAvailableParentLocalization(array $availableLocales, Localization $localization)
{
do {
if (in_array($localization->getLocale(), $availableLocales)) {
return $localization;
}
// try to load parent and stop if there is no parent
$localization = $localization->getParent();
} while (null != $localization);
return;
} | php | private function findAvailableParentLocalization(array $availableLocales, Localization $localization)
{
do {
if (in_array($localization->getLocale(), $availableLocales)) {
return $localization;
}
// try to load parent and stop if there is no parent
$localization = $localization->getParent();
} while (null != $localization);
return;
} | [
"private",
"function",
"findAvailableParentLocalization",
"(",
"array",
"$",
"availableLocales",
",",
"Localization",
"$",
"localization",
")",
"{",
"do",
"{",
"if",
"(",
"in_array",
"(",
"$",
"localization",
"->",
"getLocale",
"(",
")",
",",
"$",
"availableLocales",
")",
")",
"{",
"return",
"$",
"localization",
";",
"}",
"// try to load parent and stop if there is no parent",
"$",
"localization",
"=",
"$",
"localization",
"->",
"getParent",
"(",
")",
";",
"}",
"while",
"(",
"null",
"!=",
"$",
"localization",
")",
";",
"return",
";",
"}"
] | Finds the next available parent-localization in which the node has a translation.
@param string[] $availableLocales
@param Localization $localization The localization to start the search for
@return null|Localization | [
"Finds",
"the",
"next",
"available",
"parent",
"-",
"localization",
"in",
"which",
"the",
"node",
"has",
"a",
"translation",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Compat/LocalizationFinder.php#L85-L97 | train |
sulu/sulu | src/Sulu/Component/Content/Compat/LocalizationFinder.php | LocalizationFinder.findAvailableChildLocalization | private function findAvailableChildLocalization(array $availableLocales, Localization $localization)
{
$childrenLocalizations = $localization->getChildren();
if (!empty($childrenLocalizations)) {
foreach ($childrenLocalizations as $childrenLocalization) {
// return the localization if a translation exists in the child localization
if (in_array($childrenLocalization->getLocale(), $availableLocales)) {
return $childrenLocalization;
}
// recursively call this function for checking children
return $this->findAvailableChildLocalization($availableLocales, $childrenLocalization);
}
}
// return null if nothing was found
return;
} | php | private function findAvailableChildLocalization(array $availableLocales, Localization $localization)
{
$childrenLocalizations = $localization->getChildren();
if (!empty($childrenLocalizations)) {
foreach ($childrenLocalizations as $childrenLocalization) {
// return the localization if a translation exists in the child localization
if (in_array($childrenLocalization->getLocale(), $availableLocales)) {
return $childrenLocalization;
}
// recursively call this function for checking children
return $this->findAvailableChildLocalization($availableLocales, $childrenLocalization);
}
}
// return null if nothing was found
return;
} | [
"private",
"function",
"findAvailableChildLocalization",
"(",
"array",
"$",
"availableLocales",
",",
"Localization",
"$",
"localization",
")",
"{",
"$",
"childrenLocalizations",
"=",
"$",
"localization",
"->",
"getChildren",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"childrenLocalizations",
")",
")",
"{",
"foreach",
"(",
"$",
"childrenLocalizations",
"as",
"$",
"childrenLocalization",
")",
"{",
"// return the localization if a translation exists in the child localization",
"if",
"(",
"in_array",
"(",
"$",
"childrenLocalization",
"->",
"getLocale",
"(",
")",
",",
"$",
"availableLocales",
")",
")",
"{",
"return",
"$",
"childrenLocalization",
";",
"}",
"// recursively call this function for checking children",
"return",
"$",
"this",
"->",
"findAvailableChildLocalization",
"(",
"$",
"availableLocales",
",",
"$",
"childrenLocalization",
")",
";",
"}",
"}",
"// return null if nothing was found",
"return",
";",
"}"
] | Finds the next available child-localization in which the node has a translation.
@param string[] $availableLocales
@param Localization $localization The localization to start the search for
@return null|Localization | [
"Finds",
"the",
"next",
"available",
"child",
"-",
"localization",
"in",
"which",
"the",
"node",
"has",
"a",
"translation",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Compat/LocalizationFinder.php#L107-L125 | train |
sulu/sulu | src/Sulu/Component/Content/Compat/LocalizationFinder.php | LocalizationFinder.findAvailableLocalization | private function findAvailableLocalization(array $availableLocales, array $localizations)
{
foreach ($localizations as $localization) {
if (in_array($localization->getLocale(), $availableLocales)) {
return $localization;
}
$children = $localization->getChildren();
if ($children) {
$result = $this->findAvailableLocalization($availableLocales, $children);
if (null !== $result) {
return $result;
}
}
}
return;
} | php | private function findAvailableLocalization(array $availableLocales, array $localizations)
{
foreach ($localizations as $localization) {
if (in_array($localization->getLocale(), $availableLocales)) {
return $localization;
}
$children = $localization->getChildren();
if ($children) {
$result = $this->findAvailableLocalization($availableLocales, $children);
if (null !== $result) {
return $result;
}
}
}
return;
} | [
"private",
"function",
"findAvailableLocalization",
"(",
"array",
"$",
"availableLocales",
",",
"array",
"$",
"localizations",
")",
"{",
"foreach",
"(",
"$",
"localizations",
"as",
"$",
"localization",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"localization",
"->",
"getLocale",
"(",
")",
",",
"$",
"availableLocales",
")",
")",
"{",
"return",
"$",
"localization",
";",
"}",
"$",
"children",
"=",
"$",
"localization",
"->",
"getChildren",
"(",
")",
";",
"if",
"(",
"$",
"children",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"findAvailableLocalization",
"(",
"$",
"availableLocales",
",",
"$",
"children",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"result",
")",
"{",
"return",
"$",
"result",
";",
"}",
"}",
"}",
"return",
";",
"}"
] | Finds any localization, in which the node is translated.
@param string[] $availableLocales
@param Localization[] $localizations The available localizations
@return null|Localization | [
"Finds",
"any",
"localization",
"in",
"which",
"the",
"node",
"is",
"translated",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Content/Compat/LocalizationFinder.php#L135-L154 | train |
sulu/sulu | src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php | RecoverCommand.findCategoriesWithoutParents | private function findCategoriesWithoutParents()
{
// get categories that have no parent but depth > 0
$qb = $this->categoryRepository->createQueryBuilder('c2')
->select('count(c2.id)')
->leftJoin('c2.parent', 'c1')
->where('c2.depth <> 0 AND c2.parent IS NULL');
return $qb->getQuery()->getSingleScalarResult();
} | php | private function findCategoriesWithoutParents()
{
// get categories that have no parent but depth > 0
$qb = $this->categoryRepository->createQueryBuilder('c2')
->select('count(c2.id)')
->leftJoin('c2.parent', 'c1')
->where('c2.depth <> 0 AND c2.parent IS NULL');
return $qb->getQuery()->getSingleScalarResult();
} | [
"private",
"function",
"findCategoriesWithoutParents",
"(",
")",
"{",
"// get categories that have no parent but depth > 0",
"$",
"qb",
"=",
"$",
"this",
"->",
"categoryRepository",
"->",
"createQueryBuilder",
"(",
"'c2'",
")",
"->",
"select",
"(",
"'count(c2.id)'",
")",
"->",
"leftJoin",
"(",
"'c2.parent'",
",",
"'c1'",
")",
"->",
"where",
"(",
"'c2.depth <> 0 AND c2.parent IS NULL'",
")",
";",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}"
] | Find number of categories that have no parent but depth > 0.
@return int Number of categories without a parent | [
"Find",
"number",
"of",
"categories",
"that",
"have",
"no",
"parent",
"but",
"depth",
">",
"0",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php#L156-L165 | train |
sulu/sulu | src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php | RecoverCommand.fixWrongDepthGap | private function fixWrongDepthGap()
{
// FIXME: convert this native query to DQL (once its possible to join within UPDATE statement)
// fix categories where difference to parents depth > 1
$sql = 'UPDATE ca_categories c2
JOIN ca_categories c1 ON c2.idCategoriesParent = c1.id
SET c2.depth = (c1.depth + 1)
WHERE ( c2.depth - 1 ) <> c1.depth';
$statement = $this->entityManager->getConnection()->prepare($sql);
if ($statement->execute()) {
return $statement->rowCount();
}
return false;
} | php | private function fixWrongDepthGap()
{
// FIXME: convert this native query to DQL (once its possible to join within UPDATE statement)
// fix categories where difference to parents depth > 1
$sql = 'UPDATE ca_categories c2
JOIN ca_categories c1 ON c2.idCategoriesParent = c1.id
SET c2.depth = (c1.depth + 1)
WHERE ( c2.depth - 1 ) <> c1.depth';
$statement = $this->entityManager->getConnection()->prepare($sql);
if ($statement->execute()) {
return $statement->rowCount();
}
return false;
} | [
"private",
"function",
"fixWrongDepthGap",
"(",
")",
"{",
"// FIXME: convert this native query to DQL (once its possible to join within UPDATE statement)",
"// fix categories where difference to parents depth > 1",
"$",
"sql",
"=",
"'UPDATE ca_categories c2\n JOIN ca_categories c1 ON c2.idCategoriesParent = c1.id\n SET c2.depth = (c1.depth + 1)\n WHERE ( c2.depth - 1 ) <> c1.depth'",
";",
"$",
"statement",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"statement",
"->",
"execute",
"(",
")",
")",
"{",
"return",
"$",
"statement",
"->",
"rowCount",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Fix categories where difference to parents depth.
@return int|bool Number of affected rows | [
"Fix",
"categories",
"where",
"difference",
"to",
"parents",
"depth",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php#L172-L187 | train |
sulu/sulu | src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php | RecoverCommand.fixCategoriesWithoutParents | private function fixCategoriesWithoutParents()
{
// fix categories that have no parent but depth > 0
$qb = $this->categoryRepository->createQueryBuilder('c2')
->update()
->set('c2.depth', 0)
->where('c2.parent IS NULL AND c2.depth != 0');
$qb->getQuery()->execute();
} | php | private function fixCategoriesWithoutParents()
{
// fix categories that have no parent but depth > 0
$qb = $this->categoryRepository->createQueryBuilder('c2')
->update()
->set('c2.depth', 0)
->where('c2.parent IS NULL AND c2.depth != 0');
$qb->getQuery()->execute();
} | [
"private",
"function",
"fixCategoriesWithoutParents",
"(",
")",
"{",
"// fix categories that have no parent but depth > 0",
"$",
"qb",
"=",
"$",
"this",
"->",
"categoryRepository",
"->",
"createQueryBuilder",
"(",
"'c2'",
")",
"->",
"update",
"(",
")",
"->",
"set",
"(",
"'c2.depth'",
",",
"0",
")",
"->",
"where",
"(",
"'c2.parent IS NULL AND c2.depth != 0'",
")",
";",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}"
] | Set every category where depth > 0 and has no parents to depth 0. | [
"Set",
"every",
"category",
"where",
"depth",
">",
"0",
"and",
"has",
"no",
"parents",
"to",
"depth",
"0",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/CategoryBundle/Command/RecoverCommand.php#L192-L201 | train |
sulu/sulu | src/Sulu/Bundle/SnippetBundle/Twig/SnippetAreaTwigExtension.php | SnippetAreaTwigExtension.loadByArea | public function loadByArea($area, $webspaceKey = null, $locale = null)
{
if (!$webspaceKey) {
$webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
}
if (!$locale) {
$locale = $this->requestAnalyzer->getCurrentLocalization()->getLocale();
}
try {
$snippet = $this->defaultSnippetManager->load($webspaceKey, $area, $locale);
} catch (WrongSnippetTypeException $exception) {
return null;
} catch (DocumentNotFoundException $exception) {
return null;
}
if (!$snippet) {
return null;
}
$snippets = $this->snippetResolver->resolve([$snippet->getUuid()], $webspaceKey, $locale);
if (!array_key_exists(0, $snippets)) {
return null;
}
return $snippets[0];
} | php | public function loadByArea($area, $webspaceKey = null, $locale = null)
{
if (!$webspaceKey) {
$webspaceKey = $this->requestAnalyzer->getWebspace()->getKey();
}
if (!$locale) {
$locale = $this->requestAnalyzer->getCurrentLocalization()->getLocale();
}
try {
$snippet = $this->defaultSnippetManager->load($webspaceKey, $area, $locale);
} catch (WrongSnippetTypeException $exception) {
return null;
} catch (DocumentNotFoundException $exception) {
return null;
}
if (!$snippet) {
return null;
}
$snippets = $this->snippetResolver->resolve([$snippet->getUuid()], $webspaceKey, $locale);
if (!array_key_exists(0, $snippets)) {
return null;
}
return $snippets[0];
} | [
"public",
"function",
"loadByArea",
"(",
"$",
"area",
",",
"$",
"webspaceKey",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"webspaceKey",
")",
"{",
"$",
"webspaceKey",
"=",
"$",
"this",
"->",
"requestAnalyzer",
"->",
"getWebspace",
"(",
")",
"->",
"getKey",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"locale",
")",
"{",
"$",
"locale",
"=",
"$",
"this",
"->",
"requestAnalyzer",
"->",
"getCurrentLocalization",
"(",
")",
"->",
"getLocale",
"(",
")",
";",
"}",
"try",
"{",
"$",
"snippet",
"=",
"$",
"this",
"->",
"defaultSnippetManager",
"->",
"load",
"(",
"$",
"webspaceKey",
",",
"$",
"area",
",",
"$",
"locale",
")",
";",
"}",
"catch",
"(",
"WrongSnippetTypeException",
"$",
"exception",
")",
"{",
"return",
"null",
";",
"}",
"catch",
"(",
"DocumentNotFoundException",
"$",
"exception",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"snippet",
")",
"{",
"return",
"null",
";",
"}",
"$",
"snippets",
"=",
"$",
"this",
"->",
"snippetResolver",
"->",
"resolve",
"(",
"[",
"$",
"snippet",
"->",
"getUuid",
"(",
")",
"]",
",",
"$",
"webspaceKey",
",",
"$",
"locale",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"0",
",",
"$",
"snippets",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"snippets",
"[",
"0",
"]",
";",
"}"
] | Load snippet for webspace by area.
@param string $area
@param string $webspaceKey
@param string $locale
@return array | [
"Load",
"snippet",
"for",
"webspace",
"by",
"area",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/SnippetBundle/Twig/SnippetAreaTwigExtension.php#L69-L97 | train |
sulu/sulu | src/Sulu/Bundle/PreviewBundle/DependencyInjection/Configuration.php | Configuration.addFileSystemNode | private function addFileSystemNode()
{
$builder = new TreeBuilder();
$node = $builder->root('file_system');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('%sulu.cache_dir%/preview')->end()
->scalarNode('extension')->defaultNull()->end()
->integerNode('umask')->defaultValue(0002)->end()
->end();
return $node;
} | php | private function addFileSystemNode()
{
$builder = new TreeBuilder();
$node = $builder->root('file_system');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('directory')->defaultValue('%sulu.cache_dir%/preview')->end()
->scalarNode('extension')->defaultNull()->end()
->integerNode('umask')->defaultValue(0002)->end()
->end();
return $node;
} | [
"private",
"function",
"addFileSystemNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'file_system'",
")",
";",
"$",
"node",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'directory'",
")",
"->",
"defaultValue",
"(",
"'%sulu.cache_dir%/preview'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'extension'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"integerNode",
"(",
"'umask'",
")",
"->",
"defaultValue",
"(",
"0002",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] | Build file_system node configuration definition.
@return NodeDefinition | [
"Build",
"file_system",
"node",
"configuration",
"definition",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PreviewBundle/DependencyInjection/Configuration.php#L83-L97 | train |
sulu/sulu | src/Sulu/Bundle/PreviewBundle/DependencyInjection/Configuration.php | Configuration.addRedisNode | private function addRedisNode()
{
$builder = new TreeBuilder();
$node = $builder->root('redis');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('host')->defaultValue('127.0.0.1')->end()
->scalarNode('port')->defaultValue('6379')->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('timeout')->defaultNull()->end()
->scalarNode('database')->defaultNull()->end()
->end();
return $node;
} | php | private function addRedisNode()
{
$builder = new TreeBuilder();
$node = $builder->root('redis');
$node
->addDefaultsIfNotSet()
->children()
->scalarNode('connection_id')->defaultNull()->end()
->scalarNode('host')->defaultValue('127.0.0.1')->end()
->scalarNode('port')->defaultValue('6379')->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('timeout')->defaultNull()->end()
->scalarNode('database')->defaultNull()->end()
->end();
return $node;
} | [
"private",
"function",
"addRedisNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'redis'",
")",
";",
"$",
"node",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'connection_id'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'host'",
")",
"->",
"defaultValue",
"(",
"'127.0.0.1'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'port'",
")",
"->",
"defaultValue",
"(",
"'6379'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'password'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'timeout'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'database'",
")",
"->",
"defaultNull",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] | Build redis node configuration definition.
@return NodeDefinition | [
"Build",
"redis",
"node",
"configuration",
"definition",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PreviewBundle/DependencyInjection/Configuration.php#L104-L121 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php | BlameTimestampSubscriber.handleBlameTimestamp | public function handleBlameTimestamp(PreIndexEvent $event)
{
$subject = $event->getSubject();
$document = $event->getDocument();
if ($subject instanceof UserBlameInterface) {
$this->mapCreatorAndChanger($document, $subject->getCreator(), $subject->getChanger());
}
if ($subject instanceof TimestampableInterface) {
$this->mapTimestamp($document, $subject->getCreated(), $subject->getChanged());
}
} | php | public function handleBlameTimestamp(PreIndexEvent $event)
{
$subject = $event->getSubject();
$document = $event->getDocument();
if ($subject instanceof UserBlameInterface) {
$this->mapCreatorAndChanger($document, $subject->getCreator(), $subject->getChanger());
}
if ($subject instanceof TimestampableInterface) {
$this->mapTimestamp($document, $subject->getCreated(), $subject->getChanged());
}
} | [
"public",
"function",
"handleBlameTimestamp",
"(",
"PreIndexEvent",
"$",
"event",
")",
"{",
"$",
"subject",
"=",
"$",
"event",
"->",
"getSubject",
"(",
")",
";",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"if",
"(",
"$",
"subject",
"instanceof",
"UserBlameInterface",
")",
"{",
"$",
"this",
"->",
"mapCreatorAndChanger",
"(",
"$",
"document",
",",
"$",
"subject",
"->",
"getCreator",
"(",
")",
",",
"$",
"subject",
"->",
"getChanger",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"subject",
"instanceof",
"TimestampableInterface",
")",
"{",
"$",
"this",
"->",
"mapTimestamp",
"(",
"$",
"document",
",",
"$",
"subject",
"->",
"getCreated",
"(",
")",
",",
"$",
"subject",
"->",
"getChanged",
"(",
")",
")",
";",
"}",
"}"
] | Map blame and timestamp information to the search document.
@param PreIndexEvent $event | [
"Map",
"blame",
"and",
"timestamp",
"information",
"to",
"the",
"search",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php#L69-L81 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php | BlameTimestampSubscriber.getFieldValue | private function getFieldValue($document, $fieldName)
{
if (false === $document->hasField($fieldName)) {
return;
}
return $document->getField($fieldName)->getValue();
} | php | private function getFieldValue($document, $fieldName)
{
if (false === $document->hasField($fieldName)) {
return;
}
return $document->getField($fieldName)->getValue();
} | [
"private",
"function",
"getFieldValue",
"(",
"$",
"document",
",",
"$",
"fieldName",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"document",
"->",
"hasField",
"(",
"$",
"fieldName",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"document",
"->",
"getField",
"(",
"$",
"fieldName",
")",
"->",
"getValue",
"(",
")",
";",
"}"
] | Return the named field from the document or return null.
@param mixed $document
@param mixed $fieldName | [
"Return",
"the",
"named",
"field",
"from",
"the",
"document",
"or",
"return",
"null",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php#L114-L121 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php | BlameTimestampSubscriber.mapTimestamp | private function mapTimestamp(Document $document, \DateTime $created = null, \DateTime $changed = null)
{
$document->addField(
$this->factory->createField('created', $created ? $created->format('c') : null, 'string')
);
$document->addField(
$this->factory->createField('changed', $changed ? $changed->format('c') : null, 'string')
);
} | php | private function mapTimestamp(Document $document, \DateTime $created = null, \DateTime $changed = null)
{
$document->addField(
$this->factory->createField('created', $created ? $created->format('c') : null, 'string')
);
$document->addField(
$this->factory->createField('changed', $changed ? $changed->format('c') : null, 'string')
);
} | [
"private",
"function",
"mapTimestamp",
"(",
"Document",
"$",
"document",
",",
"\\",
"DateTime",
"$",
"created",
"=",
"null",
",",
"\\",
"DateTime",
"$",
"changed",
"=",
"null",
")",
"{",
"$",
"document",
"->",
"addField",
"(",
"$",
"this",
"->",
"factory",
"->",
"createField",
"(",
"'created'",
",",
"$",
"created",
"?",
"$",
"created",
"->",
"format",
"(",
"'c'",
")",
":",
"null",
",",
"'string'",
")",
")",
";",
"$",
"document",
"->",
"addField",
"(",
"$",
"this",
"->",
"factory",
"->",
"createField",
"(",
"'changed'",
",",
"$",
"changed",
"?",
"$",
"changed",
"->",
"format",
"(",
"'c'",
")",
":",
"null",
",",
"'string'",
")",
")",
";",
"}"
] | Map timestamps to the search document.
@param Document $document
@param \DateTime $created
@param \DateTime $changed | [
"Map",
"timestamps",
"to",
"the",
"search",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php#L130-L139 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php | BlameTimestampSubscriber.mapCreatorAndChanger | private function mapCreatorAndChanger(Document $document, UserInterface $creator = null, UserInterface $changer = null)
{
$document->addField(
$this->factory->createField('changer', $changer ? $changer->getUsername() : null, 'string')
);
$document->addField(
$this->factory->createField('changer_id', $changer ? $changer->getId() : null, 'string')
);
$document->addField(
$this->factory->createField('creator', $creator ? $creator->getUsername() : null, 'string')
);
$document->addField(
$this->factory->createField('creator_id', $creator ? $creator->getId() : null, 'string')
);
} | php | private function mapCreatorAndChanger(Document $document, UserInterface $creator = null, UserInterface $changer = null)
{
$document->addField(
$this->factory->createField('changer', $changer ? $changer->getUsername() : null, 'string')
);
$document->addField(
$this->factory->createField('changer_id', $changer ? $changer->getId() : null, 'string')
);
$document->addField(
$this->factory->createField('creator', $creator ? $creator->getUsername() : null, 'string')
);
$document->addField(
$this->factory->createField('creator_id', $creator ? $creator->getId() : null, 'string')
);
} | [
"private",
"function",
"mapCreatorAndChanger",
"(",
"Document",
"$",
"document",
",",
"UserInterface",
"$",
"creator",
"=",
"null",
",",
"UserInterface",
"$",
"changer",
"=",
"null",
")",
"{",
"$",
"document",
"->",
"addField",
"(",
"$",
"this",
"->",
"factory",
"->",
"createField",
"(",
"'changer'",
",",
"$",
"changer",
"?",
"$",
"changer",
"->",
"getUsername",
"(",
")",
":",
"null",
",",
"'string'",
")",
")",
";",
"$",
"document",
"->",
"addField",
"(",
"$",
"this",
"->",
"factory",
"->",
"createField",
"(",
"'changer_id'",
",",
"$",
"changer",
"?",
"$",
"changer",
"->",
"getId",
"(",
")",
":",
"null",
",",
"'string'",
")",
")",
";",
"$",
"document",
"->",
"addField",
"(",
"$",
"this",
"->",
"factory",
"->",
"createField",
"(",
"'creator'",
",",
"$",
"creator",
"?",
"$",
"creator",
"->",
"getUsername",
"(",
")",
":",
"null",
",",
"'string'",
")",
")",
";",
"$",
"document",
"->",
"addField",
"(",
"$",
"this",
"->",
"factory",
"->",
"createField",
"(",
"'creator_id'",
",",
"$",
"creator",
"?",
"$",
"creator",
"->",
"getId",
"(",
")",
":",
"null",
",",
"'string'",
")",
")",
";",
"}"
] | Map the creator and changer to the document.
@param Document $document
@param UserInterface $creator
@param UserInterface $changer | [
"Map",
"the",
"creator",
"and",
"changer",
"to",
"the",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Search/EventSubscriber/BlameTimestampSubscriber.php#L148-L163 | train |
sulu/sulu | src/Sulu/Bundle/PageBundle/Command/WebspaceImportCommand.php | WebspaceImportCommand.printExceptions | protected function printExceptions($import, $output = null)
{
if (null === $output) {
$output = new NullOutput();
}
$output->writeln([
'',
'',
'<info>Import Result</info>',
'<info>===============</info>',
'<info>' . $import->successes . ' Documents imported.</info>',
'<comment>' . count($import->failed) . ' Documents ignored.</comment>',
]);
if (!isset($import->exceptionStore['ignore'])) {
return;
}
// If more than 20 exceptions write only into log.
if (count($import->exceptionStore['ignore']) > 20) {
foreach ($import->exceptionStore['ignore'] as $msg) {
$this->logger->info($msg);
}
return;
}
foreach ($import->exceptionStore['ignore'] as $msg) {
$output->writeln('<comment>' . $msg . '</comment>');
$this->logger->info($msg);
}
} | php | protected function printExceptions($import, $output = null)
{
if (null === $output) {
$output = new NullOutput();
}
$output->writeln([
'',
'',
'<info>Import Result</info>',
'<info>===============</info>',
'<info>' . $import->successes . ' Documents imported.</info>',
'<comment>' . count($import->failed) . ' Documents ignored.</comment>',
]);
if (!isset($import->exceptionStore['ignore'])) {
return;
}
// If more than 20 exceptions write only into log.
if (count($import->exceptionStore['ignore']) > 20) {
foreach ($import->exceptionStore['ignore'] as $msg) {
$this->logger->info($msg);
}
return;
}
foreach ($import->exceptionStore['ignore'] as $msg) {
$output->writeln('<comment>' . $msg . '</comment>');
$this->logger->info($msg);
}
} | [
"protected",
"function",
"printExceptions",
"(",
"$",
"import",
",",
"$",
"output",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"output",
")",
"{",
"$",
"output",
"=",
"new",
"NullOutput",
"(",
")",
";",
"}",
"$",
"output",
"->",
"writeln",
"(",
"[",
"''",
",",
"''",
",",
"'<info>Import Result</info>'",
",",
"'<info>===============</info>'",
",",
"'<info>'",
".",
"$",
"import",
"->",
"successes",
".",
"' Documents imported.</info>'",
",",
"'<comment>'",
".",
"count",
"(",
"$",
"import",
"->",
"failed",
")",
".",
"' Documents ignored.</comment>'",
",",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"import",
"->",
"exceptionStore",
"[",
"'ignore'",
"]",
")",
")",
"{",
"return",
";",
"}",
"// If more than 20 exceptions write only into log.",
"if",
"(",
"count",
"(",
"$",
"import",
"->",
"exceptionStore",
"[",
"'ignore'",
"]",
")",
">",
"20",
")",
"{",
"foreach",
"(",
"$",
"import",
"->",
"exceptionStore",
"[",
"'ignore'",
"]",
"as",
"$",
"msg",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"$",
"msg",
")",
";",
"}",
"return",
";",
"}",
"foreach",
"(",
"$",
"import",
"->",
"exceptionStore",
"[",
"'ignore'",
"]",
"as",
"$",
"msg",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"'<comment>'",
".",
"$",
"msg",
".",
"'</comment>'",
")",
";",
"$",
"this",
"->",
"logger",
"->",
"info",
"(",
"$",
"msg",
")",
";",
"}",
"}"
] | Print the completion message after import is done.
@param \stdClass $import
@param OutputInterface $output | [
"Print",
"the",
"completion",
"message",
"after",
"import",
"is",
"done",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/PageBundle/Command/WebspaceImportCommand.php#L124-L156 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.parseXml | protected function parseXml($file)
{
$this->xpath = new \DOMXPath($this->tryLoad($file));
$this->xpath->registerNamespace('x', 'http://schemas.sulu.io/webspace/webspace');
// set simple webspace properties
$this->webspace = new Webspace();
$this->webspace->setName($this->xpath->query('/x:webspace/x:name')->item(0)->nodeValue);
$this->webspace->setKey($this->xpath->query('/x:webspace/x:key')->item(0)->nodeValue);
$this->webspace->setTheme($this->generateTheme());
$this->webspace->setNavigation($this->generateNavigation());
$this->webspace->setResourceLocatorStrategy('tree_leaf_edit');
$this->generateTemplates($this->webspace);
$this->generateDefaultTemplates($this->webspace);
// set security
$this->generateSecurity();
// set localizations on webspaces
$this->generateWebspaceLocalizations();
// set segments on webspaces
$this->generateSegments();
// set portals on webspaces
$this->generatePortals();
// validate the webspace, and throw exceptions if not valid
$this->validate();
return $this->webspace;
} | php | protected function parseXml($file)
{
$this->xpath = new \DOMXPath($this->tryLoad($file));
$this->xpath->registerNamespace('x', 'http://schemas.sulu.io/webspace/webspace');
// set simple webspace properties
$this->webspace = new Webspace();
$this->webspace->setName($this->xpath->query('/x:webspace/x:name')->item(0)->nodeValue);
$this->webspace->setKey($this->xpath->query('/x:webspace/x:key')->item(0)->nodeValue);
$this->webspace->setTheme($this->generateTheme());
$this->webspace->setNavigation($this->generateNavigation());
$this->webspace->setResourceLocatorStrategy('tree_leaf_edit');
$this->generateTemplates($this->webspace);
$this->generateDefaultTemplates($this->webspace);
// set security
$this->generateSecurity();
// set localizations on webspaces
$this->generateWebspaceLocalizations();
// set segments on webspaces
$this->generateSegments();
// set portals on webspaces
$this->generatePortals();
// validate the webspace, and throw exceptions if not valid
$this->validate();
return $this->webspace;
} | [
"protected",
"function",
"parseXml",
"(",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"this",
"->",
"tryLoad",
"(",
"$",
"file",
")",
")",
";",
"$",
"this",
"->",
"xpath",
"->",
"registerNamespace",
"(",
"'x'",
",",
"'http://schemas.sulu.io/webspace/webspace'",
")",
";",
"// set simple webspace properties",
"$",
"this",
"->",
"webspace",
"=",
"new",
"Webspace",
"(",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"setName",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:name'",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"setKey",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:key'",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"setTheme",
"(",
"$",
"this",
"->",
"generateTheme",
"(",
")",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"setNavigation",
"(",
"$",
"this",
"->",
"generateNavigation",
"(",
")",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"setResourceLocatorStrategy",
"(",
"'tree_leaf_edit'",
")",
";",
"$",
"this",
"->",
"generateTemplates",
"(",
"$",
"this",
"->",
"webspace",
")",
";",
"$",
"this",
"->",
"generateDefaultTemplates",
"(",
"$",
"this",
"->",
"webspace",
")",
";",
"// set security",
"$",
"this",
"->",
"generateSecurity",
"(",
")",
";",
"// set localizations on webspaces",
"$",
"this",
"->",
"generateWebspaceLocalizations",
"(",
")",
";",
"// set segments on webspaces",
"$",
"this",
"->",
"generateSegments",
"(",
")",
";",
"// set portals on webspaces",
"$",
"this",
"->",
"generatePortals",
"(",
")",
";",
"// validate the webspace, and throw exceptions if not valid",
"$",
"this",
"->",
"validate",
"(",
")",
";",
"return",
"$",
"this",
"->",
"webspace",
";",
"}"
] | Parses the entire file and returns a webspace object.
@param $file
@return Webspace | [
"Parses",
"the",
"entire",
"file",
"and",
"returns",
"a",
"webspace",
"object",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L99-L131 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.tryLoad | protected function tryLoad($file)
{
try {
return XmlUtils::loadFile($file, __DIR__ . static::SCHEMA_LOCATION);
} catch (\InvalidArgumentException $e) {
throw new InvalidWebspaceException(
sprintf(
'Could not parse webspace XML file "%s"',
$file
),
null,
$e
);
}
} | php | protected function tryLoad($file)
{
try {
return XmlUtils::loadFile($file, __DIR__ . static::SCHEMA_LOCATION);
} catch (\InvalidArgumentException $e) {
throw new InvalidWebspaceException(
sprintf(
'Could not parse webspace XML file "%s"',
$file
),
null,
$e
);
}
} | [
"protected",
"function",
"tryLoad",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"return",
"XmlUtils",
"::",
"loadFile",
"(",
"$",
"file",
",",
"__DIR__",
".",
"static",
"::",
"SCHEMA_LOCATION",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidWebspaceException",
"(",
"sprintf",
"(",
"'Could not parse webspace XML file \"%s\"'",
",",
"$",
"file",
")",
",",
"null",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Returns xml-doc when one scheme matches.
@param string $file
@return \DOMDocument
@throws InvalidWebspaceException | [
"Returns",
"xml",
"-",
"doc",
"when",
"one",
"scheme",
"matches",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L142-L156 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.loadPortalLocalizationDefaultFromWebspace | protected function loadPortalLocalizationDefaultFromWebspace($portal)
{
$webspaceDefaultLocalization = $this->webspace->getDefaultLocalization();
foreach ($portal->getLocalizations() as $localization) {
if ($webspaceDefaultLocalization
&& $webspaceDefaultLocalization->getLocale() == $localization->getLocale()
) {
$localization->setDefault(true);
$portal->setDefaultLocalization($localization);
return true;
}
}
return false;
} | php | protected function loadPortalLocalizationDefaultFromWebspace($portal)
{
$webspaceDefaultLocalization = $this->webspace->getDefaultLocalization();
foreach ($portal->getLocalizations() as $localization) {
if ($webspaceDefaultLocalization
&& $webspaceDefaultLocalization->getLocale() == $localization->getLocale()
) {
$localization->setDefault(true);
$portal->setDefaultLocalization($localization);
return true;
}
}
return false;
} | [
"protected",
"function",
"loadPortalLocalizationDefaultFromWebspace",
"(",
"$",
"portal",
")",
"{",
"$",
"webspaceDefaultLocalization",
"=",
"$",
"this",
"->",
"webspace",
"->",
"getDefaultLocalization",
"(",
")",
";",
"foreach",
"(",
"$",
"portal",
"->",
"getLocalizations",
"(",
")",
"as",
"$",
"localization",
")",
"{",
"if",
"(",
"$",
"webspaceDefaultLocalization",
"&&",
"$",
"webspaceDefaultLocalization",
"->",
"getLocale",
"(",
")",
"==",
"$",
"localization",
"->",
"getLocale",
"(",
")",
")",
"{",
"$",
"localization",
"->",
"setDefault",
"(",
"true",
")",
";",
"$",
"portal",
"->",
"setDefaultLocalization",
"(",
"$",
"localization",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Sets the default localization for the given portal.
@param $portal Portal
@return bool True when successful, otherwise false | [
"Sets",
"the",
"default",
"localization",
"for",
"the",
"given",
"portal",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L175-L191 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generatePortalLocalizations | protected function generatePortalLocalizations(\DOMNode $portalNode, Portal $portal)
{
if ($this->xpath->query('x:localizations', $portalNode)->length > 0) {
// set localizations from portal, if they are set
$localizationNodes = $this->xpath->query('x:localizations/x:localization', $portalNode);
$this->generateLocalizationsFromNodeList($localizationNodes, $portal);
} else {
// if the portal has no localizations fallback to the localizations from the webspace
$localizationNodes = $this->xpath->query('/x:webspace/x:localizations//x:localization');
$this->generateLocalizationsFromNodeList($localizationNodes, $portal, true);
}
} | php | protected function generatePortalLocalizations(\DOMNode $portalNode, Portal $portal)
{
if ($this->xpath->query('x:localizations', $portalNode)->length > 0) {
// set localizations from portal, if they are set
$localizationNodes = $this->xpath->query('x:localizations/x:localization', $portalNode);
$this->generateLocalizationsFromNodeList($localizationNodes, $portal);
} else {
// if the portal has no localizations fallback to the localizations from the webspace
$localizationNodes = $this->xpath->query('/x:webspace/x:localizations//x:localization');
$this->generateLocalizationsFromNodeList($localizationNodes, $portal, true);
}
} | [
"protected",
"function",
"generatePortalLocalizations",
"(",
"\\",
"DOMNode",
"$",
"portalNode",
",",
"Portal",
"$",
"portal",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:localizations'",
",",
"$",
"portalNode",
")",
"->",
"length",
">",
"0",
")",
"{",
"// set localizations from portal, if they are set",
"$",
"localizationNodes",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:localizations/x:localization'",
",",
"$",
"portalNode",
")",
";",
"$",
"this",
"->",
"generateLocalizationsFromNodeList",
"(",
"$",
"localizationNodes",
",",
"$",
"portal",
")",
";",
"}",
"else",
"{",
"// if the portal has no localizations fallback to the localizations from the webspace",
"$",
"localizationNodes",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:localizations//x:localization'",
")",
";",
"$",
"this",
"->",
"generateLocalizationsFromNodeList",
"(",
"$",
"localizationNodes",
",",
"$",
"portal",
",",
"true",
")",
";",
"}",
"}"
] | Generates all localizations for the given portal.
@param \DOMNode $portalNode
@param Portal $portal | [
"Generates",
"all",
"localizations",
"for",
"the",
"given",
"portal",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L199-L210 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateLocalizationsFromNodeList | protected function generateLocalizationsFromNodeList(\DOMNodeList $localizationNodes, Portal $portal, $flat = false)
{
foreach ($localizationNodes as $localizationNode) {
$localization = $this->generateLocalizationFromNode($localizationNode, $flat);
$portal->addLocalization($localization);
}
} | php | protected function generateLocalizationsFromNodeList(\DOMNodeList $localizationNodes, Portal $portal, $flat = false)
{
foreach ($localizationNodes as $localizationNode) {
$localization = $this->generateLocalizationFromNode($localizationNode, $flat);
$portal->addLocalization($localization);
}
} | [
"protected",
"function",
"generateLocalizationsFromNodeList",
"(",
"\\",
"DOMNodeList",
"$",
"localizationNodes",
",",
"Portal",
"$",
"portal",
",",
"$",
"flat",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"localizationNodes",
"as",
"$",
"localizationNode",
")",
"{",
"$",
"localization",
"=",
"$",
"this",
"->",
"generateLocalizationFromNode",
"(",
"$",
"localizationNode",
",",
"$",
"flat",
")",
";",
"$",
"portal",
"->",
"addLocalization",
"(",
"$",
"localization",
")",
";",
"}",
"}"
] | Generates the localizations for the given portal from the given DOMNodeList.
@param \DOMNodeList $localizationNodes
@param Portal $portal
@param bool $flat | [
"Generates",
"the",
"localizations",
"for",
"the",
"given",
"portal",
"from",
"the",
"given",
"DOMNodeList",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L219-L226 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateLocalizationFromNode | protected function generateLocalizationFromNode(\DOMElement $localizationNode, $flat = false, $parent = null)
{
$localization = new Localization();
$localization->setLanguage($localizationNode->attributes->getNamedItem('language')->nodeValue);
// set parent if given
if ($parent) {
$localization->setParent($parent);
}
// set optional nodes
$countryNode = $localizationNode->attributes->getNamedItem('country');
if ($countryNode) {
$localization->setCountry($countryNode->nodeValue);
}
$shadowNode = $localizationNode->attributes->getNamedItem('shadow');
if ($shadowNode) {
$localization->setShadow($shadowNode->nodeValue);
}
$defaultNode = $localizationNode->attributes->getNamedItem('default');
if ($defaultNode) {
$localization->setDefault('true' == $defaultNode->nodeValue);
} else {
$localization->setDefault(false);
}
$xDefaultNode = $localizationNode->attributes->getNamedItem('x-default');
if ($xDefaultNode) {
$localization->setXDefault('true' == $xDefaultNode->nodeValue);
} else {
$localization->setXDefault(false);
}
// set child nodes
if (!$flat) {
foreach ($this->xpath->query('x:localization', $localizationNode) as $childNode) {
$localization->addChild($this->generateLocalizationFromNode($childNode, $flat, $localization));
}
}
return $localization;
} | php | protected function generateLocalizationFromNode(\DOMElement $localizationNode, $flat = false, $parent = null)
{
$localization = new Localization();
$localization->setLanguage($localizationNode->attributes->getNamedItem('language')->nodeValue);
// set parent if given
if ($parent) {
$localization->setParent($parent);
}
// set optional nodes
$countryNode = $localizationNode->attributes->getNamedItem('country');
if ($countryNode) {
$localization->setCountry($countryNode->nodeValue);
}
$shadowNode = $localizationNode->attributes->getNamedItem('shadow');
if ($shadowNode) {
$localization->setShadow($shadowNode->nodeValue);
}
$defaultNode = $localizationNode->attributes->getNamedItem('default');
if ($defaultNode) {
$localization->setDefault('true' == $defaultNode->nodeValue);
} else {
$localization->setDefault(false);
}
$xDefaultNode = $localizationNode->attributes->getNamedItem('x-default');
if ($xDefaultNode) {
$localization->setXDefault('true' == $xDefaultNode->nodeValue);
} else {
$localization->setXDefault(false);
}
// set child nodes
if (!$flat) {
foreach ($this->xpath->query('x:localization', $localizationNode) as $childNode) {
$localization->addChild($this->generateLocalizationFromNode($childNode, $flat, $localization));
}
}
return $localization;
} | [
"protected",
"function",
"generateLocalizationFromNode",
"(",
"\\",
"DOMElement",
"$",
"localizationNode",
",",
"$",
"flat",
"=",
"false",
",",
"$",
"parent",
"=",
"null",
")",
"{",
"$",
"localization",
"=",
"new",
"Localization",
"(",
")",
";",
"$",
"localization",
"->",
"setLanguage",
"(",
"$",
"localizationNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'language'",
")",
"->",
"nodeValue",
")",
";",
"// set parent if given",
"if",
"(",
"$",
"parent",
")",
"{",
"$",
"localization",
"->",
"setParent",
"(",
"$",
"parent",
")",
";",
"}",
"// set optional nodes",
"$",
"countryNode",
"=",
"$",
"localizationNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'country'",
")",
";",
"if",
"(",
"$",
"countryNode",
")",
"{",
"$",
"localization",
"->",
"setCountry",
"(",
"$",
"countryNode",
"->",
"nodeValue",
")",
";",
"}",
"$",
"shadowNode",
"=",
"$",
"localizationNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'shadow'",
")",
";",
"if",
"(",
"$",
"shadowNode",
")",
"{",
"$",
"localization",
"->",
"setShadow",
"(",
"$",
"shadowNode",
"->",
"nodeValue",
")",
";",
"}",
"$",
"defaultNode",
"=",
"$",
"localizationNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'default'",
")",
";",
"if",
"(",
"$",
"defaultNode",
")",
"{",
"$",
"localization",
"->",
"setDefault",
"(",
"'true'",
"==",
"$",
"defaultNode",
"->",
"nodeValue",
")",
";",
"}",
"else",
"{",
"$",
"localization",
"->",
"setDefault",
"(",
"false",
")",
";",
"}",
"$",
"xDefaultNode",
"=",
"$",
"localizationNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'x-default'",
")",
";",
"if",
"(",
"$",
"xDefaultNode",
")",
"{",
"$",
"localization",
"->",
"setXDefault",
"(",
"'true'",
"==",
"$",
"xDefaultNode",
"->",
"nodeValue",
")",
";",
"}",
"else",
"{",
"$",
"localization",
"->",
"setXDefault",
"(",
"false",
")",
";",
"}",
"// set child nodes",
"if",
"(",
"!",
"$",
"flat",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:localization'",
",",
"$",
"localizationNode",
")",
"as",
"$",
"childNode",
")",
"{",
"$",
"localization",
"->",
"addChild",
"(",
"$",
"this",
"->",
"generateLocalizationFromNode",
"(",
"$",
"childNode",
",",
"$",
"flat",
",",
"$",
"localization",
")",
")",
";",
"}",
"}",
"return",
"$",
"localization",
";",
"}"
] | Generates a localization from the given node.
@param \DOMElement|\DOMNode $localizationNode
@param bool $flat
@param null $parent
@return Localization | [
"Generates",
"a",
"localization",
"from",
"the",
"given",
"node",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L237-L280 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateSecurity | protected function generateSecurity()
{
$securitySystemNode = $this->xpath->query('/x:webspace/x:security/x:system');
if ($securitySystemNode->length > 0) {
$security = new Security();
$security->setSystem($securitySystemNode->item(0)->nodeValue);
$this->webspace->setSecurity($security);
}
} | php | protected function generateSecurity()
{
$securitySystemNode = $this->xpath->query('/x:webspace/x:security/x:system');
if ($securitySystemNode->length > 0) {
$security = new Security();
$security->setSystem($securitySystemNode->item(0)->nodeValue);
$this->webspace->setSecurity($security);
}
} | [
"protected",
"function",
"generateSecurity",
"(",
")",
"{",
"$",
"securitySystemNode",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:security/x:system'",
")",
";",
"if",
"(",
"$",
"securitySystemNode",
"->",
"length",
">",
"0",
")",
"{",
"$",
"security",
"=",
"new",
"Security",
"(",
")",
";",
"$",
"security",
"->",
"setSystem",
"(",
"$",
"securitySystemNode",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"setSecurity",
"(",
"$",
"security",
")",
";",
"}",
"}"
] | Generates and sets the security object from the XML document. | [
"Generates",
"and",
"sets",
"the",
"security",
"object",
"from",
"the",
"XML",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L285-L293 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateWebspaceLocalizations | protected function generateWebspaceLocalizations()
{
foreach ($this->xpath->query('/x:webspace/x:localizations/x:localization') as $localizationNode) {
$localization = $this->generateLocalizationFromNode($localizationNode);
$this->webspace->addLocalization($localization);
}
} | php | protected function generateWebspaceLocalizations()
{
foreach ($this->xpath->query('/x:webspace/x:localizations/x:localization') as $localizationNode) {
$localization = $this->generateLocalizationFromNode($localizationNode);
$this->webspace->addLocalization($localization);
}
} | [
"protected",
"function",
"generateWebspaceLocalizations",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:localizations/x:localization'",
")",
"as",
"$",
"localizationNode",
")",
"{",
"$",
"localization",
"=",
"$",
"this",
"->",
"generateLocalizationFromNode",
"(",
"$",
"localizationNode",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"addLocalization",
"(",
"$",
"localization",
")",
";",
"}",
"}"
] | Generates the localization for the webspace from the XML document. | [
"Generates",
"the",
"localization",
"for",
"the",
"webspace",
"from",
"the",
"XML",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L298-L305 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateSegments | protected function generateSegments()
{
foreach ($this->xpath->query('/x:webspace/x:segments/x:segment') as $segmentNode) {
/** @var \DOMNode $segmentNode */
$segment = new Segment();
$segment->setName($segmentNode->nodeValue);
$segment->setKey($segmentNode->attributes->getNamedItem('key')->nodeValue);
$defaultNode = $segmentNode->attributes->getNamedItem('default');
if ($defaultNode) {
$segment->setDefault('true' == $defaultNode->nodeValue);
} else {
$segment->setDefault(false);
}
$this->webspace->addSegment($segment);
}
} | php | protected function generateSegments()
{
foreach ($this->xpath->query('/x:webspace/x:segments/x:segment') as $segmentNode) {
/** @var \DOMNode $segmentNode */
$segment = new Segment();
$segment->setName($segmentNode->nodeValue);
$segment->setKey($segmentNode->attributes->getNamedItem('key')->nodeValue);
$defaultNode = $segmentNode->attributes->getNamedItem('default');
if ($defaultNode) {
$segment->setDefault('true' == $defaultNode->nodeValue);
} else {
$segment->setDefault(false);
}
$this->webspace->addSegment($segment);
}
} | [
"protected",
"function",
"generateSegments",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:segments/x:segment'",
")",
"as",
"$",
"segmentNode",
")",
"{",
"/** @var \\DOMNode $segmentNode */",
"$",
"segment",
"=",
"new",
"Segment",
"(",
")",
";",
"$",
"segment",
"->",
"setName",
"(",
"$",
"segmentNode",
"->",
"nodeValue",
")",
";",
"$",
"segment",
"->",
"setKey",
"(",
"$",
"segmentNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'key'",
")",
"->",
"nodeValue",
")",
";",
"$",
"defaultNode",
"=",
"$",
"segmentNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'default'",
")",
";",
"if",
"(",
"$",
"defaultNode",
")",
"{",
"$",
"segment",
"->",
"setDefault",
"(",
"'true'",
"==",
"$",
"defaultNode",
"->",
"nodeValue",
")",
";",
"}",
"else",
"{",
"$",
"segment",
"->",
"setDefault",
"(",
"false",
")",
";",
"}",
"$",
"this",
"->",
"webspace",
"->",
"addSegment",
"(",
"$",
"segment",
")",
";",
"}",
"}"
] | Generates the available segments for the webspace from the XML document. | [
"Generates",
"the",
"available",
"segments",
"for",
"the",
"webspace",
"from",
"the",
"XML",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L310-L327 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generatePortals | protected function generatePortals()
{
foreach ($this->xpath->query('/x:webspace/x:portals/x:portal') as $portalNode) {
/** @var \DOMNode $portalNode */
$portal = new Portal();
$portal->setName($this->xpath->query('x:name', $portalNode)->item(0)->nodeValue);
$portal->setKey($this->xpath->query('x:key', $portalNode)->item(0)->nodeValue);
// set localization on portal
$this->generatePortalLocalizations($portalNode, $portal);
$this->webspace->addPortal($portal);
$portal->setWebspace($this->webspace);
// set environments
$this->generateEnvironments($portalNode, $portal);
}
} | php | protected function generatePortals()
{
foreach ($this->xpath->query('/x:webspace/x:portals/x:portal') as $portalNode) {
/** @var \DOMNode $portalNode */
$portal = new Portal();
$portal->setName($this->xpath->query('x:name', $portalNode)->item(0)->nodeValue);
$portal->setKey($this->xpath->query('x:key', $portalNode)->item(0)->nodeValue);
// set localization on portal
$this->generatePortalLocalizations($portalNode, $portal);
$this->webspace->addPortal($portal);
$portal->setWebspace($this->webspace);
// set environments
$this->generateEnvironments($portalNode, $portal);
}
} | [
"protected",
"function",
"generatePortals",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:portals/x:portal'",
")",
"as",
"$",
"portalNode",
")",
"{",
"/** @var \\DOMNode $portalNode */",
"$",
"portal",
"=",
"new",
"Portal",
"(",
")",
";",
"$",
"portal",
"->",
"setName",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:name'",
",",
"$",
"portalNode",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
")",
";",
"$",
"portal",
"->",
"setKey",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:key'",
",",
"$",
"portalNode",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
")",
";",
"// set localization on portal",
"$",
"this",
"->",
"generatePortalLocalizations",
"(",
"$",
"portalNode",
",",
"$",
"portal",
")",
";",
"$",
"this",
"->",
"webspace",
"->",
"addPortal",
"(",
"$",
"portal",
")",
";",
"$",
"portal",
"->",
"setWebspace",
"(",
"$",
"this",
"->",
"webspace",
")",
";",
"// set environments",
"$",
"this",
"->",
"generateEnvironments",
"(",
"$",
"portalNode",
",",
"$",
"portal",
")",
";",
"}",
"}"
] | Generate all the portals for the webspace. | [
"Generate",
"all",
"the",
"portals",
"for",
"the",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L332-L350 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateTheme | protected function generateTheme()
{
$nodes = $this->xpath->query('/x:webspace/x:theme/x:key');
if ($nodes->length > 0) {
return $nodes->item(0)->nodeValue;
}
$nodes = $this->xpath->query('/x:webspace/x:theme');
if (0 === $nodes->length) {
return;
}
return $nodes->item(0)->nodeValue;
} | php | protected function generateTheme()
{
$nodes = $this->xpath->query('/x:webspace/x:theme/x:key');
if ($nodes->length > 0) {
return $nodes->item(0)->nodeValue;
}
$nodes = $this->xpath->query('/x:webspace/x:theme');
if (0 === $nodes->length) {
return;
}
return $nodes->item(0)->nodeValue;
} | [
"protected",
"function",
"generateTheme",
"(",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:theme/x:key'",
")",
";",
"if",
"(",
"$",
"nodes",
"->",
"length",
">",
"0",
")",
"{",
"return",
"$",
"nodes",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
";",
"}",
"$",
"nodes",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:theme'",
")",
";",
"if",
"(",
"0",
"===",
"$",
"nodes",
"->",
"length",
")",
"{",
"return",
";",
"}",
"return",
"$",
"nodes",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
";",
"}"
] | Generates the theme for the webspace.
@return string | [
"Generates",
"the",
"theme",
"for",
"the",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L357-L370 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateTemplates | protected function generateTemplates(Webspace $webspace)
{
$defaultErrorTemplates = 0;
foreach ($this->xpath->query('/x:webspace/x:theme/x:error-templates/x:error-template') as $errorTemplateNode) {
/* @var \DOMNode $errorTemplateNode */
$template = $errorTemplateNode->nodeValue;
if (null !== ($codeNode = $errorTemplateNode->attributes->getNamedItem('code'))) {
$webspace->addTemplate('error-' . $codeNode->nodeValue, $template);
} elseif (null !== ($defaultNode = $errorTemplateNode->attributes->getNamedItem('default'))) {
$default = 'true' === $defaultNode->nodeValue;
if (!$default) {
throw new InvalidDefaultErrorTemplateException($template, $this->webspace->getKey());
}
++$defaultErrorTemplates;
$webspace->addTemplate('error', $template);
} else {
throw new InvalidErrorTemplateException($template, $this->webspace->getKey());
}
}
// only one or none default error-template is legal
if ($defaultErrorTemplates > 1) {
throw new InvalidAmountOfDefaultErrorTemplateException($this->webspace->getKey());
}
return $webspace;
} | php | protected function generateTemplates(Webspace $webspace)
{
$defaultErrorTemplates = 0;
foreach ($this->xpath->query('/x:webspace/x:theme/x:error-templates/x:error-template') as $errorTemplateNode) {
/* @var \DOMNode $errorTemplateNode */
$template = $errorTemplateNode->nodeValue;
if (null !== ($codeNode = $errorTemplateNode->attributes->getNamedItem('code'))) {
$webspace->addTemplate('error-' . $codeNode->nodeValue, $template);
} elseif (null !== ($defaultNode = $errorTemplateNode->attributes->getNamedItem('default'))) {
$default = 'true' === $defaultNode->nodeValue;
if (!$default) {
throw new InvalidDefaultErrorTemplateException($template, $this->webspace->getKey());
}
++$defaultErrorTemplates;
$webspace->addTemplate('error', $template);
} else {
throw new InvalidErrorTemplateException($template, $this->webspace->getKey());
}
}
// only one or none default error-template is legal
if ($defaultErrorTemplates > 1) {
throw new InvalidAmountOfDefaultErrorTemplateException($this->webspace->getKey());
}
return $webspace;
} | [
"protected",
"function",
"generateTemplates",
"(",
"Webspace",
"$",
"webspace",
")",
"{",
"$",
"defaultErrorTemplates",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:theme/x:error-templates/x:error-template'",
")",
"as",
"$",
"errorTemplateNode",
")",
"{",
"/* @var \\DOMNode $errorTemplateNode */",
"$",
"template",
"=",
"$",
"errorTemplateNode",
"->",
"nodeValue",
";",
"if",
"(",
"null",
"!==",
"(",
"$",
"codeNode",
"=",
"$",
"errorTemplateNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'code'",
")",
")",
")",
"{",
"$",
"webspace",
"->",
"addTemplate",
"(",
"'error-'",
".",
"$",
"codeNode",
"->",
"nodeValue",
",",
"$",
"template",
")",
";",
"}",
"elseif",
"(",
"null",
"!==",
"(",
"$",
"defaultNode",
"=",
"$",
"errorTemplateNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'default'",
")",
")",
")",
"{",
"$",
"default",
"=",
"'true'",
"===",
"$",
"defaultNode",
"->",
"nodeValue",
";",
"if",
"(",
"!",
"$",
"default",
")",
"{",
"throw",
"new",
"InvalidDefaultErrorTemplateException",
"(",
"$",
"template",
",",
"$",
"this",
"->",
"webspace",
"->",
"getKey",
"(",
")",
")",
";",
"}",
"++",
"$",
"defaultErrorTemplates",
";",
"$",
"webspace",
"->",
"addTemplate",
"(",
"'error'",
",",
"$",
"template",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidErrorTemplateException",
"(",
"$",
"template",
",",
"$",
"this",
"->",
"webspace",
"->",
"getKey",
"(",
")",
")",
";",
"}",
"}",
"// only one or none default error-template is legal",
"if",
"(",
"$",
"defaultErrorTemplates",
">",
"1",
")",
"{",
"throw",
"new",
"InvalidAmountOfDefaultErrorTemplateException",
"(",
"$",
"this",
"->",
"webspace",
"->",
"getKey",
"(",
")",
")",
";",
"}",
"return",
"$",
"webspace",
";",
"}"
] | Generates the available template types for the given webspace.
@param Webspace $webspace
@return Webspace
@throws InvalidAmountOfDefaultErrorTemplateException
@throws InvalidDefaultErrorTemplateException
@throws InvalidErrorTemplateException | [
"Generates",
"the",
"available",
"template",
"types",
"for",
"the",
"given",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L383-L410 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateDefaultTemplates | protected function generateDefaultTemplates(Webspace $webspace)
{
$expected = ['page', 'home'];
foreach ($this->xpath->query('/x:webspace/x:theme/x:default-templates/x:default-template') as $node) {
/* @var \DOMNode $node */
$template = $node->nodeValue;
$type = $node->attributes->getNamedItem('type')->nodeValue;
$webspace->addDefaultTemplate($type, $template);
if ('homepage' === $type) {
$webspace->addDefaultTemplate('home', $template);
}
}
$found = array_keys($webspace->getDefaultTemplates());
foreach ($expected as $item) {
if (!in_array($item, $found)) {
throw new ExpectedDefaultTemplatesNotFound($this->webspace->getKey(), $expected, $found);
}
}
return $webspace;
} | php | protected function generateDefaultTemplates(Webspace $webspace)
{
$expected = ['page', 'home'];
foreach ($this->xpath->query('/x:webspace/x:theme/x:default-templates/x:default-template') as $node) {
/* @var \DOMNode $node */
$template = $node->nodeValue;
$type = $node->attributes->getNamedItem('type')->nodeValue;
$webspace->addDefaultTemplate($type, $template);
if ('homepage' === $type) {
$webspace->addDefaultTemplate('home', $template);
}
}
$found = array_keys($webspace->getDefaultTemplates());
foreach ($expected as $item) {
if (!in_array($item, $found)) {
throw new ExpectedDefaultTemplatesNotFound($this->webspace->getKey(), $expected, $found);
}
}
return $webspace;
} | [
"protected",
"function",
"generateDefaultTemplates",
"(",
"Webspace",
"$",
"webspace",
")",
"{",
"$",
"expected",
"=",
"[",
"'page'",
",",
"'home'",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:theme/x:default-templates/x:default-template'",
")",
"as",
"$",
"node",
")",
"{",
"/* @var \\DOMNode $node */",
"$",
"template",
"=",
"$",
"node",
"->",
"nodeValue",
";",
"$",
"type",
"=",
"$",
"node",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'type'",
")",
"->",
"nodeValue",
";",
"$",
"webspace",
"->",
"addDefaultTemplate",
"(",
"$",
"type",
",",
"$",
"template",
")",
";",
"if",
"(",
"'homepage'",
"===",
"$",
"type",
")",
"{",
"$",
"webspace",
"->",
"addDefaultTemplate",
"(",
"'home'",
",",
"$",
"template",
")",
";",
"}",
"}",
"$",
"found",
"=",
"array_keys",
"(",
"$",
"webspace",
"->",
"getDefaultTemplates",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"expected",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"item",
",",
"$",
"found",
")",
")",
"{",
"throw",
"new",
"ExpectedDefaultTemplatesNotFound",
"(",
"$",
"this",
"->",
"webspace",
"->",
"getKey",
"(",
")",
",",
"$",
"expected",
",",
"$",
"found",
")",
";",
"}",
"}",
"return",
"$",
"webspace",
";",
"}"
] | Generates the default templates for the webspace.
@param Webspace $webspace
@return Webspace
@throws ExpectedDefaultTemplatesNotFound | [
"Generates",
"the",
"default",
"templates",
"for",
"the",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L421-L444 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateNavigation | protected function generateNavigation()
{
$contexts = [];
foreach ($this->xpath->query('/x:webspace/x:navigation/x:contexts/x:context') as $contextNode) {
/* @var \DOMNode $contextNode */
$contexts[] = new NavigationContext(
$contextNode->attributes->getNamedItem('key')->nodeValue,
$this->loadMeta('x:meta/x:*', $contextNode)
);
}
return new Navigation($contexts);
} | php | protected function generateNavigation()
{
$contexts = [];
foreach ($this->xpath->query('/x:webspace/x:navigation/x:contexts/x:context') as $contextNode) {
/* @var \DOMNode $contextNode */
$contexts[] = new NavigationContext(
$contextNode->attributes->getNamedItem('key')->nodeValue,
$this->loadMeta('x:meta/x:*', $contextNode)
);
}
return new Navigation($contexts);
} | [
"protected",
"function",
"generateNavigation",
"(",
")",
"{",
"$",
"contexts",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'/x:webspace/x:navigation/x:contexts/x:context'",
")",
"as",
"$",
"contextNode",
")",
"{",
"/* @var \\DOMNode $contextNode */",
"$",
"contexts",
"[",
"]",
"=",
"new",
"NavigationContext",
"(",
"$",
"contextNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'key'",
")",
"->",
"nodeValue",
",",
"$",
"this",
"->",
"loadMeta",
"(",
"'x:meta/x:*'",
",",
"$",
"contextNode",
")",
")",
";",
"}",
"return",
"new",
"Navigation",
"(",
"$",
"contexts",
")",
";",
"}"
] | Generates the availabel navigation contexts for the webspace.
@return Navigation | [
"Generates",
"the",
"availabel",
"navigation",
"contexts",
"for",
"the",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L451-L464 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.loadMeta | protected function loadMeta($path, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($this->xpath->query($path, $context) as $node) {
$attribute = $node->tagName;
$lang = $this->xpath->query('@lang', $node)->item(0)->nodeValue;
if (!isset($result[$node->tagName])) {
$result[$attribute] = [];
}
$result[$attribute][$lang] = $node->textContent;
}
return $result;
} | php | protected function loadMeta($path, \DOMNode $context = null)
{
$result = [];
/** @var \DOMElement $node */
foreach ($this->xpath->query($path, $context) as $node) {
$attribute = $node->tagName;
$lang = $this->xpath->query('@lang', $node)->item(0)->nodeValue;
if (!isset($result[$node->tagName])) {
$result[$attribute] = [];
}
$result[$attribute][$lang] = $node->textContent;
}
return $result;
} | [
"protected",
"function",
"loadMeta",
"(",
"$",
"path",
",",
"\\",
"DOMNode",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"/** @var \\DOMElement $node */",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"$",
"path",
",",
"$",
"context",
")",
"as",
"$",
"node",
")",
"{",
"$",
"attribute",
"=",
"$",
"node",
"->",
"tagName",
";",
"$",
"lang",
"=",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'@lang'",
",",
"$",
"node",
")",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"node",
"->",
"tagName",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"attribute",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"result",
"[",
"$",
"attribute",
"]",
"[",
"$",
"lang",
"]",
"=",
"$",
"node",
"->",
"textContent",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Loads the meta information like a translatable title from the webspace.
@param $path
@param \DOMNode|null $context
@return array | [
"Loads",
"the",
"meta",
"information",
"like",
"a",
"translatable",
"title",
"from",
"the",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L474-L490 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateEnvironments | protected function generateEnvironments(\DOMNode $portalNode, Portal $portal)
{
foreach ($this->xpath->query('x:environments/x:environment', $portalNode) as $environmentNode) {
/** @var \DOMNode $environmentNode */
$environment = new Environment();
$environment->setType($environmentNode->attributes->getNamedItem('type')->nodeValue);
$this->generateUrls($environmentNode, $environment);
$this->generateCustomUrls($environmentNode, $environment);
$portal->addEnvironment($environment);
}
} | php | protected function generateEnvironments(\DOMNode $portalNode, Portal $portal)
{
foreach ($this->xpath->query('x:environments/x:environment', $portalNode) as $environmentNode) {
/** @var \DOMNode $environmentNode */
$environment = new Environment();
$environment->setType($environmentNode->attributes->getNamedItem('type')->nodeValue);
$this->generateUrls($environmentNode, $environment);
$this->generateCustomUrls($environmentNode, $environment);
$portal->addEnvironment($environment);
}
} | [
"protected",
"function",
"generateEnvironments",
"(",
"\\",
"DOMNode",
"$",
"portalNode",
",",
"Portal",
"$",
"portal",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:environments/x:environment'",
",",
"$",
"portalNode",
")",
"as",
"$",
"environmentNode",
")",
"{",
"/** @var \\DOMNode $environmentNode */",
"$",
"environment",
"=",
"new",
"Environment",
"(",
")",
";",
"$",
"environment",
"->",
"setType",
"(",
"$",
"environmentNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'type'",
")",
"->",
"nodeValue",
")",
";",
"$",
"this",
"->",
"generateUrls",
"(",
"$",
"environmentNode",
",",
"$",
"environment",
")",
";",
"$",
"this",
"->",
"generateCustomUrls",
"(",
"$",
"environmentNode",
",",
"$",
"environment",
")",
";",
"$",
"portal",
"->",
"addEnvironment",
"(",
"$",
"environment",
")",
";",
"}",
"}"
] | Generates the definitions for the available environments for this webspace.
@param \DOMNode $portalNode
@param Portal $portal | [
"Generates",
"the",
"definitions",
"for",
"the",
"available",
"environments",
"for",
"this",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L498-L510 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateUrls | protected function generateUrls(\DOMNode $environmentNode, Environment $environment)
{
foreach ($this->xpath->query('x:urls/x:url', $environmentNode) as $urlNode) {
// check if the url is valid, and throw an exception otherwise
if (!$this->checkUrlNode($urlNode)) {
throw new InvalidUrlDefinitionException($this->webspace, $urlNode->nodeValue);
}
/** @var \DOMNode $urlNode */
$url = new Url();
$url->setUrl(rtrim($urlNode->nodeValue, '/'));
// set optional nodes
$url->setLanguage($this->getOptionalNodeAttribute($urlNode, 'language'));
$url->setCountry($this->getOptionalNodeAttribute($urlNode, 'country'));
$url->setSegment($this->getOptionalNodeAttribute($urlNode, 'segment'));
$url->setRedirect($this->getOptionalNodeAttribute($urlNode, 'redirect'));
$url->setMain($this->getOptionalNodeAttribute($urlNode, 'main', false));
$environment->addUrl($url);
}
} | php | protected function generateUrls(\DOMNode $environmentNode, Environment $environment)
{
foreach ($this->xpath->query('x:urls/x:url', $environmentNode) as $urlNode) {
// check if the url is valid, and throw an exception otherwise
if (!$this->checkUrlNode($urlNode)) {
throw new InvalidUrlDefinitionException($this->webspace, $urlNode->nodeValue);
}
/** @var \DOMNode $urlNode */
$url = new Url();
$url->setUrl(rtrim($urlNode->nodeValue, '/'));
// set optional nodes
$url->setLanguage($this->getOptionalNodeAttribute($urlNode, 'language'));
$url->setCountry($this->getOptionalNodeAttribute($urlNode, 'country'));
$url->setSegment($this->getOptionalNodeAttribute($urlNode, 'segment'));
$url->setRedirect($this->getOptionalNodeAttribute($urlNode, 'redirect'));
$url->setMain($this->getOptionalNodeAttribute($urlNode, 'main', false));
$environment->addUrl($url);
}
} | [
"protected",
"function",
"generateUrls",
"(",
"\\",
"DOMNode",
"$",
"environmentNode",
",",
"Environment",
"$",
"environment",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:urls/x:url'",
",",
"$",
"environmentNode",
")",
"as",
"$",
"urlNode",
")",
"{",
"// check if the url is valid, and throw an exception otherwise",
"if",
"(",
"!",
"$",
"this",
"->",
"checkUrlNode",
"(",
"$",
"urlNode",
")",
")",
"{",
"throw",
"new",
"InvalidUrlDefinitionException",
"(",
"$",
"this",
"->",
"webspace",
",",
"$",
"urlNode",
"->",
"nodeValue",
")",
";",
"}",
"/** @var \\DOMNode $urlNode */",
"$",
"url",
"=",
"new",
"Url",
"(",
")",
";",
"$",
"url",
"->",
"setUrl",
"(",
"rtrim",
"(",
"$",
"urlNode",
"->",
"nodeValue",
",",
"'/'",
")",
")",
";",
"// set optional nodes",
"$",
"url",
"->",
"setLanguage",
"(",
"$",
"this",
"->",
"getOptionalNodeAttribute",
"(",
"$",
"urlNode",
",",
"'language'",
")",
")",
";",
"$",
"url",
"->",
"setCountry",
"(",
"$",
"this",
"->",
"getOptionalNodeAttribute",
"(",
"$",
"urlNode",
",",
"'country'",
")",
")",
";",
"$",
"url",
"->",
"setSegment",
"(",
"$",
"this",
"->",
"getOptionalNodeAttribute",
"(",
"$",
"urlNode",
",",
"'segment'",
")",
")",
";",
"$",
"url",
"->",
"setRedirect",
"(",
"$",
"this",
"->",
"getOptionalNodeAttribute",
"(",
"$",
"urlNode",
",",
"'redirect'",
")",
")",
";",
"$",
"url",
"->",
"setMain",
"(",
"$",
"this",
"->",
"getOptionalNodeAttribute",
"(",
"$",
"urlNode",
",",
"'main'",
",",
"false",
")",
")",
";",
"$",
"environment",
"->",
"addUrl",
"(",
"$",
"url",
")",
";",
"}",
"}"
] | Generates the URLs for the given environment.
@param \DOMNode $environmentNode
@param Environment $environment
@throws Exception\InvalidUrlDefinitionException | [
"Generates",
"the",
"URLs",
"for",
"the",
"given",
"environment",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L520-L542 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.generateCustomUrls | protected function generateCustomUrls(\DOMNode $environmentNode, Environment $environment)
{
foreach ($this->xpath->query('x:custom-urls/x:custom-url', $environmentNode) as $urlNode) {
/** @var \DOMNode $urlNode */
$url = new CustomUrl();
$url->setUrl(rtrim($urlNode->nodeValue, '/'));
if (false === strpos($url->getUrl(), '*')) {
throw new InvalidCustomUrlException($this->webspace, $url->getUrl());
}
$environment->addCustomUrl($url);
}
} | php | protected function generateCustomUrls(\DOMNode $environmentNode, Environment $environment)
{
foreach ($this->xpath->query('x:custom-urls/x:custom-url', $environmentNode) as $urlNode) {
/** @var \DOMNode $urlNode */
$url = new CustomUrl();
$url->setUrl(rtrim($urlNode->nodeValue, '/'));
if (false === strpos($url->getUrl(), '*')) {
throw new InvalidCustomUrlException($this->webspace, $url->getUrl());
}
$environment->addCustomUrl($url);
}
} | [
"protected",
"function",
"generateCustomUrls",
"(",
"\\",
"DOMNode",
"$",
"environmentNode",
",",
"Environment",
"$",
"environment",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"xpath",
"->",
"query",
"(",
"'x:custom-urls/x:custom-url'",
",",
"$",
"environmentNode",
")",
"as",
"$",
"urlNode",
")",
"{",
"/** @var \\DOMNode $urlNode */",
"$",
"url",
"=",
"new",
"CustomUrl",
"(",
")",
";",
"$",
"url",
"->",
"setUrl",
"(",
"rtrim",
"(",
"$",
"urlNode",
"->",
"nodeValue",
",",
"'/'",
")",
")",
";",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"url",
"->",
"getUrl",
"(",
")",
",",
"'*'",
")",
")",
"{",
"throw",
"new",
"InvalidCustomUrlException",
"(",
"$",
"this",
"->",
"webspace",
",",
"$",
"url",
"->",
"getUrl",
"(",
")",
")",
";",
"}",
"$",
"environment",
"->",
"addCustomUrl",
"(",
"$",
"url",
")",
";",
"}",
"}"
] | Generates the custom URLs from the XML document.
A custom URL must contain at lease one *, which will be used as a placeholder.
@param \DOMNode $environmentNode
@param Environment $environment
@throws InvalidCustomUrlException | [
"Generates",
"the",
"custom",
"URLs",
"from",
"the",
"XML",
"document",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L554-L568 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.getOptionalNodeAttribute | protected function getOptionalNodeAttribute(\DOMNode $node, $name, $default = null)
{
$attribute = $node->attributes->getNamedItem($name);
if ($attribute) {
return $attribute->nodeValue;
}
return $default;
} | php | protected function getOptionalNodeAttribute(\DOMNode $node, $name, $default = null)
{
$attribute = $node->attributes->getNamedItem($name);
if ($attribute) {
return $attribute->nodeValue;
}
return $default;
} | [
"protected",
"function",
"getOptionalNodeAttribute",
"(",
"\\",
"DOMNode",
"$",
"node",
",",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"attribute",
"=",
"$",
"node",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"attribute",
")",
"{",
"return",
"$",
"attribute",
"->",
"nodeValue",
";",
"}",
"return",
"$",
"default",
";",
"}"
] | Returns an optional value from the given node. The default value will be used if the node does not exist.
@param \DOMNode $node
@param string $name
@param mixed $default
@return mixed | [
"Returns",
"an",
"optional",
"value",
"from",
"the",
"given",
"node",
".",
"The",
"default",
"value",
"will",
"be",
"used",
"if",
"the",
"node",
"does",
"not",
"exist",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L579-L587 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.checkUrlNode | protected function checkUrlNode(\DOMNode $urlNode)
{
$hasLocalization = (null != $urlNode->attributes->getNamedItem('localization'))
|| (false !== strpos($urlNode->nodeValue, '{localization}'));
$hasLanguage = (null != $urlNode->attributes->getNamedItem('language'))
|| (false !== strpos($urlNode->nodeValue, '{language}'))
|| $hasLocalization;
$hasSegment = (0 == count($this->webspace->getSegments()))
|| (null != $urlNode->attributes->getNamedItem('segment'))
|| (false !== strpos($urlNode->nodeValue, '{segment}'));
$hasRedirect = (null != $urlNode->attributes->getNamedItem('redirect'));
return ($hasLanguage && $hasSegment) || $hasRedirect;
} | php | protected function checkUrlNode(\DOMNode $urlNode)
{
$hasLocalization = (null != $urlNode->attributes->getNamedItem('localization'))
|| (false !== strpos($urlNode->nodeValue, '{localization}'));
$hasLanguage = (null != $urlNode->attributes->getNamedItem('language'))
|| (false !== strpos($urlNode->nodeValue, '{language}'))
|| $hasLocalization;
$hasSegment = (0 == count($this->webspace->getSegments()))
|| (null != $urlNode->attributes->getNamedItem('segment'))
|| (false !== strpos($urlNode->nodeValue, '{segment}'));
$hasRedirect = (null != $urlNode->attributes->getNamedItem('redirect'));
return ($hasLanguage && $hasSegment) || $hasRedirect;
} | [
"protected",
"function",
"checkUrlNode",
"(",
"\\",
"DOMNode",
"$",
"urlNode",
")",
"{",
"$",
"hasLocalization",
"=",
"(",
"null",
"!=",
"$",
"urlNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'localization'",
")",
")",
"||",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"urlNode",
"->",
"nodeValue",
",",
"'{localization}'",
")",
")",
";",
"$",
"hasLanguage",
"=",
"(",
"null",
"!=",
"$",
"urlNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'language'",
")",
")",
"||",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"urlNode",
"->",
"nodeValue",
",",
"'{language}'",
")",
")",
"||",
"$",
"hasLocalization",
";",
"$",
"hasSegment",
"=",
"(",
"0",
"==",
"count",
"(",
"$",
"this",
"->",
"webspace",
"->",
"getSegments",
"(",
")",
")",
")",
"||",
"(",
"null",
"!=",
"$",
"urlNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'segment'",
")",
")",
"||",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"urlNode",
"->",
"nodeValue",
",",
"'{segment}'",
")",
")",
";",
"$",
"hasRedirect",
"=",
"(",
"null",
"!=",
"$",
"urlNode",
"->",
"attributes",
"->",
"getNamedItem",
"(",
"'redirect'",
")",
")",
";",
"return",
"(",
"$",
"hasLanguage",
"&&",
"$",
"hasSegment",
")",
"||",
"$",
"hasRedirect",
";",
"}"
] | Checks if the urlNode is valid for this webspace.
@param \DOMNode $urlNode
@return bool | [
"Checks",
"if",
"the",
"urlNode",
"is",
"valid",
"for",
"this",
"webspace",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L596-L612 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.validateWebspaceDefaultLocalization | protected function validateWebspaceDefaultLocalization()
{
try {
$this->validateDefaultLocalization($this->webspace->getLocalizations());
} catch (InvalidDefaultLocalizationException $ex) {
throw new InvalidWebspaceDefaultLocalizationException($this->webspace);
}
} | php | protected function validateWebspaceDefaultLocalization()
{
try {
$this->validateDefaultLocalization($this->webspace->getLocalizations());
} catch (InvalidDefaultLocalizationException $ex) {
throw new InvalidWebspaceDefaultLocalizationException($this->webspace);
}
} | [
"protected",
"function",
"validateWebspaceDefaultLocalization",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"validateDefaultLocalization",
"(",
"$",
"this",
"->",
"webspace",
"->",
"getLocalizations",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InvalidDefaultLocalizationException",
"$",
"ex",
")",
"{",
"throw",
"new",
"InvalidWebspaceDefaultLocalizationException",
"(",
"$",
"this",
"->",
"webspace",
")",
";",
"}",
"}"
] | Validate default webspace localization.
@throws Exception\InvalidWebspaceDefaultLocalizationException | [
"Validate",
"default",
"webspace",
"localization",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L619-L626 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.validateDefaultPortalLocalization | protected function validateDefaultPortalLocalization()
{
// check all portal localizations
foreach ($this->webspace->getPortals() as $portal) {
try {
if (!$this->validateDefaultLocalization($portal->getLocalizations())) {
// try to load the webspace localizations before throwing an exception
if (!$this->loadPortalLocalizationDefaultFromWebspace($portal)) {
throw new PortalDefaultLocalizationNotFoundException($this->webspace, $portal);
}
}
} catch (InvalidDefaultLocalizationException $ex) {
throw new InvalidPortalDefaultLocalizationException($this->webspace, $portal);
}
}
} | php | protected function validateDefaultPortalLocalization()
{
// check all portal localizations
foreach ($this->webspace->getPortals() as $portal) {
try {
if (!$this->validateDefaultLocalization($portal->getLocalizations())) {
// try to load the webspace localizations before throwing an exception
if (!$this->loadPortalLocalizationDefaultFromWebspace($portal)) {
throw new PortalDefaultLocalizationNotFoundException($this->webspace, $portal);
}
}
} catch (InvalidDefaultLocalizationException $ex) {
throw new InvalidPortalDefaultLocalizationException($this->webspace, $portal);
}
}
} | [
"protected",
"function",
"validateDefaultPortalLocalization",
"(",
")",
"{",
"// check all portal localizations",
"foreach",
"(",
"$",
"this",
"->",
"webspace",
"->",
"getPortals",
"(",
")",
"as",
"$",
"portal",
")",
"{",
"try",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"validateDefaultLocalization",
"(",
"$",
"portal",
"->",
"getLocalizations",
"(",
")",
")",
")",
"{",
"// try to load the webspace localizations before throwing an exception",
"if",
"(",
"!",
"$",
"this",
"->",
"loadPortalLocalizationDefaultFromWebspace",
"(",
"$",
"portal",
")",
")",
"{",
"throw",
"new",
"PortalDefaultLocalizationNotFoundException",
"(",
"$",
"this",
"->",
"webspace",
",",
"$",
"portal",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"InvalidDefaultLocalizationException",
"$",
"ex",
")",
"{",
"throw",
"new",
"InvalidPortalDefaultLocalizationException",
"(",
"$",
"this",
"->",
"webspace",
",",
"$",
"portal",
")",
";",
"}",
"}",
"}"
] | Validate portal localization.
@throws Exception\PortalDefaultLocalizationNotFoundException
@throws Exception\InvalidPortalDefaultLocalizationException | [
"Validate",
"portal",
"localization",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L634-L649 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.validateWebspaceDefaultSegment | protected function validateWebspaceDefaultSegment()
{
// check if there are duplicate defaults in the webspaces segments
$segments = $this->webspace->getSegments();
if ($segments) {
$webspaceDefaultSegmentFound = false;
foreach ($segments as $webspaceSegment) {
if ($webspaceSegment->isDefault()) {
// throw an exception, if a new default segment is found, although there already is one
if ($webspaceDefaultSegmentFound) {
throw new InvalidWebspaceDefaultSegmentException($this->webspace);
}
$webspaceDefaultSegmentFound = true;
}
}
if (!$webspaceDefaultSegmentFound) {
throw new WebspaceDefaultSegmentNotFoundException($this->webspace);
}
}
} | php | protected function validateWebspaceDefaultSegment()
{
// check if there are duplicate defaults in the webspaces segments
$segments = $this->webspace->getSegments();
if ($segments) {
$webspaceDefaultSegmentFound = false;
foreach ($segments as $webspaceSegment) {
if ($webspaceSegment->isDefault()) {
// throw an exception, if a new default segment is found, although there already is one
if ($webspaceDefaultSegmentFound) {
throw new InvalidWebspaceDefaultSegmentException($this->webspace);
}
$webspaceDefaultSegmentFound = true;
}
}
if (!$webspaceDefaultSegmentFound) {
throw new WebspaceDefaultSegmentNotFoundException($this->webspace);
}
}
} | [
"protected",
"function",
"validateWebspaceDefaultSegment",
"(",
")",
"{",
"// check if there are duplicate defaults in the webspaces segments",
"$",
"segments",
"=",
"$",
"this",
"->",
"webspace",
"->",
"getSegments",
"(",
")",
";",
"if",
"(",
"$",
"segments",
")",
"{",
"$",
"webspaceDefaultSegmentFound",
"=",
"false",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"webspaceSegment",
")",
"{",
"if",
"(",
"$",
"webspaceSegment",
"->",
"isDefault",
"(",
")",
")",
"{",
"// throw an exception, if a new default segment is found, although there already is one",
"if",
"(",
"$",
"webspaceDefaultSegmentFound",
")",
"{",
"throw",
"new",
"InvalidWebspaceDefaultSegmentException",
"(",
"$",
"this",
"->",
"webspace",
")",
";",
"}",
"$",
"webspaceDefaultSegmentFound",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"webspaceDefaultSegmentFound",
")",
"{",
"throw",
"new",
"WebspaceDefaultSegmentNotFoundException",
"(",
"$",
"this",
"->",
"webspace",
")",
";",
"}",
"}",
"}"
] | Validate webspace default segment.
@throws Exception\WebspaceDefaultSegmentNotFoundException
@throws Exception\InvalidWebspaceDefaultSegmentException | [
"Validate",
"webspace",
"default",
"segment",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L657-L677 | train |
sulu/sulu | src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php | XmlFileLoader10.validateDefaultLocalization | protected function validateDefaultLocalization($localizations)
{
$result = false;
foreach ($localizations as $localization) {
if ($localization->isDefault()) {
if ($result) {
throw new InvalidDefaultLocalizationException();
}
$result = true;
}
}
return $result;
} | php | protected function validateDefaultLocalization($localizations)
{
$result = false;
foreach ($localizations as $localization) {
if ($localization->isDefault()) {
if ($result) {
throw new InvalidDefaultLocalizationException();
}
$result = true;
}
}
return $result;
} | [
"protected",
"function",
"validateDefaultLocalization",
"(",
"$",
"localizations",
")",
"{",
"$",
"result",
"=",
"false",
";",
"foreach",
"(",
"$",
"localizations",
"as",
"$",
"localization",
")",
"{",
"if",
"(",
"$",
"localization",
"->",
"isDefault",
"(",
")",
")",
"{",
"if",
"(",
"$",
"result",
")",
"{",
"throw",
"new",
"InvalidDefaultLocalizationException",
"(",
")",
";",
"}",
"$",
"result",
"=",
"true",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Returns true if there is one default localization.
@param $localizations
@return bool
@throws Exception\InvalidDefaultLocalizationException | [
"Returns",
"true",
"if",
"there",
"is",
"one",
"default",
"localization",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Loader/XmlFileLoader10.php#L688-L701 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Entity/CollectionRepository.php | CollectionRepository.getIdsQuery | private function getIdsQuery(
$depth = 0,
$filter = [],
$sortBy = [],
CollectionInterface $collection = null,
$select = 'collection.id'
) {
$queryBuilder = $this->createQueryBuilder('collection')
->select($select)
->where('collection.depth <= :depth');
$collectionDepth = null !== $collection ? $collection->getDepth() : 0;
$queryBuilder->setParameter('depth', $collectionDepth + $depth);
if (null !== $collection) {
$queryBuilder->andWhere('collection.lft BETWEEN :lft AND :rgt AND collection.id != :id');
$queryBuilder->setParameter('lft', $collection->getLft());
$queryBuilder->setParameter('rgt', $collection->getRgt());
$queryBuilder->setParameter('id', $collection->getId());
}
if (array_key_exists('search', $filter) && null !== $filter['search'] ||
array_key_exists('locale', $filter) ||
count($sortBy) > 0
) {
$queryBuilder->leftJoin('collection.meta', 'collectionMeta');
$queryBuilder->leftJoin('collection.defaultMeta', 'defaultMeta');
}
if (array_key_exists('search', $filter) && null !== $filter['search']) {
$queryBuilder->andWhere('collectionMeta.title LIKE :search OR defaultMeta.locale != :locale');
$queryBuilder->setParameter('search', '%' . $filter['search'] . '%');
}
if (array_key_exists('locale', $filter)) {
$queryBuilder->andWhere('collectionMeta.locale = :locale OR defaultMeta.locale != :locale');
$queryBuilder->setParameter('locale', $filter['locale']);
}
if (array_key_exists('systemCollections', $filter) && !$filter['systemCollections']) {
$queryBuilder->leftJoin('collection.type', 'collectionType');
$queryBuilder->andWhere('collectionType.key != :type');
$queryBuilder->setParameter('type', SystemCollectionManagerInterface::COLLECTION_TYPE);
}
if (count($sortBy) > 0) {
foreach ($sortBy as $column => $order) {
$queryBuilder->addOrderBy(
'collectionMeta.' . $column,
('asc' === strtolower($order) ? 'ASC' : 'DESC')
);
}
}
$queryBuilder->addOrderBy('collection.id', 'ASC');
if (array_key_exists('limit', $filter)) {
$queryBuilder->setMaxResults($filter['limit']);
}
if (array_key_exists('offset', $filter)) {
$queryBuilder->setFirstResult($filter['offset']);
}
return $queryBuilder->getQuery();
} | php | private function getIdsQuery(
$depth = 0,
$filter = [],
$sortBy = [],
CollectionInterface $collection = null,
$select = 'collection.id'
) {
$queryBuilder = $this->createQueryBuilder('collection')
->select($select)
->where('collection.depth <= :depth');
$collectionDepth = null !== $collection ? $collection->getDepth() : 0;
$queryBuilder->setParameter('depth', $collectionDepth + $depth);
if (null !== $collection) {
$queryBuilder->andWhere('collection.lft BETWEEN :lft AND :rgt AND collection.id != :id');
$queryBuilder->setParameter('lft', $collection->getLft());
$queryBuilder->setParameter('rgt', $collection->getRgt());
$queryBuilder->setParameter('id', $collection->getId());
}
if (array_key_exists('search', $filter) && null !== $filter['search'] ||
array_key_exists('locale', $filter) ||
count($sortBy) > 0
) {
$queryBuilder->leftJoin('collection.meta', 'collectionMeta');
$queryBuilder->leftJoin('collection.defaultMeta', 'defaultMeta');
}
if (array_key_exists('search', $filter) && null !== $filter['search']) {
$queryBuilder->andWhere('collectionMeta.title LIKE :search OR defaultMeta.locale != :locale');
$queryBuilder->setParameter('search', '%' . $filter['search'] . '%');
}
if (array_key_exists('locale', $filter)) {
$queryBuilder->andWhere('collectionMeta.locale = :locale OR defaultMeta.locale != :locale');
$queryBuilder->setParameter('locale', $filter['locale']);
}
if (array_key_exists('systemCollections', $filter) && !$filter['systemCollections']) {
$queryBuilder->leftJoin('collection.type', 'collectionType');
$queryBuilder->andWhere('collectionType.key != :type');
$queryBuilder->setParameter('type', SystemCollectionManagerInterface::COLLECTION_TYPE);
}
if (count($sortBy) > 0) {
foreach ($sortBy as $column => $order) {
$queryBuilder->addOrderBy(
'collectionMeta.' . $column,
('asc' === strtolower($order) ? 'ASC' : 'DESC')
);
}
}
$queryBuilder->addOrderBy('collection.id', 'ASC');
if (array_key_exists('limit', $filter)) {
$queryBuilder->setMaxResults($filter['limit']);
}
if (array_key_exists('offset', $filter)) {
$queryBuilder->setFirstResult($filter['offset']);
}
return $queryBuilder->getQuery();
} | [
"private",
"function",
"getIdsQuery",
"(",
"$",
"depth",
"=",
"0",
",",
"$",
"filter",
"=",
"[",
"]",
",",
"$",
"sortBy",
"=",
"[",
"]",
",",
"CollectionInterface",
"$",
"collection",
"=",
"null",
",",
"$",
"select",
"=",
"'collection.id'",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"createQueryBuilder",
"(",
"'collection'",
")",
"->",
"select",
"(",
"$",
"select",
")",
"->",
"where",
"(",
"'collection.depth <= :depth'",
")",
";",
"$",
"collectionDepth",
"=",
"null",
"!==",
"$",
"collection",
"?",
"$",
"collection",
"->",
"getDepth",
"(",
")",
":",
"0",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'depth'",
",",
"$",
"collectionDepth",
"+",
"$",
"depth",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"collection",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'collection.lft BETWEEN :lft AND :rgt AND collection.id != :id'",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'lft'",
",",
"$",
"collection",
"->",
"getLft",
"(",
")",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'rgt'",
",",
"$",
"collection",
"->",
"getRgt",
"(",
")",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'id'",
",",
"$",
"collection",
"->",
"getId",
"(",
")",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'search'",
",",
"$",
"filter",
")",
"&&",
"null",
"!==",
"$",
"filter",
"[",
"'search'",
"]",
"||",
"array_key_exists",
"(",
"'locale'",
",",
"$",
"filter",
")",
"||",
"count",
"(",
"$",
"sortBy",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"->",
"leftJoin",
"(",
"'collection.meta'",
",",
"'collectionMeta'",
")",
";",
"$",
"queryBuilder",
"->",
"leftJoin",
"(",
"'collection.defaultMeta'",
",",
"'defaultMeta'",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'search'",
",",
"$",
"filter",
")",
"&&",
"null",
"!==",
"$",
"filter",
"[",
"'search'",
"]",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'collectionMeta.title LIKE :search OR defaultMeta.locale != :locale'",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'search'",
",",
"'%'",
".",
"$",
"filter",
"[",
"'search'",
"]",
".",
"'%'",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'locale'",
",",
"$",
"filter",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'collectionMeta.locale = :locale OR defaultMeta.locale != :locale'",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'locale'",
",",
"$",
"filter",
"[",
"'locale'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'systemCollections'",
",",
"$",
"filter",
")",
"&&",
"!",
"$",
"filter",
"[",
"'systemCollections'",
"]",
")",
"{",
"$",
"queryBuilder",
"->",
"leftJoin",
"(",
"'collection.type'",
",",
"'collectionType'",
")",
";",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"'collectionType.key != :type'",
")",
";",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"'type'",
",",
"SystemCollectionManagerInterface",
"::",
"COLLECTION_TYPE",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"sortBy",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"sortBy",
"as",
"$",
"column",
"=>",
"$",
"order",
")",
"{",
"$",
"queryBuilder",
"->",
"addOrderBy",
"(",
"'collectionMeta.'",
".",
"$",
"column",
",",
"(",
"'asc'",
"===",
"strtolower",
"(",
"$",
"order",
")",
"?",
"'ASC'",
":",
"'DESC'",
")",
")",
";",
"}",
"}",
"$",
"queryBuilder",
"->",
"addOrderBy",
"(",
"'collection.id'",
",",
"'ASC'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'limit'",
",",
"$",
"filter",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"setMaxResults",
"(",
"$",
"filter",
"[",
"'limit'",
"]",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'offset'",
",",
"$",
"filter",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"setFirstResult",
"(",
"$",
"filter",
"[",
"'offset'",
"]",
")",
";",
"}",
"return",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
";",
"}"
] | Returns the basic query which selects the ids of a collection for a given
set of parameters.
@param int $depth
@param array $filter
@param array $sortBy
@param CollectionInterface|null $collection
@param string $select
@return Query | [
"Returns",
"the",
"basic",
"query",
"which",
"selects",
"the",
"ids",
"of",
"a",
"collection",
"for",
"a",
"given",
"set",
"of",
"parameters",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Entity/CollectionRepository.php#L316-L380 | train |
sulu/sulu | src/Sulu/Component/DocumentManager/Subscriber/Phpcr/RefreshSubscriber.php | RefreshSubscriber.refreshDocument | public function refreshDocument(RefreshEvent $event)
{
$document = $event->getDocument();
$node = $this->documentRegistry->getNodeForDocument($document);
$locale = $this->documentRegistry->getLocaleForDocument($document);
// revert/reload the node to the persisted state
$node->revert();
$this->rehydrateDocument($document, $node, $locale);
} | php | public function refreshDocument(RefreshEvent $event)
{
$document = $event->getDocument();
$node = $this->documentRegistry->getNodeForDocument($document);
$locale = $this->documentRegistry->getLocaleForDocument($document);
// revert/reload the node to the persisted state
$node->revert();
$this->rehydrateDocument($document, $node, $locale);
} | [
"public",
"function",
"refreshDocument",
"(",
"RefreshEvent",
"$",
"event",
")",
"{",
"$",
"document",
"=",
"$",
"event",
"->",
"getDocument",
"(",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"documentRegistry",
"->",
"getNodeForDocument",
"(",
"$",
"document",
")",
";",
"$",
"locale",
"=",
"$",
"this",
"->",
"documentRegistry",
"->",
"getLocaleForDocument",
"(",
"$",
"document",
")",
";",
"// revert/reload the node to the persisted state",
"$",
"node",
"->",
"revert",
"(",
")",
";",
"$",
"this",
"->",
"rehydrateDocument",
"(",
"$",
"document",
",",
"$",
"node",
",",
"$",
"locale",
")",
";",
"}"
] | Refreshes the document when the DocumentManager method for it is called.
@param RefreshEvent $event | [
"Refreshes",
"the",
"document",
"when",
"the",
"DocumentManager",
"method",
"for",
"it",
"is",
"called",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Phpcr/RefreshSubscriber.php#L57-L67 | train |
sulu/sulu | src/Sulu/Component/DocumentManager/Subscriber/Phpcr/RefreshSubscriber.php | RefreshSubscriber.refreshDocumentForDeleteDraft | public function refreshDocumentForDeleteDraft(RemoveDraftEvent $event)
{
$this->rehydrateDocument($event->getDocument(), $event->getNode(), $event->getLocale());
} | php | public function refreshDocumentForDeleteDraft(RemoveDraftEvent $event)
{
$this->rehydrateDocument($event->getDocument(), $event->getNode(), $event->getLocale());
} | [
"public",
"function",
"refreshDocumentForDeleteDraft",
"(",
"RemoveDraftEvent",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"rehydrateDocument",
"(",
"$",
"event",
"->",
"getDocument",
"(",
")",
",",
"$",
"event",
"->",
"getNode",
"(",
")",
",",
"$",
"event",
"->",
"getLocale",
"(",
")",
")",
";",
"}"
] | Refreshes the document after a draft have been removed.
@param RemoveDraftEvent $event | [
"Refreshes",
"the",
"document",
"after",
"a",
"draft",
"have",
"been",
"removed",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Phpcr/RefreshSubscriber.php#L74-L77 | train |
sulu/sulu | src/Sulu/Component/DocumentManager/Subscriber/Phpcr/RefreshSubscriber.php | RefreshSubscriber.rehydrateDocument | private function rehydrateDocument($document, NodeInterface $node, $locale)
{
$hydrateEvent = new HydrateEvent($node, $locale, ['rehydrate' => true]);
$hydrateEvent->setDocument($document);
$this->eventDispatcher->dispatch(Events::HYDRATE, $hydrateEvent);
} | php | private function rehydrateDocument($document, NodeInterface $node, $locale)
{
$hydrateEvent = new HydrateEvent($node, $locale, ['rehydrate' => true]);
$hydrateEvent->setDocument($document);
$this->eventDispatcher->dispatch(Events::HYDRATE, $hydrateEvent);
} | [
"private",
"function",
"rehydrateDocument",
"(",
"$",
"document",
",",
"NodeInterface",
"$",
"node",
",",
"$",
"locale",
")",
"{",
"$",
"hydrateEvent",
"=",
"new",
"HydrateEvent",
"(",
"$",
"node",
",",
"$",
"locale",
",",
"[",
"'rehydrate'",
"=>",
"true",
"]",
")",
";",
"$",
"hydrateEvent",
"->",
"setDocument",
"(",
"$",
"document",
")",
";",
"$",
"this",
"->",
"eventDispatcher",
"->",
"dispatch",
"(",
"Events",
"::",
"HYDRATE",
",",
"$",
"hydrateEvent",
")",
";",
"}"
] | Rehydrates the given document from the given node for the given locale.
@param object $document
@param NodeInterface $node
@param string $locale | [
"Rehydrates",
"the",
"given",
"document",
"from",
"the",
"given",
"node",
"for",
"the",
"given",
"locale",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/DocumentManager/Subscriber/Phpcr/RefreshSubscriber.php#L86-L91 | train |
sulu/sulu | src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupEvaluationController.php | TargetGroupEvaluationController.targetGroupAction | public function targetGroupAction(Request $request)
{
$currentTargetGroup = null;
if ($request->headers->has($this->targetGroupHeader)) {
$currentTargetGroup = $this->targetGroupRepository->find($request->headers->get($this->targetGroupHeader));
}
$targetGroup = $this->targetGroupEvaluator->evaluate(
$currentTargetGroup ? TargetGroupRuleInterface::FREQUENCY_SESSION : TargetGroupRuleInterface::FREQUENCY_VISITOR,
$currentTargetGroup
);
$response = new Response(null, 200, [
$this->targetGroupHeader => $targetGroup ? $targetGroup->getId() : 0,
]);
return $response;
} | php | public function targetGroupAction(Request $request)
{
$currentTargetGroup = null;
if ($request->headers->has($this->targetGroupHeader)) {
$currentTargetGroup = $this->targetGroupRepository->find($request->headers->get($this->targetGroupHeader));
}
$targetGroup = $this->targetGroupEvaluator->evaluate(
$currentTargetGroup ? TargetGroupRuleInterface::FREQUENCY_SESSION : TargetGroupRuleInterface::FREQUENCY_VISITOR,
$currentTargetGroup
);
$response = new Response(null, 200, [
$this->targetGroupHeader => $targetGroup ? $targetGroup->getId() : 0,
]);
return $response;
} | [
"public",
"function",
"targetGroupAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"currentTargetGroup",
"=",
"null",
";",
"if",
"(",
"$",
"request",
"->",
"headers",
"->",
"has",
"(",
"$",
"this",
"->",
"targetGroupHeader",
")",
")",
"{",
"$",
"currentTargetGroup",
"=",
"$",
"this",
"->",
"targetGroupRepository",
"->",
"find",
"(",
"$",
"request",
"->",
"headers",
"->",
"get",
"(",
"$",
"this",
"->",
"targetGroupHeader",
")",
")",
";",
"}",
"$",
"targetGroup",
"=",
"$",
"this",
"->",
"targetGroupEvaluator",
"->",
"evaluate",
"(",
"$",
"currentTargetGroup",
"?",
"TargetGroupRuleInterface",
"::",
"FREQUENCY_SESSION",
":",
"TargetGroupRuleInterface",
"::",
"FREQUENCY_VISITOR",
",",
"$",
"currentTargetGroup",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
"null",
",",
"200",
",",
"[",
"$",
"this",
"->",
"targetGroupHeader",
"=>",
"$",
"targetGroup",
"?",
"$",
"targetGroup",
"->",
"getId",
"(",
")",
":",
"0",
",",
"]",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Takes the request and evaluates a target group based on the request.
@param Request $request
@return Response | [
"Takes",
"the",
"request",
"and",
"evaluates",
"a",
"target",
"group",
"based",
"on",
"the",
"request",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupEvaluationController.php#L71-L88 | train |
sulu/sulu | src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupEvaluationController.php | TargetGroupEvaluationController.targetGroupHitAction | public function targetGroupHitAction()
{
$currentTargetGroup = $this->targetGroupRepository->find($this->targetGroupStore->getTargetGroupId(true));
$targetGroup = $this->targetGroupEvaluator->evaluate(TargetGroupRuleInterface::FREQUENCY_HIT, $currentTargetGroup);
$response = new Response();
if ($targetGroup) {
$this->targetGroupStore->updateTargetGroupId($targetGroup->getId());
}
return $response;
} | php | public function targetGroupHitAction()
{
$currentTargetGroup = $this->targetGroupRepository->find($this->targetGroupStore->getTargetGroupId(true));
$targetGroup = $this->targetGroupEvaluator->evaluate(TargetGroupRuleInterface::FREQUENCY_HIT, $currentTargetGroup);
$response = new Response();
if ($targetGroup) {
$this->targetGroupStore->updateTargetGroupId($targetGroup->getId());
}
return $response;
} | [
"public",
"function",
"targetGroupHitAction",
"(",
")",
"{",
"$",
"currentTargetGroup",
"=",
"$",
"this",
"->",
"targetGroupRepository",
"->",
"find",
"(",
"$",
"this",
"->",
"targetGroupStore",
"->",
"getTargetGroupId",
"(",
"true",
")",
")",
";",
"$",
"targetGroup",
"=",
"$",
"this",
"->",
"targetGroupEvaluator",
"->",
"evaluate",
"(",
"TargetGroupRuleInterface",
"::",
"FREQUENCY_HIT",
",",
"$",
"currentTargetGroup",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"if",
"(",
"$",
"targetGroup",
")",
"{",
"$",
"this",
"->",
"targetGroupStore",
"->",
"updateTargetGroupId",
"(",
"$",
"targetGroup",
"->",
"getId",
"(",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | This end point is called by the injected code on the website to update the target group on every hit.
@return Response | [
"This",
"end",
"point",
"is",
"called",
"by",
"the",
"injected",
"code",
"on",
"the",
"website",
"to",
"update",
"the",
"target",
"group",
"on",
"every",
"hit",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/AudienceTargetingBundle/Controller/TargetGroupEvaluationController.php#L95-L107 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.updateConditionGroup | protected function updateConditionGroup(ConditionGroupEntity $conditionGroup, $matchedEntry)
{
if (array_key_exists('id', $matchedEntry) && isset($matchedEntry['conditions'])) {
$conditionIds = [];
foreach ($matchedEntry['conditions'] as $conditionData) {
if (array_key_exists('id', $conditionData)) {
/** @var ConditionEntity $conditionEntity */
$conditionEntity = $this->conditionRepository->findById($conditionData['id']);
// check if condition exists at all
if (!$conditionEntity) {
throw new FilterDependencyNotFoundException(
self::$conditionEntityName,
$conditionData['id']
);
}
// check if conditions is related with condition group
if ($conditionEntity->getConditionGroup()->getId() !== $conditionGroup->getId()) {
throw new ConditionGroupMismatchException(
$matchedEntry['id']
);
}
$conditionIds[] = $conditionEntity->getId();
} else {
$conditionEntity = new ConditionEntity();
$conditionEntity->setConditionGroup($conditionGroup);
$conditionGroup->addCondition($conditionEntity);
$this->em->persist($conditionEntity);
$conditionIds[] = $conditionEntity->getId();
}
$conditionEntity->setField($this->getProperty($conditionData, 'field', $conditionEntity->getField()));
$conditionEntity->setOperator(
$this->getProperty($conditionData, 'operator', $conditionEntity->getOperator())
);
$conditionEntity->setType($this->getProperty($conditionData, 'type', $conditionEntity->getType()));
$value = $this->getValueForCondition(
$this->getProperty($conditionData, 'value', $conditionEntity->getValue()),
$conditionEntity->getType()
);
$conditionEntity->setValue($value);
}
$this->removeNonExistentConditions($conditionGroup, $conditionIds);
}
return true;
} | php | protected function updateConditionGroup(ConditionGroupEntity $conditionGroup, $matchedEntry)
{
if (array_key_exists('id', $matchedEntry) && isset($matchedEntry['conditions'])) {
$conditionIds = [];
foreach ($matchedEntry['conditions'] as $conditionData) {
if (array_key_exists('id', $conditionData)) {
/** @var ConditionEntity $conditionEntity */
$conditionEntity = $this->conditionRepository->findById($conditionData['id']);
// check if condition exists at all
if (!$conditionEntity) {
throw new FilterDependencyNotFoundException(
self::$conditionEntityName,
$conditionData['id']
);
}
// check if conditions is related with condition group
if ($conditionEntity->getConditionGroup()->getId() !== $conditionGroup->getId()) {
throw new ConditionGroupMismatchException(
$matchedEntry['id']
);
}
$conditionIds[] = $conditionEntity->getId();
} else {
$conditionEntity = new ConditionEntity();
$conditionEntity->setConditionGroup($conditionGroup);
$conditionGroup->addCondition($conditionEntity);
$this->em->persist($conditionEntity);
$conditionIds[] = $conditionEntity->getId();
}
$conditionEntity->setField($this->getProperty($conditionData, 'field', $conditionEntity->getField()));
$conditionEntity->setOperator(
$this->getProperty($conditionData, 'operator', $conditionEntity->getOperator())
);
$conditionEntity->setType($this->getProperty($conditionData, 'type', $conditionEntity->getType()));
$value = $this->getValueForCondition(
$this->getProperty($conditionData, 'value', $conditionEntity->getValue()),
$conditionEntity->getType()
);
$conditionEntity->setValue($value);
}
$this->removeNonExistentConditions($conditionGroup, $conditionIds);
}
return true;
} | [
"protected",
"function",
"updateConditionGroup",
"(",
"ConditionGroupEntity",
"$",
"conditionGroup",
",",
"$",
"matchedEntry",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'id'",
",",
"$",
"matchedEntry",
")",
"&&",
"isset",
"(",
"$",
"matchedEntry",
"[",
"'conditions'",
"]",
")",
")",
"{",
"$",
"conditionIds",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"matchedEntry",
"[",
"'conditions'",
"]",
"as",
"$",
"conditionData",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'id'",
",",
"$",
"conditionData",
")",
")",
"{",
"/** @var ConditionEntity $conditionEntity */",
"$",
"conditionEntity",
"=",
"$",
"this",
"->",
"conditionRepository",
"->",
"findById",
"(",
"$",
"conditionData",
"[",
"'id'",
"]",
")",
";",
"// check if condition exists at all",
"if",
"(",
"!",
"$",
"conditionEntity",
")",
"{",
"throw",
"new",
"FilterDependencyNotFoundException",
"(",
"self",
"::",
"$",
"conditionEntityName",
",",
"$",
"conditionData",
"[",
"'id'",
"]",
")",
";",
"}",
"// check if conditions is related with condition group",
"if",
"(",
"$",
"conditionEntity",
"->",
"getConditionGroup",
"(",
")",
"->",
"getId",
"(",
")",
"!==",
"$",
"conditionGroup",
"->",
"getId",
"(",
")",
")",
"{",
"throw",
"new",
"ConditionGroupMismatchException",
"(",
"$",
"matchedEntry",
"[",
"'id'",
"]",
")",
";",
"}",
"$",
"conditionIds",
"[",
"]",
"=",
"$",
"conditionEntity",
"->",
"getId",
"(",
")",
";",
"}",
"else",
"{",
"$",
"conditionEntity",
"=",
"new",
"ConditionEntity",
"(",
")",
";",
"$",
"conditionEntity",
"->",
"setConditionGroup",
"(",
"$",
"conditionGroup",
")",
";",
"$",
"conditionGroup",
"->",
"addCondition",
"(",
"$",
"conditionEntity",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"conditionEntity",
")",
";",
"$",
"conditionIds",
"[",
"]",
"=",
"$",
"conditionEntity",
"->",
"getId",
"(",
")",
";",
"}",
"$",
"conditionEntity",
"->",
"setField",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"conditionData",
",",
"'field'",
",",
"$",
"conditionEntity",
"->",
"getField",
"(",
")",
")",
")",
";",
"$",
"conditionEntity",
"->",
"setOperator",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"conditionData",
",",
"'operator'",
",",
"$",
"conditionEntity",
"->",
"getOperator",
"(",
")",
")",
")",
";",
"$",
"conditionEntity",
"->",
"setType",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"conditionData",
",",
"'type'",
",",
"$",
"conditionEntity",
"->",
"getType",
"(",
")",
")",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getValueForCondition",
"(",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"conditionData",
",",
"'value'",
",",
"$",
"conditionEntity",
"->",
"getValue",
"(",
")",
")",
",",
"$",
"conditionEntity",
"->",
"getType",
"(",
")",
")",
";",
"$",
"conditionEntity",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"removeNonExistentConditions",
"(",
"$",
"conditionGroup",
",",
"$",
"conditionIds",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Updates the given condition group with the values from the given array.
@param ConditionGroupEntity $conditionGroup
@param array $matchedEntry
@return bool
@throws ConditionGroupMismatchException
@throws FilterDependencyNotFoundException | [
"Updates",
"the",
"given",
"condition",
"group",
"with",
"the",
"values",
"from",
"the",
"given",
"array",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L300-L350 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.getValueForCondition | protected function getValueForCondition($value, $type)
{
// check if date and not a relative value like -1 week
if (DataTypes::DATETIME_TYPE === $type && !preg_match('/[A-Za-z]{3,}/', $value)) {
return (new \DateTime($value))->format(\DateTime::ISO8601);
}
return $value;
} | php | protected function getValueForCondition($value, $type)
{
// check if date and not a relative value like -1 week
if (DataTypes::DATETIME_TYPE === $type && !preg_match('/[A-Za-z]{3,}/', $value)) {
return (new \DateTime($value))->format(\DateTime::ISO8601);
}
return $value;
} | [
"protected",
"function",
"getValueForCondition",
"(",
"$",
"value",
",",
"$",
"type",
")",
"{",
"// check if date and not a relative value like -1 week",
"if",
"(",
"DataTypes",
"::",
"DATETIME_TYPE",
"===",
"$",
"type",
"&&",
"!",
"preg_match",
"(",
"'/[A-Za-z]{3,}/'",
",",
"$",
"value",
")",
")",
"{",
"return",
"(",
"new",
"\\",
"DateTime",
"(",
"$",
"value",
")",
")",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Parses the value for a condition - is mainly used for parsing values with type datetime
but excludes relative values like "-1 week" or "now".
@return string | [
"Parses",
"the",
"value",
"for",
"a",
"condition",
"-",
"is",
"mainly",
"used",
"for",
"parsing",
"values",
"with",
"type",
"datetime",
"but",
"excludes",
"relative",
"values",
"like",
"-",
"1",
"week",
"or",
"now",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L358-L366 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.addConditionGroup | protected function addConditionGroup(Filter $filter, $conditionGroupData)
{
if (array_key_exists('id', $conditionGroupData)) {
throw new EntityIdAlreadySetException(self::$conditionGroupEntityName, $conditionGroupData['id']);
} elseif (array_key_exists('conditions', $conditionGroupData)) {
$conditionGroup = new ConditionGroupEntity();
$conditionGroup->setFilter($filter->getEntity());
foreach ($conditionGroupData['conditions'] as $conditionData) {
if (array_key_exists('id', $conditionData)) {
throw new EntityIdAlreadySetException(self::$conditionEntityName, $conditionData['id']);
} elseif ($this->isValidConditionData($conditionData)) {
$condition = new ConditionEntity();
$condition->setType($conditionData['type']);
$value = $this->getValueForCondition(
$conditionData['value'],
$conditionData['type']
);
$condition->setValue($value);
$condition->setOperator($conditionData['operator']);
$condition->setField($conditionData['field']);
$condition->setConditionGroup($conditionGroup);
$conditionGroup->addCondition($condition);
$conditionGroup->setFilter($filter->getEntity());
$this->em->persist($condition);
}
}
$filter->getEntity()->addConditionGroup($conditionGroup);
$this->em->persist($conditionGroup);
}
return true;
} | php | protected function addConditionGroup(Filter $filter, $conditionGroupData)
{
if (array_key_exists('id', $conditionGroupData)) {
throw new EntityIdAlreadySetException(self::$conditionGroupEntityName, $conditionGroupData['id']);
} elseif (array_key_exists('conditions', $conditionGroupData)) {
$conditionGroup = new ConditionGroupEntity();
$conditionGroup->setFilter($filter->getEntity());
foreach ($conditionGroupData['conditions'] as $conditionData) {
if (array_key_exists('id', $conditionData)) {
throw new EntityIdAlreadySetException(self::$conditionEntityName, $conditionData['id']);
} elseif ($this->isValidConditionData($conditionData)) {
$condition = new ConditionEntity();
$condition->setType($conditionData['type']);
$value = $this->getValueForCondition(
$conditionData['value'],
$conditionData['type']
);
$condition->setValue($value);
$condition->setOperator($conditionData['operator']);
$condition->setField($conditionData['field']);
$condition->setConditionGroup($conditionGroup);
$conditionGroup->addCondition($condition);
$conditionGroup->setFilter($filter->getEntity());
$this->em->persist($condition);
}
}
$filter->getEntity()->addConditionGroup($conditionGroup);
$this->em->persist($conditionGroup);
}
return true;
} | [
"protected",
"function",
"addConditionGroup",
"(",
"Filter",
"$",
"filter",
",",
"$",
"conditionGroupData",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'id'",
",",
"$",
"conditionGroupData",
")",
")",
"{",
"throw",
"new",
"EntityIdAlreadySetException",
"(",
"self",
"::",
"$",
"conditionGroupEntityName",
",",
"$",
"conditionGroupData",
"[",
"'id'",
"]",
")",
";",
"}",
"elseif",
"(",
"array_key_exists",
"(",
"'conditions'",
",",
"$",
"conditionGroupData",
")",
")",
"{",
"$",
"conditionGroup",
"=",
"new",
"ConditionGroupEntity",
"(",
")",
";",
"$",
"conditionGroup",
"->",
"setFilter",
"(",
"$",
"filter",
"->",
"getEntity",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"conditionGroupData",
"[",
"'conditions'",
"]",
"as",
"$",
"conditionData",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'id'",
",",
"$",
"conditionData",
")",
")",
"{",
"throw",
"new",
"EntityIdAlreadySetException",
"(",
"self",
"::",
"$",
"conditionEntityName",
",",
"$",
"conditionData",
"[",
"'id'",
"]",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isValidConditionData",
"(",
"$",
"conditionData",
")",
")",
"{",
"$",
"condition",
"=",
"new",
"ConditionEntity",
"(",
")",
";",
"$",
"condition",
"->",
"setType",
"(",
"$",
"conditionData",
"[",
"'type'",
"]",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getValueForCondition",
"(",
"$",
"conditionData",
"[",
"'value'",
"]",
",",
"$",
"conditionData",
"[",
"'type'",
"]",
")",
";",
"$",
"condition",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"$",
"condition",
"->",
"setOperator",
"(",
"$",
"conditionData",
"[",
"'operator'",
"]",
")",
";",
"$",
"condition",
"->",
"setField",
"(",
"$",
"conditionData",
"[",
"'field'",
"]",
")",
";",
"$",
"condition",
"->",
"setConditionGroup",
"(",
"$",
"conditionGroup",
")",
";",
"$",
"conditionGroup",
"->",
"addCondition",
"(",
"$",
"condition",
")",
";",
"$",
"conditionGroup",
"->",
"setFilter",
"(",
"$",
"filter",
"->",
"getEntity",
"(",
")",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"condition",
")",
";",
"}",
"}",
"$",
"filter",
"->",
"getEntity",
"(",
")",
"->",
"addConditionGroup",
"(",
"$",
"conditionGroup",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"conditionGroup",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Adds a condition group to the given filter.
@param Filter $filter The filter to add the condition group to
@param array $conditionGroupData The array containing the data for the additional condition group
@return bool
@throws EntityIdAlreadySetException
@throws FilterDependencyNotFoundException | [
"Adds",
"a",
"condition",
"group",
"to",
"the",
"given",
"filter",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L379-L412 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.isValidConditionData | protected function isValidConditionData($data)
{
if (!array_key_exists('field', $data)) {
throw new MissingConditionAttributeException('field');
}
if (!array_key_exists('operator', $data)) {
throw new MissingConditionAttributeException('operator');
}
if (!array_key_exists('type', $data)) {
throw new MissingConditionAttributeException('type');
}
if (!array_key_exists('value', $data)) {
throw new MissingConditionAttributeException('value');
}
return true;
} | php | protected function isValidConditionData($data)
{
if (!array_key_exists('field', $data)) {
throw new MissingConditionAttributeException('field');
}
if (!array_key_exists('operator', $data)) {
throw new MissingConditionAttributeException('operator');
}
if (!array_key_exists('type', $data)) {
throw new MissingConditionAttributeException('type');
}
if (!array_key_exists('value', $data)) {
throw new MissingConditionAttributeException('value');
}
return true;
} | [
"protected",
"function",
"isValidConditionData",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'field'",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"MissingConditionAttributeException",
"(",
"'field'",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'operator'",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"MissingConditionAttributeException",
"(",
"'operator'",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'type'",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"MissingConditionAttributeException",
"(",
"'type'",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'value'",
",",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"MissingConditionAttributeException",
"(",
"'value'",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Checks if the given data is correct for a condition.
@param array $data The data to check
@return bool
@throws MissingConditionAttributeException | [
"Checks",
"if",
"the",
"given",
"data",
"is",
"correct",
"for",
"a",
"condition",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L471-L487 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.getFeaturesForContext | public function getFeaturesForContext($context)
{
if ($this->contextConfiguration && array_key_exists($context, $this->contextConfiguration)) {
return $this->contextConfiguration[$context]['features'];
}
return;
} | php | public function getFeaturesForContext($context)
{
if ($this->contextConfiguration && array_key_exists($context, $this->contextConfiguration)) {
return $this->contextConfiguration[$context]['features'];
}
return;
} | [
"public",
"function",
"getFeaturesForContext",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contextConfiguration",
"&&",
"array_key_exists",
"(",
"$",
"context",
",",
"$",
"this",
"->",
"contextConfiguration",
")",
")",
"{",
"return",
"$",
"this",
"->",
"contextConfiguration",
"[",
"$",
"context",
"]",
"[",
"'features'",
"]",
";",
"}",
"return",
";",
"}"
] | Returns the configured features for a context.
@param $context
@return array|null | [
"Returns",
"the",
"configured",
"features",
"for",
"a",
"context",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L506-L513 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.removeNonExistentConditions | protected function removeNonExistentConditions(
$conditionGroup,
$conditionIds
) {
foreach ($conditionGroup->getConditions() as $condition) {
if ($condition->getId() && !in_array($condition->getId(), $conditionIds)) {
$conditionGroup->removeCondition($condition);
$this->em->remove($condition);
}
}
} | php | protected function removeNonExistentConditions(
$conditionGroup,
$conditionIds
) {
foreach ($conditionGroup->getConditions() as $condition) {
if ($condition->getId() && !in_array($condition->getId(), $conditionIds)) {
$conditionGroup->removeCondition($condition);
$this->em->remove($condition);
}
}
} | [
"protected",
"function",
"removeNonExistentConditions",
"(",
"$",
"conditionGroup",
",",
"$",
"conditionIds",
")",
"{",
"foreach",
"(",
"$",
"conditionGroup",
"->",
"getConditions",
"(",
")",
"as",
"$",
"condition",
")",
"{",
"if",
"(",
"$",
"condition",
"->",
"getId",
"(",
")",
"&&",
"!",
"in_array",
"(",
"$",
"condition",
"->",
"getId",
"(",
")",
",",
"$",
"conditionIds",
")",
")",
"{",
"$",
"conditionGroup",
"->",
"removeCondition",
"(",
"$",
"condition",
")",
";",
"$",
"this",
"->",
"em",
"->",
"remove",
"(",
"$",
"condition",
")",
";",
"}",
"}",
"}"
] | Removes conditions from condition groups when they are not in the given array.
@param ConditionGroupEntity $conditionGroup
@param array $conditionIds | [
"Removes",
"conditions",
"from",
"condition",
"groups",
"when",
"they",
"are",
"not",
"in",
"the",
"given",
"array",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L521-L531 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.hasContext | public function hasContext($context)
{
if ($this->contextConfiguration && array_key_exists($context, $this->contextConfiguration)) {
return true;
}
return false;
} | php | public function hasContext($context)
{
if ($this->contextConfiguration && array_key_exists($context, $this->contextConfiguration)) {
return true;
}
return false;
} | [
"public",
"function",
"hasContext",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"contextConfiguration",
"&&",
"array_key_exists",
"(",
"$",
"context",
",",
"$",
"this",
"->",
"contextConfiguration",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if the context exists.
@param $context
@return bool | [
"Checks",
"if",
"the",
"context",
"exists",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L540-L547 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.isFeatureEnabled | public function isFeatureEnabled($context, $feature)
{
if ($this->hasContext($context) &&
false !== array_search($feature, $this->getFeaturesForContext($context))
) {
return true;
}
return false;
} | php | public function isFeatureEnabled($context, $feature)
{
if ($this->hasContext($context) &&
false !== array_search($feature, $this->getFeaturesForContext($context))
) {
return true;
}
return false;
} | [
"public",
"function",
"isFeatureEnabled",
"(",
"$",
"context",
",",
"$",
"feature",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasContext",
"(",
"$",
"context",
")",
"&&",
"false",
"!==",
"array_search",
"(",
"$",
"feature",
",",
"$",
"this",
"->",
"getFeaturesForContext",
"(",
"$",
"context",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks if a feature is enabled for a context.
@param $context
@param $feature
@return bool | [
"Checks",
"if",
"a",
"feature",
"is",
"enabled",
"for",
"a",
"context",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L557-L566 | train |
sulu/sulu | src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php | FilterManager.findFiltersForUserAndContext | public function findFiltersForUserAndContext($context, $userId, $locale)
{
$filters = $this->filterRepository->findByUserAndContextAndLocale($locale, $context, $userId);
array_walk(
$filters,
function(&$filter) use ($locale) {
$filter = new Filter($filter, $locale);
}
);
return $filters;
} | php | public function findFiltersForUserAndContext($context, $userId, $locale)
{
$filters = $this->filterRepository->findByUserAndContextAndLocale($locale, $context, $userId);
array_walk(
$filters,
function(&$filter) use ($locale) {
$filter = new Filter($filter, $locale);
}
);
return $filters;
} | [
"public",
"function",
"findFiltersForUserAndContext",
"(",
"$",
"context",
",",
"$",
"userId",
",",
"$",
"locale",
")",
"{",
"$",
"filters",
"=",
"$",
"this",
"->",
"filterRepository",
"->",
"findByUserAndContextAndLocale",
"(",
"$",
"locale",
",",
"$",
"context",
",",
"$",
"userId",
")",
";",
"array_walk",
"(",
"$",
"filters",
",",
"function",
"(",
"&",
"$",
"filter",
")",
"use",
"(",
"$",
"locale",
")",
"{",
"$",
"filter",
"=",
"new",
"Filter",
"(",
"$",
"filter",
",",
"$",
"locale",
")",
";",
"}",
")",
";",
"return",
"$",
"filters",
";",
"}"
] | Finds all filters filtered by context and user and
for the given locale.
@param string $context
@param $userId
@param string $locale
@return \Sulu\Bundle\ResourceBundle\Api\Filter[] | [
"Finds",
"all",
"filters",
"filtered",
"by",
"context",
"and",
"user",
"and",
"for",
"the",
"given",
"locale",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/ResourceBundle/Resource/FilterManager.php#L578-L589 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php | MediaManager.buildData | private function buildData($uploadedFile, $data, $user)
{
if (!($uploadedFile instanceof UploadedFile)) {
throw new InvalidFileException('Given uploaded file is not of instance UploadedFile');
}
$this->validator->validate($uploadedFile);
$data['storageOptions'] = $this->storage->save(
$uploadedFile->getPathname(),
$this->getNormalizedFileName($uploadedFile->getClientOriginalName())
);
$data['name'] = $uploadedFile->getClientOriginalName();
$data['size'] = $uploadedFile->getSize();
$data['mimeType'] = $uploadedFile->getMimeType();
$data['properties'] = $this->getProperties($uploadedFile);
$data['type'] = [
'id' => $this->typeManager->getMediaType($uploadedFile->getMimeType()),
];
return $this->createMedia($data, $user);
} | php | private function buildData($uploadedFile, $data, $user)
{
if (!($uploadedFile instanceof UploadedFile)) {
throw new InvalidFileException('Given uploaded file is not of instance UploadedFile');
}
$this->validator->validate($uploadedFile);
$data['storageOptions'] = $this->storage->save(
$uploadedFile->getPathname(),
$this->getNormalizedFileName($uploadedFile->getClientOriginalName())
);
$data['name'] = $uploadedFile->getClientOriginalName();
$data['size'] = $uploadedFile->getSize();
$data['mimeType'] = $uploadedFile->getMimeType();
$data['properties'] = $this->getProperties($uploadedFile);
$data['type'] = [
'id' => $this->typeManager->getMediaType($uploadedFile->getMimeType()),
];
return $this->createMedia($data, $user);
} | [
"private",
"function",
"buildData",
"(",
"$",
"uploadedFile",
",",
"$",
"data",
",",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"uploadedFile",
"instanceof",
"UploadedFile",
")",
")",
"{",
"throw",
"new",
"InvalidFileException",
"(",
"'Given uploaded file is not of instance UploadedFile'",
")",
";",
"}",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"$",
"uploadedFile",
")",
";",
"$",
"data",
"[",
"'storageOptions'",
"]",
"=",
"$",
"this",
"->",
"storage",
"->",
"save",
"(",
"$",
"uploadedFile",
"->",
"getPathname",
"(",
")",
",",
"$",
"this",
"->",
"getNormalizedFileName",
"(",
"$",
"uploadedFile",
"->",
"getClientOriginalName",
"(",
")",
")",
")",
";",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"uploadedFile",
"->",
"getClientOriginalName",
"(",
")",
";",
"$",
"data",
"[",
"'size'",
"]",
"=",
"$",
"uploadedFile",
"->",
"getSize",
"(",
")",
";",
"$",
"data",
"[",
"'mimeType'",
"]",
"=",
"$",
"uploadedFile",
"->",
"getMimeType",
"(",
")",
";",
"$",
"data",
"[",
"'properties'",
"]",
"=",
"$",
"this",
"->",
"getProperties",
"(",
"$",
"uploadedFile",
")",
";",
"$",
"data",
"[",
"'type'",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"typeManager",
"->",
"getMediaType",
"(",
"$",
"uploadedFile",
"->",
"getMimeType",
"(",
")",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"createMedia",
"(",
"$",
"data",
",",
"$",
"user",
")",
";",
"}"
] | Prepares data.
@param UploadedFile $uploadedFile
@param array $data
@param UserInterface $user
@return Media
@throws InvalidFileException | [
"Prepares",
"data",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php#L461-L483 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php | MediaManager.createMedia | protected function createMedia($data, $user)
{
$mediaEntity = $this->mediaRepository->createNew();
$mediaEntity->setCreator($user);
$mediaEntity->setChanger($user);
$file = new File();
$file->setCreator($user);
$file->setChanger($user);
$file->setVersion(1);
$file->setMedia($mediaEntity);
$fileVersion = new FileVersion();
$fileVersion->setCreator($user);
$fileVersion->setChanger($user);
$fileVersion->setVersion(1);
$fileVersion->setFile($file);
$file->addFileVersion($fileVersion);
$mediaEntity->addFile($file);
$media = new Media($mediaEntity, $data['locale'], null);
$media = $this->setDataToMedia(
$media,
$data,
$user
);
$fileVersion->setDefaultMeta($fileVersion->getMeta()->first());
$mediaEntity = $media->getEntity();
$this->em->persist($mediaEntity);
$this->em->flush();
return $media;
} | php | protected function createMedia($data, $user)
{
$mediaEntity = $this->mediaRepository->createNew();
$mediaEntity->setCreator($user);
$mediaEntity->setChanger($user);
$file = new File();
$file->setCreator($user);
$file->setChanger($user);
$file->setVersion(1);
$file->setMedia($mediaEntity);
$fileVersion = new FileVersion();
$fileVersion->setCreator($user);
$fileVersion->setChanger($user);
$fileVersion->setVersion(1);
$fileVersion->setFile($file);
$file->addFileVersion($fileVersion);
$mediaEntity->addFile($file);
$media = new Media($mediaEntity, $data['locale'], null);
$media = $this->setDataToMedia(
$media,
$data,
$user
);
$fileVersion->setDefaultMeta($fileVersion->getMeta()->first());
$mediaEntity = $media->getEntity();
$this->em->persist($mediaEntity);
$this->em->flush();
return $media;
} | [
"protected",
"function",
"createMedia",
"(",
"$",
"data",
",",
"$",
"user",
")",
"{",
"$",
"mediaEntity",
"=",
"$",
"this",
"->",
"mediaRepository",
"->",
"createNew",
"(",
")",
";",
"$",
"mediaEntity",
"->",
"setCreator",
"(",
"$",
"user",
")",
";",
"$",
"mediaEntity",
"->",
"setChanger",
"(",
"$",
"user",
")",
";",
"$",
"file",
"=",
"new",
"File",
"(",
")",
";",
"$",
"file",
"->",
"setCreator",
"(",
"$",
"user",
")",
";",
"$",
"file",
"->",
"setChanger",
"(",
"$",
"user",
")",
";",
"$",
"file",
"->",
"setVersion",
"(",
"1",
")",
";",
"$",
"file",
"->",
"setMedia",
"(",
"$",
"mediaEntity",
")",
";",
"$",
"fileVersion",
"=",
"new",
"FileVersion",
"(",
")",
";",
"$",
"fileVersion",
"->",
"setCreator",
"(",
"$",
"user",
")",
";",
"$",
"fileVersion",
"->",
"setChanger",
"(",
"$",
"user",
")",
";",
"$",
"fileVersion",
"->",
"setVersion",
"(",
"1",
")",
";",
"$",
"fileVersion",
"->",
"setFile",
"(",
"$",
"file",
")",
";",
"$",
"file",
"->",
"addFileVersion",
"(",
"$",
"fileVersion",
")",
";",
"$",
"mediaEntity",
"->",
"addFile",
"(",
"$",
"file",
")",
";",
"$",
"media",
"=",
"new",
"Media",
"(",
"$",
"mediaEntity",
",",
"$",
"data",
"[",
"'locale'",
"]",
",",
"null",
")",
";",
"$",
"media",
"=",
"$",
"this",
"->",
"setDataToMedia",
"(",
"$",
"media",
",",
"$",
"data",
",",
"$",
"user",
")",
";",
"$",
"fileVersion",
"->",
"setDefaultMeta",
"(",
"$",
"fileVersion",
"->",
"getMeta",
"(",
")",
"->",
"first",
"(",
")",
")",
";",
"$",
"mediaEntity",
"=",
"$",
"media",
"->",
"getEntity",
"(",
")",
";",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"mediaEntity",
")",
";",
"$",
"this",
"->",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"media",
";",
"}"
] | Create a new media.
@param $data
@param $user
@return Media | [
"Create",
"a",
"new",
"media",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php#L493-L529 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php | MediaManager.getCurrentUser | protected function getCurrentUser()
{
if (!$this->tokenStorage) {
return;
}
if (!$this->tokenStorage->getToken()) {
return;
}
$user = $this->tokenStorage->getToken()->getUser();
if ($user instanceof UserInterface) {
return $user;
}
return;
} | php | protected function getCurrentUser()
{
if (!$this->tokenStorage) {
return;
}
if (!$this->tokenStorage->getToken()) {
return;
}
$user = $this->tokenStorage->getToken()->getUser();
if ($user instanceof UserInterface) {
return $user;
}
return;
} | [
"protected",
"function",
"getCurrentUser",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"tokenStorage",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"user",
"=",
"$",
"this",
"->",
"tokenStorage",
"->",
"getToken",
"(",
")",
"->",
"getUser",
"(",
")",
";",
"if",
"(",
"$",
"user",
"instanceof",
"UserInterface",
")",
"{",
"return",
"$",
"user",
";",
"}",
"return",
";",
"}"
] | Returns current user or null if no user is loggedin.
@return UserInterface|void | [
"Returns",
"current",
"user",
"or",
"null",
"if",
"no",
"user",
"is",
"loggedin",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php#L908-L925 | train |
sulu/sulu | src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php | MediaManager.getNormalizedFileName | private function getNormalizedFileName($originalFileName)
{
if (false !== strpos($originalFileName, '.')) {
$pathParts = pathinfo($originalFileName);
$fileName = $this->pathCleaner->cleanup($pathParts['filename']);
$fileName .= '.' . $pathParts['extension'];
} else {
$fileName = $this->pathCleaner->cleanup($originalFileName);
}
return $fileName;
} | php | private function getNormalizedFileName($originalFileName)
{
if (false !== strpos($originalFileName, '.')) {
$pathParts = pathinfo($originalFileName);
$fileName = $this->pathCleaner->cleanup($pathParts['filename']);
$fileName .= '.' . $pathParts['extension'];
} else {
$fileName = $this->pathCleaner->cleanup($originalFileName);
}
return $fileName;
} | [
"private",
"function",
"getNormalizedFileName",
"(",
"$",
"originalFileName",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"originalFileName",
",",
"'.'",
")",
")",
"{",
"$",
"pathParts",
"=",
"pathinfo",
"(",
"$",
"originalFileName",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"pathCleaner",
"->",
"cleanup",
"(",
"$",
"pathParts",
"[",
"'filename'",
"]",
")",
";",
"$",
"fileName",
".=",
"'.'",
".",
"$",
"pathParts",
"[",
"'extension'",
"]",
";",
"}",
"else",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"pathCleaner",
"->",
"cleanup",
"(",
"$",
"originalFileName",
")",
";",
"}",
"return",
"$",
"fileName",
";",
"}"
] | Returns file name without special characters and preserves file extension.
@param $originalFileName
@return string | [
"Returns",
"file",
"name",
"without",
"special",
"characters",
"and",
"preserves",
"file",
"extension",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/MediaBundle/Media/Manager/MediaManager.php#L934-L945 | train |
sulu/sulu | src/Sulu/Bundle/LocationBundle/Geolocator/GeolocatorResponse.php | GeolocatorResponse.toArray | public function toArray()
{
$res = [];
foreach ($this->locations as $location) {
$res[] = $location->toArray();
}
return $res;
} | php | public function toArray()
{
$res = [];
foreach ($this->locations as $location) {
$res[] = $location->toArray();
}
return $res;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"res",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"locations",
"as",
"$",
"location",
")",
"{",
"$",
"res",
"[",
"]",
"=",
"$",
"location",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
"$",
"res",
";",
"}"
] | Return an array representation of the response.
@return array | [
"Return",
"an",
"array",
"representation",
"of",
"the",
"response",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/LocationBundle/Geolocator/GeolocatorResponse.php#L36-L44 | train |
sulu/sulu | src/Sulu/Bundle/DocumentManagerBundle/Initializer/Initializer.php | Initializer.initialize | public function initialize(OutputInterface $output = null, $purge = false)
{
$output = $output ?: new NullOutput();
arsort($this->initializerMap);
foreach (array_keys($this->initializerMap) as $initializerId) {
$output->writeln(sprintf('<comment>%s</>', $initializerId));
$initializer = $this->container->get($initializerId);
$initializer->initialize($output, $purge);
}
$output->write(PHP_EOL);
$output->writeln('<comment>*</> Legend: [+] Added [*] Updated [-] Purged [ ] No change');
} | php | public function initialize(OutputInterface $output = null, $purge = false)
{
$output = $output ?: new NullOutput();
arsort($this->initializerMap);
foreach (array_keys($this->initializerMap) as $initializerId) {
$output->writeln(sprintf('<comment>%s</>', $initializerId));
$initializer = $this->container->get($initializerId);
$initializer->initialize($output, $purge);
}
$output->write(PHP_EOL);
$output->writeln('<comment>*</> Legend: [+] Added [*] Updated [-] Purged [ ] No change');
} | [
"public",
"function",
"initialize",
"(",
"OutputInterface",
"$",
"output",
"=",
"null",
",",
"$",
"purge",
"=",
"false",
")",
"{",
"$",
"output",
"=",
"$",
"output",
"?",
":",
"new",
"NullOutput",
"(",
")",
";",
"arsort",
"(",
"$",
"this",
"->",
"initializerMap",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"initializerMap",
")",
"as",
"$",
"initializerId",
")",
"{",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'<comment>%s</>'",
",",
"$",
"initializerId",
")",
")",
";",
"$",
"initializer",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"initializerId",
")",
";",
"$",
"initializer",
"->",
"initialize",
"(",
"$",
"output",
",",
"$",
"purge",
")",
";",
"}",
"$",
"output",
"->",
"write",
"(",
"PHP_EOL",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"'<comment>*</> Legend: [+] Added [*] Updated [-] Purged [ ] No change'",
")",
";",
"}"
] | Initialize the content repository, optionally purging it before-hand.
@param OutputInterface $output
@param bool $purge | [
"Initialize",
"the",
"content",
"repository",
"optionally",
"purging",
"it",
"before",
"-",
"hand",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Bundle/DocumentManagerBundle/Initializer/Initializer.php#L52-L65 | train |
sulu/sulu | src/Sulu/Component/Webspace/Manager/WebspaceManager.php | WebspaceManager.getWebspaceCollection | public function getWebspaceCollection()
{
if (null === $this->webspaceCollection) {
$class = $this->options['cache_class'];
$cache = new ConfigCache(
$this->options['cache_dir'] . '/' . $class . '.php',
$this->options['debug']
);
if (!$cache->isFresh()) {
$webspaceCollectionBuilder = new WebspaceCollectionBuilder(
$this->loader,
$this->urlReplacer,
$this->options['config_dir']
);
$webspaceCollection = $webspaceCollectionBuilder->build();
$dumper = new PhpWebspaceCollectionDumper($webspaceCollection);
$cache->write(
$dumper->dump(
[
'cache_class' => $class,
'base_class' => $this->options['base_class'],
]
),
$webspaceCollection->getResources()
);
}
require_once $cache->getPath();
$this->webspaceCollection = new $class();
}
return $this->webspaceCollection;
} | php | public function getWebspaceCollection()
{
if (null === $this->webspaceCollection) {
$class = $this->options['cache_class'];
$cache = new ConfigCache(
$this->options['cache_dir'] . '/' . $class . '.php',
$this->options['debug']
);
if (!$cache->isFresh()) {
$webspaceCollectionBuilder = new WebspaceCollectionBuilder(
$this->loader,
$this->urlReplacer,
$this->options['config_dir']
);
$webspaceCollection = $webspaceCollectionBuilder->build();
$dumper = new PhpWebspaceCollectionDumper($webspaceCollection);
$cache->write(
$dumper->dump(
[
'cache_class' => $class,
'base_class' => $this->options['base_class'],
]
),
$webspaceCollection->getResources()
);
}
require_once $cache->getPath();
$this->webspaceCollection = new $class();
}
return $this->webspaceCollection;
} | [
"public",
"function",
"getWebspaceCollection",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"webspaceCollection",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"options",
"[",
"'cache_class'",
"]",
";",
"$",
"cache",
"=",
"new",
"ConfigCache",
"(",
"$",
"this",
"->",
"options",
"[",
"'cache_dir'",
"]",
".",
"'/'",
".",
"$",
"class",
".",
"'.php'",
",",
"$",
"this",
"->",
"options",
"[",
"'debug'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"cache",
"->",
"isFresh",
"(",
")",
")",
"{",
"$",
"webspaceCollectionBuilder",
"=",
"new",
"WebspaceCollectionBuilder",
"(",
"$",
"this",
"->",
"loader",
",",
"$",
"this",
"->",
"urlReplacer",
",",
"$",
"this",
"->",
"options",
"[",
"'config_dir'",
"]",
")",
";",
"$",
"webspaceCollection",
"=",
"$",
"webspaceCollectionBuilder",
"->",
"build",
"(",
")",
";",
"$",
"dumper",
"=",
"new",
"PhpWebspaceCollectionDumper",
"(",
"$",
"webspaceCollection",
")",
";",
"$",
"cache",
"->",
"write",
"(",
"$",
"dumper",
"->",
"dump",
"(",
"[",
"'cache_class'",
"=>",
"$",
"class",
",",
"'base_class'",
"=>",
"$",
"this",
"->",
"options",
"[",
"'base_class'",
"]",
",",
"]",
")",
",",
"$",
"webspaceCollection",
"->",
"getResources",
"(",
")",
")",
";",
"}",
"require_once",
"$",
"cache",
"->",
"getPath",
"(",
")",
";",
"$",
"this",
"->",
"webspaceCollection",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"webspaceCollection",
";",
"}"
] | Returns all the webspaces managed by this specific instance.
@return WebspaceCollection | [
"Returns",
"all",
"the",
"webspaces",
"managed",
"by",
"this",
"specific",
"instance",
"."
] | 6766a36cc2f0c807c59202bf7540a08c4ef31192 | https://github.com/sulu/sulu/blob/6766a36cc2f0c807c59202bf7540a08c4ef31192/src/Sulu/Component/Webspace/Manager/WebspaceManager.php#L294-L328 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.