本文整理匯總了PHP中TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayUtility::arrayExport方法的具體用法?PHP ArrayUtility::arrayExport怎麽用?PHP ArrayUtility::arrayExport使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類TYPO3\CMS\Core\Utility\ArrayUtility
的用法示例。
在下文中一共展示了ArrayUtility::arrayExport方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: writeLocalConfiguration
/**
* Write local configuration array to typo3conf/LocalConfiguration.php
*
* @param array $configuration The local configuration to be written
* @throws \RuntimeException
* @return boolean TRUE on success
* @access private
*/
public function writeLocalConfiguration(array $configuration)
{
$localConfigurationFile = $this->getLocalConfigurationFileLocation();
if (!$this->canWriteConfiguration()) {
throw new \RuntimeException($localConfigurationFile . ' is not writable.', 1346323822);
}
$configuration = Utility\ArrayUtility::sortByKeyRecursive($configuration);
$result = Utility\GeneralUtility::writeFile($localConfigurationFile, '<?php' . LF . 'return ' . Utility\ArrayUtility::arrayExport(Utility\ArrayUtility::renumberKeysToAvoidLeapsIfKeysAreAllNumeric($configuration)) . ';' . LF . '?>', TRUE);
Utility\OpcodeCacheUtility::clearAllActive($localConfigurationFile);
return $result;
}
示例2: writeLocalConfiguration
/**
* Write local configuration array to typo3conf/LocalConfiguration.php
*
* @param array $configuration The local configuration to be written
* @throws \RuntimeException
* @return boolean TRUE on success
* @access private
*/
public function writeLocalConfiguration(array $configuration)
{
$localConfigurationFile = $this->getLocalConfigurationFileResource();
if (!@is_file($localConfigurationFile) || !@is_writable($localConfigurationFile)) {
throw new \RuntimeException($localConfigurationFile . ' does not exist or is not writable.', 1346323822);
}
$configuration = Utility\ArrayUtility::sortByKeyRecursive($configuration);
$result = Utility\GeneralUtility::writeFile($localConfigurationFile, '<?php' . LF . 'return ' . Utility\ArrayUtility::arrayExport($configuration) . ';' . LF . '?>');
return $result === FALSE ? FALSE : TRUE;
}
示例3: arrayExportReturnsKeyIndexForNonConsecutiveCountedArrays
/**
* @test
*/
public function arrayExportReturnsKeyIndexForNonConsecutiveCountedArrays()
{
$array = array(0 => 'zero', 1 => 'one', 3 => 'three', 4 => 'four');
$expected = 'array(' . LF . TAB . '0 => \'zero\',' . LF . TAB . '1 => \'one\',' . LF . TAB . '3 => \'three\',' . LF . TAB . '4 => \'four\',' . LF . ')';
$this->assertSame($expected, ArrayUtility::arrayExport($array));
}
示例4: doGenerateConfiguration
/**
* Performs actual generation.
*
* @param resource $fd FIle descriptor to write to
* @return void
*/
protected function doGenerateConfiguration(&$fd)
{
$this->databaseConnection = $GLOBALS['TYPO3_DB'];
$this->hasStaticInfoTables = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables');
$conf = array();
$template = $this->getTemplate();
// Find all domains
$domains = $this->databaseConnection->exec_SELECTgetRows('pid,domainName,redirectTo', 'sys_domain', 'hidden=0', '', '', '', 'domainName');
if (count($domains) == 0) {
$conf['_DEFAULT'] = $template;
$rows = $this->databaseConnection->exec_SELECTgetRows('uid', 'pages', 'deleted=0 AND hidden=0 AND is_siteroot=1', '', '', '1');
if (count($rows) > 0) {
$conf['_DEFAULT']['pagePath']['rootpage_id'] = $rows[0]['uid'];
}
} else {
foreach ($domains as $domain) {
if ($domain['redirectTo'] != '') {
// Redirects to another domain, see if we can make a shortcut
$parts = parse_url($domain['redirectTo']);
if (isset($domains[$parts['host']]) && ($domains['path'] == '/' || $domains['path'] == '')) {
// Make a shortcut
if ($conf[$parts['host']] != $domain['domainName']) {
// Here if there were no redirect from this domain to source domain
$conf[$domain['domainName']] = $parts['host'];
}
continue;
}
}
// Make entry
$conf[$domain['domainName']] = $template;
$conf[$domain['domainName']]['pagePath']['rootpage_id'] = $domain['pid'];
}
}
// Post process generated configuration
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['postProcessConfiguration'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['postProcessConfiguration'] as $userFunc) {
$parameters = array('config' => &$conf);
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($userFunc, $parameters, $this);
}
}
fwrite($fd, '<' . '?php' . LF . '$GLOBALS[\'TYPO3_CONF_VARS\'][\'EXTCONF\'][\'realurl\']=' . \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($conf) . ';' . chr(10));
}
示例5: createFontAction
/**
* Create a font
*
* @return void
*/
public function createFontAction()
{
$fontUid = $this->request->getArgument('uid');
$currentFont = $this->fontRepository->findByUid($fontUid);
$feedback = Font::createFont($fontUid, $currentFont);
Styles::createCss($fontUid, $currentFont);
Styles::createLess($fontUid, $currentFont);
Styles::createScss($fontUid, $currentFont);
//$this->createCss($this->request->getArgument('uid'));
if (!empty($feedback)) {
$errorMessage = \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($feedback);
$this->addFlashMessage(LocalizationUtility::translate('LLL:EXT:fontawesomeplus/Resources/Private/Language/locallang_be_module.xlf:error.creatingFont.body', 'fontawesomeplus') . '<br>' . $errorMessage, LocalizationUtility::translate('LLL:EXT:fontawesomeplus/Resources/Private/Language/locallang_be_module.xlf:error.creatingFont.title', 'fontawesomeplus'), FlashMessage::ERROR);
$this->forward('viewZipfiles');
} else {
Zip::createZip($currentFont);
$this->addFlashMessage(LocalizationUtility::translate('LLL:EXT:fontawesomeplus/Resources/Private/Language/locallang_be_module.xlf:ok.creatingFont.body', 'fontawesomeplus'), LocalizationUtility::translate('LLL:EXT:fontawesomeplus/Resources/Private/Language/locallang_be_module.xlf:ok.creatingFont.title', 'fontawesomeplus'), FlashMessage::OK);
$this->forward('viewZipfiles');
}
}
示例6: sortAndSavePackageStates
/**
* Saves the current content of $this->packageStatesConfiguration to the
* PackageStates.php file.
*
* @throws Exception\PackageStatesFileNotWritableException
*/
protected function sortAndSavePackageStates()
{
$this->sortAvailablePackagesByDependencies();
$this->packageStatesConfiguration['version'] = 4;
$fileDescription = "# PackageStates.php\n\n";
$fileDescription .= "# This file is maintained by TYPO3's package management. Although you can edit it\n";
$fileDescription .= "# manually, you should rather use the extension manager for maintaining packages.\n";
$fileDescription .= "# This file will be regenerated automatically if it doesn't exist. Deleting this file\n";
$fileDescription .= "# should, however, never become necessary if you use the package commands.\n";
// We do not need the dependencies and suggestions on disk...
foreach ($this->packageStatesConfiguration['packages'] as &$packageConfiguration) {
if (isset($packageConfiguration['dependencies'])) {
unset($packageConfiguration['dependencies']);
}
if (isset($packageConfiguration['suggestions'])) {
unset($packageConfiguration['suggestions']);
}
}
if (!@is_writable($this->packageStatesPathAndFilename)) {
// If file does not exists try to create it
$fileHandle = @fopen($this->packageStatesPathAndFilename, 'x');
if (!$fileHandle) {
throw new Exception\PackageStatesFileNotWritableException(sprintf('We could not update the list of installed packages because the file %s is not writable. Please, check the file system permissions for this file and make sure that the web server can update it.', $this->packageStatesPathAndFilename), 1382449759);
}
fclose($fileHandle);
}
$packageStatesCode = "<?php\n{$fileDescription}\nreturn " . ArrayUtility::arrayExport($this->packageStatesConfiguration) . ";\n";
GeneralUtility::writeFile($this->packageStatesPathAndFilename, $packageStatesCode, true);
$this->initializeCompatibilityLoadedExtArray();
GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive($this->packageStatesPathAndFilename);
}
示例7: writeLocalConfiguration
/**
* Write local configuration array to typo3conf/LocalConfiguration.php
*
* @param array $configuration The local configuration to be written
* @return boolean TRUE on success
*/
protected static function writeLocalConfiguration(array $configuration)
{
$configuration = \TYPO3\CMS\Core\Utility\ArrayUtility::sortByKeyRecursive($configuration);
$result = \TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . static::LOCAL_CONFIGURATION_FILE, '<?php' . LF . 'return ' . \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($configuration) . ';' . LF . '?>');
return $result === FALSE ? FALSE : TRUE;
}
示例8: writeLocalConfiguration
/**
* Write local configuration array to typo3conf/LocalConfiguration.php
*
* @param array $configuration The local configuration to be written
* @throws \RuntimeException
* @return bool TRUE on success
* @access private
*/
public function writeLocalConfiguration(array $configuration)
{
$localConfigurationFile = $this->getLocalConfigurationFileLocation();
if (!$this->canWriteConfiguration()) {
throw new \RuntimeException($localConfigurationFile . ' is not writable.', 1346323822);
}
$configuration = ArrayUtility::sortByKeyRecursive($configuration);
$result = GeneralUtility::writeFile($localConfigurationFile, '<?php' . LF . 'return ' . ArrayUtility::arrayExport(ArrayUtility::renumberKeysToAvoidLeapsIfKeysAreAllNumeric($configuration)) . ';' . LF, true);
GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive($localConfigurationFile);
return $result;
}
示例9: setUpPackageStates
/**
* Compile typo3conf/PackageStates.php containing default packages like core,
* a test specific list of additional core extensions, and a list of
* test extensions.
* For functional and acceptance tests.
*
* @param string $instancePath Absolute path to test instance
* @param array $defaultCoreExtensionsToLoad Default list of core extensions to load
* @param array $additionalCoreExtensionsToLoad Additional core extensions to load
* @param array $testExtensionPaths Paths to extensions relative to document root
* @throws Exception
*/
public function setUpPackageStates($instancePath, array $defaultCoreExtensionsToLoad, array $additionalCoreExtensionsToLoad, array $testExtensionPaths)
{
$packageStates = array('packages' => array(), 'version' => 4);
// Register default list of extensions and set active
foreach ($defaultCoreExtensionsToLoad as $extensionName) {
$packageStates['packages'][$extensionName] = array('state' => 'active', 'packagePath' => 'typo3/sysext/' . $extensionName . '/', 'classesPath' => 'Classes/');
}
// Register additional core extensions and set active
foreach ($additionalCoreExtensionsToLoad as $extensionName) {
if (isset($packageSates['packages'][$extensionName])) {
throw new Exception($extensionName . ' is already registered as default core extension to load, no need to load it explicitly', 1390913893);
}
$packageStates['packages'][$extensionName] = array('state' => 'active', 'packagePath' => 'typo3/sysext/' . $extensionName . '/', 'classesPath' => 'Classes/');
}
// Activate test extensions that have been symlinked before
foreach ($testExtensionPaths as $extensionPath) {
$extensionName = basename($extensionPath);
if (isset($packageSates['packages'][$extensionName])) {
throw new Exception($extensionName . ' is already registered as extension to load, no need to load it explicitly', 1390913894);
}
$packageStates['packages'][$extensionName] = array('state' => 'active', 'packagePath' => 'typo3conf/ext/' . $extensionName . '/', 'classesPath' => 'Classes/');
}
$result = $this->writeFile($instancePath . '/typo3conf/PackageStates.php', '<?php' . chr(10) . 'return ' . ArrayUtility::arrayExport($packageStates) . ';');
if (!$result) {
throw new Exception('Can not write PackageStates', 1381612729);
}
}
示例10: setUpPackageStates
/**
* Compile typo3conf/PackageStates.php containing default packages like core,
* a test specific list of additional core extensions, and a list of
* test extensions.
* For functional and acceptance tests.
*
* @param string $instancePath Absolute path to test instance
* @param array $defaultCoreExtensionsToLoad Default list of core extensions to load
* @param array $additionalCoreExtensionsToLoad Additional core extensions to load
* @param array $testExtensionPaths Paths to extensions relative to document root
* @throws Exception
*/
public function setUpPackageStates($instancePath, array $defaultCoreExtensionsToLoad, array $additionalCoreExtensionsToLoad, array $testExtensionPaths)
{
$packageStates = ['packages' => [], 'version' => 5];
// Register default list of extensions and set active
foreach ($defaultCoreExtensionsToLoad as $extensionName) {
$packageStates['packages'][$extensionName] = ['packagePath' => 'typo3/sysext/' . $extensionName . '/'];
}
// Register additional core extensions and set active
foreach ($additionalCoreExtensionsToLoad as $extensionName) {
$packageStates['packages'][$extensionName] = ['packagePath' => 'typo3/sysext/' . $extensionName . '/'];
}
// Activate test extensions that have been symlinked before
foreach ($testExtensionPaths as $extensionPath) {
$extensionName = basename($extensionPath);
$packageStates['packages'][$extensionName] = ['packagePath' => 'typo3conf/ext/' . $extensionName . '/'];
}
$result = $this->writeFile($instancePath . '/typo3conf/PackageStates.php', '<?php' . chr(10) . 'return ' . ArrayUtility::arrayExport($packageStates) . ';');
if (!$result) {
throw new Exception('Can not write PackageStates', 1381612729);
}
}
示例11: performUpdate
/**
* Performs the update action.
*
* The methods reads localconf.php line by line and classifies every line
* to be either part of LocalConfiguration (everything that starts with TYPO3_CONF_VARS),
* belongs to the database settings (those will be merged to TYPO3_CONF_VARS),
* and everything else (those will be moved to the AdditionalConfiguration file.
*
* @param array &$dbQueries: Queries done in this update
* @param mixed &$customMessages: Custom messages
* @return boolean TRUE if everything went well
*/
public function performUpdate(array &$dbQueries, &$customMessages)
{
$result = FALSE;
try {
$localConfigurationContent = file(PATH_typo3conf . 'localconf.php');
// Line array for the three categories: localConfiguration, db settings, additionalConfiguration
$typo3ConfigurationVariables = array();
$typo3DatabaseVariables = array();
$additionalConfiguration = array();
foreach ($localConfigurationContent as $line) {
$line = trim($line);
$matches = array();
// Convert extList to array
if (preg_match('/^\\$TYPO3_CONF_VARS\\[\'EXT\'\\]\\[\'extList\'\\] *={1} *\'(.+)\';{1}/', $line, $matches) === 1) {
$extListAsArray = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $matches[1], TRUE);
$typo3ConfigurationVariables[] = '$TYPO3_CONF_VARS[\'EXT\'][\'extListArray\'] = ' . var_export($extListAsArray, TRUE) . ';';
$typo3ConfigurationVariables[] = '$TYPO3_CONF_VARS[\'EXT\'][\'extList\'] = \'' . $matches[1] . '\';';
} elseif (preg_match('/^\\$TYPO3_CONF_VARS.+;{1}/', $line, $matches) === 1) {
$typo3ConfigurationVariables[] = $matches[0];
} elseif (preg_match('/^\\$typo_db.+;{1}/', $line, $matches) === 1) {
eval($matches[0]);
if (isset($typo_db_host)) {
$typo3DatabaseVariables['host'] = $typo_db_host;
} elseif (isset($typo_db)) {
$typo3DatabaseVariables['database'] = $typo_db;
} elseif (isset($typo_db_username)) {
$typo3DatabaseVariables['username'] = $typo_db_username;
} elseif (isset($typo_db_password)) {
$typo3DatabaseVariables['password'] = $typo_db_password;
} elseif (isset($typo_db_extTableDef_script)) {
$typo3DatabaseVariables['extTablesDefinitionScript'] = $typo_db_extTableDef_script;
}
unset($typo_db_host, $typo_db, $typo_db_username, $typo_db_password, $typo_db_extTableDef_script);
} elseif (strlen($line) > 0 && preg_match('/^\\/\\/.+|^#.+|^<\\?php$|^<\\?$|^\\?>$/', $line, $matches) === 0) {
$additionalConfiguration[] = $line;
}
}
// Build new TYPO3_CONF_VARS array
$TYPO3_CONF_VARS = NULL;
eval(implode(LF, $typo3ConfigurationVariables));
// Add db settings to array
$TYPO3_CONF_VARS['DB'] = $typo3DatabaseVariables;
$TYPO3_CONF_VARS = \TYPO3\CMS\Core\Utility\ArrayUtility::sortByKeyRecursive($TYPO3_CONF_VARS);
// Write out new LocalConfiguration file
\TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::LOCAL_CONFIGURATION_FILE, '<?php' . LF . 'return ' . \TYPO3\CMS\Core\Utility\ArrayUtility::arrayExport($TYPO3_CONF_VARS) . ';' . LF . '?>');
// Write out new AdditionalConfiguration file
if (sizeof($additionalConfiguration) > 0) {
\TYPO3\CMS\Core\Utility\GeneralUtility::writeFile(PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::ADDITIONAL_CONFIGURATION_FILE, '<?php' . LF . implode(LF, $additionalConfiguration) . LF . '?>');
} else {
@unlink(PATH_site . \TYPO3\CMS\Core\Configuration\ConfigurationManager::ADDITIONAL_CONFIGURATION_FILE);
}
rename(PATH_site . 'typo3conf/localconf.php', PATH_site . 'typo3conf/localconf.obsolete.php');
$result = TRUE;
} catch (\Exception $e) {
}
return $result;
}