コード例 #1
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
ファイル: DataHandler.php プロジェクト: rickymathew/TYPO3.CMS
 /**
  * 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
0
 /**
  * @test
  * @dataProvider setValueByPathSetsCorrectValueDataProvider
  */
 public function setValueByPathSetsCorrectValue(array $array, $path, $value, $expectedResult)
 {
     $this->assertEquals($expectedResult, ArrayUtility::setValueByPath($array, $path, $value));
 }
コード例 #6
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * @param string $propertyPath
  * @param mixed $value
  * @return void
  */
 public function setFormValue(string $propertyPath, $value)
 {
     $this->formValues = ArrayUtility::setValueByPath($this->formValues, $propertyPath, $value);
 }
コード例 #9
0
 /**
  * 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
0
ファイル: Setup.php プロジェクト: r3h6/TYPO3.EXT.frp_example
 /**
  * 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
0
 /**
  * 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);
     }
 }