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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findByIdentifierWithoutReduce | public function findByIdentifierWithoutReduce($identifier, Workspace $workspace)
{
$workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
$queryBuilder = $this->createQueryBuilder($workspaces);
$this->addIdentifierConstraintToQueryBuilder($queryBuilder, $identifier);
$query = $queryBuilder->getQuery();
$foundNodes = $query->getResult();
return $foundNodes;
} | php | public function findByIdentifierWithoutReduce($identifier, Workspace $workspace)
{
$workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
$queryBuilder = $this->createQueryBuilder($workspaces);
$this->addIdentifierConstraintToQueryBuilder($queryBuilder, $identifier);
$query = $queryBuilder->getQuery();
$foundNodes = $query->getResult();
return $foundNodes;
} | [
"public",
"function",
"findByIdentifierWithoutReduce",
"(",
"$",
"identifier",
",",
"Workspace",
"$",
"workspace",
")",
"{",
"$",
"workspaces",
"=",
"$",
"this",
"->",
"collectWorkspaceAndAllBaseWorkspaces",
"(",
"$",
"workspace",
")",
";",
"$",
"queryBuilder",
"=... | Find NodeData by identifier path without any dimension reduction
Only used internally for finding whether the node exists in another dimension
@param string $identifier
@param Workspace $workspace
@return array<\Neos\ContentRepository\Domain\Model\NodeData> A unreduced array of NodeData | [
"Find",
"NodeData",
"by",
"identifier",
"path",
"without",
"any",
"dimension",
"reduction"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L669-L680 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.openIndexSpace | protected function openIndexSpace($parentPath, $referenceIndex)
{
$this->systemLogger->info(sprintf('Opening sortindex space after index %s at path %s.', $referenceIndex, $parentPath), LogEnvironment::fromMethodName(__METHOD__));
/** @var Query $query */
$query = $this->entityManager->createQuery('SELECT n.Persistence_Object_Identifier identifier, n.index, n.path FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash ORDER BY n.index ASC');
$query->setParameter('parentPathHash', md5($parentPath));
$nodesOnLevel = [];
/** @var $node NodeData */
foreach ($query->getArrayResult() as $node) {
$nodesOnLevel[] = [
'identifier' => $node['identifier'],
'path' => $node['path'],
'index' => $node['index']
];
}
/** @var $node NodeData */
foreach ($this->addedNodes as $node) {
if ($node->getParentPath() === $parentPath) {
$nodesOnLevel[] = [
'addedNode' => $node,
'path' => $node->getPath(),
'index' => $node->getIndex()
];
}
}
$query = $this->entityManager->createQuery('UPDATE Neos\ContentRepository\Domain\Model\NodeData n SET n.index = :index WHERE n.Persistence_Object_Identifier = :identifier');
foreach ($nodesOnLevel as $node) {
if ($node['index'] < $referenceIndex) {
continue;
}
$newIndex = $node['index'] + 100;
if ($newIndex > self::INDEX_MAXIMUM) {
throw new Exception\NodeException(sprintf('Reached maximum node index of %s while setting index of node %s.', $newIndex, $node['path']), 1317140402);
}
if (isset($node['addedNode'])) {
$node['addedNode']->setIndex($newIndex);
} else {
if ($entity = $this->entityManager->getUnitOfWork()->tryGetById($node['identifier'], NodeData::class)) {
$entity->setIndex($newIndex);
}
$query->setParameter('index', $newIndex);
$query->setParameter('identifier', $node['identifier']);
$query->execute();
}
}
} | php | protected function openIndexSpace($parentPath, $referenceIndex)
{
$this->systemLogger->info(sprintf('Opening sortindex space after index %s at path %s.', $referenceIndex, $parentPath), LogEnvironment::fromMethodName(__METHOD__));
/** @var Query $query */
$query = $this->entityManager->createQuery('SELECT n.Persistence_Object_Identifier identifier, n.index, n.path FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash ORDER BY n.index ASC');
$query->setParameter('parentPathHash', md5($parentPath));
$nodesOnLevel = [];
/** @var $node NodeData */
foreach ($query->getArrayResult() as $node) {
$nodesOnLevel[] = [
'identifier' => $node['identifier'],
'path' => $node['path'],
'index' => $node['index']
];
}
/** @var $node NodeData */
foreach ($this->addedNodes as $node) {
if ($node->getParentPath() === $parentPath) {
$nodesOnLevel[] = [
'addedNode' => $node,
'path' => $node->getPath(),
'index' => $node->getIndex()
];
}
}
$query = $this->entityManager->createQuery('UPDATE Neos\ContentRepository\Domain\Model\NodeData n SET n.index = :index WHERE n.Persistence_Object_Identifier = :identifier');
foreach ($nodesOnLevel as $node) {
if ($node['index'] < $referenceIndex) {
continue;
}
$newIndex = $node['index'] + 100;
if ($newIndex > self::INDEX_MAXIMUM) {
throw new Exception\NodeException(sprintf('Reached maximum node index of %s while setting index of node %s.', $newIndex, $node['path']), 1317140402);
}
if (isset($node['addedNode'])) {
$node['addedNode']->setIndex($newIndex);
} else {
if ($entity = $this->entityManager->getUnitOfWork()->tryGetById($node['identifier'], NodeData::class)) {
$entity->setIndex($newIndex);
}
$query->setParameter('index', $newIndex);
$query->setParameter('identifier', $node['identifier']);
$query->execute();
}
}
} | [
"protected",
"function",
"openIndexSpace",
"(",
"$",
"parentPath",
",",
"$",
"referenceIndex",
")",
"{",
"$",
"this",
"->",
"systemLogger",
"->",
"info",
"(",
"sprintf",
"(",
"'Opening sortindex space after index %s at path %s.'",
",",
"$",
"referenceIndex",
",",
"$... | Make room in the sortindex-index space of a given path in preparation to inserting a node.
All indices that are greater or equal to the given referenceIndex are incremented by 100
@param string $parentPath
@param integer $referenceIndex
@throws Exception\NodeException | [
"Make",
"room",
"in",
"the",
"sortindex",
"-",
"index",
"space",
"of",
"a",
"given",
"path",
"in",
"preparation",
"to",
"inserting",
"a",
"node",
".",
"All",
"indices",
"that",
"are",
"greater",
"or",
"equal",
"to",
"the",
"given",
"referenceIndex",
"are",... | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L732-L781 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findNextFreeIndexInParentPath | protected function findNextFreeIndexInParentPath($parentPath)
{
if (!isset($this->highestIndexCache[$parentPath])) {
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery('SELECT MAX(n.index) FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash');
$query->setParameter('parentPathHash', md5($parentPath));
$this->highestIndexCache[$parentPath] = $query->getSingleScalarResult() ?: 0;
}
$this->highestIndexCache[$parentPath] += 100;
return $this->highestIndexCache[$parentPath];
} | php | protected function findNextFreeIndexInParentPath($parentPath)
{
if (!isset($this->highestIndexCache[$parentPath])) {
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery('SELECT MAX(n.index) FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash');
$query->setParameter('parentPathHash', md5($parentPath));
$this->highestIndexCache[$parentPath] = $query->getSingleScalarResult() ?: 0;
}
$this->highestIndexCache[$parentPath] += 100;
return $this->highestIndexCache[$parentPath];
} | [
"protected",
"function",
"findNextFreeIndexInParentPath",
"(",
"$",
"parentPath",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"highestIndexCache",
"[",
"$",
"parentPath",
"]",
")",
")",
"{",
"/** @var \\Doctrine\\ORM\\Query $query */",
"$",
"query",... | Finds the next free index on the level below the given parent path
across all workspaces.
@param string $parentPath Path of the parent node specifying the level in the node tree
@return integer The next available index | [
"Finds",
"the",
"next",
"free",
"index",
"on",
"the",
"level",
"below",
"the",
"given",
"parent",
"path",
"across",
"all",
"workspaces",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L790-L802 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findNextLowerIndex | protected function findNextLowerIndex($parentPath, $referenceIndex)
{
$this->persistEntities();
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery('SELECT MAX(n.index) FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash AND n.index < :referenceIndex');
$query->setParameter('parentPathHash', md5($parentPath));
$query->setParameter('referenceIndex', $referenceIndex);
return $query->getSingleScalarResult() ?: 0;
} | php | protected function findNextLowerIndex($parentPath, $referenceIndex)
{
$this->persistEntities();
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery('SELECT MAX(n.index) FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash AND n.index < :referenceIndex');
$query->setParameter('parentPathHash', md5($parentPath));
$query->setParameter('referenceIndex', $referenceIndex);
return $query->getSingleScalarResult() ?: 0;
} | [
"protected",
"function",
"findNextLowerIndex",
"(",
"$",
"parentPath",
",",
"$",
"referenceIndex",
")",
"{",
"$",
"this",
"->",
"persistEntities",
"(",
")",
";",
"/** @var \\Doctrine\\ORM\\Query $query */",
"$",
"query",
"=",
"$",
"this",
"->",
"entityManager",
"-... | Returns the next-lower-index seen from the given reference index in the
level below the specified parent path. If no node with a lower than the
given index exists at that level, the reference index is returned.
The result is determined workspace-agnostic.
@param string $parentPath Path of the parent node specifying the level in the node tree
@param integer $referenceIndex Index of a known node
@return integer The currently next lower index | [
"Returns",
"the",
"next",
"-",
"lower",
"-",
"index",
"seen",
"from",
"the",
"given",
"reference",
"index",
"in",
"the",
"level",
"below",
"the",
"specified",
"parent",
"path",
".",
"If",
"no",
"node",
"with",
"a",
"lower",
"than",
"the",
"given",
"index... | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L825-L834 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findNextHigherIndex | protected function findNextHigherIndex($parentPath, $referenceIndex)
{
if (isset($this->highestIndexCache[$parentPath]) && $this->highestIndexCache[$parentPath] === $referenceIndex) {
null;
}
$this->persistEntities();
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery('SELECT MIN(n.index) FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash AND n.index > :referenceIndex');
$query->setParameter('parentPathHash', md5($parentPath));
$query->setParameter('referenceIndex', $referenceIndex);
return $query->getSingleScalarResult() ?: null;
} | php | protected function findNextHigherIndex($parentPath, $referenceIndex)
{
if (isset($this->highestIndexCache[$parentPath]) && $this->highestIndexCache[$parentPath] === $referenceIndex) {
null;
}
$this->persistEntities();
/** @var \Doctrine\ORM\Query $query */
$query = $this->entityManager->createQuery('SELECT MIN(n.index) FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.parentPathHash = :parentPathHash AND n.index > :referenceIndex');
$query->setParameter('parentPathHash', md5($parentPath));
$query->setParameter('referenceIndex', $referenceIndex);
return $query->getSingleScalarResult() ?: null;
} | [
"protected",
"function",
"findNextHigherIndex",
"(",
"$",
"parentPath",
",",
"$",
"referenceIndex",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"highestIndexCache",
"[",
"$",
"parentPath",
"]",
")",
"&&",
"$",
"this",
"->",
"highestIndexCache",
"["... | Returns the next-higher-index seen from the given reference index in the
level below the specified parent path. If no node with a higher than the
given index exists at that level, NULL is returned.
The result is determined workspace-agnostic.
@param string $parentPath Path of the parent node specifying the level in the node tree
@param integer $referenceIndex Index of a known node
@return integer The currently next higher index or NULL if no node with a higher index exists | [
"Returns",
"the",
"next",
"-",
"higher",
"-",
"index",
"seen",
"from",
"the",
"given",
"reference",
"index",
"in",
"the",
"level",
"below",
"the",
"specified",
"parent",
"path",
".",
"If",
"no",
"node",
"with",
"a",
"higher",
"than",
"the",
"given",
"ind... | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L847-L859 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.countByWorkspace | public function countByWorkspace(Workspace $workspace)
{
$query = $this->createQuery();
$nodesInDatabase = $query->matching($query->equals('workspace', $workspace))->execute()->count();
$nodesInMemory = 0;
/** @var $node NodeData */
foreach ($this->addedNodes as $node) {
if ($node->getWorkspace()->getName() === $workspace->getName()) {
$nodesInMemory++;
}
}
return $nodesInDatabase + $nodesInMemory;
} | php | public function countByWorkspace(Workspace $workspace)
{
$query = $this->createQuery();
$nodesInDatabase = $query->matching($query->equals('workspace', $workspace))->execute()->count();
$nodesInMemory = 0;
/** @var $node NodeData */
foreach ($this->addedNodes as $node) {
if ($node->getWorkspace()->getName() === $workspace->getName()) {
$nodesInMemory++;
}
}
return $nodesInDatabase + $nodesInMemory;
} | [
"public",
"function",
"countByWorkspace",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
")",
";",
"$",
"nodesInDatabase",
"=",
"$",
"query",
"->",
"matching",
"(",
"$",
"query",
"->",
"equals",
"(... | Counts the number of nodes within the specified workspace
Note: Also counts removed nodes
@param Workspace $workspace The containing workspace
@return integer The number of nodes found | [
"Counts",
"the",
"number",
"of",
"nodes",
"within",
"the",
"specified",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L869-L883 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.sortNodesByIndex | protected function sortNodesByIndex(array $nodes)
{
usort($nodes, function (NodeData $node1, NodeData $node2) {
if ($node1->getIndex() < $node2->getIndex()) {
return -1;
} elseif ($node1->getIndex() > $node2->getIndex()) {
return 1;
} else {
return strcmp($node1->getIdentifier(), $node2->getIdentifier());
}
});
return $nodes;
} | php | protected function sortNodesByIndex(array $nodes)
{
usort($nodes, function (NodeData $node1, NodeData $node2) {
if ($node1->getIndex() < $node2->getIndex()) {
return -1;
} elseif ($node1->getIndex() > $node2->getIndex()) {
return 1;
} else {
return strcmp($node1->getIdentifier(), $node2->getIdentifier());
}
});
return $nodes;
} | [
"protected",
"function",
"sortNodesByIndex",
"(",
"array",
"$",
"nodes",
")",
"{",
"usort",
"(",
"$",
"nodes",
",",
"function",
"(",
"NodeData",
"$",
"node1",
",",
"NodeData",
"$",
"node2",
")",
"{",
"if",
"(",
"$",
"node1",
"->",
"getIndex",
"(",
")",... | Sorts the given nodes by their index
@param array $nodes Nodes
@return array Nodes sorted by index | [
"Sorts",
"the",
"given",
"nodes",
"by",
"their",
"index"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L891-L904 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findByProperties | public function findByProperties($term, $nodeTypeFilter, $workspace, $dimensions, $pathStartingPoint = null)
{
if (empty($term)) {
throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
}
$workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
$queryBuilder = $this->createQueryBuilder($workspaces);
$this->addDimensionJoinConstraintsToQueryBuilder($queryBuilder, $dimensions);
$this->addNodeTypeFilterConstraintsToQueryBuilder($queryBuilder, $nodeTypeFilter);
if (is_array($term)) {
if (count($term) !== 1) {
throw new \InvalidArgumentException('Currently only a 1-dimensional key => value array term is supported.', 1460437584);
}
// Build the like parameter as "key": "value" to search by a specific key and value
$likeParameter = '%' . UnicodeFunctions::strtolower(trim(json_encode($term, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE), "{}\n\t ")) . '%';
} else {
// Convert to lowercase, then to json, and then trim quotes from json to have valid JSON escaping.
$likeParameter = '%' . trim(json_encode(UnicodeFunctions::strtolower($term), JSON_UNESCAPED_UNICODE), '"') . '%';
}
$queryBuilder->andWhere("LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :term")->setParameter('term', $likeParameter);
if (strlen($pathStartingPoint) > 0) {
$pathStartingPoint = strtolower($pathStartingPoint);
$queryBuilder->andWhere(
$queryBuilder->expr()->orx()
->add($queryBuilder->expr()->eq('n.parentPathHash', ':parentPathHash'))
->add($queryBuilder->expr()->eq('n.pathHash', ':pathHash'))
->add($queryBuilder->expr()->like('n.parentPath', ':parentPath')))
->setParameter('parentPathHash', md5($pathStartingPoint))
->setParameter('pathHash', md5($pathStartingPoint))
->setParameter('parentPath', rtrim($pathStartingPoint, '/') . '/%');
}
$query = $queryBuilder->getQuery();
$foundNodes = $query->getResult();
$foundNodes = $this->reduceNodeVariantsByWorkspacesAndDimensions($foundNodes, $workspaces, $dimensions);
$foundNodes = $this->withoutRemovedNodes($foundNodes);
return $foundNodes;
} | php | public function findByProperties($term, $nodeTypeFilter, $workspace, $dimensions, $pathStartingPoint = null)
{
if (empty($term)) {
throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
}
$workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
$queryBuilder = $this->createQueryBuilder($workspaces);
$this->addDimensionJoinConstraintsToQueryBuilder($queryBuilder, $dimensions);
$this->addNodeTypeFilterConstraintsToQueryBuilder($queryBuilder, $nodeTypeFilter);
if (is_array($term)) {
if (count($term) !== 1) {
throw new \InvalidArgumentException('Currently only a 1-dimensional key => value array term is supported.', 1460437584);
}
// Build the like parameter as "key": "value" to search by a specific key and value
$likeParameter = '%' . UnicodeFunctions::strtolower(trim(json_encode($term, JSON_PRETTY_PRINT | JSON_FORCE_OBJECT | JSON_UNESCAPED_UNICODE), "{}\n\t ")) . '%';
} else {
// Convert to lowercase, then to json, and then trim quotes from json to have valid JSON escaping.
$likeParameter = '%' . trim(json_encode(UnicodeFunctions::strtolower($term), JSON_UNESCAPED_UNICODE), '"') . '%';
}
$queryBuilder->andWhere("LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :term")->setParameter('term', $likeParameter);
if (strlen($pathStartingPoint) > 0) {
$pathStartingPoint = strtolower($pathStartingPoint);
$queryBuilder->andWhere(
$queryBuilder->expr()->orx()
->add($queryBuilder->expr()->eq('n.parentPathHash', ':parentPathHash'))
->add($queryBuilder->expr()->eq('n.pathHash', ':pathHash'))
->add($queryBuilder->expr()->like('n.parentPath', ':parentPath')))
->setParameter('parentPathHash', md5($pathStartingPoint))
->setParameter('pathHash', md5($pathStartingPoint))
->setParameter('parentPath', rtrim($pathStartingPoint, '/') . '/%');
}
$query = $queryBuilder->getQuery();
$foundNodes = $query->getResult();
$foundNodes = $this->reduceNodeVariantsByWorkspacesAndDimensions($foundNodes, $workspaces, $dimensions);
$foundNodes = $this->withoutRemovedNodes($foundNodes);
return $foundNodes;
} | [
"public",
"function",
"findByProperties",
"(",
"$",
"term",
",",
"$",
"nodeTypeFilter",
",",
"$",
"workspace",
",",
"$",
"dimensions",
",",
"$",
"pathStartingPoint",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"term",
")",
")",
"{",
"throw",
"... | Find nodes by a value in properties
This method is internal and will be replaced with better search capabilities.
@param string|array $term Search term
@param string $nodeTypeFilter Node type filter
@param Workspace $workspace
@param array $dimensions
@param string $pathStartingPoint
@return array<\Neos\ContentRepository\Domain\Model\NodeData> | [
"Find",
"nodes",
"by",
"a",
"value",
"in",
"properties"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1029-L1072 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.addNodeTypeFilterConstraintsToQueryBuilder | public function addNodeTypeFilterConstraintsToQueryBuilder(QueryBuilder $queryBuilder, $nodeTypeFilter)
{
$constraints = $this->getNodeTypeFilterConstraintsForDql($nodeTypeFilter);
if (count($constraints['includeNodeTypes']) > 0) {
$queryBuilder->andWhere('n.nodeType IN (:includeNodeTypes)')
->setParameter('includeNodeTypes', $constraints['includeNodeTypes']);
}
if (count($constraints['excludeNodeTypes']) > 0) {
$queryBuilder->andWhere('n.nodeType NOT IN (:excludeNodeTypes)')
->setParameter('excludeNodeTypes', $constraints['excludeNodeTypes']);
}
} | php | public function addNodeTypeFilterConstraintsToQueryBuilder(QueryBuilder $queryBuilder, $nodeTypeFilter)
{
$constraints = $this->getNodeTypeFilterConstraintsForDql($nodeTypeFilter);
if (count($constraints['includeNodeTypes']) > 0) {
$queryBuilder->andWhere('n.nodeType IN (:includeNodeTypes)')
->setParameter('includeNodeTypes', $constraints['includeNodeTypes']);
}
if (count($constraints['excludeNodeTypes']) > 0) {
$queryBuilder->andWhere('n.nodeType NOT IN (:excludeNodeTypes)')
->setParameter('excludeNodeTypes', $constraints['excludeNodeTypes']);
}
} | [
"public",
"function",
"addNodeTypeFilterConstraintsToQueryBuilder",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"$",
"nodeTypeFilter",
")",
"{",
"$",
"constraints",
"=",
"$",
"this",
"->",
"getNodeTypeFilterConstraintsForDql",
"(",
"$",
"nodeTypeFilter",
")",
";",
... | Add node type filter constraints to the query builder
@param QueryBuilder $queryBuilder
@param string $nodeTypeFilter
@return void | [
"Add",
"node",
"type",
"filter",
"constraints",
"to",
"the",
"query",
"builder"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1096-L1107 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.filterOutRemovedObjects | protected function filterOutRemovedObjects(array &$objects)
{
foreach ($objects as $index => $object) {
if ($this->removedNodes->contains($object)) {
unset($objects[$index]);
}
}
} | php | protected function filterOutRemovedObjects(array &$objects)
{
foreach ($objects as $index => $object) {
if ($this->removedNodes->contains($object)) {
unset($objects[$index]);
}
}
} | [
"protected",
"function",
"filterOutRemovedObjects",
"(",
"array",
"&",
"$",
"objects",
")",
"{",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"index",
"=>",
"$",
"object",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"removedNodes",
"->",
"contains",
"(",
"$",
... | Iterates of the array of objects and removes all those which have recently been removed from the repository,
but whose removal has not yet been persisted.
Technically this is a check of the given array against $this->removedNodes.
@param array &$objects An array of objects to filter, passed by reference.
@return void | [
"Iterates",
"of",
"the",
"array",
"of",
"objects",
"and",
"removes",
"all",
"those",
"which",
"have",
"recently",
"been",
"removed",
"from",
"the",
"repository",
"but",
"whose",
"removal",
"has",
"not",
"yet",
"been",
"persisted",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1196-L1203 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findByWorkspace | public function findByWorkspace(Workspace $workspace)
{
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('n')
->from(NodeData::class, 'n')
->where('n.workspace = :workspace')
->andWhere('n.movedTo IS NULL OR n.removed = :removed')
->orderBy('n.path', 'ASC')
->setParameter('workspace', $workspace->getName())
->setParameter('removed', false, \PDO::PARAM_BOOL);
return $queryBuilder->getQuery()->getResult();
} | php | public function findByWorkspace(Workspace $workspace)
{
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('n')
->from(NodeData::class, 'n')
->where('n.workspace = :workspace')
->andWhere('n.movedTo IS NULL OR n.removed = :removed')
->orderBy('n.path', 'ASC')
->setParameter('workspace', $workspace->getName())
->setParameter('removed', false, \PDO::PARAM_BOOL);
return $queryBuilder->getQuery()->getResult();
} | [
"public",
"function",
"findByWorkspace",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"/** @var QueryBuilder $queryBuilder */",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"sele... | Find all NodeData objects inside a given workspace sorted by path to be used
in publishing. The order makes sure that parent nodes are published first.
Shadow nodes are excluded, because they will be published when publishing the moved node.
@param Workspace $workspace
@return array<NodeData> | [
"Find",
"all",
"NodeData",
"objects",
"inside",
"a",
"given",
"workspace",
"sorted",
"by",
"path",
"to",
"be",
"used",
"in",
"publishing",
".",
"The",
"order",
"makes",
"sure",
"that",
"parent",
"nodes",
"are",
"published",
"first",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1386-L1400 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findByPathWithoutReduce | public function findByPathWithoutReduce($path, Workspace $workspace, $includeRemovedNodes = false, $recursive = false)
{
$path = strtolower($path);
$workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
$queryBuilder = $this->createQueryBuilder($workspaces);
$this->addPathConstraintToQueryBuilder($queryBuilder, $path, $recursive);
$query = $queryBuilder->getQuery();
$foundNodes = $query->getResult();
// Consider materialized, but not yet persisted nodes
foreach ($this->addedNodes as $addedNode) {
if (($addedNode->getPath() === $path || ($recursive && NodePaths::isSubPathOf($path, $addedNode->getPath()))) && in_array($addedNode->getWorkspace(), $workspaces)) {
$foundNodes[] = $addedNode;
}
}
$foundNodes = $this->reduceNodeVariantsByWorkspaces($foundNodes, $workspaces);
if ($includeRemovedNodes === false) {
$foundNodes = $this->withoutRemovedNodes($foundNodes);
}
return $foundNodes;
} | php | public function findByPathWithoutReduce($path, Workspace $workspace, $includeRemovedNodes = false, $recursive = false)
{
$path = strtolower($path);
$workspaces = $this->collectWorkspaceAndAllBaseWorkspaces($workspace);
$queryBuilder = $this->createQueryBuilder($workspaces);
$this->addPathConstraintToQueryBuilder($queryBuilder, $path, $recursive);
$query = $queryBuilder->getQuery();
$foundNodes = $query->getResult();
// Consider materialized, but not yet persisted nodes
foreach ($this->addedNodes as $addedNode) {
if (($addedNode->getPath() === $path || ($recursive && NodePaths::isSubPathOf($path, $addedNode->getPath()))) && in_array($addedNode->getWorkspace(), $workspaces)) {
$foundNodes[] = $addedNode;
}
}
$foundNodes = $this->reduceNodeVariantsByWorkspaces($foundNodes, $workspaces);
if ($includeRemovedNodes === false) {
$foundNodes = $this->withoutRemovedNodes($foundNodes);
}
return $foundNodes;
} | [
"public",
"function",
"findByPathWithoutReduce",
"(",
"$",
"path",
",",
"Workspace",
"$",
"workspace",
",",
"$",
"includeRemovedNodes",
"=",
"false",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"$",
"path",
"=",
"strtolower",
"(",
"$",
"path",
")",
";",... | Find all node data in a path matching the given workspace hierarchy
Internal method, used by Node::setPath
@param string $path
@param Workspace $workspace
@param boolean $includeRemovedNodes Should removed nodes be included in the result (defaults to false)
@param boolean $recursive
@return array<NodeData> Node data reduced by workspace but with all existing content dimension variants, includes removed nodes | [
"Find",
"all",
"node",
"data",
"in",
"a",
"path",
"matching",
"the",
"given",
"workspace",
"hierarchy"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1439-L1462 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.findNodesByPathPrefixAndRelatedEntities | public function findNodesByPathPrefixAndRelatedEntities($pathPrefix, $relationMap)
{
$queryBuilder = $this->buildQueryBuilderForRelationMap($relationMap);
if (trim($pathPrefix) !== '') {
$queryBuilder->andWhere('n.path LIKE :pathPrefix');
$queryBuilder->setParameter('pathPrefix', trim($pathPrefix) . '%');
}
return $queryBuilder->getQuery()->getResult();
} | php | public function findNodesByPathPrefixAndRelatedEntities($pathPrefix, $relationMap)
{
$queryBuilder = $this->buildQueryBuilderForRelationMap($relationMap);
if (trim($pathPrefix) !== '') {
$queryBuilder->andWhere('n.path LIKE :pathPrefix');
$queryBuilder->setParameter('pathPrefix', trim($pathPrefix) . '%');
}
return $queryBuilder->getQuery()->getResult();
} | [
"public",
"function",
"findNodesByPathPrefixAndRelatedEntities",
"(",
"$",
"pathPrefix",
",",
"$",
"relationMap",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"buildQueryBuilderForRelationMap",
"(",
"$",
"relationMap",
")",
";",
"if",
"(",
"trim",
"(",
... | Searches for possible relations to the given entity identifiers in NodeData using a path prefix.
Will return all possible NodeData objects that contain this identifiers.
See buildQueryBuilderForRelationMap for the relationMap definition.
Note: This is an internal method that is likely to be replaced in the future.
@param string $pathPrefix
@param array $relationMap
@return array | [
"Searches",
"for",
"possible",
"relations",
"to",
"the",
"given",
"entity",
"identifiers",
"in",
"NodeData",
"using",
"a",
"path",
"prefix",
".",
"Will",
"return",
"all",
"possible",
"NodeData",
"objects",
"that",
"contain",
"this",
"identifiers",
".",
"See",
... | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1490-L1500 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.removeAllInPath | public function removeAllInPath($path)
{
$path = strtolower($path);
$query = $this->entityManager->createQuery('DELETE FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.path LIKE :path');
$query->setParameter('path', $path . '/%');
$query->execute();
} | php | public function removeAllInPath($path)
{
$path = strtolower($path);
$query = $this->entityManager->createQuery('DELETE FROM Neos\ContentRepository\Domain\Model\NodeData n WHERE n.path LIKE :path');
$query->setParameter('path', $path . '/%');
$query->execute();
} | [
"public",
"function",
"removeAllInPath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"strtolower",
"(",
"$",
"path",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQuery",
"(",
"'DELETE FROM Neos\\ContentRepository\\Domain\\Model... | Remove all nodes below a given path. Does not care about workspaces and dimensions.
@param string $path Starting point path underneath all nodes are to be removed.
@return void | [
"Remove",
"all",
"nodes",
"below",
"a",
"given",
"path",
".",
"Does",
"not",
"care",
"about",
"workspaces",
"and",
"dimensions",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1508-L1514 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php | NodeDataRepository.buildQueryBuilderForRelationMap | protected function buildQueryBuilderForRelationMap($relationMap)
{
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('n')
->from(NodeData::class, 'n');
$constraints = [];
$parameters = [];
foreach ($relationMap as $relatedObjectType => $relatedIdentifiers) {
foreach ($relatedIdentifiers as $relatedIdentifier) {
// entity references like "__identifier": "so-me-uu-id"
$constraints[] = '(LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :entity' . md5($relatedIdentifier) . ' )';
$parameters['entity' . md5($relatedIdentifier)] = '%"__identifier": "' . strtolower($relatedIdentifier) . '"%';
// asset references in text like "asset://so-me-uu-id"
$constraints[] = '(LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :asset' . md5($relatedIdentifier) . ' )';
switch ($this->entityManager->getConnection()->getDatabasePlatform()->getName()) {
case 'postgresql':
$parameters['asset' . md5($relatedIdentifier)] = '%asset://' . strtolower($relatedIdentifier) . '%';
break;
case 'sqlite':
$parameters['asset' . md5($relatedIdentifier)] = '%asset:\/\/' . strtolower($relatedIdentifier) . '%';
break;
default:
$parameters['asset' . md5($relatedIdentifier)] = '%asset:\\\\/\\\\/' . strtolower($relatedIdentifier) . '%';
}
}
}
$queryBuilder->where(implode(' OR ', $constraints));
$queryBuilder->setParameters($parameters);
return $queryBuilder;
} | php | protected function buildQueryBuilderForRelationMap($relationMap)
{
/** @var QueryBuilder $queryBuilder */
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('n')
->from(NodeData::class, 'n');
$constraints = [];
$parameters = [];
foreach ($relationMap as $relatedObjectType => $relatedIdentifiers) {
foreach ($relatedIdentifiers as $relatedIdentifier) {
// entity references like "__identifier": "so-me-uu-id"
$constraints[] = '(LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :entity' . md5($relatedIdentifier) . ' )';
$parameters['entity' . md5($relatedIdentifier)] = '%"__identifier": "' . strtolower($relatedIdentifier) . '"%';
// asset references in text like "asset://so-me-uu-id"
$constraints[] = '(LOWER(NEOSCR_TOSTRING(n.properties)) LIKE :asset' . md5($relatedIdentifier) . ' )';
switch ($this->entityManager->getConnection()->getDatabasePlatform()->getName()) {
case 'postgresql':
$parameters['asset' . md5($relatedIdentifier)] = '%asset://' . strtolower($relatedIdentifier) . '%';
break;
case 'sqlite':
$parameters['asset' . md5($relatedIdentifier)] = '%asset:\/\/' . strtolower($relatedIdentifier) . '%';
break;
default:
$parameters['asset' . md5($relatedIdentifier)] = '%asset:\\\\/\\\\/' . strtolower($relatedIdentifier) . '%';
}
}
}
$queryBuilder->where(implode(' OR ', $constraints));
$queryBuilder->setParameters($parameters);
return $queryBuilder;
} | [
"protected",
"function",
"buildQueryBuilderForRelationMap",
"(",
"$",
"relationMap",
")",
"{",
"/** @var QueryBuilder $queryBuilder */",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
... | Returns a query builder for a query on node data using the given
relation map.
$objectTypeMap = [
'Neos\Media\Domain\Model\Asset' => ['some-uuid-here'],
'Neos\Media\Domain\Model\ImageVariant' => ['some-uuid-here', 'another-uuid-here']
]
@param array $relationMap
@return QueryBuilder | [
"Returns",
"a",
"query",
"builder",
"for",
"a",
"query",
"on",
"node",
"data",
"using",
"the",
"given",
"relation",
"map",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Repository/NodeDataRepository.php#L1685-L1720 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/NodeType/NodeTypeConstraints.php | NodeTypeConstraints.withExplicitlyDisallowedNodeType | public function withExplicitlyDisallowedNodeType(NodeTypeName $nodeTypeName): NodeTypeConstraints
{
$disallowedNodeTypeNames = $this->explicitlyDisallowedNodeTypeNames;
$disallowedNodeTypeNames[] = $nodeTypeName;
return new NodeTypeConstraints($this->wildcardAllowed, $this->explicitlyAllowedNodeTypeNames, $disallowedNodeTypeNames);
} | php | public function withExplicitlyDisallowedNodeType(NodeTypeName $nodeTypeName): NodeTypeConstraints
{
$disallowedNodeTypeNames = $this->explicitlyDisallowedNodeTypeNames;
$disallowedNodeTypeNames[] = $nodeTypeName;
return new NodeTypeConstraints($this->wildcardAllowed, $this->explicitlyAllowedNodeTypeNames, $disallowedNodeTypeNames);
} | [
"public",
"function",
"withExplicitlyDisallowedNodeType",
"(",
"NodeTypeName",
"$",
"nodeTypeName",
")",
":",
"NodeTypeConstraints",
"{",
"$",
"disallowedNodeTypeNames",
"=",
"$",
"this",
"->",
"explicitlyDisallowedNodeTypeNames",
";",
"$",
"disallowedNodeTypeNames",
"[",
... | IMMUTABLE, returns a new instance
@param NodeTypeName $nodeTypeName
@return NodeTypeConstraints | [
"IMMUTABLE",
"returns",
"a",
"new",
"instance"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/NodeType/NodeTypeConstraints.php#L105-L110 | train |
neos/neos-development-collection | Neos.Fusion/Classes/FusionObjects/Http/ResponseHeadImplementation.php | ResponseHeadImplementation.evaluate | public function evaluate()
{
// TODO: Adjust for Neos 5.0 (PSR-7)
$httpResponse = new Response();
$httpResponse->setVersion($this->getHttpVersion());
$httpResponse->setStatus($this->getStatusCode());
$httpResponse->setHeaders(new Headers());
foreach ($this->getHeaders() as $name => $value) {
$httpResponse->setHeader($name, $value);
}
return implode("\r\n", $httpResponse->renderHeaders()) . "\r\n\r\n";
} | php | public function evaluate()
{
// TODO: Adjust for Neos 5.0 (PSR-7)
$httpResponse = new Response();
$httpResponse->setVersion($this->getHttpVersion());
$httpResponse->setStatus($this->getStatusCode());
$httpResponse->setHeaders(new Headers());
foreach ($this->getHeaders() as $name => $value) {
$httpResponse->setHeader($name, $value);
}
return implode("\r\n", $httpResponse->renderHeaders()) . "\r\n\r\n";
} | [
"public",
"function",
"evaluate",
"(",
")",
"{",
"// TODO: Adjust for Neos 5.0 (PSR-7)",
"$",
"httpResponse",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"httpResponse",
"->",
"setVersion",
"(",
"$",
"this",
"->",
"getHttpVersion",
"(",
")",
")",
";",
"$",
"... | Just return the processed value
@return mixed | [
"Just",
"return",
"the",
"processed",
"value"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Fusion/Classes/FusionObjects/Http/ResponseHeadImplementation.php#L70-L83 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/CreateContentContextTrait.php | CreateContentContextTrait.createContentContext | protected function createContentContext($workspaceName, array $dimensions = [])
{
$contextProperties = [
'workspaceName' => $workspaceName,
'invisibleContentShown' => true,
'inaccessibleContentShown' => true
];
if ($dimensions !== []) {
$contextProperties['dimensions'] = $dimensions;
$contextProperties['targetDimensions'] = array_map(function ($dimensionValues) {
return array_shift($dimensionValues);
}, $dimensions);
}
return $this->_contextFactory->create($contextProperties);
} | php | protected function createContentContext($workspaceName, array $dimensions = [])
{
$contextProperties = [
'workspaceName' => $workspaceName,
'invisibleContentShown' => true,
'inaccessibleContentShown' => true
];
if ($dimensions !== []) {
$contextProperties['dimensions'] = $dimensions;
$contextProperties['targetDimensions'] = array_map(function ($dimensionValues) {
return array_shift($dimensionValues);
}, $dimensions);
}
return $this->_contextFactory->create($contextProperties);
} | [
"protected",
"function",
"createContentContext",
"(",
"$",
"workspaceName",
",",
"array",
"$",
"dimensions",
"=",
"[",
"]",
")",
"{",
"$",
"contextProperties",
"=",
"[",
"'workspaceName'",
"=>",
"$",
"workspaceName",
",",
"'invisibleContentShown'",
"=>",
"true",
... | Create a ContentContext based on the given workspace name
@param string $workspaceName Name of the workspace to set for the context
@param array $dimensions Optional list of dimensions and their values which should be set
@return ContentContext | [
"Create",
"a",
"ContentContext",
"based",
"on",
"the",
"given",
"workspace",
"name"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/CreateContentContextTrait.php#L45-L61 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/CreateContentContextTrait.php | CreateContentContextTrait.createContextMatchingNodeData | protected function createContextMatchingNodeData(NodeData $nodeData)
{
$nodePath = NodePaths::getRelativePathBetween(SiteService::SITES_ROOT_PATH, $nodeData->getPath());
list($siteNodeName) = explode('/', $nodePath);
$site = $this->_siteRepository->findOneByNodeName($siteNodeName);
$contextProperties = [
'workspaceName' => $nodeData->getWorkspace()->getName(),
'invisibleContentShown' => true,
'inaccessibleContentShown' => true,
'removedContentShown' => true,
'dimensions' => $nodeData->getDimensionValues(),
'currentSite' => $site
];
if ($site instanceof Site && $domain = $site->getFirstActiveDomain()) {
$contextProperties['currentDomain'] = $domain;
}
return $this->_contextFactory->create($contextProperties);
} | php | protected function createContextMatchingNodeData(NodeData $nodeData)
{
$nodePath = NodePaths::getRelativePathBetween(SiteService::SITES_ROOT_PATH, $nodeData->getPath());
list($siteNodeName) = explode('/', $nodePath);
$site = $this->_siteRepository->findOneByNodeName($siteNodeName);
$contextProperties = [
'workspaceName' => $nodeData->getWorkspace()->getName(),
'invisibleContentShown' => true,
'inaccessibleContentShown' => true,
'removedContentShown' => true,
'dimensions' => $nodeData->getDimensionValues(),
'currentSite' => $site
];
if ($site instanceof Site && $domain = $site->getFirstActiveDomain()) {
$contextProperties['currentDomain'] = $domain;
}
return $this->_contextFactory->create($contextProperties);
} | [
"protected",
"function",
"createContextMatchingNodeData",
"(",
"NodeData",
"$",
"nodeData",
")",
"{",
"$",
"nodePath",
"=",
"NodePaths",
"::",
"getRelativePathBetween",
"(",
"SiteService",
"::",
"SITES_ROOT_PATH",
",",
"$",
"nodeData",
"->",
"getPath",
"(",
")",
"... | Generates a Context that exactly fits the given NodeData Workspace, Dimensions & Site.
@param NodeData $nodeData
@return ContentContext | [
"Generates",
"a",
"Context",
"that",
"exactly",
"fits",
"the",
"given",
"NodeData",
"Workspace",
"Dimensions",
"&",
"Site",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/CreateContentContextTrait.php#L69-L89 | train |
neos/neos-development-collection | Neos.Fusion/Classes/Core/Cache/CacheSegmentParser.php | CacheSegmentParser.parseSegment | protected function parseSegment($currentPosition)
{
$nextStartPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_START_TOKEN);
if ($nextStartPosition !== $currentPosition) {
throw new Exception(sprintf('The current position (%d) is not the start of a segment, next start position %d', $currentPosition, $nextStartPosition), 1472464124);
}
$segmentData = [
'identifier' => '',
'type' => '',
'context' => '',
'metadata' => '',
'content' => '',
'cleanContent' => '',
'embed' => ''
];
$nextEndPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_END_TOKEN);
$currentPosition = $this->calculateCurrentPosition($nextStartPosition);
$nextStartPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_START_TOKEN);
$nextIdentifierSeparatorPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN);
$nextSecondIdentifierSeparatorPosition = $this->calculateNextTokenPosition($nextIdentifierSeparatorPosition + 1, ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN);
if ($nextIdentifierSeparatorPosition === false || $nextSecondIdentifierSeparatorPosition === false
|| $nextStartPosition !== false && $nextStartPosition < $nextSecondIdentifierSeparatorPosition
|| $nextEndPosition !== false && $nextEndPosition < $nextSecondIdentifierSeparatorPosition
) {
throw new Exception(sprintf('Missing segment separator token after position %d', $currentPosition), 1391855139);
}
$identifier = $this->extractContent($currentPosition, $nextIdentifierSeparatorPosition);
$contextOrMetadata = $this->extractContent($this->calculateCurrentPosition($nextIdentifierSeparatorPosition), $nextSecondIdentifierSeparatorPosition);
$segmentData['identifier'] = $identifier;
$segmentData['type'] = ContentCache::SEGMENT_TYPE_CACHED;
$segmentData['metadata'] = $contextOrMetadata;
$segmentData['context'] = $contextOrMetadata;
if (strpos($identifier, 'eval=') === 0) {
$segmentData['type'] = ContentCache::SEGMENT_TYPE_UNCACHED;
unset($segmentData['metadata']);
$this->uncachedPartCount++;
}
if (strpos($identifier, 'evalCached=') === 0) {
$segmentData['type'] = ContentCache::SEGMENT_TYPE_DYNAMICCACHED;
$segmentData['identifier'] = substr($identifier, 11);
$additionalData = json_decode($contextOrMetadata, true);
$segmentData['metadata'] = $additionalData['metadata'];
$this->uncachedPartCount++;
}
$currentPosition = $this->calculateCurrentPosition($nextSecondIdentifierSeparatorPosition);
$segmentData = $this->extractContentAndSubSegments($currentPosition, $segmentData);
if ($segmentData['type'] === ContentCache::SEGMENT_TYPE_CACHED || $segmentData['type'] === ContentCache::SEGMENT_TYPE_DYNAMICCACHED) {
$this->cacheSegments[$identifier] = $this->reduceSegmentDataToCacheRelevantInformation($segmentData);
}
return $segmentData;
} | php | protected function parseSegment($currentPosition)
{
$nextStartPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_START_TOKEN);
if ($nextStartPosition !== $currentPosition) {
throw new Exception(sprintf('The current position (%d) is not the start of a segment, next start position %d', $currentPosition, $nextStartPosition), 1472464124);
}
$segmentData = [
'identifier' => '',
'type' => '',
'context' => '',
'metadata' => '',
'content' => '',
'cleanContent' => '',
'embed' => ''
];
$nextEndPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_END_TOKEN);
$currentPosition = $this->calculateCurrentPosition($nextStartPosition);
$nextStartPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_START_TOKEN);
$nextIdentifierSeparatorPosition = $this->calculateNextTokenPosition($currentPosition, ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN);
$nextSecondIdentifierSeparatorPosition = $this->calculateNextTokenPosition($nextIdentifierSeparatorPosition + 1, ContentCache::CACHE_SEGMENT_SEPARATOR_TOKEN);
if ($nextIdentifierSeparatorPosition === false || $nextSecondIdentifierSeparatorPosition === false
|| $nextStartPosition !== false && $nextStartPosition < $nextSecondIdentifierSeparatorPosition
|| $nextEndPosition !== false && $nextEndPosition < $nextSecondIdentifierSeparatorPosition
) {
throw new Exception(sprintf('Missing segment separator token after position %d', $currentPosition), 1391855139);
}
$identifier = $this->extractContent($currentPosition, $nextIdentifierSeparatorPosition);
$contextOrMetadata = $this->extractContent($this->calculateCurrentPosition($nextIdentifierSeparatorPosition), $nextSecondIdentifierSeparatorPosition);
$segmentData['identifier'] = $identifier;
$segmentData['type'] = ContentCache::SEGMENT_TYPE_CACHED;
$segmentData['metadata'] = $contextOrMetadata;
$segmentData['context'] = $contextOrMetadata;
if (strpos($identifier, 'eval=') === 0) {
$segmentData['type'] = ContentCache::SEGMENT_TYPE_UNCACHED;
unset($segmentData['metadata']);
$this->uncachedPartCount++;
}
if (strpos($identifier, 'evalCached=') === 0) {
$segmentData['type'] = ContentCache::SEGMENT_TYPE_DYNAMICCACHED;
$segmentData['identifier'] = substr($identifier, 11);
$additionalData = json_decode($contextOrMetadata, true);
$segmentData['metadata'] = $additionalData['metadata'];
$this->uncachedPartCount++;
}
$currentPosition = $this->calculateCurrentPosition($nextSecondIdentifierSeparatorPosition);
$segmentData = $this->extractContentAndSubSegments($currentPosition, $segmentData);
if ($segmentData['type'] === ContentCache::SEGMENT_TYPE_CACHED || $segmentData['type'] === ContentCache::SEGMENT_TYPE_DYNAMICCACHED) {
$this->cacheSegments[$identifier] = $this->reduceSegmentDataToCacheRelevantInformation($segmentData);
}
return $segmentData;
} | [
"protected",
"function",
"parseSegment",
"(",
"$",
"currentPosition",
")",
"{",
"$",
"nextStartPosition",
"=",
"$",
"this",
"->",
"calculateNextTokenPosition",
"(",
"$",
"currentPosition",
",",
"ContentCache",
"::",
"CACHE_SEGMENT_START_TOKEN",
")",
";",
"if",
"(",
... | Parses a segment at current position diving down into nested segments.
The returned segmentData array has the following keys:
- identifier -> The identifier of this entry for cached segments (or the eval expression for everything else)
- type -> The type of segment (one of the ContentCache::SEGMENT_TYPE_* constants)
- context -> eventual context information saved for a cached segment (optional)
- metadata -> cache entry metadata like tags
- content -> the content of this segment including embed code for sub segments
- cleanContent -> the raw content without any cache references for this segment and all sub segments
- embed -> the placeholder content for this segment to be used in "content" of parent segments
@param integer $currentPosition
@return array
@throws Exception | [
"Parses",
"a",
"segment",
"at",
"current",
"position",
"diving",
"down",
"into",
"nested",
"segments",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Fusion/Classes/Core/Cache/CacheSegmentParser.php#L114-L175 | train |
neos/neos-development-collection | Neos.Media.Browser/Classes/ViewHelpers/ThumbnailViewHelper.php | ThumbnailViewHelper.render | public function render(AssetProxyInterface $assetProxy = null, $width = null, $height = null)
{
if ($width === null || $height === null) {
$width = 250;
$height = 250;
}
if ($width <= 250 && $height <= 250) {
$thumbnailUri = $assetProxy->getThumbnailUri();
} else {
$thumbnailUri = $assetProxy->getPreviewUri();
}
$this->tag->addAttributes([
'width' => $width,
'height' => $height,
'src' => $thumbnailUri
]);
return $this->tag->render();
} | php | public function render(AssetProxyInterface $assetProxy = null, $width = null, $height = null)
{
if ($width === null || $height === null) {
$width = 250;
$height = 250;
}
if ($width <= 250 && $height <= 250) {
$thumbnailUri = $assetProxy->getThumbnailUri();
} else {
$thumbnailUri = $assetProxy->getPreviewUri();
}
$this->tag->addAttributes([
'width' => $width,
'height' => $height,
'src' => $thumbnailUri
]);
return $this->tag->render();
} | [
"public",
"function",
"render",
"(",
"AssetProxyInterface",
"$",
"assetProxy",
"=",
"null",
",",
"$",
"width",
"=",
"null",
",",
"$",
"height",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"width",
"===",
"null",
"||",
"$",
"height",
"===",
"null",
")",
"{... | Renders an HTML img tag with a thumbnail or preview image, created from a given asset proxy.
@param AssetProxyInterface $assetProxy The asset to be rendered as a thumbnail
@param integer $width Desired width of the thumbnail
@param integer $height Desired height of the thumbnail
@return string an <img...> html tag | [
"Renders",
"an",
"HTML",
"img",
"tag",
"with",
"a",
"thumbnail",
"or",
"preview",
"image",
"created",
"from",
"a",
"given",
"asset",
"proxy",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media.Browser/Classes/ViewHelpers/ThumbnailViewHelper.php#L60-L80 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Migration/Transformations/RenameProperty.php | RenameProperty.isTransformable | public function isTransformable(NodeData $node)
{
return ($node->hasProperty($this->oldPropertyName) && !$node->hasProperty($this->newPropertyName));
} | php | public function isTransformable(NodeData $node)
{
return ($node->hasProperty($this->oldPropertyName) && !$node->hasProperty($this->newPropertyName));
} | [
"public",
"function",
"isTransformable",
"(",
"NodeData",
"$",
"node",
")",
"{",
"return",
"(",
"$",
"node",
"->",
"hasProperty",
"(",
"$",
"this",
"->",
"oldPropertyName",
")",
"&&",
"!",
"$",
"node",
"->",
"hasProperty",
"(",
"$",
"this",
"->",
"newPro... | Returns true if the given node has a property with the name to work on
and does not yet have a property with the name to rename that property to.
@param NodeData $node
@return boolean | [
"Returns",
"true",
"if",
"the",
"given",
"node",
"has",
"a",
"property",
"with",
"the",
"name",
"to",
"work",
"on",
"and",
"does",
"not",
"yet",
"have",
"a",
"property",
"with",
"the",
"name",
"to",
"rename",
"that",
"property",
"to",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Migration/Transformations/RenameProperty.php#L64-L67 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Migration/Transformations/RenameProperty.php | RenameProperty.execute | public function execute(NodeData $node)
{
$node->setProperty($this->newPropertyName, $node->getProperty($this->oldPropertyName));
$node->removeProperty($this->oldPropertyName);
} | php | public function execute(NodeData $node)
{
$node->setProperty($this->newPropertyName, $node->getProperty($this->oldPropertyName));
$node->removeProperty($this->oldPropertyName);
} | [
"public",
"function",
"execute",
"(",
"NodeData",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"setProperty",
"(",
"$",
"this",
"->",
"newPropertyName",
",",
"$",
"node",
"->",
"getProperty",
"(",
"$",
"this",
"->",
"oldPropertyName",
")",
")",
";",
"$",
... | Renames the configured property to the new name.
@param NodeData $node
@return void | [
"Renames",
"the",
"configured",
"property",
"to",
"the",
"new",
"name",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Migration/Transformations/RenameProperty.php#L75-L79 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.indexAction | public function indexAction()
{
$currentAccount = $this->securityContext->getAccount();
$userWorkspace = $this->workspaceRepository->findOneByName(UserUtility::getPersonalWorkspaceNameForUsername($currentAccount->getAccountIdentifier()));
/** @var Workspace $userWorkspace */
$workspacesAndCounts = [
$userWorkspace->getName() => [
'workspace' => $userWorkspace,
'changesCounts' => $this->computeChangesCount($userWorkspace),
'canPublish' => false,
'canManage' => false,
'canDelete' => false
]
];
foreach ($this->workspaceRepository->findAll() as $workspace) {
/** @var Workspace $workspace */
// FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
if (!$workspace->isPersonalWorkspace() && ($workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
$workspacesAndCounts[$workspace->getName()]['workspace'] = $workspace;
$workspacesAndCounts[$workspace->getName()]['changesCounts'] = $this->computeChangesCount($workspace);
$workspacesAndCounts[$workspace->getName()]['canPublish'] = $this->userService->currentUserCanPublishToWorkspace($workspace);
$workspacesAndCounts[$workspace->getName()]['canManage'] = $this->userService->currentUserCanManageWorkspace($workspace);
$workspacesAndCounts[$workspace->getName()]['dependentWorkspacesCount'] = count($this->workspaceRepository->findByBaseWorkspace($workspace));
}
}
$this->view->assign('userWorkspace', $userWorkspace);
$this->view->assign('workspacesAndChangeCounts', $workspacesAndCounts);
} | php | public function indexAction()
{
$currentAccount = $this->securityContext->getAccount();
$userWorkspace = $this->workspaceRepository->findOneByName(UserUtility::getPersonalWorkspaceNameForUsername($currentAccount->getAccountIdentifier()));
/** @var Workspace $userWorkspace */
$workspacesAndCounts = [
$userWorkspace->getName() => [
'workspace' => $userWorkspace,
'changesCounts' => $this->computeChangesCount($userWorkspace),
'canPublish' => false,
'canManage' => false,
'canDelete' => false
]
];
foreach ($this->workspaceRepository->findAll() as $workspace) {
/** @var Workspace $workspace */
// FIXME: This check should be implemented through a specialized Workspace Privilege or something similar
if (!$workspace->isPersonalWorkspace() && ($workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
$workspacesAndCounts[$workspace->getName()]['workspace'] = $workspace;
$workspacesAndCounts[$workspace->getName()]['changesCounts'] = $this->computeChangesCount($workspace);
$workspacesAndCounts[$workspace->getName()]['canPublish'] = $this->userService->currentUserCanPublishToWorkspace($workspace);
$workspacesAndCounts[$workspace->getName()]['canManage'] = $this->userService->currentUserCanManageWorkspace($workspace);
$workspacesAndCounts[$workspace->getName()]['dependentWorkspacesCount'] = count($this->workspaceRepository->findByBaseWorkspace($workspace));
}
}
$this->view->assign('userWorkspace', $userWorkspace);
$this->view->assign('workspacesAndChangeCounts', $workspacesAndCounts);
} | [
"public",
"function",
"indexAction",
"(",
")",
"{",
"$",
"currentAccount",
"=",
"$",
"this",
"->",
"securityContext",
"->",
"getAccount",
"(",
")",
";",
"$",
"userWorkspace",
"=",
"$",
"this",
"->",
"workspaceRepository",
"->",
"findOneByName",
"(",
"UserUtili... | Display a list of unpublished content
@return void | [
"Display",
"a",
"list",
"of",
"unpublished",
"content"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L130-L160 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.editAction | public function editAction(Workspace $workspace)
{
$this->view->assign('workspace', $workspace);
$this->view->assign('baseWorkspaceOptions', $this->prepareBaseWorkspaceOptions($workspace));
$this->view->assign('disableBaseWorkspaceSelector', $this->publishingService->getUnpublishedNodesCount($workspace) > 0);
$this->view->assign('showOwnerSelector', $this->userService->currentUserCanTransferOwnershipOfWorkspace($workspace));
$this->view->assign('ownerOptions', $this->prepareOwnerOptions());
} | php | public function editAction(Workspace $workspace)
{
$this->view->assign('workspace', $workspace);
$this->view->assign('baseWorkspaceOptions', $this->prepareBaseWorkspaceOptions($workspace));
$this->view->assign('disableBaseWorkspaceSelector', $this->publishingService->getUnpublishedNodesCount($workspace) > 0);
$this->view->assign('showOwnerSelector', $this->userService->currentUserCanTransferOwnershipOfWorkspace($workspace));
$this->view->assign('ownerOptions', $this->prepareOwnerOptions());
} | [
"public",
"function",
"editAction",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"$",
"this",
"->",
"view",
"->",
"assign",
"(",
"'workspace'",
",",
"$",
"workspace",
")",
";",
"$",
"this",
"->",
"view",
"->",
"assign",
"(",
"'baseWorkspaceOptions'",
",",... | Edit a workspace
@param Workspace $workspace
@return void | [
"Edit",
"a",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L230-L237 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.updateAction | public function updateAction(Workspace $workspace)
{
if ($workspace->getTitle() === '') {
$workspace->setTitle($workspace->getName());
}
$this->workspaceRepository->update($workspace);
$this->addFlashMessage($this->translator->translateById('workspaces.workspaceHasBeenUpdated', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | php | public function updateAction(Workspace $workspace)
{
if ($workspace->getTitle() === '') {
$workspace->setTitle($workspace->getName());
}
$this->workspaceRepository->update($workspace);
$this->addFlashMessage($this->translator->translateById('workspaces.workspaceHasBeenUpdated', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | [
"public",
"function",
"updateAction",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"if",
"(",
"$",
"workspace",
"->",
"getTitle",
"(",
")",
"===",
"''",
")",
"{",
"$",
"workspace",
"->",
"setTitle",
"(",
"$",
"workspace",
"->",
"getName",
"(",
")",
")... | Update a workspace
@param Workspace $workspace A workspace to update
@return void | [
"Update",
"a",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L258-L267 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.deleteAction | public function deleteAction(Workspace $workspace)
{
if ($workspace->isPersonalWorkspace()) {
$this->redirect('index');
}
$dependentWorkspaces = $this->workspaceRepository->findByBaseWorkspace($workspace);
if (count($dependentWorkspaces) > 0) {
$dependentWorkspaceTitles = [];
/** @var Workspace $dependentWorkspace */
foreach ($dependentWorkspaces as $dependentWorkspace) {
$dependentWorkspaceTitles[] = $dependentWorkspace->getTitle();
}
$message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfDependencies', [$workspace->getTitle(), implode(', ', $dependentWorkspaceTitles)], null, null, 'Modules', 'Neos.Neos');
$this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
$this->redirect('index');
}
$nodesCount = 0;
try {
$nodesCount = $this->publishingService->getUnpublishedNodesCount($workspace);
} catch (\Exception $exception) {
$message = $this->translator->translateById('workspaces.notDeletedErrorWhileFetchingUnpublishedNodes', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos');
$this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
$this->redirect('index');
}
if ($nodesCount > 0) {
$message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfUnpublishedNodes', [$workspace->getTitle(), $nodesCount], $nodesCount, null, 'Modules', 'Neos.Neos');
$this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
$this->redirect('index');
}
$this->workspaceRepository->remove($workspace);
$this->addFlashMessage($message = $this->translator->translateById('workspaces.workspaceHasBeenRemoved', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | php | public function deleteAction(Workspace $workspace)
{
if ($workspace->isPersonalWorkspace()) {
$this->redirect('index');
}
$dependentWorkspaces = $this->workspaceRepository->findByBaseWorkspace($workspace);
if (count($dependentWorkspaces) > 0) {
$dependentWorkspaceTitles = [];
/** @var Workspace $dependentWorkspace */
foreach ($dependentWorkspaces as $dependentWorkspace) {
$dependentWorkspaceTitles[] = $dependentWorkspace->getTitle();
}
$message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfDependencies', [$workspace->getTitle(), implode(', ', $dependentWorkspaceTitles)], null, null, 'Modules', 'Neos.Neos');
$this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
$this->redirect('index');
}
$nodesCount = 0;
try {
$nodesCount = $this->publishingService->getUnpublishedNodesCount($workspace);
} catch (\Exception $exception) {
$message = $this->translator->translateById('workspaces.notDeletedErrorWhileFetchingUnpublishedNodes', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos');
$this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
$this->redirect('index');
}
if ($nodesCount > 0) {
$message = $this->translator->translateById('workspaces.workspaceCannotBeDeletedBecauseOfUnpublishedNodes', [$workspace->getTitle(), $nodesCount], $nodesCount, null, 'Modules', 'Neos.Neos');
$this->addFlashMessage($message, '', Message::SEVERITY_WARNING);
$this->redirect('index');
}
$this->workspaceRepository->remove($workspace);
$this->addFlashMessage($message = $this->translator->translateById('workspaces.workspaceHasBeenRemoved', [$workspace->getTitle()], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | [
"public",
"function",
"deleteAction",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"if",
"(",
"$",
"workspace",
"->",
"isPersonalWorkspace",
"(",
")",
")",
"{",
"$",
"this",
"->",
"redirect",
"(",
"'index'",
")",
";",
"}",
"$",
"dependentWorkspaces",
"=",... | Delete a workspace
@param Workspace $workspace A workspace to delete
@return void | [
"Delete",
"a",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L275-L311 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.publishNodeAction | public function publishNodeAction(NodeInterface $node, Workspace $selectedWorkspace)
{
$this->publishingService->publishNode($node);
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangeHasBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
} | php | public function publishNodeAction(NodeInterface $node, Workspace $selectedWorkspace)
{
$this->publishingService->publishNode($node);
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangeHasBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
} | [
"public",
"function",
"publishNodeAction",
"(",
"NodeInterface",
"$",
"node",
",",
"Workspace",
"$",
"selectedWorkspace",
")",
"{",
"$",
"this",
"->",
"publishingService",
"->",
"publishNode",
"(",
"$",
"node",
")",
";",
"$",
"this",
"->",
"addFlashMessage",
"... | Publish a single node
@param NodeInterface $node
@param Workspace $selectedWorkspace | [
"Publish",
"a",
"single",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L359-L364 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.discardNodeAction | public function discardNodeAction(NodeInterface $node, Workspace $selectedWorkspace)
{
// Hint: we cannot use $node->remove() here, as this removes the node recursively (but we just want to *discard changes*)
$this->publishingService->discardNode($node);
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangeHasBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
} | php | public function discardNodeAction(NodeInterface $node, Workspace $selectedWorkspace)
{
// Hint: we cannot use $node->remove() here, as this removes the node recursively (but we just want to *discard changes*)
$this->publishingService->discardNode($node);
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangeHasBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
} | [
"public",
"function",
"discardNodeAction",
"(",
"NodeInterface",
"$",
"node",
",",
"Workspace",
"$",
"selectedWorkspace",
")",
"{",
"// Hint: we cannot use $node->remove() here, as this removes the node recursively (but we just want to *discard changes*)",
"$",
"this",
"->",
"publi... | Discard a a single node
@param NodeInterface $node
@param Workspace $selectedWorkspace
@throws WorkspaceException | [
"Discard",
"a",
"a",
"single",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L373-L379 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.publishOrDiscardNodesAction | public function publishOrDiscardNodesAction(array $nodes, $action, Workspace $selectedWorkspace = null)
{
$propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration();
$propertyMappingConfiguration->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
foreach ($nodes as $key => $node) {
$nodes[$key] = $this->propertyMapper->convert($node, NodeInterface::class, $propertyMappingConfiguration);
}
switch ($action) {
case 'publish':
foreach ($nodes as $node) {
$this->publishingService->publishNode($node);
}
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
break;
case 'discard':
$this->publishingService->discardNodes($nodes);
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
break;
default:
throw new \RuntimeException('Invalid action "' . htmlspecialchars($action) . '" given.', 1346167441);
}
$this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
} | php | public function publishOrDiscardNodesAction(array $nodes, $action, Workspace $selectedWorkspace = null)
{
$propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration();
$propertyMappingConfiguration->setTypeConverterOption(NodeConverter::class, NodeConverter::REMOVED_CONTENT_SHOWN, true);
foreach ($nodes as $key => $node) {
$nodes[$key] = $this->propertyMapper->convert($node, NodeInterface::class, $propertyMappingConfiguration);
}
switch ($action) {
case 'publish':
foreach ($nodes as $node) {
$this->publishingService->publishNode($node);
}
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenPublished', [], null, null, 'Modules', 'Neos.Neos'));
break;
case 'discard':
$this->publishingService->discardNodes($nodes);
$this->addFlashMessage($this->translator->translateById('workspaces.selectedChangesHaveBeenDiscarded', [], null, null, 'Modules', 'Neos.Neos'));
break;
default:
throw new \RuntimeException('Invalid action "' . htmlspecialchars($action) . '" given.', 1346167441);
}
$this->redirect('show', null, null, ['workspace' => $selectedWorkspace]);
} | [
"public",
"function",
"publishOrDiscardNodesAction",
"(",
"array",
"$",
"nodes",
",",
"$",
"action",
",",
"Workspace",
"$",
"selectedWorkspace",
"=",
"null",
")",
"{",
"$",
"propertyMappingConfiguration",
"=",
"$",
"this",
"->",
"propertyMapper",
"->",
"buildPrope... | Publishes or discards the given nodes
@param array $nodes <\Neos\ContentRepository\Domain\Model\NodeInterface> $nodes
@param string $action
@param Workspace $selectedWorkspace
@throws \Exception
@throws \Neos\Flow\Property\Exception
@throws \Neos\Flow\Security\Exception | [
"Publishes",
"or",
"discards",
"the",
"given",
"nodes"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L391-L414 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.publishWorkspaceAction | public function publishWorkspaceAction(Workspace $workspace)
{
if (($targetWorkspace = $workspace->getBaseWorkspace()) === null) {
$targetWorkspace = $this->workspaceRepository->findOneByName('live');
}
$this->publishingService->publishNodes($this->publishingService->getUnpublishedNodes($workspace), $targetWorkspace);
$this->addFlashMessage($this->translator->translateById('workspaces.allChangesInWorkspaceHaveBeenPublished', [htmlspecialchars($workspace->getTitle()), htmlspecialchars($targetWorkspace->getTitle())], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | php | public function publishWorkspaceAction(Workspace $workspace)
{
if (($targetWorkspace = $workspace->getBaseWorkspace()) === null) {
$targetWorkspace = $this->workspaceRepository->findOneByName('live');
}
$this->publishingService->publishNodes($this->publishingService->getUnpublishedNodes($workspace), $targetWorkspace);
$this->addFlashMessage($this->translator->translateById('workspaces.allChangesInWorkspaceHaveBeenPublished', [htmlspecialchars($workspace->getTitle()), htmlspecialchars($targetWorkspace->getTitle())], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | [
"public",
"function",
"publishWorkspaceAction",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"if",
"(",
"(",
"$",
"targetWorkspace",
"=",
"$",
"workspace",
"->",
"getBaseWorkspace",
"(",
")",
")",
"===",
"null",
")",
"{",
"$",
"targetWorkspace",
"=",
"$",
... | Publishes the whole workspace
@param Workspace $workspace
@return void | [
"Publishes",
"the",
"whole",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L422-L430 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.discardWorkspaceAction | public function discardWorkspaceAction(Workspace $workspace)
{
$unpublishedNodes = $this->publishingService->getUnpublishedNodes($workspace);
$this->publishingService->discardNodes($unpublishedNodes);
$this->addFlashMessage($this->translator->translateById('workspaces.allChangesInWorkspaceHaveBeenDiscarded', [htmlspecialchars($workspace->getTitle())], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | php | public function discardWorkspaceAction(Workspace $workspace)
{
$unpublishedNodes = $this->publishingService->getUnpublishedNodes($workspace);
$this->publishingService->discardNodes($unpublishedNodes);
$this->addFlashMessage($this->translator->translateById('workspaces.allChangesInWorkspaceHaveBeenDiscarded', [htmlspecialchars($workspace->getTitle())], null, null, 'Modules', 'Neos.Neos'));
$this->redirect('index');
} | [
"public",
"function",
"discardWorkspaceAction",
"(",
"Workspace",
"$",
"workspace",
")",
"{",
"$",
"unpublishedNodes",
"=",
"$",
"this",
"->",
"publishingService",
"->",
"getUnpublishedNodes",
"(",
"$",
"workspace",
")",
";",
"$",
"this",
"->",
"publishingService"... | Discards content of the whole workspace
@param Workspace $workspace
@return void | [
"Discards",
"content",
"of",
"the",
"whole",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L438-L444 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.computeChangesCount | protected function computeChangesCount(Workspace $selectedWorkspace)
{
$changesCount = ['new' => 0, 'changed' => 0, 'removed' => 0, 'total' => 0];
foreach ($this->computeSiteChanges($selectedWorkspace) as $siteChanges) {
foreach ($siteChanges['documents'] as $documentChanges) {
foreach ($documentChanges['changes'] as $change) {
if ($change['node']->isRemoved()) {
$changesCount['removed']++;
} elseif ($change['isNew']) {
$changesCount['new']++;
} else {
$changesCount['changed']++;
};
$changesCount['total']++;
}
}
}
return $changesCount;
} | php | protected function computeChangesCount(Workspace $selectedWorkspace)
{
$changesCount = ['new' => 0, 'changed' => 0, 'removed' => 0, 'total' => 0];
foreach ($this->computeSiteChanges($selectedWorkspace) as $siteChanges) {
foreach ($siteChanges['documents'] as $documentChanges) {
foreach ($documentChanges['changes'] as $change) {
if ($change['node']->isRemoved()) {
$changesCount['removed']++;
} elseif ($change['isNew']) {
$changesCount['new']++;
} else {
$changesCount['changed']++;
};
$changesCount['total']++;
}
}
}
return $changesCount;
} | [
"protected",
"function",
"computeChangesCount",
"(",
"Workspace",
"$",
"selectedWorkspace",
")",
"{",
"$",
"changesCount",
"=",
"[",
"'new'",
"=>",
"0",
",",
"'changed'",
"=>",
"0",
",",
"'removed'",
"=>",
"0",
",",
"'total'",
"=>",
"0",
"]",
";",
"foreach... | Computes the number of added, changed and removed nodes for the given workspace
@param Workspace $selectedWorkspace
@return array | [
"Computes",
"the",
"number",
"of",
"added",
"changed",
"and",
"removed",
"nodes",
"for",
"the",
"given",
"workspace"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L452-L471 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.renderSlimmedDownContent | protected function renderSlimmedDownContent($propertyValue)
{
$content = '';
if (is_string($propertyValue)) {
$contentSnippet = preg_replace('/<br[^>]*>/', "\n", $propertyValue);
$contentSnippet = preg_replace('/<[^>]*>/', ' ', $contentSnippet);
$contentSnippet = str_replace(' ', ' ', $contentSnippet);
$content = trim(preg_replace('/ {2,}/', ' ', $contentSnippet));
}
return $content;
} | php | protected function renderSlimmedDownContent($propertyValue)
{
$content = '';
if (is_string($propertyValue)) {
$contentSnippet = preg_replace('/<br[^>]*>/', "\n", $propertyValue);
$contentSnippet = preg_replace('/<[^>]*>/', ' ', $contentSnippet);
$contentSnippet = str_replace(' ', ' ', $contentSnippet);
$content = trim(preg_replace('/ {2,}/', ' ', $contentSnippet));
}
return $content;
} | [
"protected",
"function",
"renderSlimmedDownContent",
"(",
"$",
"propertyValue",
")",
"{",
"$",
"content",
"=",
"''",
";",
"if",
"(",
"is_string",
"(",
"$",
"propertyValue",
")",
")",
"{",
"$",
"contentSnippet",
"=",
"preg_replace",
"(",
"'/<br[^>]*>/'",
",",
... | Renders a slimmed down representation of a property of the given node. The output will be HTML, but does not
contain any markup from the original content.
Note: It's clear that this method needs to be extracted and moved to a more universal service at some point.
However, since we only implemented diff-view support for this particular controller at the moment, it stays
here for the time being. Once we start displaying diffs elsewhere, we should refactor the diff rendering part.
@param mixed $propertyValue
@return string | [
"Renders",
"a",
"slimmed",
"down",
"representation",
"of",
"a",
"property",
"of",
"the",
"given",
"node",
".",
"The",
"output",
"will",
"be",
"HTML",
"but",
"does",
"not",
"contain",
"any",
"markup",
"from",
"the",
"original",
"content",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L642-L652 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.getPropertyLabel | protected function getPropertyLabel($propertyName, NodeInterface $changedNode)
{
$properties = $changedNode->getNodeType()->getProperties();
if (!isset($properties[$propertyName]) ||
!isset($properties[$propertyName]['ui']['label'])
) {
return $propertyName;
}
return $properties[$propertyName]['ui']['label'];
} | php | protected function getPropertyLabel($propertyName, NodeInterface $changedNode)
{
$properties = $changedNode->getNodeType()->getProperties();
if (!isset($properties[$propertyName]) ||
!isset($properties[$propertyName]['ui']['label'])
) {
return $propertyName;
}
return $properties[$propertyName]['ui']['label'];
} | [
"protected",
"function",
"getPropertyLabel",
"(",
"$",
"propertyName",
",",
"NodeInterface",
"$",
"changedNode",
")",
"{",
"$",
"properties",
"=",
"$",
"changedNode",
"->",
"getNodeType",
"(",
")",
"->",
"getProperties",
"(",
")",
";",
"if",
"(",
"!",
"isset... | Tries to determine a label for the specified property
@param string $propertyName
@param NodeInterface $changedNode
@return string | [
"Tries",
"to",
"determine",
"a",
"label",
"for",
"the",
"specified",
"property"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L661-L670 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.prepareBaseWorkspaceOptions | protected function prepareBaseWorkspaceOptions(Workspace $excludedWorkspace = null)
{
$baseWorkspaceOptions = [];
foreach ($this->workspaceRepository->findAll() as $workspace) {
/** @var Workspace $workspace */
if (!$workspace->isPersonalWorkspace() && $workspace !== $excludedWorkspace && ($workspace->isPublicWorkspace() || $workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
$baseWorkspaceOptions[$workspace->getName()] = $workspace->getTitle();
}
}
return $baseWorkspaceOptions;
} | php | protected function prepareBaseWorkspaceOptions(Workspace $excludedWorkspace = null)
{
$baseWorkspaceOptions = [];
foreach ($this->workspaceRepository->findAll() as $workspace) {
/** @var Workspace $workspace */
if (!$workspace->isPersonalWorkspace() && $workspace !== $excludedWorkspace && ($workspace->isPublicWorkspace() || $workspace->isInternalWorkspace() || $this->userService->currentUserCanManageWorkspace($workspace))) {
$baseWorkspaceOptions[$workspace->getName()] = $workspace->getTitle();
}
}
return $baseWorkspaceOptions;
} | [
"protected",
"function",
"prepareBaseWorkspaceOptions",
"(",
"Workspace",
"$",
"excludedWorkspace",
"=",
"null",
")",
"{",
"$",
"baseWorkspaceOptions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"workspaceRepository",
"->",
"findAll",
"(",
")",
"as",... | Creates an array of workspace names and their respective titles which are possible base workspaces for other
workspaces.
@param Workspace $excludedWorkspace If set, this workspace will be excluded from the list of returned workspaces
@return array | [
"Creates",
"an",
"array",
"of",
"workspace",
"names",
"and",
"their",
"respective",
"titles",
"which",
"are",
"possible",
"base",
"workspaces",
"for",
"other",
"workspaces",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L709-L720 | train |
neos/neos-development-collection | Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php | WorkspacesController.prepareOwnerOptions | protected function prepareOwnerOptions()
{
$ownerOptions = ['' => '-'];
foreach ($this->userService->getUsers() as $user) {
/** @var User $user */
$ownerOptions[$this->persistenceManager->getIdentifierByObject($user)] = $user->getLabel();
}
return $ownerOptions;
} | php | protected function prepareOwnerOptions()
{
$ownerOptions = ['' => '-'];
foreach ($this->userService->getUsers() as $user) {
/** @var User $user */
$ownerOptions[$this->persistenceManager->getIdentifierByObject($user)] = $user->getLabel();
}
return $ownerOptions;
} | [
"protected",
"function",
"prepareOwnerOptions",
"(",
")",
"{",
"$",
"ownerOptions",
"=",
"[",
"''",
"=>",
"'-'",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"userService",
"->",
"getUsers",
"(",
")",
"as",
"$",
"user",
")",
"{",
"/** @var User $user */",
... | Creates an array of user names and their respective labels which are possible owners for a workspace.
@return array | [
"Creates",
"an",
"array",
"of",
"user",
"names",
"and",
"their",
"respective",
"labels",
"which",
"are",
"possible",
"owners",
"for",
"a",
"workspace",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Controller/Module/Management/WorkspacesController.php#L727-L736 | train |
neos/neos-development-collection | Neos.Diff/Classes/Renderer/Text/TextUnifiedRenderer.php | TextUnifiedRenderer.render | public function render()
{
$diff = '';
$opCodes = $this->diff->getGroupedOpcodes();
foreach ($opCodes as $group) {
$lastItem = count($group) - 1;
$i1 = $group[0][1];
$i2 = $group[$lastItem][2];
$j1 = $group[0][3];
$j2 = $group[$lastItem][4];
if ($i1 == 0 && $i2 == 0) {
$i1 = -1;
$i2 = -1;
}
$diff .= '@@ -' . ($i1 + 1) . ',' . ($i2 - $i1) . ' +' . ($j1 + 1) . ',' . ($j2 - $j1) . " @@\n";
foreach ($group as $code) {
list($tag, $i1, $i2, $j1, $j2) = $code;
if ($tag == 'equal') {
$diff .= ' ' . implode("\n ", $this->diff->GetA($i1, $i2)) . "\n";
} else {
if ($tag == 'replace' || $tag == 'delete') {
$diff .= '-' . implode("\n-", $this->diff->GetA($i1, $i2)) . "\n";
}
if ($tag == 'replace' || $tag == 'insert') {
$diff .= '+' . implode("\n+", $this->diff->GetB($j1, $j2)) . "\n";
}
}
}
}
return $diff;
} | php | public function render()
{
$diff = '';
$opCodes = $this->diff->getGroupedOpcodes();
foreach ($opCodes as $group) {
$lastItem = count($group) - 1;
$i1 = $group[0][1];
$i2 = $group[$lastItem][2];
$j1 = $group[0][3];
$j2 = $group[$lastItem][4];
if ($i1 == 0 && $i2 == 0) {
$i1 = -1;
$i2 = -1;
}
$diff .= '@@ -' . ($i1 + 1) . ',' . ($i2 - $i1) . ' +' . ($j1 + 1) . ',' . ($j2 - $j1) . " @@\n";
foreach ($group as $code) {
list($tag, $i1, $i2, $j1, $j2) = $code;
if ($tag == 'equal') {
$diff .= ' ' . implode("\n ", $this->diff->GetA($i1, $i2)) . "\n";
} else {
if ($tag == 'replace' || $tag == 'delete') {
$diff .= '-' . implode("\n-", $this->diff->GetA($i1, $i2)) . "\n";
}
if ($tag == 'replace' || $tag == 'insert') {
$diff .= '+' . implode("\n+", $this->diff->GetB($j1, $j2)) . "\n";
}
}
}
}
return $diff;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"diff",
"=",
"''",
";",
"$",
"opCodes",
"=",
"$",
"this",
"->",
"diff",
"->",
"getGroupedOpcodes",
"(",
")",
";",
"foreach",
"(",
"$",
"opCodes",
"as",
"$",
"group",
")",
"{",
"$",
"lastItem",
"="... | Render and return a unified diff.
@return string The unified diff. | [
"Render",
"and",
"return",
"a",
"unified",
"diff",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Diff/Classes/Renderer/Text/TextUnifiedRenderer.php#L27-L60 | train |
neos/neos-development-collection | Neos.Neos/Classes/ViewHelpers/Backend/ChangeStatsViewHelper.php | ChangeStatsViewHelper.render | public function render(array $changeCounts)
{
$this->templateVariableContainer->add('newCountRatio', $changeCounts['new'] / $changeCounts['total'] * 100);
$this->templateVariableContainer->add('changedCountRatio', $changeCounts['changed'] / $changeCounts['total'] * 100);
$this->templateVariableContainer->add('removedCountRatio', $changeCounts['removed'] / $changeCounts['total'] * 100);
$content = $this->renderChildren();
$this->templateVariableContainer->remove('newCountRatio');
$this->templateVariableContainer->remove('changedCountRatio');
$this->templateVariableContainer->remove('removedCountRatio');
return $content;
} | php | public function render(array $changeCounts)
{
$this->templateVariableContainer->add('newCountRatio', $changeCounts['new'] / $changeCounts['total'] * 100);
$this->templateVariableContainer->add('changedCountRatio', $changeCounts['changed'] / $changeCounts['total'] * 100);
$this->templateVariableContainer->add('removedCountRatio', $changeCounts['removed'] / $changeCounts['total'] * 100);
$content = $this->renderChildren();
$this->templateVariableContainer->remove('newCountRatio');
$this->templateVariableContainer->remove('changedCountRatio');
$this->templateVariableContainer->remove('removedCountRatio');
return $content;
} | [
"public",
"function",
"render",
"(",
"array",
"$",
"changeCounts",
")",
"{",
"$",
"this",
"->",
"templateVariableContainer",
"->",
"add",
"(",
"'newCountRatio'",
",",
"$",
"changeCounts",
"[",
"'new'",
"]",
"/",
"$",
"changeCounts",
"[",
"'total'",
"]",
"*",... | Expects an array of change count data and adds calculated ratios to the rendered child view
@param array $changeCounts Expected keys: new, changed, removed
@return string | [
"Expects",
"an",
"array",
"of",
"change",
"count",
"data",
"and",
"adds",
"calculated",
"ratios",
"to",
"the",
"rendered",
"child",
"view"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/ViewHelpers/Backend/ChangeStatsViewHelper.php#L34-L45 | train |
neos/neos-development-collection | Neos.Media/Classes/Domain/Model/Adjustment/CropImageAdjustment.php | CropImageAdjustment.calculateDimensionsByAspectRatio | public static function calculateDimensionsByAspectRatio(int $originalWidth, int $originalHeight, AspectRatio $desiredAspectRatio): array
{
$newWidth = $originalWidth;
$newHeight = round($originalWidth / $desiredAspectRatio->getRatio());
$newX = 0;
$newY = round(($originalHeight - $newHeight) / 2);
if ($newHeight > $originalHeight) {
$newHeight = $originalHeight;
$newY = 0;
$newWidth = round($originalHeight * $desiredAspectRatio->getRatio());
$newX = round(($originalWidth - $newWidth) / 2);
}
return [$newX, $newY, $newWidth, $newHeight];
} | php | public static function calculateDimensionsByAspectRatio(int $originalWidth, int $originalHeight, AspectRatio $desiredAspectRatio): array
{
$newWidth = $originalWidth;
$newHeight = round($originalWidth / $desiredAspectRatio->getRatio());
$newX = 0;
$newY = round(($originalHeight - $newHeight) / 2);
if ($newHeight > $originalHeight) {
$newHeight = $originalHeight;
$newY = 0;
$newWidth = round($originalHeight * $desiredAspectRatio->getRatio());
$newX = round(($originalWidth - $newWidth) / 2);
}
return [$newX, $newY, $newWidth, $newHeight];
} | [
"public",
"static",
"function",
"calculateDimensionsByAspectRatio",
"(",
"int",
"$",
"originalWidth",
",",
"int",
"$",
"originalHeight",
",",
"AspectRatio",
"$",
"desiredAspectRatio",
")",
":",
"array",
"{",
"$",
"newWidth",
"=",
"$",
"originalWidth",
";",
"$",
... | Calculates the actual position and dimensions of the cropping area based on the given image
dimensions and desired aspect ratio.
@param int $originalWidth Width of the original image
@param int $originalHeight Height of the original image
@param AspectRatio $desiredAspectRatio The desired aspect ratio
@return array Returns an array containing x, y, width and height | [
"Calculates",
"the",
"actual",
"position",
"and",
"dimensions",
"of",
"the",
"cropping",
"area",
"based",
"on",
"the",
"given",
"image",
"dimensions",
"and",
"desired",
"aspect",
"ratio",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/Domain/Model/Adjustment/CropImageAdjustment.php#L201-L216 | train |
neos/neos-development-collection | Neos.Media/Classes/Domain/Model/Adjustment/CropImageAdjustment.php | CropImageAdjustment.refit | public function refit(ImageInterface $image): void
{
$this->x = 0;
$this->y = 0;
$ratio = $this->getWidth() / $image->getWidth();
$this->setWidth($image->getWidth());
$this->setHeight($this->getHeight() / $ratio);
if ($this->getHeight() > $image->getHeight()) {
$ratio = $this->getHeight() / $image->getHeight();
$this->setWidth($this->getWidth() / $ratio);
$this->setHeight($image->getHeight());
}
} | php | public function refit(ImageInterface $image): void
{
$this->x = 0;
$this->y = 0;
$ratio = $this->getWidth() / $image->getWidth();
$this->setWidth($image->getWidth());
$this->setHeight($this->getHeight() / $ratio);
if ($this->getHeight() > $image->getHeight()) {
$ratio = $this->getHeight() / $image->getHeight();
$this->setWidth($this->getWidth() / $ratio);
$this->setHeight($image->getHeight());
}
} | [
"public",
"function",
"refit",
"(",
"ImageInterface",
"$",
"image",
")",
":",
"void",
"{",
"$",
"this",
"->",
"x",
"=",
"0",
";",
"$",
"this",
"->",
"y",
"=",
"0",
";",
"$",
"ratio",
"=",
"$",
"this",
"->",
"getWidth",
"(",
")",
"/",
"$",
"imag... | Refits the crop proportions to be the maximum size within the image boundaries.
@param ImageInterface $image
@return void | [
"Refits",
"the",
"crop",
"proportions",
"to",
"be",
"the",
"maximum",
"size",
"within",
"the",
"image",
"boundaries",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/Domain/Model/Adjustment/CropImageAdjustment.php#L271-L285 | train |
neos/neos-development-collection | Neos.Media/Classes/TypeConverter/ImageInterfaceArrayPresenter.php | ImageInterfaceArrayPresenter.convertFrom | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
$data = [
'__identity' => $this->persistenceManager->getIdentifierByObject($source),
'__type' => TypeHandling::getTypeForValue($source)
];
if ($source instanceof ImageVariant) {
$data['originalAsset'] = [
'__identity' => $this->persistenceManager->getIdentifierByObject($source->getOriginalAsset()),
];
$adjustments = [];
foreach ($source->getAdjustments() as $adjustment) {
$index = TypeHandling::getTypeForValue($adjustment);
$adjustments[$index] = [];
foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
$adjustments[$index][$propertyName] = $propertyValue;
}
}
$data['adjustments'] = $adjustments;
}
return $data;
} | php | public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
$data = [
'__identity' => $this->persistenceManager->getIdentifierByObject($source),
'__type' => TypeHandling::getTypeForValue($source)
];
if ($source instanceof ImageVariant) {
$data['originalAsset'] = [
'__identity' => $this->persistenceManager->getIdentifierByObject($source->getOriginalAsset()),
];
$adjustments = [];
foreach ($source->getAdjustments() as $adjustment) {
$index = TypeHandling::getTypeForValue($adjustment);
$adjustments[$index] = [];
foreach (ObjectAccess::getGettableProperties($adjustment) as $propertyName => $propertyValue) {
$adjustments[$index][$propertyName] = $propertyValue;
}
}
$data['adjustments'] = $adjustments;
}
return $data;
} | [
"public",
"function",
"convertFrom",
"(",
"$",
"source",
",",
"$",
"targetType",
",",
"array",
"$",
"convertedChildProperties",
"=",
"[",
"]",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"'_... | Convert an object from \Neos\Media\Domain\Model\ImageInterface to a json representation
@param ImageInterface $source
@param string $targetType must be 'string'
@param array $convertedChildProperties
@param PropertyMappingConfigurationInterface $configuration
@return string|Error The converted Image, a Validation Error or NULL | [
"Convert",
"an",
"object",
"from",
"\\",
"Neos",
"\\",
"Media",
"\\",
"Domain",
"\\",
"Model",
"\\",
"ImageInterface",
"to",
"a",
"json",
"representation"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/TypeConverter/ImageInterfaceArrayPresenter.php#L86-L110 | train |
neos/neos-development-collection | Neos.Neos/Classes/Domain/Model/Site.php | Site.getPrimaryDomain | public function getPrimaryDomain()
{
return isset($this->primaryDomain) && $this->primaryDomain->getActive() ? $this->primaryDomain : $this->getFirstActiveDomain();
} | php | public function getPrimaryDomain()
{
return isset($this->primaryDomain) && $this->primaryDomain->getActive() ? $this->primaryDomain : $this->getFirstActiveDomain();
} | [
"public",
"function",
"getPrimaryDomain",
"(",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"primaryDomain",
")",
"&&",
"$",
"this",
"->",
"primaryDomain",
"->",
"getActive",
"(",
")",
"?",
"$",
"this",
"->",
"primaryDomain",
":",
"$",
"this",
"-... | Returns the primary domain, if one has been defined.
@return Domain The primary domain or NULL
@api | [
"Returns",
"the",
"primary",
"domain",
"if",
"one",
"has",
"been",
"defined",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Domain/Model/Site.php#L309-L312 | train |
neos/neos-development-collection | Neos.Media/Classes/Domain/Service/FileTypeIconService.php | FileTypeIconService.getIcon | public static function getIcon($filename): array
{
$fileExtention = self::extractFileExtension($filename);
if (isset(self::$cache[$fileExtention])) {
return self::$cache[$fileExtention];
}
$fileTypeIcon = new FileTypeIcon($fileExtention);
self::$cache[$fileExtention] = [
'src' => $fileTypeIcon->path(),
'alt' => $fileTypeIcon->alt()
];
return self::$cache[$fileExtention];
} | php | public static function getIcon($filename): array
{
$fileExtention = self::extractFileExtension($filename);
if (isset(self::$cache[$fileExtention])) {
return self::$cache[$fileExtention];
}
$fileTypeIcon = new FileTypeIcon($fileExtention);
self::$cache[$fileExtention] = [
'src' => $fileTypeIcon->path(),
'alt' => $fileTypeIcon->alt()
];
return self::$cache[$fileExtention];
} | [
"public",
"static",
"function",
"getIcon",
"(",
"$",
"filename",
")",
":",
"array",
"{",
"$",
"fileExtention",
"=",
"self",
"::",
"extractFileExtension",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"cache",
"[",
"$",
"fi... | Returns an icon for a file type within given dimensions
@param string $filename
@return array | [
"Returns",
"an",
"icon",
"for",
"a",
"file",
"type",
"within",
"given",
"dimensions"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/Domain/Service/FileTypeIconService.php#L29-L44 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/LinkingService.php | LinkingService.convertUriToObject | public function convertUriToObject($uri, NodeInterface $contextNode = null)
{
if ($uri instanceof Uri) {
$uri = (string)$uri;
}
if (preg_match(self::PATTERN_SUPPORTED_URIS, $uri, $matches) === 1) {
switch ($matches[1]) {
case 'node':
if ($contextNode === null) {
throw new \RuntimeException('node:// URI conversion requires a context node to be passed', 1409734235);
};
return $contextNode->getContext()->getNodeByIdentifier($matches[2]);
case 'asset':
return $this->assetRepository->findByIdentifier($matches[2]);
}
}
return null;
} | php | public function convertUriToObject($uri, NodeInterface $contextNode = null)
{
if ($uri instanceof Uri) {
$uri = (string)$uri;
}
if (preg_match(self::PATTERN_SUPPORTED_URIS, $uri, $matches) === 1) {
switch ($matches[1]) {
case 'node':
if ($contextNode === null) {
throw new \RuntimeException('node:// URI conversion requires a context node to be passed', 1409734235);
};
return $contextNode->getContext()->getNodeByIdentifier($matches[2]);
case 'asset':
return $this->assetRepository->findByIdentifier($matches[2]);
}
}
return null;
} | [
"public",
"function",
"convertUriToObject",
"(",
"$",
"uri",
",",
"NodeInterface",
"$",
"contextNode",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"uri",
"instanceof",
"Uri",
")",
"{",
"$",
"uri",
"=",
"(",
"string",
")",
"$",
"uri",
";",
"}",
"if",
"(",
... | Return the object the URI addresses or NULL.
@param string|Uri $uri
@param NodeInterface $contextNode
@return NodeInterface|AssetInterface|NULL | [
"Return",
"the",
"object",
"the",
"URI",
"addresses",
"or",
"NULL",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/LinkingService.php#L192-L212 | train |
neos/neos-development-collection | Neos.Neos/Classes/Fusion/ExceptionHandlers/NodeWrappingHandler.php | NodeWrappingHandler.handle | protected function handle($fusionPath, \Exception $exception, $referenceCode)
{
$handler = new ContextDependentHandler();
$handler->setRuntime($this->runtime);
$output = $handler->handleRenderingException($fusionPath, $exception);
$currentContext = $this->getRuntime()->getCurrentContext();
if (isset($currentContext['node'])) {
/** @var NodeInterface $node */
$node = $currentContext['node'];
$applicationContext = $this->environment->getContext();
if ($applicationContext->isProduction() && $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess') && $node->getContext()->getWorkspaceName() !== 'live') {
$output = '<div class="neos-rendering-exception"><div class="neos-rendering-exception-title">Failed to render element' . $output . '</div></div>';
}
return $this->contentElementWrappingService->wrapContentObject($node, $output, $fusionPath);
}
return $output;
} | php | protected function handle($fusionPath, \Exception $exception, $referenceCode)
{
$handler = new ContextDependentHandler();
$handler->setRuntime($this->runtime);
$output = $handler->handleRenderingException($fusionPath, $exception);
$currentContext = $this->getRuntime()->getCurrentContext();
if (isset($currentContext['node'])) {
/** @var NodeInterface $node */
$node = $currentContext['node'];
$applicationContext = $this->environment->getContext();
if ($applicationContext->isProduction() && $this->privilegeManager->isPrivilegeTargetGranted('Neos.Neos:Backend.GeneralAccess') && $node->getContext()->getWorkspaceName() !== 'live') {
$output = '<div class="neos-rendering-exception"><div class="neos-rendering-exception-title">Failed to render element' . $output . '</div></div>';
}
return $this->contentElementWrappingService->wrapContentObject($node, $output, $fusionPath);
}
return $output;
} | [
"protected",
"function",
"handle",
"(",
"$",
"fusionPath",
",",
"\\",
"Exception",
"$",
"exception",
",",
"$",
"referenceCode",
")",
"{",
"$",
"handler",
"=",
"new",
"ContextDependentHandler",
"(",
")",
";",
"$",
"handler",
"->",
"setRuntime",
"(",
"$",
"t... | renders the exception to nice html content element to display, edit, remove, ...
@param string $fusionPath - path causing the exception
@param \Exception $exception - exception to handle
@param integer $referenceCode - might be unset
@return string | [
"renders",
"the",
"exception",
"to",
"nice",
"html",
"content",
"element",
"to",
"display",
"edit",
"remove",
"..."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Fusion/ExceptionHandlers/NodeWrappingHandler.php#L55-L74 | train |
neos/neos-development-collection | Neos.Neos/Classes/Fusion/ExceptionHandlers/NodeWrappingHandler.php | NodeWrappingHandler.getMessage | protected function getMessage(\Exception $exception, $referenceCode)
{
if (isset($referenceCode)) {
return sprintf('%s (%s)', $exception->getMessage(), $referenceCode);
}
return $exception->getMessage();
} | php | protected function getMessage(\Exception $exception, $referenceCode)
{
if (isset($referenceCode)) {
return sprintf('%s (%s)', $exception->getMessage(), $referenceCode);
}
return $exception->getMessage();
} | [
"protected",
"function",
"getMessage",
"(",
"\\",
"Exception",
"$",
"exception",
",",
"$",
"referenceCode",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"referenceCode",
")",
")",
"{",
"return",
"sprintf",
"(",
"'%s (%s)'",
",",
"$",
"exception",
"->",
"getMess... | appends the given reference code to the exception's message
unless it is unset
@param \Exception $exception
@param $referenceCode
@return string | [
"appends",
"the",
"given",
"reference",
"code",
"to",
"the",
"exception",
"s",
"message",
"unless",
"it",
"is",
"unset"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Fusion/ExceptionHandlers/NodeWrappingHandler.php#L84-L90 | train |
neos/neos-development-collection | Neos.Neos/Classes/Command/SiteCommandController.php | SiteCommandController.createCommand | public function createCommand($name, $packageKey, $nodeType = 'Neos.NodeTypes:Page', $nodeName = null, $inactive = false)
{
if ($nodeName === null) {
$nodeName = $this->nodeService->generateUniqueNodeName(SiteService::SITES_ROOT_PATH, $name);
}
if ($this->siteRepository->findOneByNodeName($nodeName)) {
$this->outputLine('<error>A site with siteNodeName "%s" already exists</error>', [$nodeName]);
$this->quit(1);
}
if ($this->packageManager->isPackageAvailable($packageKey) === false) {
$this->outputLine('<error>Could not find package "%s"</error>', [$packageKey]);
$this->quit(1);
}
$siteNodeType = $this->nodeTypeManager->getNodeType($nodeType);
if ($siteNodeType === null || $siteNodeType->getName() === 'Neos.Neos:FallbackNode') {
$this->outputLine('<error>The given node type "%s" was not found</error>', [$nodeType]);
$this->quit(1);
}
if ($siteNodeType->isOfType('Neos.Neos:Document') === false) {
$this->outputLine('<error>The given node type "%s" is not based on the superType "%s"</error>', [$nodeType, 'Neos.Neos:Document']);
$this->quit(1);
}
$rootNode = $this->nodeContextFactory->create()->getRootNode();
// We fetch the workspace to be sure it's known to the persistence manager and persist all
// so the workspace and site node are persisted before we import any nodes to it.
$rootNode->getContext()->getWorkspace();
$this->persistenceManager->persistAll();
$sitesNode = $rootNode->getNode(SiteService::SITES_ROOT_PATH);
if ($sitesNode === null) {
$sitesNode = $rootNode->createNode(NodePaths::getNodeNameFromPath(SiteService::SITES_ROOT_PATH));
}
$siteNode = $sitesNode->createNode($nodeName, $siteNodeType);
$siteNode->setProperty('title', $name);
$site = new Site($nodeName);
$site->setSiteResourcesPackageKey($packageKey);
$site->setState($inactive ? Site::STATE_OFFLINE : Site::STATE_ONLINE);
$site->setName($name);
$this->siteRepository->add($site);
$this->outputLine('Successfully created site "%s" with siteNode "%s", type "%s", packageKey "%s" and state "%s"', [$name, $nodeName, $nodeType, $packageKey, $inactive ? 'offline' : 'online']);
} | php | public function createCommand($name, $packageKey, $nodeType = 'Neos.NodeTypes:Page', $nodeName = null, $inactive = false)
{
if ($nodeName === null) {
$nodeName = $this->nodeService->generateUniqueNodeName(SiteService::SITES_ROOT_PATH, $name);
}
if ($this->siteRepository->findOneByNodeName($nodeName)) {
$this->outputLine('<error>A site with siteNodeName "%s" already exists</error>', [$nodeName]);
$this->quit(1);
}
if ($this->packageManager->isPackageAvailable($packageKey) === false) {
$this->outputLine('<error>Could not find package "%s"</error>', [$packageKey]);
$this->quit(1);
}
$siteNodeType = $this->nodeTypeManager->getNodeType($nodeType);
if ($siteNodeType === null || $siteNodeType->getName() === 'Neos.Neos:FallbackNode') {
$this->outputLine('<error>The given node type "%s" was not found</error>', [$nodeType]);
$this->quit(1);
}
if ($siteNodeType->isOfType('Neos.Neos:Document') === false) {
$this->outputLine('<error>The given node type "%s" is not based on the superType "%s"</error>', [$nodeType, 'Neos.Neos:Document']);
$this->quit(1);
}
$rootNode = $this->nodeContextFactory->create()->getRootNode();
// We fetch the workspace to be sure it's known to the persistence manager and persist all
// so the workspace and site node are persisted before we import any nodes to it.
$rootNode->getContext()->getWorkspace();
$this->persistenceManager->persistAll();
$sitesNode = $rootNode->getNode(SiteService::SITES_ROOT_PATH);
if ($sitesNode === null) {
$sitesNode = $rootNode->createNode(NodePaths::getNodeNameFromPath(SiteService::SITES_ROOT_PATH));
}
$siteNode = $sitesNode->createNode($nodeName, $siteNodeType);
$siteNode->setProperty('title', $name);
$site = new Site($nodeName);
$site->setSiteResourcesPackageKey($packageKey);
$site->setState($inactive ? Site::STATE_OFFLINE : Site::STATE_ONLINE);
$site->setName($name);
$this->siteRepository->add($site);
$this->outputLine('Successfully created site "%s" with siteNode "%s", type "%s", packageKey "%s" and state "%s"', [$name, $nodeName, $nodeType, $packageKey, $inactive ? 'offline' : 'online']);
} | [
"public",
"function",
"createCommand",
"(",
"$",
"name",
",",
"$",
"packageKey",
",",
"$",
"nodeType",
"=",
"'Neos.NodeTypes:Page'",
",",
"$",
"nodeName",
"=",
"null",
",",
"$",
"inactive",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"nodeName",
"===",
"null... | Create a new site
This command allows to create a blank site with just a single empty document in the default dimension.
The name of the site, the packageKey must be specified.
If no ``nodeType`` option is specified the command will use `Neos.NodeTypes:Page` as fallback. The node type
must already exists and have the superType ``Neos.Neos:Document``.
If no ``nodeName`` option is specified the command will create a unique node-name from the name of the site.
If a node name is given it has to be unique for the setup.
If the flag ``activate`` is set to false new site will not be activated.
@param string $name The name of the site
@param string $packageKey The site package
@param string $nodeType The node type to use for the site node. (Default = Neos.NodeTypes:Page)
@param string $nodeName The name of the site node. If no nodeName is given it will be determined from the siteName.
@param boolean $inactive The new site is not activated immediately (default = false).
@return void | [
"Create",
"a",
"new",
"site"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Command/SiteCommandController.php#L139-L187 | train |
neos/neos-development-collection | Neos.Neos/Classes/Command/SiteCommandController.php | SiteCommandController.importCommand | public function importCommand($packageKey = null, $filename = null)
{
$exceedingArguments = $this->request->getExceedingArguments();
if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
if (file_exists($exceedingArguments[0])) {
$filename = $exceedingArguments[0];
} elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
$packageKey = $exceedingArguments[0];
}
}
if ($packageKey === null && $filename === null) {
$this->outputLine('You have to specify either "--package-key" or "--filename"');
$this->quit(1);
}
// Since this command uses a lot of memory when large sites are imported, we warn the user to watch for
// the confirmation of a successful import.
$this->outputLine('<b>This command can use a lot of memory when importing sites with many resources.</b>');
$this->outputLine('If the import is successful, you will see a message saying "Import of site ... finished".');
$this->outputLine('If you do not see this message, the import failed, most likely due to insufficient memory.');
$this->outputLine('Increase the <b>memory_limit</b> configuration parameter of your php CLI to attempt to fix this.');
$this->outputLine('Starting import...');
$this->outputLine('---');
$site = null;
if ($filename !== null) {
try {
$site = $this->siteImportService->importFromFile($filename);
} catch (\Exception $exception) {
$logMessage = $this->throwableStorage->logThrowable($exception);
$this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
$this->outputLine('<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>', [$filename, $exception->getMessage()]);
$this->quit(1);
}
} else {
try {
$site = $this->siteImportService->importFromPackage($packageKey);
} catch (\Exception $exception) {
$logMessage = $this->throwableStorage->logThrowable($exception);
$this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
$this->outputLine('<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>', [$packageKey, $exception->getMessage()]);
$this->quit(1);
}
}
$this->outputLine('Import of site "%s" finished.', [$site->getName()]);
} | php | public function importCommand($packageKey = null, $filename = null)
{
$exceedingArguments = $this->request->getExceedingArguments();
if (isset($exceedingArguments[0]) && $packageKey === null && $filename === null) {
if (file_exists($exceedingArguments[0])) {
$filename = $exceedingArguments[0];
} elseif ($this->packageManager->isPackageAvailable($exceedingArguments[0])) {
$packageKey = $exceedingArguments[0];
}
}
if ($packageKey === null && $filename === null) {
$this->outputLine('You have to specify either "--package-key" or "--filename"');
$this->quit(1);
}
// Since this command uses a lot of memory when large sites are imported, we warn the user to watch for
// the confirmation of a successful import.
$this->outputLine('<b>This command can use a lot of memory when importing sites with many resources.</b>');
$this->outputLine('If the import is successful, you will see a message saying "Import of site ... finished".');
$this->outputLine('If you do not see this message, the import failed, most likely due to insufficient memory.');
$this->outputLine('Increase the <b>memory_limit</b> configuration parameter of your php CLI to attempt to fix this.');
$this->outputLine('Starting import...');
$this->outputLine('---');
$site = null;
if ($filename !== null) {
try {
$site = $this->siteImportService->importFromFile($filename);
} catch (\Exception $exception) {
$logMessage = $this->throwableStorage->logThrowable($exception);
$this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
$this->outputLine('<error>During the import of the file "%s" an exception occurred: %s, see log for further information.</error>', [$filename, $exception->getMessage()]);
$this->quit(1);
}
} else {
try {
$site = $this->siteImportService->importFromPackage($packageKey);
} catch (\Exception $exception) {
$logMessage = $this->throwableStorage->logThrowable($exception);
$this->logger->error($logMessage, LogEnvironment::fromMethodName(__METHOD__));
$this->outputLine('<error>During the import of the "Sites.xml" from the package "%s" an exception occurred: %s, see log for further information.</error>', [$packageKey, $exception->getMessage()]);
$this->quit(1);
}
}
$this->outputLine('Import of site "%s" finished.', [$site->getName()]);
} | [
"public",
"function",
"importCommand",
"(",
"$",
"packageKey",
"=",
"null",
",",
"$",
"filename",
"=",
"null",
")",
"{",
"$",
"exceedingArguments",
"=",
"$",
"this",
"->",
"request",
"->",
"getExceedingArguments",
"(",
")",
";",
"if",
"(",
"isset",
"(",
... | Import sites content
This command allows for importing one or more sites or partial content from an XML source. The format must
be identical to that produced by the export command.
If a filename is specified, this command expects the corresponding file to contain the XML structure. The
filename php://stdin can be used to read from standard input.
If a package key is specified, this command expects a Sites.xml file to be located in the private resources
directory of the given package (Resources/Private/Content/Sites.xml).
@param string $packageKey Package key specifying the package containing the sites content
@param string $filename relative path and filename to the XML file containing the sites content
@return void | [
"Import",
"sites",
"content"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Command/SiteCommandController.php#L205-L252 | train |
neos/neos-development-collection | Neos.Neos/Classes/Command/SiteCommandController.php | SiteCommandController.listCommand | public function listCommand()
{
$sites = $this->siteRepository->findAll();
if ($sites->count() === 0) {
$this->outputLine('No sites available');
$this->quit(0);
}
$longestSiteName = 4;
$longestNodeName = 9;
$longestSiteResource = 17;
$availableSites = [];
foreach ($sites as $site) {
/** @var Site $site */
array_push($availableSites, [
'name' => $site->getName(),
'nodeName' => $site->getNodeName(),
'siteResourcesPackageKey' => $site->getSiteResourcesPackageKey(),
'status' => ($site->getState() === SITE::STATE_ONLINE) ? 'online' : 'offline'
]);
if (strlen($site->getName()) > $longestSiteName) {
$longestSiteName = strlen($site->getName());
}
if (strlen($site->getNodeName()) > $longestNodeName) {
$longestNodeName = strlen($site->getNodeName());
}
if (strlen($site->getSiteResourcesPackageKey()) > $longestSiteResource) {
$longestSiteResource = strlen($site->getSiteResourcesPackageKey());
}
}
$this->outputLine();
$this->outputLine(' ' . str_pad('Name', $longestSiteName + 15) . str_pad('Node name', $longestNodeName + 15) . str_pad('Resources package', $longestSiteResource + 15) . 'Status ');
$this->outputLine(str_repeat('-', $longestSiteName + $longestNodeName + $longestSiteResource + 7 + 15 + 15 + 15 + 2));
foreach ($availableSites as $site) {
$this->outputLine(' ' . str_pad($site['name'], $longestSiteName + 15) . str_pad($site['nodeName'], $longestNodeName + 15) . str_pad($site['siteResourcesPackageKey'], $longestSiteResource + 15) . $site['status']);
}
$this->outputLine();
} | php | public function listCommand()
{
$sites = $this->siteRepository->findAll();
if ($sites->count() === 0) {
$this->outputLine('No sites available');
$this->quit(0);
}
$longestSiteName = 4;
$longestNodeName = 9;
$longestSiteResource = 17;
$availableSites = [];
foreach ($sites as $site) {
/** @var Site $site */
array_push($availableSites, [
'name' => $site->getName(),
'nodeName' => $site->getNodeName(),
'siteResourcesPackageKey' => $site->getSiteResourcesPackageKey(),
'status' => ($site->getState() === SITE::STATE_ONLINE) ? 'online' : 'offline'
]);
if (strlen($site->getName()) > $longestSiteName) {
$longestSiteName = strlen($site->getName());
}
if (strlen($site->getNodeName()) > $longestNodeName) {
$longestNodeName = strlen($site->getNodeName());
}
if (strlen($site->getSiteResourcesPackageKey()) > $longestSiteResource) {
$longestSiteResource = strlen($site->getSiteResourcesPackageKey());
}
}
$this->outputLine();
$this->outputLine(' ' . str_pad('Name', $longestSiteName + 15) . str_pad('Node name', $longestNodeName + 15) . str_pad('Resources package', $longestSiteResource + 15) . 'Status ');
$this->outputLine(str_repeat('-', $longestSiteName + $longestNodeName + $longestSiteResource + 7 + 15 + 15 + 15 + 2));
foreach ($availableSites as $site) {
$this->outputLine(' ' . str_pad($site['name'], $longestSiteName + 15) . str_pad($site['nodeName'], $longestNodeName + 15) . str_pad($site['siteResourcesPackageKey'], $longestSiteResource + 15) . $site['status']);
}
$this->outputLine();
} | [
"public",
"function",
"listCommand",
"(",
")",
"{",
"$",
"sites",
"=",
"$",
"this",
"->",
"siteRepository",
"->",
"findAll",
"(",
")",
";",
"if",
"(",
"$",
"sites",
"->",
"count",
"(",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"outputLine",
"("... | List available sites
@return void | [
"List",
"available",
"sites"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Command/SiteCommandController.php#L337-L377 | train |
neos/neos-development-collection | Neos.Neos/Classes/Command/SiteCommandController.php | SiteCommandController.findSitesByNodeNamePattern | protected function findSitesByNodeNamePattern($siteNodePattern)
{
return array_filter(
$this->siteRepository->findAll()->toArray(),
function ($site) use ($siteNodePattern) {
return fnmatch($siteNodePattern, $site->getNodeName());
}
);
} | php | protected function findSitesByNodeNamePattern($siteNodePattern)
{
return array_filter(
$this->siteRepository->findAll()->toArray(),
function ($site) use ($siteNodePattern) {
return fnmatch($siteNodePattern, $site->getNodeName());
}
);
} | [
"protected",
"function",
"findSitesByNodeNamePattern",
"(",
"$",
"siteNodePattern",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"siteRepository",
"->",
"findAll",
"(",
")",
"->",
"toArray",
"(",
")",
",",
"function",
"(",
"$",
"site",
")",
"u... | Find all sites the match the given site-node-name-pattern with support for globbing
@param string $siteNodePattern nodeName patterns for sites to find
@return array<Site> | [
"Find",
"all",
"sites",
"the",
"match",
"the",
"given",
"site",
"-",
"node",
"-",
"name",
"-",
"pattern",
"with",
"support",
"for",
"globbing"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Command/SiteCommandController.php#L429-L437 | train |
neos/neos-development-collection | Neos.Media.Browser/Classes/Controller/UsageController.php | UsageController.relatedNodesAction | public function relatedNodesAction(AssetInterface $asset)
{
$userWorkspace = $this->userService->getPersonalWorkspace();
$usageReferences = $this->assetService->getUsageReferences($asset);
$relatedNodes = [];
$inaccessibleRelations = [];
$existingSites = $this->siteRepository->findAll();
foreach ($usageReferences as $usage) {
$inaccessibleRelation = [
'type' => get_class($usage),
'usage' => $usage
];
if (!$usage instanceof AssetUsageInNodeProperties) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
try {
$nodeType = $this->nodeTypeManager->getNodeType($usage->getNodeTypeName());
} catch (NodeTypeNotFoundException $e) {
$nodeType = null;
}
/** @var Workspace $workspace */
$workspace = $this->workspaceRepository->findByIdentifier($usage->getWorkspaceName());
$accessible = $this->domainUserService->currentUserCanReadWorkspace($workspace);
$inaccessibleRelation['nodeIdentifier'] = $usage->getNodeIdentifier();
$inaccessibleRelation['workspaceName'] = $usage->getWorkspaceName();
$inaccessibleRelation['workspace'] = $workspace;
$inaccessibleRelation['nodeType'] = $nodeType;
$inaccessibleRelation['accessible'] = $accessible;
if (!$accessible) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
$node = $this->getNodeFrom($usage);
// this should actually never happen.
if (!$node) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
$flowQuery = new FlowQuery([$node]);
$documentNode = $flowQuery->closest('[instanceof Neos.Neos:Document]')->get(0);
// this should actually never happen, too.
if (!$documentNode) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
$site = $node->getContext()->getCurrentSite();
foreach ($existingSites as $existingSite) {
/** @var Site $existingSite * */
$siteNodePath = '/sites/' . $existingSite->getNodeName();
if ($siteNodePath === $node->getPAth() || strpos($node->getPath(), $siteNodePath . '/') === 0) {
$site = $existingSite;
}
}
$relatedNodes[$site->getNodeName()]['site'] = $site;
$relatedNodes[$site->getNodeName()]['nodes'][] = [
'node' => $node,
'documentNode' => $documentNode
];
}
$this->view->assignMultiple([
'totalUsageCount' => count($usageReferences),
'nodeUsageClass' => AssetUsageInNodeProperties::class,
'asset' => $asset,
'inaccessibleRelations' => $inaccessibleRelations,
'relatedNodes' => $relatedNodes,
'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets(),
'userWorkspace' => $userWorkspace
]);
} | php | public function relatedNodesAction(AssetInterface $asset)
{
$userWorkspace = $this->userService->getPersonalWorkspace();
$usageReferences = $this->assetService->getUsageReferences($asset);
$relatedNodes = [];
$inaccessibleRelations = [];
$existingSites = $this->siteRepository->findAll();
foreach ($usageReferences as $usage) {
$inaccessibleRelation = [
'type' => get_class($usage),
'usage' => $usage
];
if (!$usage instanceof AssetUsageInNodeProperties) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
try {
$nodeType = $this->nodeTypeManager->getNodeType($usage->getNodeTypeName());
} catch (NodeTypeNotFoundException $e) {
$nodeType = null;
}
/** @var Workspace $workspace */
$workspace = $this->workspaceRepository->findByIdentifier($usage->getWorkspaceName());
$accessible = $this->domainUserService->currentUserCanReadWorkspace($workspace);
$inaccessibleRelation['nodeIdentifier'] = $usage->getNodeIdentifier();
$inaccessibleRelation['workspaceName'] = $usage->getWorkspaceName();
$inaccessibleRelation['workspace'] = $workspace;
$inaccessibleRelation['nodeType'] = $nodeType;
$inaccessibleRelation['accessible'] = $accessible;
if (!$accessible) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
$node = $this->getNodeFrom($usage);
// this should actually never happen.
if (!$node) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
$flowQuery = new FlowQuery([$node]);
$documentNode = $flowQuery->closest('[instanceof Neos.Neos:Document]')->get(0);
// this should actually never happen, too.
if (!$documentNode) {
$inaccessibleRelations[] = $inaccessibleRelation;
continue;
}
$site = $node->getContext()->getCurrentSite();
foreach ($existingSites as $existingSite) {
/** @var Site $existingSite * */
$siteNodePath = '/sites/' . $existingSite->getNodeName();
if ($siteNodePath === $node->getPAth() || strpos($node->getPath(), $siteNodePath . '/') === 0) {
$site = $existingSite;
}
}
$relatedNodes[$site->getNodeName()]['site'] = $site;
$relatedNodes[$site->getNodeName()]['nodes'][] = [
'node' => $node,
'documentNode' => $documentNode
];
}
$this->view->assignMultiple([
'totalUsageCount' => count($usageReferences),
'nodeUsageClass' => AssetUsageInNodeProperties::class,
'asset' => $asset,
'inaccessibleRelations' => $inaccessibleRelations,
'relatedNodes' => $relatedNodes,
'contentDimensions' => $this->contentDimensionPresetSource->getAllPresets(),
'userWorkspace' => $userWorkspace
]);
} | [
"public",
"function",
"relatedNodesAction",
"(",
"AssetInterface",
"$",
"asset",
")",
"{",
"$",
"userWorkspace",
"=",
"$",
"this",
"->",
"userService",
"->",
"getPersonalWorkspace",
"(",
")",
";",
"$",
"usageReferences",
"=",
"$",
"this",
"->",
"assetService",
... | Get Related Nodes for an asset
@param AssetInterface $asset
@return void | [
"Get",
"Related",
"Nodes",
"for",
"an",
"asset"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media.Browser/Classes/Controller/UsageController.php#L89-L170 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.setPath | protected function setPath(string $path, bool $checkForExistence = true): void
{
$originalPath = $this->nodeData->getPath();
if ($originalPath === $path) {
return;
}
$pathAvailable = $checkForExistence ? $this->isNodePathAvailable($path) : true;
if (!$pathAvailable) {
throw new NodeException(sprintf('Can not rename the node "%s" as a node already exists on path "%s"', $this->getPath(), $path), 1414436551);
}
$changedNodePathsCollection = $this->setPathInternal($path, !$checkForExistence);
$this->nodeDataRepository->persistEntities();
array_walk($changedNodePathsCollection, function ($changedNodePathInformation) {
call_user_func_array([
$this,
'emitNodePathChanged'
], $changedNodePathInformation);
});
} | php | protected function setPath(string $path, bool $checkForExistence = true): void
{
$originalPath = $this->nodeData->getPath();
if ($originalPath === $path) {
return;
}
$pathAvailable = $checkForExistence ? $this->isNodePathAvailable($path) : true;
if (!$pathAvailable) {
throw new NodeException(sprintf('Can not rename the node "%s" as a node already exists on path "%s"', $this->getPath(), $path), 1414436551);
}
$changedNodePathsCollection = $this->setPathInternal($path, !$checkForExistence);
$this->nodeDataRepository->persistEntities();
array_walk($changedNodePathsCollection, function ($changedNodePathInformation) {
call_user_func_array([
$this,
'emitNodePathChanged'
], $changedNodePathInformation);
});
} | [
"protected",
"function",
"setPath",
"(",
"string",
"$",
"path",
",",
"bool",
"$",
"checkForExistence",
"=",
"true",
")",
":",
"void",
"{",
"$",
"originalPath",
"=",
"$",
"this",
"->",
"nodeData",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"origina... | Sets the absolute path of this node.
This method is only for internal use by the content repository or node methods. Changing
the path of a node manually may lead to unexpected behavior.
To achieve a correct behavior when changing the path (moving the node) in a workspace, a shadow node data that will
hide the node data in the base workspace will be created. Thus queries do not need to worry about moved nodes.
Through a movedTo reference the shadow node data will be removed when publishing the moved node.
@param string $path
@param boolean $checkForExistence Checks for existence at target path, internally used for recursions and shadow nodes.
@return void
@throws NodeException
@throws NodeTypeNotFoundException | [
"Sets",
"the",
"absolute",
"path",
"of",
"this",
"node",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L171-L191 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.isNodePathAvailable | protected function isNodePathAvailable(string $path): bool
{
$existingNodeDataArray = $this->nodeDataRepository->findByPathWithoutReduce($path, $this->context->getWorkspace());
$nonMatchingNodeData = array_filter($existingNodeDataArray, function (NodeData $nodeData) {
return ($nodeData->getIdentifier() !== $this->getIdentifier());
});
return ($nonMatchingNodeData === []);
} | php | protected function isNodePathAvailable(string $path): bool
{
$existingNodeDataArray = $this->nodeDataRepository->findByPathWithoutReduce($path, $this->context->getWorkspace());
$nonMatchingNodeData = array_filter($existingNodeDataArray, function (NodeData $nodeData) {
return ($nodeData->getIdentifier() !== $this->getIdentifier());
});
return ($nonMatchingNodeData === []);
} | [
"protected",
"function",
"isNodePathAvailable",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"$",
"existingNodeDataArray",
"=",
"$",
"this",
"->",
"nodeDataRepository",
"->",
"findByPathWithoutReduce",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"context",
... | Checks if the given node path is available for this node, so either no node with this path exists or an existing node has the same identifier.
@param string $path
@return boolean | [
"Checks",
"if",
"the",
"given",
"node",
"path",
"is",
"available",
"for",
"this",
"node",
"so",
"either",
"no",
"node",
"with",
"this",
"path",
"exists",
"or",
"an",
"existing",
"node",
"has",
"the",
"same",
"identifier",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L199-L208 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.setPathInternal | protected function setPathInternal(string $destinationPath, bool $recursiveCall): array
{
if ($this->getNodeType()->isAggregate()) {
return $this->setPathInternalForAggregate($destinationPath, $recursiveCall);
}
$originalPath = $this->nodeData->getPath();
/** @var Node $childNode */
foreach ($this->getChildNodes() as $childNode) {
$childNode->setPath(NodePaths::addNodePathSegment($destinationPath, $childNode->getName()), false);
}
$this->moveNodeToDestinationPath($this, $destinationPath);
return [
[$this, $originalPath, $this->getNodeData()->getPath(), $recursiveCall]
];
} | php | protected function setPathInternal(string $destinationPath, bool $recursiveCall): array
{
if ($this->getNodeType()->isAggregate()) {
return $this->setPathInternalForAggregate($destinationPath, $recursiveCall);
}
$originalPath = $this->nodeData->getPath();
/** @var Node $childNode */
foreach ($this->getChildNodes() as $childNode) {
$childNode->setPath(NodePaths::addNodePathSegment($destinationPath, $childNode->getName()), false);
}
$this->moveNodeToDestinationPath($this, $destinationPath);
return [
[$this, $originalPath, $this->getNodeData()->getPath(), $recursiveCall]
];
} | [
"protected",
"function",
"setPathInternal",
"(",
"string",
"$",
"destinationPath",
",",
"bool",
"$",
"recursiveCall",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"getNodeType",
"(",
")",
"->",
"isAggregate",
"(",
")",
")",
"{",
"return",
"$",
"... | Moves a node and sub nodes to the new path.
This process is different depending on the fact if the node is an aggregate type or not.
@param string $destinationPath the new node path
@param boolean $recursiveCall is this a recursive call
@return array NodeVariants and old and new paths
@throws NodeException
@throws NodeTypeNotFoundException | [
"Moves",
"a",
"node",
"and",
"sub",
"nodes",
"to",
"the",
"new",
"path",
".",
"This",
"process",
"is",
"different",
"depending",
"on",
"the",
"fact",
"if",
"the",
"node",
"is",
"an",
"aggregate",
"type",
"or",
"not",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L220-L238 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.setPathInternalForAggregate | protected function setPathInternalForAggregate(string $destinationPath, bool $recursiveCall): array
{
$originalPath = $this->nodeData->getPath();
$nodeDataVariantsAndChildren = $this->nodeDataRepository->findByPathWithoutReduce($originalPath, $this->context->getWorkspace(), true, true);
$changedNodePathsCollection = array_map(function ($nodeData) use ($destinationPath, $originalPath, $recursiveCall) {
return $this->moveNodeData($nodeData, $originalPath, $destinationPath, $recursiveCall);
}, $nodeDataVariantsAndChildren);
return array_filter($changedNodePathsCollection);
} | php | protected function setPathInternalForAggregate(string $destinationPath, bool $recursiveCall): array
{
$originalPath = $this->nodeData->getPath();
$nodeDataVariantsAndChildren = $this->nodeDataRepository->findByPathWithoutReduce($originalPath, $this->context->getWorkspace(), true, true);
$changedNodePathsCollection = array_map(function ($nodeData) use ($destinationPath, $originalPath, $recursiveCall) {
return $this->moveNodeData($nodeData, $originalPath, $destinationPath, $recursiveCall);
}, $nodeDataVariantsAndChildren);
return array_filter($changedNodePathsCollection);
} | [
"protected",
"function",
"setPathInternalForAggregate",
"(",
"string",
"$",
"destinationPath",
",",
"bool",
"$",
"recursiveCall",
")",
":",
"array",
"{",
"$",
"originalPath",
"=",
"$",
"this",
"->",
"nodeData",
"->",
"getPath",
"(",
")",
";",
"$",
"nodeDataVar... | Moves a node and sub nodes to the new path given with special logic for aggregate node types.
@param string $destinationPath the new node path
@param boolean $recursiveCall is this a recursive call
@return array of arrays with NodeVariant and old and new path and if this was a recursive call | [
"Moves",
"a",
"node",
"and",
"sub",
"nodes",
"to",
"the",
"new",
"path",
"given",
"with",
"special",
"logic",
"for",
"aggregate",
"node",
"types",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L247-L257 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.moveNodeData | protected function moveNodeData(NodeData $nodeData, string $originalPath, string $destinationPath, bool $recursiveCall)
{
$recursiveCall = $recursiveCall || ($this->nodeData !== $nodeData);
$nodeVariant = null;
// $nodeData at this point could contain *our own NodeData reference* ($this->nodeData), as we find all NodeData objects
// (across all dimensions) with the same path.
//
// We need to ensure that our own Node object's nodeData reference ($this->nodeData) is also updated correctly if a new NodeData object
// is returned; as we rely on the fact that $this->getPath() will return the new node path in all circumstances.
//
// However, $this->createNodeForVariant() only returns $this if the Context object is the same as $this->context; which is not
// the case if $this->context contains dimension fallbacks such as "Language: EN, DE".
//
// The "if" statement below is actually a workaround to ensure that if the NodeData object is our own one, we update *ourselves* correctly,
// and thus return the correct (new) Node Path when calling $this->getPath() afterwards.
// FIXME: This is dangerous and probably the NodeFactory should take care of globally tracking usage of NodeData objects and replacing them in Node objects
if ($this->nodeData === $nodeData) {
$nodeVariant = $this;
}
if ($nodeVariant === null) {
$nodeVariant = $this->createNodeForVariant($nodeData);
}
$moveVariantResult = $nodeVariant === null ? null : $this->moveVariantOrChild($originalPath, $destinationPath, $nodeVariant);
if ($moveVariantResult !== null) {
array_push($moveVariantResult, $recursiveCall);
}
return $moveVariantResult;
} | php | protected function moveNodeData(NodeData $nodeData, string $originalPath, string $destinationPath, bool $recursiveCall)
{
$recursiveCall = $recursiveCall || ($this->nodeData !== $nodeData);
$nodeVariant = null;
// $nodeData at this point could contain *our own NodeData reference* ($this->nodeData), as we find all NodeData objects
// (across all dimensions) with the same path.
//
// We need to ensure that our own Node object's nodeData reference ($this->nodeData) is also updated correctly if a new NodeData object
// is returned; as we rely on the fact that $this->getPath() will return the new node path in all circumstances.
//
// However, $this->createNodeForVariant() only returns $this if the Context object is the same as $this->context; which is not
// the case if $this->context contains dimension fallbacks such as "Language: EN, DE".
//
// The "if" statement below is actually a workaround to ensure that if the NodeData object is our own one, we update *ourselves* correctly,
// and thus return the correct (new) Node Path when calling $this->getPath() afterwards.
// FIXME: This is dangerous and probably the NodeFactory should take care of globally tracking usage of NodeData objects and replacing them in Node objects
if ($this->nodeData === $nodeData) {
$nodeVariant = $this;
}
if ($nodeVariant === null) {
$nodeVariant = $this->createNodeForVariant($nodeData);
}
$moveVariantResult = $nodeVariant === null ? null : $this->moveVariantOrChild($originalPath, $destinationPath, $nodeVariant);
if ($moveVariantResult !== null) {
array_push($moveVariantResult, $recursiveCall);
}
return $moveVariantResult;
} | [
"protected",
"function",
"moveNodeData",
"(",
"NodeData",
"$",
"nodeData",
",",
"string",
"$",
"originalPath",
",",
"string",
"$",
"destinationPath",
",",
"bool",
"$",
"recursiveCall",
")",
"{",
"$",
"recursiveCall",
"=",
"$",
"recursiveCall",
"||",
"(",
"$",
... | Moves a NodeData object that is either a variant or child node to the given destination path.
@param NodeData $nodeData
@param string $originalPath
@param string $destinationPath
@param boolean $recursiveCall
@return array|null
@throws NodeConfigurationException | [
"Moves",
"a",
"NodeData",
"object",
"that",
"is",
"either",
"a",
"variant",
"or",
"child",
"node",
"to",
"the",
"given",
"destination",
"path",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L269-L300 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.createNodeForVariant | protected function createNodeForVariant(NodeData $nodeData): NodeInterface
{
$contextProperties = $this->context->getProperties();
$contextProperties['dimensions'] = $nodeData->getDimensionValues();
unset($contextProperties['targetDimensions']);
$adjustedContext = $this->contextFactory->create($contextProperties);
return $this->nodeFactory->createFromNodeData($nodeData, $adjustedContext);
} | php | protected function createNodeForVariant(NodeData $nodeData): NodeInterface
{
$contextProperties = $this->context->getProperties();
$contextProperties['dimensions'] = $nodeData->getDimensionValues();
unset($contextProperties['targetDimensions']);
$adjustedContext = $this->contextFactory->create($contextProperties);
return $this->nodeFactory->createFromNodeData($nodeData, $adjustedContext);
} | [
"protected",
"function",
"createNodeForVariant",
"(",
"NodeData",
"$",
"nodeData",
")",
":",
"NodeInterface",
"{",
"$",
"contextProperties",
"=",
"$",
"this",
"->",
"context",
"->",
"getProperties",
"(",
")",
";",
"$",
"contextProperties",
"[",
"'dimensions'",
"... | Create a node for the given NodeData, given that it is a variant of the current node
@param NodeData $nodeData
@return NodeInterface
@throws NodeConfigurationException | [
"Create",
"a",
"node",
"for",
"the",
"given",
"NodeData",
"given",
"that",
"it",
"is",
"a",
"variant",
"of",
"the",
"current",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L309-L317 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.moveNodeToDestinationPath | protected function moveNodeToDestinationPath(NodeInterface $node, $destinationPath)
{
$nodeData = $node->getNodeData();
$possibleShadowedNodeData = $nodeData->move($destinationPath, $this->context->getWorkspace());
if ($node instanceof Node) {
$node->setNodeData($possibleShadowedNodeData);
}
} | php | protected function moveNodeToDestinationPath(NodeInterface $node, $destinationPath)
{
$nodeData = $node->getNodeData();
$possibleShadowedNodeData = $nodeData->move($destinationPath, $this->context->getWorkspace());
if ($node instanceof Node) {
$node->setNodeData($possibleShadowedNodeData);
}
} | [
"protected",
"function",
"moveNodeToDestinationPath",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"destinationPath",
")",
"{",
"$",
"nodeData",
"=",
"$",
"node",
"->",
"getNodeData",
"(",
")",
";",
"$",
"possibleShadowedNodeData",
"=",
"$",
"nodeData",
"->",
... | Moves the given node to the destination path by modifying the underlaying NodeData object.
@param NodeInterface $node
@param string $destinationPath
@return void | [
"Moves",
"the",
"given",
"node",
"to",
"the",
"destination",
"path",
"by",
"modifying",
"the",
"underlaying",
"NodeData",
"object",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L349-L356 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.moveAfter | public function moveAfter(NodeInterface $referenceNode, string $newName = null): void
{
if ($referenceNode === $this) {
return;
}
if ($this->isRoot()) {
throw new NodeException('The root node cannot be moved.', 1316361483);
}
$name = $newName !== null ? $newName : $this->getName();
$referenceParentNode = $referenceNode->getParent();
if ($referenceParentNode !== $this->getParent() && $referenceParentNode->getNode($name) !== null) {
throw new NodeExistsException(sprintf('Node with path "%s" already exists.', $name), 1292503469);
}
if (($referenceParentNode instanceof Node && !$referenceParentNode->willChildNodeBeAutoCreated($name)) && !$referenceParentNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot move %s after %s', $this, $referenceNode), 1404648100);
}
$this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_AFTER);
if ($referenceNode->getParentPath() !== $this->getParentPath()) {
$this->setPath(NodePaths::addNodePathSegment($referenceNode->getParentPath(), $name));
$this->nodeDataRepository->persistEntities();
} else {
if (!$this->isNodeDataMatchingContext()) {
$this->materializeNodeData();
}
}
$this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_AFTER, $referenceNode);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitAfterNodeMove($this, $referenceNode, NodeDataRepository::POSITION_AFTER);
$this->emitNodeUpdated($this);
} | php | public function moveAfter(NodeInterface $referenceNode, string $newName = null): void
{
if ($referenceNode === $this) {
return;
}
if ($this->isRoot()) {
throw new NodeException('The root node cannot be moved.', 1316361483);
}
$name = $newName !== null ? $newName : $this->getName();
$referenceParentNode = $referenceNode->getParent();
if ($referenceParentNode !== $this->getParent() && $referenceParentNode->getNode($name) !== null) {
throw new NodeExistsException(sprintf('Node with path "%s" already exists.', $name), 1292503469);
}
if (($referenceParentNode instanceof Node && !$referenceParentNode->willChildNodeBeAutoCreated($name)) && !$referenceParentNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot move %s after %s', $this, $referenceNode), 1404648100);
}
$this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_AFTER);
if ($referenceNode->getParentPath() !== $this->getParentPath()) {
$this->setPath(NodePaths::addNodePathSegment($referenceNode->getParentPath(), $name));
$this->nodeDataRepository->persistEntities();
} else {
if (!$this->isNodeDataMatchingContext()) {
$this->materializeNodeData();
}
}
$this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_AFTER, $referenceNode);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitAfterNodeMove($this, $referenceNode, NodeDataRepository::POSITION_AFTER);
$this->emitNodeUpdated($this);
} | [
"public",
"function",
"moveAfter",
"(",
"NodeInterface",
"$",
"referenceNode",
",",
"string",
"$",
"newName",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"$",
"referenceNode",
"===",
"$",
"this",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"this",... | Moves this node after the given node
@param NodeInterface $referenceNode
@param string $newName
@throws NodeConstraintException if a node constraint prevents moving the node
@throws NodeException
@throws NodeExistsException
@throws NodeTypeNotFoundException
@api | [
"Moves",
"this",
"node",
"after",
"the",
"given",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L637-L672 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.moveInto | public function moveInto(NodeInterface $referenceNode, string $newName = null): void
{
if ($referenceNode === $this || $referenceNode === $this->getParent()) {
return;
}
if ($this->isRoot()) {
throw new NodeException('The root node cannot be moved.', 1346769001);
}
$name = $newName !== null ? $newName : $this->getName();
if ($referenceNode !== $this->getParent() && $referenceNode->getNode($name) !== null) {
throw new NodeExistsException(sprintf('Node with path "%s" already exists.', $name), 1292503470);
}
if (($referenceNode instanceof Node && !$referenceNode->willChildNodeBeAutoCreated($name)) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot move %s into %s', $this, $referenceNode), 1404648124);
}
$this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
$this->setPath(NodePaths::addNodePathSegment($referenceNode->getPath(), $name));
$this->nodeDataRepository->persistEntities();
$this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_LAST);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitAfterNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
$this->emitNodeUpdated($this);
} | php | public function moveInto(NodeInterface $referenceNode, string $newName = null): void
{
if ($referenceNode === $this || $referenceNode === $this->getParent()) {
return;
}
if ($this->isRoot()) {
throw new NodeException('The root node cannot be moved.', 1346769001);
}
$name = $newName !== null ? $newName : $this->getName();
if ($referenceNode !== $this->getParent() && $referenceNode->getNode($name) !== null) {
throw new NodeExistsException(sprintf('Node with path "%s" already exists.', $name), 1292503470);
}
if (($referenceNode instanceof Node && !$referenceNode->willChildNodeBeAutoCreated($name)) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot move %s into %s', $this, $referenceNode), 1404648124);
}
$this->emitBeforeNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
$this->setPath(NodePaths::addNodePathSegment($referenceNode->getPath(), $name));
$this->nodeDataRepository->persistEntities();
$this->nodeDataRepository->setNewIndex($this->nodeData, NodeDataRepository::POSITION_LAST);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitAfterNodeMove($this, $referenceNode, NodeDataRepository::POSITION_LAST);
$this->emitNodeUpdated($this);
} | [
"public",
"function",
"moveInto",
"(",
"NodeInterface",
"$",
"referenceNode",
",",
"string",
"$",
"newName",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"$",
"referenceNode",
"===",
"$",
"this",
"||",
"$",
"referenceNode",
"===",
"$",
"this",
"->",
"g... | Moves this node into the given node
@param NodeInterface $referenceNode
@param string $newName
@throws NodeConstraintException
@throws NodeException
@throws NodeExistsException
@throws NodeTypeNotFoundException
@api | [
"Moves",
"this",
"node",
"into",
"the",
"given",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L685-L713 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.copyBefore | public function copyBefore(NodeInterface $referenceNode, $nodeName): NodeInterface
{
if ($referenceNode->getParent()->getNode($nodeName) !== null) {
throw new NodeExistsException(sprintf('Node with path "%s/%s" already exists.', $referenceNode->getParent()->getPath(), $nodeName), 1292503465);
}
if (!$referenceNode->getParent()->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot copy %s before %s', $this, $referenceNode), 1402050232);
}
$this->emitBeforeNodeCopy($this, $referenceNode->getParent());
$copiedNode = $this->createRecursiveCopy($referenceNode->getParent(), $nodeName, $this->getNodeType()->isAggregate());
$copiedNode->moveBefore($referenceNode);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($copiedNode);
$this->emitAfterNodeCopy($copiedNode, $referenceNode->getParent());
return $copiedNode;
} | php | public function copyBefore(NodeInterface $referenceNode, $nodeName): NodeInterface
{
if ($referenceNode->getParent()->getNode($nodeName) !== null) {
throw new NodeExistsException(sprintf('Node with path "%s/%s" already exists.', $referenceNode->getParent()->getPath(), $nodeName), 1292503465);
}
if (!$referenceNode->getParent()->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot copy %s before %s', $this, $referenceNode), 1402050232);
}
$this->emitBeforeNodeCopy($this, $referenceNode->getParent());
$copiedNode = $this->createRecursiveCopy($referenceNode->getParent(), $nodeName, $this->getNodeType()->isAggregate());
$copiedNode->moveBefore($referenceNode);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($copiedNode);
$this->emitAfterNodeCopy($copiedNode, $referenceNode->getParent());
return $copiedNode;
} | [
"public",
"function",
"copyBefore",
"(",
"NodeInterface",
"$",
"referenceNode",
",",
"$",
"nodeName",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"$",
"referenceNode",
"->",
"getParent",
"(",
")",
"->",
"getNode",
"(",
"$",
"nodeName",
")",
"!==",
"null",
"... | Copies this node before the given node
@param NodeInterface $referenceNode
@param string $nodeName
@return NodeInterface
@throws NodeConstraintException
@throws NodeException
@throws NodeExistsException
@throws NodeTypeNotFoundException
@api | [
"Copies",
"this",
"node",
"before",
"the",
"given",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L727-L746 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.copyInto | public function copyInto(NodeInterface $referenceNode, $nodeName): NodeInterface
{
$this->emitBeforeNodeCopy($this, $referenceNode);
$copiedNode = $this->copyIntoInternal($referenceNode, $nodeName, $this->getNodeType()->isAggregate());
$this->emitAfterNodeCopy($this, $referenceNode);
return $copiedNode;
} | php | public function copyInto(NodeInterface $referenceNode, $nodeName): NodeInterface
{
$this->emitBeforeNodeCopy($this, $referenceNode);
$copiedNode = $this->copyIntoInternal($referenceNode, $nodeName, $this->getNodeType()->isAggregate());
$this->emitAfterNodeCopy($this, $referenceNode);
return $copiedNode;
} | [
"public",
"function",
"copyInto",
"(",
"NodeInterface",
"$",
"referenceNode",
",",
"$",
"nodeName",
")",
":",
"NodeInterface",
"{",
"$",
"this",
"->",
"emitBeforeNodeCopy",
"(",
"$",
"this",
",",
"$",
"referenceNode",
")",
";",
"$",
"copiedNode",
"=",
"$",
... | Copies this node into the given node
@param NodeInterface $referenceNode
@param string $nodeName
@return NodeInterface
@throws NodeConstraintException
@throws NodeException
@throws NodeExistsException
@throws NodeTypeNotFoundException
@api | [
"Copies",
"this",
"node",
"into",
"the",
"given",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L793-L800 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.copyIntoInternal | protected function copyIntoInternal(NodeInterface $referenceNode, string $nodeName, bool $detachedCopy): NodeInterface
{
if ($referenceNode->getNode($nodeName) !== null) {
throw new NodeExistsException('Node with path "' . $referenceNode->getPath() . '/' . $nodeName . '" already exists.', 1292503467);
}
// On copy we basically re-recreate an existing node on a new location. As we skip the constraints check on
// node creation we should do the same while writing the node on the new location.
if (($referenceNode instanceof Node && !$referenceNode->willChildNodeBeAutoCreated($nodeName)) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot copy "%s" into "%s" due to node type constraints.', $this->__toString(), $referenceNode->__toString()), 1404648177);
}
$copiedNode = $this->createRecursiveCopy($referenceNode, $nodeName, $detachedCopy);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($copiedNode);
return $copiedNode;
} | php | protected function copyIntoInternal(NodeInterface $referenceNode, string $nodeName, bool $detachedCopy): NodeInterface
{
if ($referenceNode->getNode($nodeName) !== null) {
throw new NodeExistsException('Node with path "' . $referenceNode->getPath() . '/' . $nodeName . '" already exists.', 1292503467);
}
// On copy we basically re-recreate an existing node on a new location. As we skip the constraints check on
// node creation we should do the same while writing the node on the new location.
if (($referenceNode instanceof Node && !$referenceNode->willChildNodeBeAutoCreated($nodeName)) && !$referenceNode->isNodeTypeAllowedAsChildNode($this->getNodeType())) {
throw new NodeConstraintException(sprintf('Cannot copy "%s" into "%s" due to node type constraints.', $this->__toString(), $referenceNode->__toString()), 1404648177);
}
$copiedNode = $this->createRecursiveCopy($referenceNode, $nodeName, $detachedCopy);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($copiedNode);
return $copiedNode;
} | [
"protected",
"function",
"copyIntoInternal",
"(",
"NodeInterface",
"$",
"referenceNode",
",",
"string",
"$",
"nodeName",
",",
"bool",
"$",
"detachedCopy",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"$",
"referenceNode",
"->",
"getNode",
"(",
"$",
"nodeName",
"... | Internal method to do the actual copying.
For behavior of the $detachedCopy parameter, see method Node::createRecursiveCopy().
@param NodeInterface $referenceNode
@param string $nodeName
@param boolean $detachedCopy
@return NodeInterface
@throws NodeConstraintException
@throws NodeException
@throws NodeExistsException
@throws NodeTypeNotFoundException | [
"Internal",
"method",
"to",
"do",
"the",
"actual",
"copying",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L816-L835 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.setProperty | public function setProperty($propertyName, $value): void
{
$this->materializeNodeDataAsNeeded();
// Arrays could potentially contain entities and objects could be entities. In that case even if the object is the same it needs to be persisted in NodeData.
if (!is_object($value) && !is_array($value) && $this->getProperty($propertyName) === $value) {
return;
}
$oldValue = $this->hasProperty($propertyName) ? $this->getProperty($propertyName) : null;
$this->emitBeforeNodePropertyChange($this, $propertyName, $oldValue, $value);
$this->nodeData->setProperty($propertyName, $value);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodePropertyChanged($this, $propertyName, $oldValue, $value);
$this->emitNodeUpdated($this);
} | php | public function setProperty($propertyName, $value): void
{
$this->materializeNodeDataAsNeeded();
// Arrays could potentially contain entities and objects could be entities. In that case even if the object is the same it needs to be persisted in NodeData.
if (!is_object($value) && !is_array($value) && $this->getProperty($propertyName) === $value) {
return;
}
$oldValue = $this->hasProperty($propertyName) ? $this->getProperty($propertyName) : null;
$this->emitBeforeNodePropertyChange($this, $propertyName, $oldValue, $value);
$this->nodeData->setProperty($propertyName, $value);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodePropertyChanged($this, $propertyName, $oldValue, $value);
$this->emitNodeUpdated($this);
} | [
"public",
"function",
"setProperty",
"(",
"$",
"propertyName",
",",
"$",
"value",
")",
":",
"void",
"{",
"$",
"this",
"->",
"materializeNodeDataAsNeeded",
"(",
")",
";",
"// Arrays could potentially contain entities and objects could be entities. In that case even if the obje... | Sets the specified property.
If the node has a content object attached, the property will be set there
if it is settable.
@param string $propertyName Name of the property
@param mixed $value Value of the property
@return mixed
@throws NodeException
@throws NodeTypeNotFoundException
@throws \Neos\Flow\Property\Exception
@throws \Neos\Flow\Security\Exception
@api | [
"Sets",
"the",
"specified",
"property",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L852-L866 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.unsetContentObject | public function unsetContentObject(): void
{
if ($this->getContentObject() === null) {
return;
}
$this->materializeNodeDataAsNeeded();
$this->nodeData->unsetContentObject();
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeUpdated($this);
} | php | public function unsetContentObject(): void
{
if ($this->getContentObject() === null) {
return;
}
$this->materializeNodeDataAsNeeded();
$this->nodeData->unsetContentObject();
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeUpdated($this);
} | [
"public",
"function",
"unsetContentObject",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"getContentObject",
"(",
")",
"===",
"null",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"materializeNodeDataAsNeeded",
"(",
")",
";",
"$",
"this",... | Unsets the content object of this node.
@return void
@throws NodeTypeNotFoundException
@throws NodeException
@deprecated with version 4.3 - will be removed with 5.0 without replacement. Attaching entities to nodes never really worked. Instead you can reference objects as node properties via their identifier | [
"Unsets",
"the",
"content",
"object",
"of",
"this",
"node",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1048-L1058 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.createSingleNode | public function createSingleNode($name, NodeType $nodeType = null, $identifier = null): NodeInterface
{
if ($nodeType !== null && !$this->willChildNodeBeAutoCreated($name) && !$this->isNodeTypeAllowedAsChildNode($nodeType)) {
throw new NodeConstraintException('Cannot create new node "' . $name . '" of Type "' . $nodeType->getName() . '" in ' . $this->__toString(), 1400782413);
}
$dimensions = $this->context->getTargetDimensionValues();
$nodeData = $this->nodeData->createSingleNodeData($name, $nodeType, $identifier, $this->context->getWorkspace(), $dimensions);
$node = $this->nodeFactory->createFromNodeData($nodeData, $this->context);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($node);
return $node;
} | php | public function createSingleNode($name, NodeType $nodeType = null, $identifier = null): NodeInterface
{
if ($nodeType !== null && !$this->willChildNodeBeAutoCreated($name) && !$this->isNodeTypeAllowedAsChildNode($nodeType)) {
throw new NodeConstraintException('Cannot create new node "' . $name . '" of Type "' . $nodeType->getName() . '" in ' . $this->__toString(), 1400782413);
}
$dimensions = $this->context->getTargetDimensionValues();
$nodeData = $this->nodeData->createSingleNodeData($name, $nodeType, $identifier, $this->context->getWorkspace(), $dimensions);
$node = $this->nodeFactory->createFromNodeData($nodeData, $this->context);
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($node);
return $node;
} | [
"public",
"function",
"createSingleNode",
"(",
"$",
"name",
",",
"NodeType",
"$",
"nodeType",
"=",
"null",
",",
"$",
"identifier",
"=",
"null",
")",
":",
"NodeInterface",
"{",
"if",
"(",
"$",
"nodeType",
"!==",
"null",
"&&",
"!",
"$",
"this",
"->",
"wi... | Creates, adds and returns a child node of this node, without setting default
properties or creating subnodes. Only used internally.
For internal use only!
TODO: New SiteImportService uses createNode() and DQL. When we drop the LegagcySiteImportService we can change this to protected.
@param string $name Name of the new node
@param NodeType $nodeType Node type of the new node (optional)
@param string $identifier The identifier of the node, unique within the workspace, optional(!)
@return NodeInterface
@throws NodeConfigurationException
@throws NodeConstraintException
@throws NodeException
@throws NodeExistsException
@throws NodeTypeNotFoundException | [
"Creates",
"adds",
"and",
"returns",
"a",
"child",
"node",
"of",
"this",
"node",
"without",
"setting",
"default",
"properties",
"or",
"creating",
"subnodes",
".",
"Only",
"used",
"internally",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1156-L1171 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.getNode | public function getNode($path): ?NodeInterface
{
$absolutePath = $this->nodeService->normalizePath($path, $this->getPath());
$node = $this->context->getFirstLevelNodeCache()->getByPath($absolutePath);
if ($node !== false) {
return $node;
}
$node = $this->nodeDataRepository->findOneByPathInContext($absolutePath, $this->context);
$this->context->getFirstLevelNodeCache()->setByPath($absolutePath, $node);
return $node;
} | php | public function getNode($path): ?NodeInterface
{
$absolutePath = $this->nodeService->normalizePath($path, $this->getPath());
$node = $this->context->getFirstLevelNodeCache()->getByPath($absolutePath);
if ($node !== false) {
return $node;
}
$node = $this->nodeDataRepository->findOneByPathInContext($absolutePath, $this->context);
$this->context->getFirstLevelNodeCache()->setByPath($absolutePath, $node);
return $node;
} | [
"public",
"function",
"getNode",
"(",
"$",
"path",
")",
":",
"?",
"NodeInterface",
"{",
"$",
"absolutePath",
"=",
"$",
"this",
"->",
"nodeService",
"->",
"normalizePath",
"(",
"$",
"path",
",",
"$",
"this",
"->",
"getPath",
"(",
")",
")",
";",
"$",
"... | Returns a node specified by the given relative path.
@param string $path Path specifying the node, relative to this node
@return NodeInterface|null The specified node or NULL if no such node exists
@deprecated with version 4.3 - use findNamedChildNode() instead - for absolute paths a new API will be added with 5.0 | [
"Returns",
"a",
"node",
"specified",
"by",
"the",
"given",
"relative",
"path",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1214-L1224 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.getPrimaryChildNode | public function getPrimaryChildNode(): ?NodeInterface
{
return $this->nodeDataRepository->findFirstByParentAndNodeTypeInContext($this->getPath(), null, $this->context);
} | php | public function getPrimaryChildNode(): ?NodeInterface
{
return $this->nodeDataRepository->findFirstByParentAndNodeTypeInContext($this->getPath(), null, $this->context);
} | [
"public",
"function",
"getPrimaryChildNode",
"(",
")",
":",
"?",
"NodeInterface",
"{",
"return",
"$",
"this",
"->",
"nodeDataRepository",
"->",
"findFirstByParentAndNodeTypeInContext",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"null",
",",
"$",
"this",
... | Returns the primary child node of this node.
Which node acts as a primary child node will in the future depend on the
node type. For now it is just the first child node.
@return NodeInterface|null The primary child node or NULL if no such node exists
@deprecated with version 4.3, without any replacement. | [
"Returns",
"the",
"primary",
"child",
"node",
"of",
"this",
"node",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1235-L1238 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.setRemoved | public function setRemoved($removed): void
{
if (!$this->isNodeDataMatchingContext()) {
$this->materializeNodeData();
}
if ((boolean)$removed === true) {
/** @var $childNode Node */
foreach ($this->getChildNodes() as $childNode) {
$childNode->setRemoved(true);
}
$this->nodeData->setRemoved(true);
$this->emitNodeRemoved($this);
} else {
$this->nodeData->setRemoved(false);
$this->emitNodeUpdated($this);
}
$this->context->getFirstLevelNodeCache()->flush();
} | php | public function setRemoved($removed): void
{
if (!$this->isNodeDataMatchingContext()) {
$this->materializeNodeData();
}
if ((boolean)$removed === true) {
/** @var $childNode Node */
foreach ($this->getChildNodes() as $childNode) {
$childNode->setRemoved(true);
}
$this->nodeData->setRemoved(true);
$this->emitNodeRemoved($this);
} else {
$this->nodeData->setRemoved(false);
$this->emitNodeUpdated($this);
}
$this->context->getFirstLevelNodeCache()->flush();
} | [
"public",
"function",
"setRemoved",
"(",
"$",
"removed",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isNodeDataMatchingContext",
"(",
")",
")",
"{",
"$",
"this",
"->",
"materializeNodeData",
"(",
")",
";",
"}",
"if",
"(",
"(",
"boolean",... | Enables using the remove method when only setters are available
@param boolean $removed If true, this node and it's child nodes will be removed. If it is false only this node will be restored.
@return void
@throws NodeException
@throws NodeTypeNotFoundException
@api | [
"Enables",
"using",
"the",
"remove",
"method",
"when",
"only",
"setters",
"are",
"available"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1313-L1333 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.isVisible | public function isVisible(): bool
{
if ($this->nodeData->isVisible() === false) {
return false;
}
$currentDateTime = $this->context->getCurrentDateTime();
if ($this->getHiddenBeforeDateTime() !== null && $this->getHiddenBeforeDateTime() > $currentDateTime) {
return false;
}
if ($this->getHiddenAfterDateTime() !== null && $this->getHiddenAfterDateTime() < $currentDateTime) {
return false;
}
return true;
} | php | public function isVisible(): bool
{
if ($this->nodeData->isVisible() === false) {
return false;
}
$currentDateTime = $this->context->getCurrentDateTime();
if ($this->getHiddenBeforeDateTime() !== null && $this->getHiddenBeforeDateTime() > $currentDateTime) {
return false;
}
if ($this->getHiddenAfterDateTime() !== null && $this->getHiddenAfterDateTime() < $currentDateTime) {
return false;
}
return true;
} | [
"public",
"function",
"isVisible",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"nodeData",
"->",
"isVisible",
"(",
")",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"$",
"currentDateTime",
"=",
"$",
"this",
"->",
"context",
"-... | Tells if this node is "visible".
For this the "hidden" flag and the "hiddenBeforeDateTime" and "hiddenAfterDateTime" dates are
taken into account.
@return boolean
@deprecated with version 4.3 - 5.0 will provide a new API with to retrieve visibility restrictions | [
"Tells",
"if",
"this",
"node",
"is",
"visible",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1530-L1544 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.isNodeDataMatchingContext | protected function isNodeDataMatchingContext(): bool
{
if ($this->nodeDataIsMatchingContext === null) {
$workspacesMatch = $this->workspaceIsMatchingContext();
$this->nodeDataIsMatchingContext = $workspacesMatch && $this->dimensionsAreMatchingTargetDimensionValues();
}
return $this->nodeDataIsMatchingContext;
} | php | protected function isNodeDataMatchingContext(): bool
{
if ($this->nodeDataIsMatchingContext === null) {
$workspacesMatch = $this->workspaceIsMatchingContext();
$this->nodeDataIsMatchingContext = $workspacesMatch && $this->dimensionsAreMatchingTargetDimensionValues();
}
return $this->nodeDataIsMatchingContext;
} | [
"protected",
"function",
"isNodeDataMatchingContext",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"nodeDataIsMatchingContext",
"===",
"null",
")",
"{",
"$",
"workspacesMatch",
"=",
"$",
"this",
"->",
"workspaceIsMatchingContext",
"(",
")",
";",
"... | The NodeData matches the context if the workspace matches exactly.
Needs to be adjusted for further context dimensions.
@return boolean | [
"The",
"NodeData",
"matches",
"the",
"context",
"if",
"the",
"workspace",
"matches",
"exactly",
".",
"Needs",
"to",
"be",
"adjusted",
"for",
"further",
"context",
"dimensions",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1699-L1707 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.similarize | public function similarize(NodeInterface $sourceNode, $isCopy = false): void
{
$this->nodeData->similarize($sourceNode->getNodeData(), $isCopy);
} | php | public function similarize(NodeInterface $sourceNode, $isCopy = false): void
{
$this->nodeData->similarize($sourceNode->getNodeData(), $isCopy);
} | [
"public",
"function",
"similarize",
"(",
"NodeInterface",
"$",
"sourceNode",
",",
"$",
"isCopy",
"=",
"false",
")",
":",
"void",
"{",
"$",
"this",
"->",
"nodeData",
"->",
"similarize",
"(",
"$",
"sourceNode",
"->",
"getNodeData",
"(",
")",
",",
"$",
"isC... | For internal use in createRecursiveCopy.
@param NodeInterface $sourceNode
@param boolean $isCopy
@return void | [
"For",
"internal",
"use",
"in",
"createRecursiveCopy",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1724-L1727 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.createVariantForContext | public function createVariantForContext($context): NodeInterface
{
$autoCreatedChildNodes = [];
$nodeType = $this->getNodeType();
foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
$childNode = $this->getNode($childNodeName);
if ($childNode !== null) {
$autoCreatedChildNodes[$childNodeName] = $childNode;
}
}
$nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues());
$nodeData->similarize($this->nodeData);
if ($this->context !== $context) {
$node = $this->nodeFactory->createFromNodeData($nodeData, $context);
} else {
$this->setNodeData($nodeData);
$node = $this;
}
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($node);
/**
* @var $autoCreatedChildNode NodeInterface
*/
foreach ($autoCreatedChildNodes as $autoCreatedChildNode) {
$existingChildNode = $node->getNode($autoCreatedChildNode->getName());
if ($existingChildNode === null || !$existingChildNode->dimensionsAreMatchingTargetDimensionValues()) {
// only if needed, see https://github.com/neos/neos-development-collection/issues/782
$autoCreatedChildNode->createVariantForContext($context);
}
}
return $node;
} | php | public function createVariantForContext($context): NodeInterface
{
$autoCreatedChildNodes = [];
$nodeType = $this->getNodeType();
foreach ($nodeType->getAutoCreatedChildNodes() as $childNodeName => $childNodeConfiguration) {
$childNode = $this->getNode($childNodeName);
if ($childNode !== null) {
$autoCreatedChildNodes[$childNodeName] = $childNode;
}
}
$nodeData = new NodeData($this->nodeData->getPath(), $context->getWorkspace(), $this->nodeData->getIdentifier(), $context->getTargetDimensionValues());
$nodeData->similarize($this->nodeData);
if ($this->context !== $context) {
$node = $this->nodeFactory->createFromNodeData($nodeData, $context);
} else {
$this->setNodeData($nodeData);
$node = $this;
}
$this->context->getFirstLevelNodeCache()->flush();
$this->emitNodeAdded($node);
/**
* @var $autoCreatedChildNode NodeInterface
*/
foreach ($autoCreatedChildNodes as $autoCreatedChildNode) {
$existingChildNode = $node->getNode($autoCreatedChildNode->getName());
if ($existingChildNode === null || !$existingChildNode->dimensionsAreMatchingTargetDimensionValues()) {
// only if needed, see https://github.com/neos/neos-development-collection/issues/782
$autoCreatedChildNode->createVariantForContext($context);
}
}
return $node;
} | [
"public",
"function",
"createVariantForContext",
"(",
"$",
"context",
")",
":",
"NodeInterface",
"{",
"$",
"autoCreatedChildNodes",
"=",
"[",
"]",
";",
"$",
"nodeType",
"=",
"$",
"this",
"->",
"getNodeType",
"(",
")",
";",
"foreach",
"(",
"$",
"nodeType",
... | Given a context a new node is returned that is like this node, but
lives in the new context.
@param Context $context
@return NodeInterface
@throws NodeConfigurationException
@throws NodeTypeNotFoundException | [
"Given",
"a",
"context",
"a",
"new",
"node",
"is",
"returned",
"that",
"is",
"like",
"this",
"node",
"but",
"lives",
"in",
"the",
"new",
"context",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1769-L1805 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.setNodeData | public function setNodeData(NodeData $nodeData): void
{
$this->nodeData = $nodeData;
$this->nodeDataIsMatchingContext = null;
} | php | public function setNodeData(NodeData $nodeData): void
{
$this->nodeData = $nodeData;
$this->nodeDataIsMatchingContext = null;
} | [
"public",
"function",
"setNodeData",
"(",
"NodeData",
"$",
"nodeData",
")",
":",
"void",
"{",
"$",
"this",
"->",
"nodeData",
"=",
"$",
"nodeData",
";",
"$",
"this",
"->",
"nodeDataIsMatchingContext",
"=",
"null",
";",
"}"
] | Set the associated NodeData in regards to the Context.
NOTE: This is internal only and should not be used outside of the ContentRepository.
@param NodeData $nodeData
@return void
@deprecated with version 4.3 - will be removed with 5.0 | [
"Set",
"the",
"associated",
"NodeData",
"in",
"regards",
"to",
"the",
"Context",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1853-L1857 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.isTethered | public function isTethered(): bool
{
$parent = $this->getParent();
if ($parent === null) {
return false;
}
if (array_key_exists($this->getName(), $parent->getNodeType()->getAutoCreatedChildNodes())) {
return true;
}
return false;
} | php | public function isTethered(): bool
{
$parent = $this->getParent();
if ($parent === null) {
return false;
}
if (array_key_exists($this->getName(), $parent->getNodeType()->getAutoCreatedChildNodes())) {
return true;
}
return false;
} | [
"public",
"function",
"isTethered",
"(",
")",
":",
"bool",
"{",
"$",
"parent",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"$",
"parent",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"... | Whether or not this node is tethered to its parent, fka auto created child node
@return bool | [
"Whether",
"or",
"not",
"this",
"node",
"is",
"tethered",
"to",
"its",
"parent",
"fka",
"auto",
"created",
"child",
"node"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L1892-L1903 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.findReferencedNodes | public function findReferencedNodes(): TraversableNodes
{
$referencedNodes = [];
foreach ($this->getNodeType()->getProperties() as $propertyName => $property) {
$propertyType = $this->getNodeType()->getPropertyType($propertyName);
if ($propertyType === 'reference' && $this->getProperty($propertyName) instanceof TraversableNodeInterface) {
$referencedNodes[] = $this->getProperty($propertyName);
} elseif ($propertyName === 'references' && !empty($this->getProperty($propertyName))) {
foreach ($this->getProperty($propertyName) as $node) {
if ($node instanceof TraversableNodeInterface) {
$referencedNodes[] = $node;
}
}
}
}
return TraversableNodes::fromArray($referencedNodes);
} | php | public function findReferencedNodes(): TraversableNodes
{
$referencedNodes = [];
foreach ($this->getNodeType()->getProperties() as $propertyName => $property) {
$propertyType = $this->getNodeType()->getPropertyType($propertyName);
if ($propertyType === 'reference' && $this->getProperty($propertyName) instanceof TraversableNodeInterface) {
$referencedNodes[] = $this->getProperty($propertyName);
} elseif ($propertyName === 'references' && !empty($this->getProperty($propertyName))) {
foreach ($this->getProperty($propertyName) as $node) {
if ($node instanceof TraversableNodeInterface) {
$referencedNodes[] = $node;
}
}
}
}
return TraversableNodes::fromArray($referencedNodes);
} | [
"public",
"function",
"findReferencedNodes",
"(",
")",
":",
"TraversableNodes",
"{",
"$",
"referencedNodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getNodeType",
"(",
")",
"->",
"getProperties",
"(",
")",
"as",
"$",
"propertyName",
"=>",
"... | Retrieves and returns all nodes referenced by this node from its subgraph.
@return TraversableNodes
@throws NodeException
@throws NodeTypeNotFoundException
@throws \Neos\Flow\Property\Exception
@throws \Neos\Flow\Security\Exception | [
"Retrieves",
"and",
"returns",
"all",
"nodes",
"referenced",
"by",
"this",
"node",
"from",
"its",
"subgraph",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L2043-L2060 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Model/Node.php | Node.findNamedReferencedNodes | public function findNamedReferencedNodes(PropertyName $edgeName): TraversableNodes
{
$referencedNodes = [];
$propertyName = (string) $edgeName;
$propertyType = $this->getNodeType()->getPropertyType($propertyName);
if ($propertyType === 'reference' && $this->getProperty($propertyName) instanceof TraversableNodeInterface) {
$referencedNodes = [$this->getProperty($propertyName)];
} elseif ($propertyName === 'references' && !empty($this->getProperty($propertyName))) {
$referencedNodes = $this->getProperty($propertyName);
}
return TraversableNodes::fromArray($referencedNodes);
} | php | public function findNamedReferencedNodes(PropertyName $edgeName): TraversableNodes
{
$referencedNodes = [];
$propertyName = (string) $edgeName;
$propertyType = $this->getNodeType()->getPropertyType($propertyName);
if ($propertyType === 'reference' && $this->getProperty($propertyName) instanceof TraversableNodeInterface) {
$referencedNodes = [$this->getProperty($propertyName)];
} elseif ($propertyName === 'references' && !empty($this->getProperty($propertyName))) {
$referencedNodes = $this->getProperty($propertyName);
}
return TraversableNodes::fromArray($referencedNodes);
} | [
"public",
"function",
"findNamedReferencedNodes",
"(",
"PropertyName",
"$",
"edgeName",
")",
":",
"TraversableNodes",
"{",
"$",
"referencedNodes",
"=",
"[",
"]",
";",
"$",
"propertyName",
"=",
"(",
"string",
")",
"$",
"edgeName",
";",
"$",
"propertyType",
"=",... | Retrieves and returns nodes referenced by this node by name from its subgraph.
@param PropertyName $edgeName
@return TraversableNodes
@throws NodeException
@throws NodeTypeNotFoundException
@throws \Neos\Flow\Property\Exception
@throws \Neos\Flow\Security\Exception | [
"Retrieves",
"and",
"returns",
"nodes",
"referenced",
"by",
"this",
"node",
"by",
"name",
"from",
"its",
"subgraph",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Model/Node.php#L2072-L2084 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/TypeConverter/NodeTemplateConverter.php | NodeTemplateConverter.convertFrom | public function convertFrom($source, $targetType = null, array $subProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
$nodeTemplate = new NodeTemplate();
$nodeType = $this->extractNodeType($targetType, $source);
$nodeTemplate->setNodeType($nodeType);
// we don't need a context or workspace for creating NodeTemplate objects, but in order to satisfy the method
// signature of setNodeProperties(), we do need one:
$context = $this->contextFactory->create($this->prepareContextProperties('live'));
$this->setNodeProperties($nodeTemplate, $nodeTemplate->getNodeType(), $source, $context);
return $nodeTemplate;
} | php | public function convertFrom($source, $targetType = null, array $subProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
$nodeTemplate = new NodeTemplate();
$nodeType = $this->extractNodeType($targetType, $source);
$nodeTemplate->setNodeType($nodeType);
// we don't need a context or workspace for creating NodeTemplate objects, but in order to satisfy the method
// signature of setNodeProperties(), we do need one:
$context = $this->contextFactory->create($this->prepareContextProperties('live'));
$this->setNodeProperties($nodeTemplate, $nodeTemplate->getNodeType(), $source, $context);
return $nodeTemplate;
} | [
"public",
"function",
"convertFrom",
"(",
"$",
"source",
",",
"$",
"targetType",
"=",
"null",
",",
"array",
"$",
"subProperties",
"=",
"[",
"]",
",",
"PropertyMappingConfigurationInterface",
"$",
"configuration",
"=",
"null",
")",
"{",
"$",
"nodeTemplate",
"="... | Converts the specified node path into a Node.
The node path must be an absolute context node path and can be specified as a string or as an array item with the
key "__contextNodePath". The latter case is for updating existing nodes.
This conversion method supports creation of new nodes because new nodes
Also note that the context's "current node" is not affected by this object converter, you will need to set it to
whatever node your "current" node is, if any.
All elements in the source array which start with two underscores (like __contextNodePath) are specially treated
by this converter.
All elements in the source array which start with a *single underscore (like _hidden) are *directly* set on the Node
object.
All other elements, not being prefixed with underscore, are properties of the node.
@param string|array $source Either a string or array containing the absolute context node path which identifies the node. For example "/sites/mysitecom/homepage/about@user-admin"
@param string $targetType not used
@param array $subProperties not used
@param PropertyMappingConfigurationInterface $configuration not used
@return mixed An object or \Neos\Error\Messages\Error if the input format is not supported or could not be converted for other reasons
@throws \Exception | [
"Converts",
"the",
"specified",
"node",
"path",
"into",
"a",
"Node",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/TypeConverter/NodeTemplateConverter.php#L80-L92 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/TypeConverter/NodeTemplateConverter.php | NodeTemplateConverter.extractNodeType | protected function extractNodeType($targetType, array $source)
{
if (isset($source['__nodeType'])) {
$nodeTypeName = $source['__nodeType'];
} else {
$matches = [];
preg_match(self::EXTRACT_CONTENT_TYPE_PATTERN, $targetType, $matches);
if (isset($matches['nodeType'])) {
$nodeTypeName = $matches['nodeType'];
} else {
$nodeTypeName = 'unstructured';
}
}
return $this->nodeTypeManager->getNodeType($nodeTypeName);
} | php | protected function extractNodeType($targetType, array $source)
{
if (isset($source['__nodeType'])) {
$nodeTypeName = $source['__nodeType'];
} else {
$matches = [];
preg_match(self::EXTRACT_CONTENT_TYPE_PATTERN, $targetType, $matches);
if (isset($matches['nodeType'])) {
$nodeTypeName = $matches['nodeType'];
} else {
$nodeTypeName = 'unstructured';
}
}
return $this->nodeTypeManager->getNodeType($nodeTypeName);
} | [
"protected",
"function",
"extractNodeType",
"(",
"$",
"targetType",
",",
"array",
"$",
"source",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"source",
"[",
"'__nodeType'",
"]",
")",
")",
"{",
"$",
"nodeTypeName",
"=",
"$",
"source",
"[",
"'__nodeType'",
"]",... | Detects the requested node type and returns a corresponding NodeType instance.
@param string $targetType
@param array $source
@return NodeType | [
"Detects",
"the",
"requested",
"node",
"type",
"and",
"returns",
"a",
"corresponding",
"NodeType",
"instance",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/TypeConverter/NodeTemplateConverter.php#L101-L115 | train |
neos/neos-development-collection | Neos.Fusion/Classes/FusionObjects/MapImplementation.php | MapImplementation.evaluate | public function evaluate()
{
$collection = $this->getItems();
$result = [];
if ($collection === null) {
return $result;
}
$this->numberOfRenderedNodes = 0;
$itemName = $this->getItemName();
if ($itemName === null) {
throw new FusionException('The Collection needs an itemName to be set.', 1344325771);
}
$itemKey = $this->getItemKey();
$iterationName = $this->getIterationName();
$collectionTotalCount = count($collection);
$itemRenderPath = $this->path . '/itemRenderer';
$fallbackRenderPath = $this->path . '/content';
if ($this->runtime->canRender($itemRenderPath) === false && $this->runtime->canRender($fallbackRenderPath)) {
$itemRenderPath = $fallbackRenderPath;
}
foreach ($collection as $collectionKey => $collectionElement) {
$context = $this->runtime->getCurrentContext();
$context[$itemName] = $collectionElement;
if ($itemKey !== null) {
$context[$itemKey] = $collectionKey;
}
if ($iterationName !== null) {
$context[$iterationName] = $this->prepareIterationInformation($collectionTotalCount);
}
$this->runtime->pushContextArray($context);
$result[$collectionKey] = $this->runtime->render($itemRenderPath);
$this->runtime->popContext();
$this->numberOfRenderedNodes++;
}
return $result;
} | php | public function evaluate()
{
$collection = $this->getItems();
$result = [];
if ($collection === null) {
return $result;
}
$this->numberOfRenderedNodes = 0;
$itemName = $this->getItemName();
if ($itemName === null) {
throw new FusionException('The Collection needs an itemName to be set.', 1344325771);
}
$itemKey = $this->getItemKey();
$iterationName = $this->getIterationName();
$collectionTotalCount = count($collection);
$itemRenderPath = $this->path . '/itemRenderer';
$fallbackRenderPath = $this->path . '/content';
if ($this->runtime->canRender($itemRenderPath) === false && $this->runtime->canRender($fallbackRenderPath)) {
$itemRenderPath = $fallbackRenderPath;
}
foreach ($collection as $collectionKey => $collectionElement) {
$context = $this->runtime->getCurrentContext();
$context[$itemName] = $collectionElement;
if ($itemKey !== null) {
$context[$itemKey] = $collectionKey;
}
if ($iterationName !== null) {
$context[$iterationName] = $this->prepareIterationInformation($collectionTotalCount);
}
$this->runtime->pushContextArray($context);
$result[$collectionKey] = $this->runtime->render($itemRenderPath);
$this->runtime->popContext();
$this->numberOfRenderedNodes++;
}
return $result;
} | [
"public",
"function",
"evaluate",
"(",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getItems",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"collection",
"===",
"null",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$... | Evaluate the collection nodes as array
@return array
@throws FusionException | [
"Evaluate",
"the",
"collection",
"nodes",
"as",
"array"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Fusion/Classes/FusionObjects/MapImplementation.php#L71-L111 | train |
neos/neos-development-collection | Neos.Media/Classes/Domain/Service/ThumbnailService.php | ThumbnailService.applyFormatToThumbnailConfiguration | protected function applyFormatToThumbnailConfiguration(ThumbnailConfiguration $configuration, string $targetFormat): ThumbnailConfiguration
{
if (strpos($targetFormat, '/') !== false) {
$targetFormat = MediaTypes::getFilenameExtensionFromMediaType($targetFormat);
}
$configuration = new ThumbnailConfiguration(
$configuration->getWidth(),
$configuration->getMaximumWidth(),
$configuration->getHeight(),
$configuration->getMaximumHeight(),
$configuration->isCroppingAllowed(),
$configuration->isUpScalingAllowed(),
$configuration->isAsync(),
$configuration->getQuality(),
$targetFormat
);
return $configuration;
} | php | protected function applyFormatToThumbnailConfiguration(ThumbnailConfiguration $configuration, string $targetFormat): ThumbnailConfiguration
{
if (strpos($targetFormat, '/') !== false) {
$targetFormat = MediaTypes::getFilenameExtensionFromMediaType($targetFormat);
}
$configuration = new ThumbnailConfiguration(
$configuration->getWidth(),
$configuration->getMaximumWidth(),
$configuration->getHeight(),
$configuration->getMaximumHeight(),
$configuration->isCroppingAllowed(),
$configuration->isUpScalingAllowed(),
$configuration->isAsync(),
$configuration->getQuality(),
$targetFormat
);
return $configuration;
} | [
"protected",
"function",
"applyFormatToThumbnailConfiguration",
"(",
"ThumbnailConfiguration",
"$",
"configuration",
",",
"string",
"$",
"targetFormat",
")",
":",
"ThumbnailConfiguration",
"{",
"if",
"(",
"strpos",
"(",
"$",
"targetFormat",
",",
"'/'",
")",
"!==",
"... | Create a new thumbnailConfiguration with the identical configuration
to the given one PLUS setting of the target-format
@param ThumbnailConfiguration $configuration
@param string $targetFormat
@return ThumbnailConfiguration | [
"Create",
"a",
"new",
"thumbnailConfiguration",
"with",
"the",
"identical",
"configuration",
"to",
"the",
"given",
"one",
"PLUS",
"setting",
"of",
"the",
"target",
"-",
"format"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/Domain/Service/ThumbnailService.php#L239-L256 | train |
neos/neos-development-collection | Neos.Media/Classes/Domain/Service/ThumbnailService.php | ThumbnailService.refreshThumbnail | public function refreshThumbnail(Thumbnail $thumbnail)
{
$thumbnail->refresh();
$this->persistenceManager->whiteListObject($thumbnail);
if (!$this->persistenceManager->isNewObject($thumbnail)) {
$this->thumbnailRepository->update($thumbnail);
}
} | php | public function refreshThumbnail(Thumbnail $thumbnail)
{
$thumbnail->refresh();
$this->persistenceManager->whiteListObject($thumbnail);
if (!$this->persistenceManager->isNewObject($thumbnail)) {
$this->thumbnailRepository->update($thumbnail);
}
} | [
"public",
"function",
"refreshThumbnail",
"(",
"Thumbnail",
"$",
"thumbnail",
")",
"{",
"$",
"thumbnail",
"->",
"refresh",
"(",
")",
";",
"$",
"this",
"->",
"persistenceManager",
"->",
"whiteListObject",
"(",
"$",
"thumbnail",
")",
";",
"if",
"(",
"!",
"$"... | Refreshes a thumbnail and persists the thumbnail
@param Thumbnail $thumbnail
@return void | [
"Refreshes",
"a",
"thumbnail",
"and",
"persists",
"the",
"thumbnail"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/Domain/Service/ThumbnailService.php#L264-L271 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Service/ContextFactory.php | ContextFactory.create | public function create(array $contextProperties = [])
{
$contextProperties = $this->mergeContextPropertiesWithDefaults($contextProperties);
$contextIdentifier = $this->getIdentifier($contextProperties);
if (!isset($this->contextInstances[$contextIdentifier])) {
$this->validateContextProperties($contextProperties);
$context = $this->buildContextInstance($contextProperties);
$this->contextInstances[$contextIdentifier] = $context;
}
return $this->contextInstances[$contextIdentifier];
} | php | public function create(array $contextProperties = [])
{
$contextProperties = $this->mergeContextPropertiesWithDefaults($contextProperties);
$contextIdentifier = $this->getIdentifier($contextProperties);
if (!isset($this->contextInstances[$contextIdentifier])) {
$this->validateContextProperties($contextProperties);
$context = $this->buildContextInstance($contextProperties);
$this->contextInstances[$contextIdentifier] = $context;
}
return $this->contextInstances[$contextIdentifier];
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"contextProperties",
"=",
"[",
"]",
")",
"{",
"$",
"contextProperties",
"=",
"$",
"this",
"->",
"mergeContextPropertiesWithDefaults",
"(",
"$",
"contextProperties",
")",
";",
"$",
"contextIdentifier",
"=",
"$",
... | Create the context from the given properties. If a context with those properties was already
created before then the existing one is returned.
The context properties to give depend on the implementation of the context object, for the
Neos\ContentRepository\Domain\Service\Context it should look like this:
array(
'workspaceName' => 'live',
'currentDateTime' => new \Neos\Flow\Utility\Now(),
'dimensions' => array(...),
'targetDimensions' => array('language' => 'de', 'persona' => 'Lisa'),
'invisibleContentShown' => false,
'removedContentShown' => false,
'inaccessibleContentShown' => false
)
This array also shows the defaults that get used if you don't provide a certain property.
@param array $contextProperties
@return Context
@api | [
"Create",
"the",
"context",
"from",
"the",
"given",
"properties",
".",
"If",
"a",
"context",
"with",
"those",
"properties",
"was",
"already",
"created",
"before",
"then",
"the",
"existing",
"one",
"is",
"returned",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Service/ContextFactory.php#L86-L97 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Service/ContextFactory.php | ContextFactory.mergeContextPropertiesWithDefaults | protected function mergeContextPropertiesWithDefaults(array $contextProperties)
{
$contextProperties = $this->removeDeprecatedProperties($contextProperties);
$defaultContextProperties = [
'workspaceName' => 'live',
'currentDateTime' => $this->now,
'dimensions' => [],
'targetDimensions' => [],
'invisibleContentShown' => false,
'removedContentShown' => false,
'inaccessibleContentShown' => false
];
$mergedProperties = Arrays::arrayMergeRecursiveOverrule($defaultContextProperties, $contextProperties, true);
$this->mergeDimensionValues($contextProperties, $mergedProperties);
$this->mergeTargetDimensionContextProperties($contextProperties, $mergedProperties, $defaultContextProperties);
return $mergedProperties;
} | php | protected function mergeContextPropertiesWithDefaults(array $contextProperties)
{
$contextProperties = $this->removeDeprecatedProperties($contextProperties);
$defaultContextProperties = [
'workspaceName' => 'live',
'currentDateTime' => $this->now,
'dimensions' => [],
'targetDimensions' => [],
'invisibleContentShown' => false,
'removedContentShown' => false,
'inaccessibleContentShown' => false
];
$mergedProperties = Arrays::arrayMergeRecursiveOverrule($defaultContextProperties, $contextProperties, true);
$this->mergeDimensionValues($contextProperties, $mergedProperties);
$this->mergeTargetDimensionContextProperties($contextProperties, $mergedProperties, $defaultContextProperties);
return $mergedProperties;
} | [
"protected",
"function",
"mergeContextPropertiesWithDefaults",
"(",
"array",
"$",
"contextProperties",
")",
"{",
"$",
"contextProperties",
"=",
"$",
"this",
"->",
"removeDeprecatedProperties",
"(",
"$",
"contextProperties",
")",
";",
"$",
"defaultContextProperties",
"="... | Merges the given context properties with sane defaults for the context implementation.
@param array $contextProperties
@return array | [
"Merges",
"the",
"given",
"context",
"properties",
"with",
"sane",
"defaults",
"for",
"the",
"context",
"implementation",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Service/ContextFactory.php#L118-L138 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Domain/Service/ContextFactory.php | ContextFactory.getIdentifierSource | protected function getIdentifierSource(array $contextProperties)
{
ksort($contextProperties);
$identifierSource = $this->contextImplementation;
foreach ($contextProperties as $propertyName => $propertyValue) {
if ($propertyName === 'dimensions') {
$stringParts = [];
foreach ($propertyValue as $dimensionName => $dimensionValues) {
$stringParts[] = $dimensionName . '=' . implode(',', $dimensionValues);
}
$stringValue = implode('&', $stringParts);
} elseif ($propertyName === 'targetDimensions') {
$stringParts = [];
foreach ($propertyValue as $dimensionName => $dimensionValue) {
$stringParts[] = $dimensionName . '=' . $dimensionValue;
}
$stringValue = implode('&', $stringParts);
} else {
$stringValue = $propertyValue instanceof \DateTimeInterface ? $propertyValue->getTimestamp() : (string)$propertyValue;
}
$identifierSource .= ':' . $stringValue;
}
return $identifierSource;
} | php | protected function getIdentifierSource(array $contextProperties)
{
ksort($contextProperties);
$identifierSource = $this->contextImplementation;
foreach ($contextProperties as $propertyName => $propertyValue) {
if ($propertyName === 'dimensions') {
$stringParts = [];
foreach ($propertyValue as $dimensionName => $dimensionValues) {
$stringParts[] = $dimensionName . '=' . implode(',', $dimensionValues);
}
$stringValue = implode('&', $stringParts);
} elseif ($propertyName === 'targetDimensions') {
$stringParts = [];
foreach ($propertyValue as $dimensionName => $dimensionValue) {
$stringParts[] = $dimensionName . '=' . $dimensionValue;
}
$stringValue = implode('&', $stringParts);
} else {
$stringValue = $propertyValue instanceof \DateTimeInterface ? $propertyValue->getTimestamp() : (string)$propertyValue;
}
$identifierSource .= ':' . $stringValue;
}
return $identifierSource;
} | [
"protected",
"function",
"getIdentifierSource",
"(",
"array",
"$",
"contextProperties",
")",
"{",
"ksort",
"(",
"$",
"contextProperties",
")",
";",
"$",
"identifierSource",
"=",
"$",
"this",
"->",
"contextImplementation",
";",
"foreach",
"(",
"$",
"contextProperti... | This creates the actual identifier and needs to be overridden by builders extending this.
@param array $contextProperties
@return string | [
"This",
"creates",
"the",
"actual",
"identifier",
"and",
"needs",
"to",
"be",
"overridden",
"by",
"builders",
"extending",
"this",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Domain/Service/ContextFactory.php#L157-L181 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Migration/Configuration/YamlConfiguration.php | YamlConfiguration.registerAvailableVersions | protected function registerAvailableVersions()
{
$this->availableVersions = [];
foreach ($this->packageManager->getAvailablePackages() as $package) {
$this->registerVersionInDirectory($package, 'TYPO3CR');
$this->registerVersionInDirectory($package, 'ContentRepository');
}
ksort($this->availableVersions);
} | php | protected function registerAvailableVersions()
{
$this->availableVersions = [];
foreach ($this->packageManager->getAvailablePackages() as $package) {
$this->registerVersionInDirectory($package, 'TYPO3CR');
$this->registerVersionInDirectory($package, 'ContentRepository');
}
ksort($this->availableVersions);
} | [
"protected",
"function",
"registerAvailableVersions",
"(",
")",
"{",
"$",
"this",
"->",
"availableVersions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"packageManager",
"->",
"getAvailablePackages",
"(",
")",
"as",
"$",
"package",
")",
"{",
"$",... | Loads a list of available versions into an array.
@return array
@throws MigrationException | [
"Loads",
"a",
"list",
"of",
"available",
"versions",
"into",
"an",
"array",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Migration/Configuration/YamlConfiguration.php#L44-L52 | train |
neos/neos-development-collection | Neos.ContentRepository/Classes/Migration/Configuration/YamlConfiguration.php | YamlConfiguration.loadConfiguration | protected function loadConfiguration($version)
{
if (!$this->isVersionAvailable($version)) {
throw new MigrationException('The requested YamlConfiguration was not available.', 1345822283);
}
$configuration = $this->yamlSourceImporter->load(substr($this->availableVersions[$version]['filePathAndName'], 0, -5));
return $configuration;
} | php | protected function loadConfiguration($version)
{
if (!$this->isVersionAvailable($version)) {
throw new MigrationException('The requested YamlConfiguration was not available.', 1345822283);
}
$configuration = $this->yamlSourceImporter->load(substr($this->availableVersions[$version]['filePathAndName'], 0, -5));
return $configuration;
} | [
"protected",
"function",
"loadConfiguration",
"(",
"$",
"version",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isVersionAvailable",
"(",
"$",
"version",
")",
")",
"{",
"throw",
"new",
"MigrationException",
"(",
"'The requested YamlConfiguration was not available.'... | Loads a specific version into an array.
@param string $version
@return array
@throws MigrationException | [
"Loads",
"a",
"specific",
"version",
"into",
"an",
"array",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.ContentRepository/Classes/Migration/Configuration/YamlConfiguration.php#L99-L107 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/Mapping/NodePropertyConverterService.php | NodePropertyConverterService.convertValue | protected function convertValue($propertyValue, $dataType)
{
$parsedType = TypeHandling::parseType($dataType);
// This hardcoded handling is to circumvent rewriting PropertyMappers that convert objects. Usually they expect the source to be an object already and break if not.
if (!TypeHandling::isSimpleType($parsedType['type']) && !is_object($propertyValue) && !is_array($propertyValue)) {
return null;
}
$conversionTargetType = $parsedType['type'];
if (!TypeHandling::isSimpleType($parsedType['type'])) {
$conversionTargetType = 'array';
}
// Technically the "string" hardcoded here is irrelevant as the configured type converter wins, but it cannot be the "elementType"
// because if the source is of the type $elementType then the PropertyMapper skips the type converter.
if ($parsedType['type'] === 'array' && $parsedType['elementType'] !== null) {
$conversionTargetType .= '<' . (TypeHandling::isSimpleType($parsedType['elementType']) ? $parsedType['elementType'] : 'string') . '>';
}
$propertyMappingConfiguration = $this->createConfiguration($dataType);
$convertedValue = $this->propertyMapper->convert($propertyValue, $conversionTargetType, $propertyMappingConfiguration);
if ($convertedValue instanceof \Neos\Error\Messages\Error) {
throw new PropertyException($convertedValue->getMessage(), $convertedValue->getCode());
}
return $convertedValue;
} | php | protected function convertValue($propertyValue, $dataType)
{
$parsedType = TypeHandling::parseType($dataType);
// This hardcoded handling is to circumvent rewriting PropertyMappers that convert objects. Usually they expect the source to be an object already and break if not.
if (!TypeHandling::isSimpleType($parsedType['type']) && !is_object($propertyValue) && !is_array($propertyValue)) {
return null;
}
$conversionTargetType = $parsedType['type'];
if (!TypeHandling::isSimpleType($parsedType['type'])) {
$conversionTargetType = 'array';
}
// Technically the "string" hardcoded here is irrelevant as the configured type converter wins, but it cannot be the "elementType"
// because if the source is of the type $elementType then the PropertyMapper skips the type converter.
if ($parsedType['type'] === 'array' && $parsedType['elementType'] !== null) {
$conversionTargetType .= '<' . (TypeHandling::isSimpleType($parsedType['elementType']) ? $parsedType['elementType'] : 'string') . '>';
}
$propertyMappingConfiguration = $this->createConfiguration($dataType);
$convertedValue = $this->propertyMapper->convert($propertyValue, $conversionTargetType, $propertyMappingConfiguration);
if ($convertedValue instanceof \Neos\Error\Messages\Error) {
throw new PropertyException($convertedValue->getMessage(), $convertedValue->getCode());
}
return $convertedValue;
} | [
"protected",
"function",
"convertValue",
"(",
"$",
"propertyValue",
",",
"$",
"dataType",
")",
"{",
"$",
"parsedType",
"=",
"TypeHandling",
"::",
"parseType",
"(",
"$",
"dataType",
")",
";",
"// This hardcoded handling is to circumvent rewriting PropertyMappers that conve... | Convert the given value to a simple type or an array of simple types.
@param mixed $propertyValue
@param string $dataType
@return mixed
@throws PropertyException | [
"Convert",
"the",
"given",
"value",
"to",
"a",
"simple",
"type",
"or",
"an",
"array",
"of",
"simple",
"types",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/Mapping/NodePropertyConverterService.php#L165-L191 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/Mapping/NodePropertyConverterService.php | NodePropertyConverterService.createConfiguration | protected function createConfiguration($dataType)
{
if (!isset($this->generatedPropertyMappingConfigurations[$dataType])) {
$propertyMappingConfiguration = new PropertyMappingConfiguration();
$propertyMappingConfiguration->allowAllProperties();
$parsedType = [
'elementType' => null,
'type' => $dataType
];
// Special handling for "reference(s)", should be deprecated and normlized to array<NodeInterface>
if ($dataType !== 'references' && $dataType !== 'reference') {
$parsedType = TypeHandling::parseType($dataType);
}
if ($this->setTypeConverterForType($propertyMappingConfiguration, $dataType) === false) {
$this->setTypeConverterForType($propertyMappingConfiguration, $parsedType['type']);
}
$elementConfiguration = $propertyMappingConfiguration->forProperty('*');
$this->setTypeConverterForType($elementConfiguration, $parsedType['elementType']);
$this->generatedPropertyMappingConfigurations[$dataType] = $propertyMappingConfiguration;
}
return $this->generatedPropertyMappingConfigurations[$dataType];
} | php | protected function createConfiguration($dataType)
{
if (!isset($this->generatedPropertyMappingConfigurations[$dataType])) {
$propertyMappingConfiguration = new PropertyMappingConfiguration();
$propertyMappingConfiguration->allowAllProperties();
$parsedType = [
'elementType' => null,
'type' => $dataType
];
// Special handling for "reference(s)", should be deprecated and normlized to array<NodeInterface>
if ($dataType !== 'references' && $dataType !== 'reference') {
$parsedType = TypeHandling::parseType($dataType);
}
if ($this->setTypeConverterForType($propertyMappingConfiguration, $dataType) === false) {
$this->setTypeConverterForType($propertyMappingConfiguration, $parsedType['type']);
}
$elementConfiguration = $propertyMappingConfiguration->forProperty('*');
$this->setTypeConverterForType($elementConfiguration, $parsedType['elementType']);
$this->generatedPropertyMappingConfigurations[$dataType] = $propertyMappingConfiguration;
}
return $this->generatedPropertyMappingConfigurations[$dataType];
} | [
"protected",
"function",
"createConfiguration",
"(",
"$",
"dataType",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"generatedPropertyMappingConfigurations",
"[",
"$",
"dataType",
"]",
")",
")",
"{",
"$",
"propertyMappingConfiguration",
"=",
"new",
... | Create a property mapping configuration for the given dataType to convert a Node property value from the given dataType to a simple type.
@param string $dataType
@return PropertyMappingConfigurationInterface | [
"Create",
"a",
"property",
"mapping",
"configuration",
"for",
"the",
"given",
"dataType",
"to",
"convert",
"a",
"Node",
"property",
"value",
"from",
"the",
"given",
"dataType",
"to",
"a",
"simple",
"type",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/Mapping/NodePropertyConverterService.php#L218-L244 | train |
neos/neos-development-collection | Neos.Media/Classes/Domain/Model/Tag.php | Tag.setAssetCollections | public function setAssetCollections(Collection $assetCollections)
{
foreach ($this->assetCollections as $existingAssetCollection) {
$existingAssetCollection->removeTag($this);
}
foreach ($assetCollections as $newAssetCollection) {
$newAssetCollection->addTag($this);
}
foreach ($this->assetCollections as $assetCollection) {
if (!$assetCollections->contains($assetCollection)) {
$assetCollections->add($assetCollection);
}
}
$this->assetCollections = $assetCollections;
} | php | public function setAssetCollections(Collection $assetCollections)
{
foreach ($this->assetCollections as $existingAssetCollection) {
$existingAssetCollection->removeTag($this);
}
foreach ($assetCollections as $newAssetCollection) {
$newAssetCollection->addTag($this);
}
foreach ($this->assetCollections as $assetCollection) {
if (!$assetCollections->contains($assetCollection)) {
$assetCollections->add($assetCollection);
}
}
$this->assetCollections = $assetCollections;
} | [
"public",
"function",
"setAssetCollections",
"(",
"Collection",
"$",
"assetCollections",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"assetCollections",
"as",
"$",
"existingAssetCollection",
")",
"{",
"$",
"existingAssetCollection",
"->",
"removeTag",
"(",
"$",
"... | Set the asset collections that include this tag
@param Collection $assetCollections
@return void | [
"Set",
"the",
"asset",
"collections",
"that",
"include",
"this",
"tag"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Media/Classes/Domain/Model/Tag.php#L87-L101 | train |
neos/neos-development-collection | Neos.Neos/Classes/Aspects/NodeTypeConfigurationEnrichmentAspect.php | NodeTypeConfigurationEnrichmentAspect.mapIconNames | protected function mapIconNames(array &$configuration)
{
if (isset($configuration['ui']['icon'])) {
$configuration['ui']['icon'] = $this->iconNameMappingService->convert($configuration['ui']['icon']);
}
$inspectorConfiguration = Arrays::getValueByPath($configuration, 'ui.inspector');
if (is_array($inspectorConfiguration)) {
foreach ($inspectorConfiguration as $elementTypeName => $elementTypeItems) {
foreach ($elementTypeItems as $elementName => $elementConfiguration) {
if (isset($inspectorConfiguration[$elementTypeName][$elementName]['icon'])) {
$configuration['ui']['inspector'][$elementTypeName][$elementName]['icon'] = $this->iconNameMappingService->convert($inspectorConfiguration[$elementTypeName][$elementName]['icon']);
}
}
}
}
} | php | protected function mapIconNames(array &$configuration)
{
if (isset($configuration['ui']['icon'])) {
$configuration['ui']['icon'] = $this->iconNameMappingService->convert($configuration['ui']['icon']);
}
$inspectorConfiguration = Arrays::getValueByPath($configuration, 'ui.inspector');
if (is_array($inspectorConfiguration)) {
foreach ($inspectorConfiguration as $elementTypeName => $elementTypeItems) {
foreach ($elementTypeItems as $elementName => $elementConfiguration) {
if (isset($inspectorConfiguration[$elementTypeName][$elementName]['icon'])) {
$configuration['ui']['inspector'][$elementTypeName][$elementName]['icon'] = $this->iconNameMappingService->convert($inspectorConfiguration[$elementTypeName][$elementName]['icon']);
}
}
}
}
} | [
"protected",
"function",
"mapIconNames",
"(",
"array",
"&",
"$",
"configuration",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"configuration",
"[",
"'ui'",
"]",
"[",
"'icon'",
"]",
")",
")",
"{",
"$",
"configuration",
"[",
"'ui'",
"]",
"[",
"'icon'",
"]",
... | Map all icon- prefixed icon names to the corresponding
names in the used icon implementation
@param array $configuration | [
"Map",
"all",
"icon",
"-",
"prefixed",
"icon",
"names",
"to",
"the",
"corresponding",
"names",
"in",
"the",
"used",
"icon",
"implementation"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Aspects/NodeTypeConfigurationEnrichmentAspect.php#L97-L113 | train |
neos/neos-development-collection | Neos.Neos/Classes/Aspects/NodeTypeConfigurationEnrichmentAspect.php | NodeTypeConfigurationEnrichmentAspect.resolveHelpMessageThumbnail | protected function resolveHelpMessageThumbnail($nodeTypeName, $configurationThumbnail)
{
if ($nodeTypeName !== null) {
$thumbnailUrl = '';
if (isset($configurationThumbnail)) {
$thumbnailUrl = $configurationThumbnail;
if (strpos($thumbnailUrl, 'resource://') === 0) {
$thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($thumbnailUrl);
}
} else {
# look in well know location
$splitPrefix = $this->splitIdentifier($nodeTypeName);
$relativePathAndFilename = 'NodeTypes/Thumbnails/' . $splitPrefix['id'] . '.png';
$resourcePath = 'resource://' . $splitPrefix['packageKey'] . '/Public/' . $relativePathAndFilename;
if (file_exists($resourcePath)) {
$thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($resourcePath);
}
}
return $thumbnailUrl;
}
} | php | protected function resolveHelpMessageThumbnail($nodeTypeName, $configurationThumbnail)
{
if ($nodeTypeName !== null) {
$thumbnailUrl = '';
if (isset($configurationThumbnail)) {
$thumbnailUrl = $configurationThumbnail;
if (strpos($thumbnailUrl, 'resource://') === 0) {
$thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($thumbnailUrl);
}
} else {
# look in well know location
$splitPrefix = $this->splitIdentifier($nodeTypeName);
$relativePathAndFilename = 'NodeTypes/Thumbnails/' . $splitPrefix['id'] . '.png';
$resourcePath = 'resource://' . $splitPrefix['packageKey'] . '/Public/' . $relativePathAndFilename;
if (file_exists($resourcePath)) {
$thumbnailUrl = $this->resourceManager->getPublicPackageResourceUriByPath($resourcePath);
}
}
return $thumbnailUrl;
}
} | [
"protected",
"function",
"resolveHelpMessageThumbnail",
"(",
"$",
"nodeTypeName",
",",
"$",
"configurationThumbnail",
")",
"{",
"if",
"(",
"$",
"nodeTypeName",
"!==",
"null",
")",
"{",
"$",
"thumbnailUrl",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"confi... | Resolve help message thumbnail url
@param string $nodeTypeName
@param string $configurationThumbnail
@return string $thumbnailUrl | [
"Resolve",
"help",
"message",
"thumbnail",
"url"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Aspects/NodeTypeConfigurationEnrichmentAspect.php#L213-L233 | train |
neos/neos-development-collection | Neos.Neos/Classes/Aspects/NodeTypeConfigurationEnrichmentAspect.php | NodeTypeConfigurationEnrichmentAspect.shouldFetchTranslation | protected function shouldFetchTranslation(array $parentConfiguration, $fieldName = 'label')
{
$fieldValue = array_key_exists($fieldName, $parentConfiguration) ? $parentConfiguration[$fieldName] : '';
return (trim($fieldValue) === 'i18n');
} | php | protected function shouldFetchTranslation(array $parentConfiguration, $fieldName = 'label')
{
$fieldValue = array_key_exists($fieldName, $parentConfiguration) ? $parentConfiguration[$fieldName] : '';
return (trim($fieldValue) === 'i18n');
} | [
"protected",
"function",
"shouldFetchTranslation",
"(",
"array",
"$",
"parentConfiguration",
",",
"$",
"fieldName",
"=",
"'label'",
")",
"{",
"$",
"fieldValue",
"=",
"array_key_exists",
"(",
"$",
"fieldName",
",",
"$",
"parentConfiguration",
")",
"?",
"$",
"pare... | Should a label be generated for the given field or is there something configured?
@param array $parentConfiguration
@param string $fieldName Name of the possibly existing subfield
@return boolean | [
"Should",
"a",
"label",
"be",
"generated",
"for",
"the",
"given",
"field",
"or",
"is",
"there",
"something",
"configured?"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Aspects/NodeTypeConfigurationEnrichmentAspect.php#L344-L349 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/ContentElementWrappingService.php | ContentElementWrappingService.renderNodePropertyAttribute | protected function renderNodePropertyAttribute(NodeInterface $node, $propertyName)
{
$attributes = [];
/** @var $contentContext ContentContext */
$contentContext = $node->getContext();
// skip the node name of the site node - TODO: Why do we need this?
if ($propertyName === '_name' && $node === $contentContext->getCurrentSiteNode()) {
return $attributes;
}
$dataType = $node->getNodeType()->getPropertyType($propertyName);
$dasherizedPropertyName = $this->dasherize($propertyName);
$propertyValue = $this->nodePropertyConverterService->getProperty($node, $propertyName);
$propertyValue = $propertyValue === null ? '' : $propertyValue;
$propertyValue = !is_string($propertyValue) ? json_encode($propertyValue) : $propertyValue;
if ($dataType !== 'string') {
$attributes['data-nodedatatype-' . $dasherizedPropertyName] = 'xsd:' . $dataType;
}
$attributes['data-node-' . $dasherizedPropertyName] = $propertyValue;
return $attributes;
} | php | protected function renderNodePropertyAttribute(NodeInterface $node, $propertyName)
{
$attributes = [];
/** @var $contentContext ContentContext */
$contentContext = $node->getContext();
// skip the node name of the site node - TODO: Why do we need this?
if ($propertyName === '_name' && $node === $contentContext->getCurrentSiteNode()) {
return $attributes;
}
$dataType = $node->getNodeType()->getPropertyType($propertyName);
$dasherizedPropertyName = $this->dasherize($propertyName);
$propertyValue = $this->nodePropertyConverterService->getProperty($node, $propertyName);
$propertyValue = $propertyValue === null ? '' : $propertyValue;
$propertyValue = !is_string($propertyValue) ? json_encode($propertyValue) : $propertyValue;
if ($dataType !== 'string') {
$attributes['data-nodedatatype-' . $dasherizedPropertyName] = 'xsd:' . $dataType;
}
$attributes['data-node-' . $dasherizedPropertyName] = $propertyValue;
return $attributes;
} | [
"protected",
"function",
"renderNodePropertyAttribute",
"(",
"NodeInterface",
"$",
"node",
",",
"$",
"propertyName",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"/** @var $contentContext ContentContext */",
"$",
"contentContext",
"=",
"$",
"node",
"->",
"getCon... | Renders data attributes needed for the given node property.
@param NodeInterface $node
@param string $propertyName
@return array | [
"Renders",
"data",
"attributes",
"needed",
"for",
"the",
"given",
"node",
"property",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/ContentElementWrappingService.php#L133-L157 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/ContentElementWrappingService.php | ContentElementWrappingService.addCssClasses | protected function addCssClasses(array $attributes, NodeInterface $node, array $initialClasses = [])
{
$classNames = $initialClasses;
// FIXME: The `dimensionsAreMatchingTargetDimensionValues` method should become part of the NodeInterface if it is used here .
if ($node instanceof Node && !$node->dimensionsAreMatchingTargetDimensionValues()) {
$classNames[] = 'neos-contentelement-shine-through';
}
if ($classNames !== []) {
$attributes['class'] = implode(' ', $classNames);
}
return $attributes;
} | php | protected function addCssClasses(array $attributes, NodeInterface $node, array $initialClasses = [])
{
$classNames = $initialClasses;
// FIXME: The `dimensionsAreMatchingTargetDimensionValues` method should become part of the NodeInterface if it is used here .
if ($node instanceof Node && !$node->dimensionsAreMatchingTargetDimensionValues()) {
$classNames[] = 'neos-contentelement-shine-through';
}
if ($classNames !== []) {
$attributes['class'] = implode(' ', $classNames);
}
return $attributes;
} | [
"protected",
"function",
"addCssClasses",
"(",
"array",
"$",
"attributes",
",",
"NodeInterface",
"$",
"node",
",",
"array",
"$",
"initialClasses",
"=",
"[",
"]",
")",
"{",
"$",
"classNames",
"=",
"$",
"initialClasses",
";",
"// FIXME: The `dimensionsAreMatchingTar... | Add required CSS classes to the attributes.
@param array $attributes
@param NodeInterface $node
@param array $initialClasses
@return array | [
"Add",
"required",
"CSS",
"classes",
"to",
"the",
"attributes",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/ContentElementWrappingService.php#L167-L180 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/ContentElementWrappingService.php | ContentElementWrappingService.addDocumentMetadata | protected function addDocumentMetadata(array $attributes, NodeInterface $node)
{
/** @var ContentContext $contentContext */
$contentContext = $node->getContext();
$attributes['data-neos-site-name'] = $contentContext->getCurrentSite()->getName();
$attributes['data-neos-site-node-context-path'] = $contentContext->getCurrentSiteNode()->getContextPath();
// Add the workspace of the content repository context to the attributes
$attributes['data-neos-context-workspace-name'] = $contentContext->getWorkspaceName();
$attributes['data-neos-context-dimensions'] = json_encode($contentContext->getDimensions());
if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) {
$attributes['data-node-__read-only'] = 'true';
$attributes['data-nodedatatype-__read-only'] = 'boolean';
}
return $attributes;
} | php | protected function addDocumentMetadata(array $attributes, NodeInterface $node)
{
/** @var ContentContext $contentContext */
$contentContext = $node->getContext();
$attributes['data-neos-site-name'] = $contentContext->getCurrentSite()->getName();
$attributes['data-neos-site-node-context-path'] = $contentContext->getCurrentSiteNode()->getContextPath();
// Add the workspace of the content repository context to the attributes
$attributes['data-neos-context-workspace-name'] = $contentContext->getWorkspaceName();
$attributes['data-neos-context-dimensions'] = json_encode($contentContext->getDimensions());
if (!$this->nodeAuthorizationService->isGrantedToEditNode($node)) {
$attributes['data-node-__read-only'] = 'true';
$attributes['data-nodedatatype-__read-only'] = 'boolean';
}
return $attributes;
} | [
"protected",
"function",
"addDocumentMetadata",
"(",
"array",
"$",
"attributes",
",",
"NodeInterface",
"$",
"node",
")",
"{",
"/** @var ContentContext $contentContext */",
"$",
"contentContext",
"=",
"$",
"node",
"->",
"getContext",
"(",
")",
";",
"$",
"attributes",... | Collects metadata for the Neos backend specifically for document nodes.
@param array $attributes
@param NodeInterface $node
@return array | [
"Collects",
"metadata",
"for",
"the",
"Neos",
"backend",
"specifically",
"for",
"document",
"nodes",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/ContentElementWrappingService.php#L189-L205 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/ContentElementWrappingService.php | ContentElementWrappingService.addGenericEditingMetadata | protected function addGenericEditingMetadata(array $attributes, NodeInterface $node)
{
$attributes['typeof'] = 'typo3:' . $node->getNodeType()->getName();
$attributes['about'] = $node->getContextPath();
$attributes['data-node-_identifier'] = $node->getIdentifier();
$attributes['data-node-__workspace-name'] = $node->getWorkspace()->getName();
$attributes['data-node-__label'] = $node->getLabel();
if ($node->getNodeType()->isOfType('Neos.Neos:ContentCollection')) {
$attributes['rel'] = 'typo3:content-collection';
}
// these properties are needed together with the current NodeType to evaluate Node Type Constraints
// TODO: this can probably be greatly cleaned up once we do not use CreateJS or VIE anymore.
if ($node->getParent()) {
$attributes['data-node-__parent-node-type'] = $node->getParent()->getNodeType()->getName();
}
if ($node->isAutoCreated()) {
$attributes['data-node-_name'] = $node->getName();
$attributes['data-node-_is-autocreated'] = 'true';
}
if ($node->getParent() && $node->getParent()->isAutoCreated()) {
$attributes['data-node-_parent-is-autocreated'] = 'true';
// we shall only add these properties if the parent is actually auto-created; as the Node-Type-Switcher in the UI relies on that.
$attributes['data-node-__parent-node-name'] = $node->getParent()->getName();
$attributes['data-node-__grandparent-node-type'] = $node->getParent()->getParent()->getNodeType()->getName();
}
return $attributes;
} | php | protected function addGenericEditingMetadata(array $attributes, NodeInterface $node)
{
$attributes['typeof'] = 'typo3:' . $node->getNodeType()->getName();
$attributes['about'] = $node->getContextPath();
$attributes['data-node-_identifier'] = $node->getIdentifier();
$attributes['data-node-__workspace-name'] = $node->getWorkspace()->getName();
$attributes['data-node-__label'] = $node->getLabel();
if ($node->getNodeType()->isOfType('Neos.Neos:ContentCollection')) {
$attributes['rel'] = 'typo3:content-collection';
}
// these properties are needed together with the current NodeType to evaluate Node Type Constraints
// TODO: this can probably be greatly cleaned up once we do not use CreateJS or VIE anymore.
if ($node->getParent()) {
$attributes['data-node-__parent-node-type'] = $node->getParent()->getNodeType()->getName();
}
if ($node->isAutoCreated()) {
$attributes['data-node-_name'] = $node->getName();
$attributes['data-node-_is-autocreated'] = 'true';
}
if ($node->getParent() && $node->getParent()->isAutoCreated()) {
$attributes['data-node-_parent-is-autocreated'] = 'true';
// we shall only add these properties if the parent is actually auto-created; as the Node-Type-Switcher in the UI relies on that.
$attributes['data-node-__parent-node-name'] = $node->getParent()->getName();
$attributes['data-node-__grandparent-node-type'] = $node->getParent()->getParent()->getNodeType()->getName();
}
return $attributes;
} | [
"protected",
"function",
"addGenericEditingMetadata",
"(",
"array",
"$",
"attributes",
",",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"attributes",
"[",
"'typeof'",
"]",
"=",
"'typo3:'",
".",
"$",
"node",
"->",
"getNodeType",
"(",
")",
"->",
"getName",
"(... | Collects metadata attributes used to allow editing of the node in the Neos backend.
@param array $attributes
@param NodeInterface $node
@return array | [
"Collects",
"metadata",
"attributes",
"used",
"to",
"allow",
"editing",
"of",
"the",
"node",
"in",
"the",
"Neos",
"backend",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/ContentElementWrappingService.php#L214-L245 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/ContentElementWrappingService.php | ContentElementWrappingService.collectEditingClassNames | protected function collectEditingClassNames(NodeInterface $node)
{
$classNames = [];
if ($node->getNodeType()->isOfType('Neos.Neos:ContentCollection')) {
// This is needed since the backend relies on this class (should not be necessary)
$classNames[] = 'neos-contentcollection';
} else {
$classNames[] = 'neos-contentelement';
}
if ($node->isRemoved()) {
$classNames[] = 'neos-contentelement-removed';
}
if ($node->isHidden()) {
$classNames[] = 'neos-contentelement-hidden';
}
if ($this->isInlineEditable($node) === false) {
$classNames[] = 'neos-not-inline-editable';
}
return $classNames;
} | php | protected function collectEditingClassNames(NodeInterface $node)
{
$classNames = [];
if ($node->getNodeType()->isOfType('Neos.Neos:ContentCollection')) {
// This is needed since the backend relies on this class (should not be necessary)
$classNames[] = 'neos-contentcollection';
} else {
$classNames[] = 'neos-contentelement';
}
if ($node->isRemoved()) {
$classNames[] = 'neos-contentelement-removed';
}
if ($node->isHidden()) {
$classNames[] = 'neos-contentelement-hidden';
}
if ($this->isInlineEditable($node) === false) {
$classNames[] = 'neos-not-inline-editable';
}
return $classNames;
} | [
"protected",
"function",
"collectEditingClassNames",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"$",
"classNames",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"node",
"->",
"getNodeType",
"(",
")",
"->",
"isOfType",
"(",
"'Neos.Neos:ContentCollection'",
")",
")",
... | Collects CSS class names used for styling editable elements in the Neos backend.
@param NodeInterface $node
@return array | [
"Collects",
"CSS",
"class",
"names",
"used",
"for",
"styling",
"editable",
"elements",
"in",
"the",
"Neos",
"backend",
"."
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/ContentElementWrappingService.php#L253-L277 | train |
neos/neos-development-collection | Neos.Neos/Classes/Service/ContentElementWrappingService.php | ContentElementWrappingService.hasInlineEditableProperties | protected function hasInlineEditableProperties(NodeInterface $node)
{
return array_reduce(array_values($node->getNodeType()->getProperties()), function ($hasInlineEditableProperties, $propertyConfiguration) {
return ($hasInlineEditableProperties || (isset($propertyConfiguration['ui']['inlineEditable']) && $propertyConfiguration['ui']['inlineEditable'] === true));
}, false);
} | php | protected function hasInlineEditableProperties(NodeInterface $node)
{
return array_reduce(array_values($node->getNodeType()->getProperties()), function ($hasInlineEditableProperties, $propertyConfiguration) {
return ($hasInlineEditableProperties || (isset($propertyConfiguration['ui']['inlineEditable']) && $propertyConfiguration['ui']['inlineEditable'] === true));
}, false);
} | [
"protected",
"function",
"hasInlineEditableProperties",
"(",
"NodeInterface",
"$",
"node",
")",
"{",
"return",
"array_reduce",
"(",
"array_values",
"(",
"$",
"node",
"->",
"getNodeType",
"(",
")",
"->",
"getProperties",
"(",
")",
")",
",",
"function",
"(",
"$"... | Checks if the given Node has any properties configured as 'inlineEditable'
@param NodeInterface $node
@return boolean | [
"Checks",
"if",
"the",
"given",
"Node",
"has",
"any",
"properties",
"configured",
"as",
"inlineEditable"
] | 9062fb5e8e9217bc99324b7eba0378e9274fc051 | https://github.com/neos/neos-development-collection/blob/9062fb5e8e9217bc99324b7eba0378e9274fc051/Neos.Neos/Classes/Service/ContentElementWrappingService.php#L301-L306 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.