/** * Sort the TypoScript objects inside $this->properties depending on: * - numerical ordering * - position meta-property * * This will ignore all properties defined in "@ignoreProperties" in TypoScript * * @see \TYPO3\Flow\Utility\PositionalArraySorter * * @return array an ordered list of keys * @throws TypoScript\Exception if the positional string has an unsupported format */ protected function sortNestedTypoScriptKeys() { $arraySorter = new PositionalArraySorter($this->properties, '__meta.position'); try { $sortedTypoScriptKeys = $arraySorter->getSortedKeys(); } catch (InvalidPositionException $exception) { throw new TypoScript\Exception('Invalid position string', 1345126502, $exception); } foreach ($this->ignoreProperties as $ignoredPropertyName) { $key = array_search($ignoredPropertyName, $sortedTypoScriptKeys); if ($key !== false) { unset($sortedTypoScriptKeys[$key]); } } return $sortedTypoScriptKeys; }
/** * @test * @dataProvider sampleArrays * * @param string $message * @param array $subject * @param string $positionPropertyPath * @param array $expectedKeyOrder */ public function getSortedKeysTests($message, array $subject, $positionPropertyPath, array $expectedKeyOrder) { $positionalArraySorter = new PositionalArraySorter($subject, $positionPropertyPath); $result = $positionalArraySorter->getSortedKeys(); $this->assertSame($expectedKeyOrder, $result, $message); }
/** * Evaluate processors on given value. * * @param mixed $valueToProcess * @param array $configurationWithEventualProcessors * @param string $typoScriptPath * @param AbstractTypoScriptObject $contextObject * @return mixed */ protected function evaluateProcessors($valueToProcess, $configurationWithEventualProcessors, $typoScriptPath, AbstractTypoScriptObject $contextObject = null) { if (isset($configurationWithEventualProcessors['__meta']['process'])) { $processorConfiguration = $configurationWithEventualProcessors['__meta']['process']; $positionalArraySorter = new PositionalArraySorter($processorConfiguration, '__meta.position'); foreach ($positionalArraySorter->getSortedKeys() as $key) { $processorPath = $typoScriptPath . '/__meta/process/' . $key; if ($this->evaluateIfCondition($processorConfiguration[$key], $processorPath, $contextObject) === false) { continue; } if (isset($processorConfiguration[$key]['expression'])) { $processorPath .= '/expression'; } $this->pushContext('value', $valueToProcess); $result = $this->evaluateInternal($processorPath, self::BEHAVIOR_EXCEPTION, $contextObject); if ($this->getLastEvaluationStatus() !== static::EVALUATION_SKIPPED) { $valueToProcess = $result; } $this->popContext(); } } return $valueToProcess; }