本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Model\NodeData::setDimensions方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeData::setDimensions方法的具体用法?PHP NodeData::setDimensions怎么用?PHP NodeData::setDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Model\NodeData
的用法示例。
在下文中一共展示了NodeData::setDimensions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Add dimensions to the node.
*
* @param \TYPO3\TYPO3CR\Domain\Model\NodeData $node
* @return void
*/
public function execute(\TYPO3\TYPO3CR\Domain\Model\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);
}
示例2: execute
/**
* Change the property on the given node.
*
* @param NodeData $node
* @return void
*/
public function execute(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);
}
示例3: 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);
}
}
}
示例4: setDimensionsRemovesDimensionValuesNotGiven
/**
* @test
*/
public function setDimensionsRemovesDimensionValuesNotGiven()
{
$nodeData = new NodeData('/foo/bar', $this->mockWorkspace, null, array('c' => array('c1', 'c2'), 'a' => array('a1')));
$dimensionsToSet = array(new NodeDimension($nodeData, 'c', 'c1'), new NodeDimension($nodeData, 'b', 'b1'), new NodeDimension($nodeData, 'f', 'f1'));
$expectedDimensionValues = array('b' => array('b1'), 'c' => array('c1'), 'f' => array('f1'));
$nodeData->setDimensions($dimensionsToSet);
$setDimensionValues = $nodeData->getDimensionValues();
$this->assertSame($expectedDimensionValues, $setDimensionValues);
}