本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Model\NodeData类的典型用法代码示例。如果您正苦于以下问题:PHP NodeData类的具体用法?PHP NodeData怎么用?PHP NodeData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Change the property on the given node.
*
* @param NodeData $node
* @return void
*/
public function execute(NodeData $node)
{
foreach ($node->getNodeType()->getProperties() as $propertyName => $propertyConfiguration) {
if (isset($propertyConfiguration['type']) && in_array(trim($propertyConfiguration['type']), $this->getHandledObjectTypes())) {
if (!isset($nodeProperties)) {
$nodeRecordQuery = $this->entityManager->getConnection()->prepare('SELECT properties FROM typo3_typo3cr_domain_model_nodedata WHERE persistence_object_identifier=?');
$nodeRecordQuery->execute([$this->persistenceManager->getIdentifierByObject($node)]);
$nodeRecord = $nodeRecordQuery->fetch(\PDO::FETCH_ASSOC);
$nodeProperties = unserialize($nodeRecord['properties']);
}
if (!isset($nodeProperties[$propertyName]) || !is_object($nodeProperties[$propertyName])) {
continue;
}
/** @var Asset $assetObject */
$assetObject = $nodeProperties[$propertyName];
$nodeProperties[$propertyName] = null;
$stream = $assetObject->getResource()->getStream();
if ($stream === false) {
continue;
}
fclose($stream);
$objectType = TypeHandling::getTypeForValue($assetObject);
$objectIdentifier = ObjectAccess::getProperty($assetObject, 'Persistence_Object_Identifier', true);
$nodeProperties[$propertyName] = array('__flow_object_type' => $objectType, '__identifier' => $objectIdentifier);
}
}
if (isset($nodeProperties)) {
$nodeUpdateQuery = $this->entityManager->getConnection()->prepare('UPDATE typo3_typo3cr_domain_model_nodedata SET properties=? WHERE persistence_object_identifier=?');
$nodeUpdateQuery->execute([serialize($nodeProperties), $this->persistenceManager->getIdentifierByObject($node)]);
}
}
示例2: execute
/**
* Add dimensions to the node.
*
* @param NodeData $node
* @return void
*/
public function execute(NodeData $node)
{
$dimensionValuesToBeAdded = $node->getDimensionValues();
foreach ($this->dimensionValues as $dimensionName => $dimensionValues) {
if (!isset($dimensionValuesToBeAdded[$dimensionName])) {
if (is_array($dimensionValues)) {
$dimensionValuesToBeAdded[$dimensionName] = $dimensionValues;
} else {
$dimensionValuesToBeAdded[$dimensionName] = array($dimensionValues);
}
}
}
if ($this->addDefaultDimensionValues === true) {
$configuredDimensions = $this->contentDimensionRepository->findAll();
foreach ($configuredDimensions as $configuredDimension) {
if (!isset($dimensionValuesToBeAdded[$configuredDimension->getIdentifier()])) {
$dimensionValuesToBeAdded[$configuredDimension->getIdentifier()] = array($configuredDimension->getDefault());
}
}
}
$dimensionsToBeSet = array();
foreach ($dimensionValuesToBeAdded as $dimensionName => $dimensionValues) {
foreach ($dimensionValues as $dimensionValue) {
$dimensionsToBeSet[] = new NodeDimension($node, $dimensionName, $dimensionValue);
}
}
$node->setDimensions($dimensionsToBeSet);
}
示例3: matches
/**
* Returns TRUE if the given node has the property and the value is not empty.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return boolean
*/
public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
{
if ($node->hasProperty($this->propertyName)) {
$propertyValue = $node->getProperty($this->propertyName);
return !empty($propertyValue);
}
return FALSE;
}
示例4: matches
/**
* Returns TRUE if the given node has the property and the value is not empty.
*
* @param NodeData $node
* @return boolean
*/
public function matches(NodeData $node)
{
if ($node->hasProperty($this->propertyName)) {
$propertyValue = $node->getProperty($this->propertyName);
return !empty($propertyValue);
}
return false;
}
示例5: createFromNodeData
/**
* Creates a node from the given NodeData container.
*
* If this factory has previously created a Node for the given $node and $context,
* it will return the same Node again.
*
* @param NodeData $nodeData
* @param Context $context
* @return \TYPO3\TYPO3CR\Domain\Model\Node
*/
public function createFromNodeData(NodeData $nodeData, Context $context)
{
$internalNodeIdentifier = $nodeData->getIdentifier() . spl_object_hash($context);
if (!isset($this->nodes[$internalNodeIdentifier])) {
$this->nodes[$internalNodeIdentifier] = new Node($nodeData, $context);
}
$node = $this->nodes[$internalNodeIdentifier];
return $this->filterNodeByContext($node, $context);
}
示例6: extractComments
/**
* Extract comments and deserialize them
*
* @param NodeInterface|NodeData $nodeOrNodeData
* @return array
*/
protected function extractComments($nodeOrNodeData)
{
if ($nodeOrNodeData->hasProperty('comments')) {
$comments = $nodeOrNodeData->getProperty('comments');
if (is_string($comments) && strlen($comments) > 0) {
return json_decode($comments, TRUE);
}
}
return array();
}
示例7: matches
/**
* Returns TRUE if the given node has the default dimension values.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return boolean
*/
public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
{
if ($this->filterForDefaultDimensionValues === true) {
$configuredDimensions = $this->contentDimensionRepository->findAll();
foreach ($configuredDimensions as $dimension) {
$this->dimensionValues[$dimension->getIdentifier()] = array($dimension->getDefault());
}
}
return $node->getDimensionValues() === $this->dimensionValues;
}
示例8: createContextMatchingNodeData
/**
* Generates a Context that exactly fits the given NodeData Workspace, Dimensions & Site.
*
* @param NodeData $nodeData
* @return ContentContext
*/
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 ($domain = $site->getFirstActiveDomain()) {
$contextProperties['currentDomain'] = $domain;
}
return $this->_contextFactory->create($contextProperties);
}
示例9: matches
/**
* Returns TRUE if the given node is of the node type this filter expects.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return boolean
*/
public function matches(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
{
if ($this->withSubTypes === true) {
$nodeIsMatchingNodeType = $node->getNodeType()->isOfType($this->nodeTypeName);
} else {
// This is needed to get the raw string NodeType to prevent errors for NodeTypes that no longer exist.
$nodeType = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($node, 'nodeType', true);
$nodeIsMatchingNodeType = $nodeType === $this->nodeTypeName;
}
if ($this->exclude === true) {
return !$nodeIsMatchingNodeType;
}
return $nodeIsMatchingNodeType;
}
示例10: execute
/**
* If AssetList contains only 1 file, and it's of type Audio, turn it into targetNodeType
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return void
*/
public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
{
$assets = $node->getProperty($this->sourcePropertyName);
if (count($assets) === 1) {
$asset = $assets[0];
if ($asset instanceof $this->assetType) {
$nodeType = $this->nodeTypeManager->getNodeType($this->targetNodeType);
$node->setNodeType($nodeType);
$node->setProperty($this->targetPropertyName, $asset);
$node->removeProperty($this->sourcePropertyName);
echo "Converted AssetList with asset of type" . $this->assetType . " to node of type " . $this->targetNodeType . "\n";
}
}
}
示例11: createVariantForContext
/**
* Given a context a new node is returned that is like this node, but
* lives in the new context.
*
* @param Context $context
* @return NodeInterface
*/
public function createVariantForContext($context)
{
$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) {
$autoCreatedChildNode->createVariantForContext($context);
}
return $node;
}
示例12: matchesWorkspaceAndDimensionsWithMatchingWorkspaceAndDimensionsReturnsTrue
/**
* @test
*/
public function matchesWorkspaceAndDimensionsWithMatchingWorkspaceAndDimensionsReturnsTrue()
{
$this->nodeData = new NodeData('/foo/bar', $this->mockWorkspace, NULL, array('locales' => array('mul_ZZ')));
$this->mockWorkspace->expects($this->any())->method('getName')->will($this->returnValue('live'));
$result = $this->nodeData->matchesWorkspaceAndDimensions($this->mockWorkspace, array('locales' => array('de_DE', 'mul_ZZ')));
$this->assertTrue($result);
}
示例13: execute
/**
* Change the property on the given node.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $nodeData
* @return void
*/
public function execute(NodeData $nodeData)
{
$dimensions = $nodeData->getDimensions();
if ($dimensions !== array()) {
$hasChanges = false;
$newDimensions = array();
foreach ($dimensions as $dimension) {
/** @var NodeDimension $dimension */
if ($dimension->getName() === $this->oldDimensionName) {
$dimension = new NodeDimension($dimension->getNodeData(), $this->newDimensionName, $dimension->getValue());
$hasChanges = true;
} else {
$dimension = new NodeDimension($dimension->getNodeData(), $dimension->getName(), $dimension->getValue());
}
$newDimensions[] = $dimension;
}
if ($hasChanges) {
$nodeData->setDimensions($newDimensions);
}
}
}
示例14: execute
/**
* Change the property on the given node.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return void
*/
public function execute(\TYPO3\TYPO3CR\Domain\Model\NodeData $node)
{
$dimensions = array();
foreach ($this->dimensionValues as $dimensionName => $dimensionConfiguration) {
foreach ($dimensionConfiguration as $dimensionValues) {
if (is_array($dimensionValues)) {
foreach ($dimensionValues as $dimensionValue) {
$dimensions[] = new NodeDimension($node, $dimensionName, $dimensionValue);
}
} else {
$dimensions[] = new NodeDimension($node, $dimensionName, $dimensionValues);
}
}
}
if ($this->addDefaultDimensionValues === TRUE) {
$configuredDimensions = $this->contentDimensionRepository->findAll();
foreach ($configuredDimensions as $configuredDimension) {
if (!isset($this->dimensionValues[$configuredDimension->getIdentifier()])) {
$dimensions[] = new NodeDimension($node, $configuredDimension->getIdentifier(), $configuredDimension->getDefault());
}
}
}
$node->setDimensions($dimensions);
}
示例15: execute
/**
* Change the property on the given node.
*
* @param NodeData $node
* @return NodeData
*/
public function execute(NodeData $node)
{
$reference = (string) $node->getProperty('plugin');
$workspace = $node->getWorkspace();
do {
if ($this->reverse === false && preg_match(NodeInterface::MATCH_PATTERN_PATH, $reference)) {
$pluginNode = $this->nodeDataRepository->findOneByPath($reference, $node->getWorkspace());
} else {
$pluginNode = $this->nodeDataRepository->findOneByIdentifier($reference, $node->getWorkspace());
}
if (isset($pluginNode)) {
break;
}
$workspace = $workspace->getBaseWorkspace();
} while ($workspace && $workspace->getName() !== 'live');
if (isset($pluginNode)) {
$node->setProperty('plugin', $this->reverse === false ? $pluginNode->getIdentifier() : $pluginNode->getPath());
}
return $node;
}