本文整理汇总了PHP中TYPO3\TYPO3CR\Domain\Service\Context::getTargetDimensions方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getTargetDimensions方法的具体用法?PHP Context::getTargetDimensions怎么用?PHP Context::getTargetDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\TYPO3CR\Domain\Service\Context
的用法示例。
在下文中一共展示了Context::getTargetDimensions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dimensionsAreMatchingTargetDimensionValues
/**
* Internal method
*
* The dimension value of this node has to match the current target dimension value (must be higher in priority or equal)
*
* @return boolean
*/
public function dimensionsAreMatchingTargetDimensionValues()
{
$dimensions = $this->getDimensions();
$contextDimensions = $this->context->getDimensions();
foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
if (!isset($dimensions[$dimensionName])) {
if ($targetDimensionValue === null) {
continue;
} else {
return false;
}
} elseif ($targetDimensionValue === null && $dimensions[$dimensionName] === array()) {
continue;
} elseif (!in_array($targetDimensionValue, $dimensions[$dimensionName], true)) {
$contextDimensionValues = $contextDimensions[$dimensionName];
$targetPositionInContext = array_search($targetDimensionValue, $contextDimensionValues, true);
$nodePositionInContext = min(array_map(function ($value) use($contextDimensionValues) {
return array_search($value, $contextDimensionValues, true);
}, $dimensions[$dimensionName]));
$val = $targetPositionInContext !== false && $nodePositionInContext !== false && $targetPositionInContext >= $nodePositionInContext;
if ($val === false) {
return false;
}
}
}
return true;
}
示例2: dimensionsAreMatchingTargetDimensionValues
/**
* The dimension value of this node has to match the current target dimension value (must be higher in priority or equal)
*
* @return boolean
*/
protected function dimensionsAreMatchingTargetDimensionValues()
{
$dimensions = $this->getDimensions();
$contextDimensions = $this->context->getDimensions();
foreach ($this->context->getTargetDimensions() as $dimensionName => $targetDimensionValue) {
if (!isset($dimensions[$dimensionName])) {
return FALSE;
} elseif (!in_array($targetDimensionValue, $dimensions[$dimensionName], TRUE)) {
$contextDimensionValues = $contextDimensions[$dimensionName];
$targetPositionInContext = array_search($targetDimensionValue, $contextDimensionValues, TRUE);
$nodePositionInContext = min(array_map(function ($value) use($contextDimensionValues) {
return array_search($value, $contextDimensionValues, TRUE);
}, $dimensions[$dimensionName]));
$val = $targetPositionInContext !== FALSE && $nodePositionInContext !== FALSE && $targetPositionInContext >= $nodePositionInContext;
if ($val === FALSE) {
return FALSE;
}
}
}
return TRUE;
}
示例3: beforeAdoptNode
/**
*
*
* @param NodeInterface $node
* @param Context $context
* @param $recursive
* @return void
*/
public function beforeAdoptNode(NodeInterface $node, Context $context, $recursive)
{
if (!$this->eventEmittingService->isEnabled()) {
return;
}
$this->initializeAccountIdentifier();
if ($this->currentlyAdopting === 0) {
/* @var $nodeEvent NodeEvent */
$nodeEvent = $this->eventEmittingService->emit(self::NODE_ADOPT, array('targetWorkspace' => $context->getWorkspaceName(), 'targetDimensions' => $context->getTargetDimensions(), 'recursive' => $recursive), 'TYPO3\\Neos\\EventLog\\Domain\\Model\\NodeEvent');
$nodeEvent->setNode($node);
$this->eventEmittingService->pushContext();
}
$this->currentlyAdopting++;
}
示例4: adjustToContext
/**
* Adjust this instance to the given context.
*
* Internal use only!
*
* @param Context $context
* @throws \TYPO3\TYPO3CR\Exception\InvalidNodeContextException
*/
public function adjustToContext(Context $context)
{
$this->setWorkspace($context->getWorkspace());
$nodeDimensions = new \Doctrine\Common\Collections\ArrayCollection();
$targetDimensionValues = $context->getTargetDimensions();
foreach ($context->getDimensions() as $dimensionName => $dimensionValues) {
if (!isset($targetDimensionValues[$dimensionName])) {
throw new \TYPO3\TYPO3CR\Exception\InvalidNodeContextException(sprintf('Missing target value for dimension "%"', $dimensionName), 1391686089);
}
$dimensionValueToSet = $targetDimensionValues[$dimensionName];
$nodeDimensions->add(new NodeDimension($this, $dimensionName, $dimensionValueToSet));
}
$this->setDimensions($nodeDimensions);
}