本文整理汇总了PHP中TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtility::setValueByPath方法的具体用法?PHP ArrayUtility::setValueByPath怎么用?PHP ArrayUtility::setValueByPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\ArrayUtility
的用法示例。
在下文中一共展示了ArrayUtility::setValueByPath方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
/**
* Self-registers the DrawItem hook
*
* @param string $extensionKey Extension key
*
* @return void
*/
public static function register($extensionKey)
{
$className = get_called_class();
if ($pos = strrpos($className, '\\')) {
$className = substr($className, $pos + 1);
}
$hookClassName = 'DreadLabs\\Vantomas\\Hook\\PageLayoutView\\DrawItem\\' . $className;
$path = 'TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|tt_content_drawItem';
$drawItems = ArrayUtility::getValueByPath($GLOBALS, $path, '|');
$drawItems[] = $hookClassName;
ArrayUtility::setValueByPath($GLOBALS, $path, $drawItems, '|');
}
示例2: convertValuedToNestedConfiguration
/**
* Converts a valued configuration to a nested configuration.
*
* array('first.second' => array('value' => 1))
* will become
* array('first.' => array('second' => ))
*
* @param array $valuedConfiguration
* @return array
*/
public function convertValuedToNestedConfiguration(array $valuedConfiguration)
{
$nestedConfiguration = array();
foreach ($valuedConfiguration as $name => $section) {
$path = str_replace('.', './', $name);
$nestedConfiguration = \TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($nestedConfiguration, $path, $section['value'], '/');
}
return $nestedConfiguration;
}
示例3: setLocalConfigurationValuesByPathValuePairs
/**
* Update / set a list of path and value pairs in local configuration file
*
* @param array $pairs Key is path, value is value to set
* @return boolean TRUE on success
*/
public function setLocalConfigurationValuesByPathValuePairs(array $pairs)
{
$localConfiguration = $this->getLocalConfiguration();
foreach ($pairs as $path => $value) {
if ($this->isValidLocalConfigurationPath($path)) {
$localConfiguration = Utility\ArrayUtility::setValueByPath($localConfiguration, $path, $value);
}
}
return $this->writeLocalConfiguration($localConfiguration);
}
示例4: updateFlexFormData
/**
* Updates FlexForm data.
*
* @param string $flexFormId, e.g. <table>:<uid>:<field>
* @param array $modifications Modifications with paths and values (e.g. 'sDEF/lDEV/field/vDEF' => 'TYPO3')
* @return void
*/
protected function updateFlexFormData($flexFormId, array $modifications)
{
list($table, $uid, $field) = explode(':', $flexFormId, 3);
if (!MathUtility::canBeInterpretedAsInteger($uid) && !empty($this->substNEWwithIDs[$uid])) {
$uid = $this->substNEWwithIDs[$uid];
}
$record = $this->recordInfo($table, $uid, '*');
if (!$table || !$uid || !$field || !is_array($record)) {
return;
}
BackendUtility::workspaceOL($table, $record);
// Get current data structure and value array:
$valueStructure = GeneralUtility::xml2array($record[$field]);
// Do recursive processing of the XML data:
foreach ($modifications as $path => $value) {
$valueStructure['data'] = ArrayUtility::setValueByPath($valueStructure['data'], $path, $value);
}
if (is_array($valueStructure['data'])) {
// The return value should be compiled back into XML
$values = array($field => $this->checkValue_flexArray2Xml($valueStructure, true));
$this->updateDB($table, $uid, $values);
}
}
示例5: setValueByPathSetsCorrectValue
/**
* @test
* @dataProvider setValueByPathSetsCorrectValueDataProvider
*/
public function setValueByPathSetsCorrectValue(array $array, $path, $value, $expectedResult)
{
$this->assertEquals($expectedResult, ArrayUtility::setValueByPath($array, $path, $value));
}
示例6: setDuplicationDataValue
/**
* Set the value within the data of the duplication process, at the given
* path.
*
* @param string $path The path within the data.
* @param mixed $value The value to set at given path in data.
* @param string $delimiter The delimiter for path, default "/".
* @return $this
*/
protected function setDuplicationDataValue($path, $value, $delimiter = '/')
{
$this->data = ArrayUtility::setValueByPath($this->data, $path, $value, $delimiter);
return $this;
}
示例7: untangleFilesArray
/**
* Transforms the convoluted _FILES superglobal into a manageable form.
*
* @param array $convolutedFiles The _FILES superglobal
* @return array Untangled files
* @see TYPO3\Flow\Utility\Environment
*/
protected function untangleFilesArray(array $convolutedFiles)
{
$untangledFiles = [];
$fieldPaths = [];
foreach ($convolutedFiles as $firstLevelFieldName => $fieldInformation) {
if (!is_array($fieldInformation['error'])) {
$fieldPaths[] = [$firstLevelFieldName];
} else {
$newFieldPaths = $this->calculateFieldPaths($fieldInformation['error'], $firstLevelFieldName);
array_walk($newFieldPaths, function (&$value, $key) {
$value = explode('/', $value);
});
$fieldPaths = array_merge($fieldPaths, $newFieldPaths);
}
}
foreach ($fieldPaths as $fieldPath) {
if (count($fieldPath) === 1) {
$fileInformation = $convolutedFiles[$fieldPath[0]];
} else {
$fileInformation = [];
foreach ($convolutedFiles[$fieldPath[0]] as $key => $subStructure) {
try {
$fileInformation[$key] = \TYPO3\CMS\Core\Utility\ArrayUtility::getValueByPath($subStructure, array_slice($fieldPath, 1));
} catch (\RuntimeException $e) {
// do nothing if the path is invalid
}
}
}
$untangledFiles = \TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($untangledFiles, $fieldPath, $fileInformation);
}
return $untangledFiles;
}
示例8: setFormValue
/**
* @param string $propertyPath
* @param mixed $value
* @return void
*/
public function setFormValue(string $propertyPath, $value)
{
$this->formValues = ArrayUtility::setValueByPath($this->formValues, $propertyPath, $value);
}
示例9: setLocalConfigurationValuesByPathValuePairs
/**
* Update / set a list of path and value pairs in local configuration file
*
* @param array $pairs Key is path, value is value to set
* @return boolean TRUE on success
*/
public static function setLocalConfigurationValuesByPathValuePairs(array $pairs)
{
$localConfiguration = static::getLocalConfiguration();
foreach ($pairs as $path => $value) {
if (static::isValidLocalConfigurationPath($path)) {
$localConfiguration = \TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($localConfiguration, $path, $value);
}
}
return static::writeLocalConfiguration($localConfiguration);
}
示例10: set
/**
* Set value by path.
* @param string $path Path to value.
* @param mixed $value
*/
public function set($path, $value)
{
// try {
$this->array = \TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($this->array, $path, $value, $this->delimiter);
// } catch (\RuntimeException $exception){
// }
}
示例11: updateFlexFormData
/**
* Updates FlexForm data.
*
* @param string $flexFormId, e.g. <table>:<uid>:<field>
* @param array $modifications Modifications with paths and values (e.g. 'sDEF/lDEV/field/vDEF' => 'TYPO3')
* @return void
*/
protected function updateFlexFormData($flexFormId, array $modifications)
{
list($table, $uid, $field) = explode(':', $flexFormId, 3);
$record = $this->recordInfo($table, $uid, '*');
if (!$table || !$uid || !$field || !is_array($record)) {
return;
}
\TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($table, $record);
// Get current data structure and value array:
$valueStructure = \TYPO3\CMS\Core\Utility\GeneralUtility::xml2array($record[$field]);
// Do recursive processing of the XML data:
foreach ($modifications as $path => $value) {
$valueStructure['data'] = \TYPO3\CMS\Core\Utility\ArrayUtility::setValueByPath($valueStructure['data'], $path, $value);
}
if (is_array($valueStructure['data'])) {
// The return value should be compiled back into XML
$values = array($field => $this->checkValue_flexArray2Xml($valueStructure, TRUE));
$this->updateDB($table, $uid, $values);
}
}