TYPO3
7.6
|
Static Public Member Functions | |
static | filterByValueRecursive ($needle= '', array $haystack=array()) |
static | isValidPath (array $array, $path, $delimiter= '/') |
static | getValueByPath (array $array, $path, $delimiter= '/') |
static | setValueByPath (array $array, $path, $value, $delimiter= '/') |
static | removeByPath (array $array, $path, $delimiter= '/') |
static | sortByKeyRecursive (array $array) |
static | sortArraysByKey (array $arrays, $key, $ascending=true) |
static | arrayExport (array $array=array(), $level=0) |
static | flatten (array $array, $prefix= '') |
static | intersectRecursive (array $source, array $mask=array()) |
static | renumberKeysToAvoidLeapsIfKeysAreAllNumeric (array $array=array(), $level=0) |
static | mergeRecursiveWithOverrule (array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true) |
static | inArray (array $in_array, $item) |
static | removeArrayEntryByValue (array $array, $cmpValue) |
static | keepItemsInArray (array $array, $keepItems, $getValueFunc=null) |
static | remapArrayKeys (array &$array, array $mappingTable) |
static | arrayDiffAssocRecursive (array $array1, array $array2) |
static | naturalKeySortRecursive (array &$array) |
Class with helper functions for array handling
Definition at line 20 of file core/Classes/Utility/ArrayUtility.php.
|
static |
Filters keys off from first array that also exist in second array. Comparison is done by keys. This method is a recursive version of php array_diff_assoc()
array | $array1 | Source array |
array | $array2 | Reduce source array by this array |
Definition at line 667 of file core/Classes/Utility/ArrayUtility.php.
References elseif.
Referenced by GeneralUtility\arrayDiffAssocRecursive(), UriBuilder\buildBackendUri(), ContentObjectRenderer\getQueryArguments(), DataHandlerHook\processCmdmap_deleteAction(), and DataHandler\unsetElementsToBeDeleted().
|
static |
Exports an array as string. Similar to var_export(), but representation follows the PSR-2 and TYPO3 core CGL.
See unit tests for detailed examples
array | $array | Array to export |
int | $level | Internal level used for recursion, do not set from outside! |
\RuntimeException |
Definition at line 303 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationManager\writeLocalConfiguration().
|
static |
Reduce an array by a search value and keep the array structure.
Comparison is type strict:
Example:
See the unit tests for more examples and expected behaviour
mixed | $needle | The value to search for |
array | $haystack | The array in which to search |
Definition at line 55 of file core/Classes/Utility/ArrayUtility.php.
References elseif.
Referenced by ExtensionManagementUtility\addTcaSelectItem().
|
static |
Converts a multidimensional array to a flat representation.
See unit tests for more details
Example:
Example:
array | $array | The (relative) array to be converted |
string | $prefix | The (relative) prefix to be used (e.g. 'section.') |
Definition at line 385 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationItemRepository\mergeWithExistingConfiguration().
|
static |
Returns a value by given path
Example
If a path segments contains a delimiter character, the path segment must be enclosed by " (double quote), see unit tests for details
array | $array | Input array |
string | $path | Path within the array |
string | $delimiter | Defined path delimiter, default / |
\RuntimeException |
Definition at line 131 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationManager\getConfigurationValueByPath(), ConfigurationManager\getDefaultConfigurationValueByPath(), BackendLayoutView\getIdentifiersToBeExcluded(), and ConfigurationManager\getLocalConfigurationValueByPath().
|
static |
Check if an string item exists in an array. Please note that the order of function parameters is reverse compared to the PHP function in_array()!!!
Comparison to PHP in_array(): -> $array = array(0, 1, 2, 3); -> variant_a := ::inArray($array, $needle) -> variant_b := in_array($needle, $array) -> variant_c := in_array($needle, $array, TRUE) +------—+--------—+--------—+--------—+ | $needle | variant_a | variant_b | variant_c | +------—+--------—+--------—+--------—+ | '1a' | FALSE | TRUE | FALSE | | '' | FALSE | TRUE | FALSE | | '0' | TRUE | TRUE | FALSE | | 0 | TRUE | TRUE | TRUE | +------—+--------—+--------—+--------—+
array | $in_array | One-dimensional array of items |
string | $item | Item to check for |
Definition at line 566 of file core/Classes/Utility/ArrayUtility.php.
Referenced by BackendUtility\blindGroupNames(), AbstractMenuContentObject\filterMenuPages(), JavaScriptMenuContentObject\generate_level(), GeneralUtility\inArray(), and AjaxRequestHandler\setContentFormat().
|
static |
Determine the intersections between two arrays, recursively comparing keys A complete sub array of $source will be preserved, if the key exists in $mask.
See unit tests for more examples and edge cases.
Example:
array | $source | Source array |
array | $mask | Array that has the keys which should be kept in the source array |
Definition at line 435 of file core/Classes/Utility/ArrayUtility.php.
|
static |
Checks if a given path exists in array
Example:
array | $array | Given array |
string | $path | Path to test, 'foo/bar/foobar' |
string | $delimiter | Delimiter for path, default / |
Definition at line 95 of file core/Classes/Utility/ArrayUtility.php.
Referenced by BackendLayoutView\getIdentifiersToBeExcluded(), ConfigurationManager\isValidLocalConfigurationPath(), and ConfigurationManager\removeLocalConfigurationKeysByPath().
|
static |
Filters an array to reduce its elements to match the condition. The values in $keepItems can be optionally evaluated by a custom callback function.
Example (arguments used to call this function): $array = array( array('aa' => array('first', 'second'), array('bb' => array('third', 'fourth'), array('cc' => array('fifth', 'sixth'), ); $keepItems = array('third'); $getValueFunc = function($value) { return $value[0]; }
Returns: array( array('bb' => array('third', 'fourth'), )
array | $array | The initial array to be filtered/reduced |
mixed | $keepItems | The items which are allowed/kept in the array - accepts array or csv string |
string | $getValueFunc | (optional) Callback function used to get the value to keep |
Definition at line 618 of file core/Classes/Utility/ArrayUtility.php.
References GeneralUtility\trimExplode().
Referenced by GeneralUtility\keepItemsInArray(), and AbstractItemProvider\removeItemsByKeepItemsPageTsConfig().
|
static |
Merges two arrays recursively and "binary safe" (integer keys are overridden as well), overruling similar values in the original array with the values of the overrule array. In case of identical keys, ie. keeping the values of the overrule array.
This method takes the original array by reference for speed optimization with large arrays
The differences to the existing PHP function array_merge_recursive() are:
array | $original | Original array. It will be modified by this method and contains the result afterwards! |
array | $overrule | Overrule array, overruling the original array |
bool | $addKeys | If set to FALSE, keys that are NOT found in $original will not be set. Thus only existing value can/will be overruled from overrule array. |
bool | $includeEmptyValues | If set, values from $overrule will overrule if they are empty or zero. |
bool | $enableUnsetFeature | If set, special values "__UNSET" can be used in the overrule array in order to unset array keys in the original array. |
Definition at line 522 of file core/Classes/Utility/ArrayUtility.php.
References elseif.
Referenced by GeneralUtility\_GETset(), GeneralUtility\_GPmerged(), TcaColumnsOverrides\addData(), PageTsConfigMerged\addData(), InlineOverrideChildTca\addData(), ExtensionManagementUtility\addExtJSModule(), TcaInlineConfiguration\addInlineSelectorAndUniqueConfiguration(), UriBuilder\buildBackendUri(), DataHandler\checkValueForFlex(), ConfigurationManager\createLocalConfigurationFromFactoryConfiguration(), ConfigurationManager\exportConfiguration(), ConfigurationForm\ext_mergeIncomingWithExisting(), DataHandler\fillInFieldArray(), TypoScriptFrontendController\getConfigArray(), SuggestWizard\getConfigurationForTable(), ConfigurationManager\getConfigurationValueByPath(), ContentObjectRenderer\getData(), ExtensionManagementUtility\getFileFieldTCAConfig(), BackendUtility\getPagesTSconfig(), LocallangXmlParser\getParsedData(), ContentObjectRenderer\getQueryArguments(), DataHandler\getTableEntries(), CategoryRegistry\getTcaFieldConfiguration(), AbstractFunctionModule\incLocalLang(), LanguageService\includeLLFile(), NewContentElementController\init(), PaginateController\initializeAction(), GeneralUtility\linkThisUrl(), ValidatorTask\loadModTsConfig(), LocalizationFactory\localizationOverride(), AbstractNode\mergeChildReturnIntoExistingResult(), FormResultCompiler\mergeResult(), ConfigurationItemRepository\mergeWithExistingConfiguration(), TypoScriptFrontendController\mergingWithGetVars(), FormEngineUtility\overrideFieldConf(), AbstractPlugin\pi_linkTP_keepPIvars(), AbstractPlugin\pi_setPiVarDefaults(), ConfigurationManager\updateLocalConfiguration(), and UriBuilder\uriFor().
|
static |
Sorts an array by key recursive - uses natural sort order (aAbB-zZ)
array | $array | array to be sorted recursively, passed by reference |
Definition at line 688 of file core/Classes/Utility/ArrayUtility.php.
Referenced by GeneralUtility\naturalKeySortRecursive().
|
static |
Rename Array keys with a given mapping table
array | $array | Array by reference which should be remapped |
array | $mappingTable | Array with remap information, array/$oldKey => $newKey) |
Definition at line 649 of file core/Classes/Utility/ArrayUtility.php.
Referenced by GeneralUtility\remapArrayKeys().
|
static |
Removes the value $cmpValue from the $array if found there. Returns the modified array
array | $array | Array containing the values |
string | $cmpValue | Value to search for and if found remove array entry where found. |
Definition at line 583 of file core/Classes/Utility/ArrayUtility.php.
References elseif.
Referenced by VersionModuleController\pageSubContent(), GeneralUtility\removeArrayEntryByValue(), and UserSettingsController\removeFromList().
|
static |
Remove a sub part from an array specified by path
array | $array | Input array to manipulate |
string | $path | Path to remove from array |
string | $delimiter | Path delimiter |
\RuntimeException |
Definition at line 217 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationManager\removeLocalConfigurationKeysByPath().
|
static |
Renumber the keys of an array to avoid leaps if keys are all numeric.
Is called recursively for nested arrays.
Example:
Given array(0 => 'Zero' 1 => 'One', 2 => 'Two', 4 => 'Three') as input, it will return array(0 => 'Zero' 1 => 'One', 2 => 'Two', 3 => 'Three')
Will treat keys string representations of number (ie. '1') equal to the numeric value (ie. 1).
Example: Given array('0' => 'Zero', '1' => 'One' ) it will return array(0 => 'Zero', 1 => 'One')
array | $array | Input array |
int | $level | Internal level used for recursion, do not set from outside! |
Definition at line 479 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationManager\writeLocalConfiguration().
|
static |
Modifies or sets a new value in an array by given path
Example:
array | $array | Input array to manipulate |
string | $path | Path in array to search for |
mixed | $value | Value to set at path location in array |
string | $delimiter | Path delimiter |
\RuntimeException |
Definition at line 178 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationManager\setLocalConfigurationValueByPath(), ConfigurationManager\setLocalConfigurationValuesByPathValuePairs(), and DataHandler\updateFlexFormData().
|
static |
Sort an array of arrays by a given key using uasort
array | $arrays | Array of arrays to sort |
string | $key | Key to sort after |
bool | $ascending | Set to TRUE for ascending order, FALSE for descending order |
\RuntimeException |
Definition at line 275 of file core/Classes/Utility/ArrayUtility.php.
Referenced by BackendUtility\getRecordsSortedByTitle().
|
static |
Sorts an array recursively by key
$array | Array to sort recursively by key |
Definition at line 255 of file core/Classes/Utility/ArrayUtility.php.
Referenced by ConfigurationManager\writeLocalConfiguration().