本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::callUserFunction方法的具体用法?PHP GeneralUtility::callUserFunction怎么用?PHP GeneralUtility::callUserFunction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::callUserFunction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMimeType
/**
* Return the mime type of a file.
*
* @return string|bool Returns the mime type or FALSE if the mime type could not be discovered
*/
public function getMimeType()
{
$mimeType = FALSE;
if ($this->isFile()) {
$fileExtensionToMimeTypeMapping = $GLOBALS['TYPO3_CONF_VARS']['SYS']['FileInfo']['fileExtensionToMimeType'];
$lowercaseFileExtension = strtolower($this->getExtension());
if (!empty($fileExtensionToMimeTypeMapping[$lowercaseFileExtension])) {
$mimeType = $fileExtensionToMimeTypeMapping[$lowercaseFileExtension];
} else {
if (function_exists('finfo_file')) {
$fileInfo = new \finfo();
$mimeType = $fileInfo->file($this->getPathname(), FILEINFO_MIME_TYPE);
} elseif (function_exists('mime_content_type')) {
$mimeType = mime_content_type($this->getPathname());
}
}
}
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuessers']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuesser'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'][\TYPO3\CMS\Core\Type\File\FileInfo::class]['mimeTypeGuesser'] as $mimeTypeGuesser) {
$hookParameters = array('mimeType' => &$mimeType);
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($mimeTypeGuesser, $hookParameters, $this);
}
}
return $mimeType;
}
示例2: addData
/**
* Enrich the processed record information with the resolved title
*
* @param array $result Incoming result array
* @return array Modified array
*/
public function addData(array $result)
{
if (!isset($result['processedTca']['ctrl']['label'])) {
throw new \UnexpectedValueException('TCA of table ' . $result['tableName'] . ' misses required [\'ctrl\'][\'label\'] definition.', 1443706103);
}
if ($result['isInlineChild'] && isset($result['processedTca']['ctrl']['formattedLabel_userFunc'])) {
// inline child with formatted user func is first
$parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'isOnSymmetricSide' => $result['isOnSymmetricSide'], 'options' => isset($result['processedTca']['ctrl']['formattedLabel_userFunc_options']) ? $result['processedTca']['ctrl']['formattedLabel_userFunc_options'] : [], 'parent' => ['uid' => $result['databaseRow']['uid'], 'config' => $result['inlineParentConfig']]];
// callUserFunction requires a third parameter, but we don't want to give $this as reference!
$null = null;
GeneralUtility::callUserFunction($result['processedTca']['ctrl']['formattedLabel_userFunc'], $parameters, $null);
$result['recordTitle'] = $parameters['title'];
} elseif ($result['isInlineChild'] && (isset($result['inlineParentConfig']['foreign_label']) || isset($result['inlineParentConfig']['symmetric_label']))) {
// inline child with foreign label or symmetric inline child with symmetric_label
$fieldName = $result['isOnSymmetricSide'] ? $result['inlineParentConfig']['symmetric_label'] : $result['inlineParentConfig']['foreign_label'];
// @todo: this is a mixup here. problem is the prep method cuts the string, but also hsc's the thing.
// @todo: this is uncool for the userfuncs, so it is applied only here. however, the OuterWrapContainer
// @todo: also prep()'s the title created by the else patch below ... find a better separation and clean this up!
$result['recordTitle'] = BackendUtility::getRecordTitlePrep($this->getRecordTitleForField($fieldName, $result));
} elseif (isset($result['processedTca']['ctrl']['label_userFunc'])) {
// userFunc takes precedence over everything else
$parameters = ['table' => $result['tableName'], 'row' => $result['databaseRow'], 'title' => '', 'options' => isset($result['processedTca']['ctrl']['label_userFunc_options']) ? $result['processedTca']['ctrl']['label_userFunc_options'] : []];
$null = null;
GeneralUtility::callUserFunction($result['processedTca']['ctrl']['label_userFunc'], $parameters, $null);
$result['recordTitle'] = $parameters['title'];
} else {
// standard record
$result = $this->getRecordTitleByLabelProperties($result);
}
return $result;
}
示例3: resolveItemProcessorFunction
/**
* Resolve "itemProcFunc" of elements.
*
* @param array $result Main result array
* @param string $fieldName Field name to handle item list for
* @param array $items Existing items array
* @return array New list of item elements
*/
protected function resolveItemProcessorFunction(array $result, $fieldName, array $items)
{
$table = $result['tableName'];
$config = $result['processedTca']['columns'][$fieldName]['config'];
$pageTsProcessorParameters = null;
if (!empty($result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['itemsProcFunc.'])) {
$pageTsProcessorParameters = $result['pageTsConfig']['TCEFORM.'][$table . '.'][$fieldName . '.']['itemsProcFunc.'];
}
$processorParameters = ['items' => &$items, 'config' => $config, 'TSconfig' => $pageTsProcessorParameters, 'table' => $table, 'row' => $result['databaseRow'], 'field' => $fieldName];
try {
GeneralUtility::callUserFunction($config['itemsProcFunc'], $processorParameters, $this);
} catch (\Exception $exception) {
// The itemsProcFunc method may throw an exception, create a flash message if so
$languageService = $this->getLanguageService();
$fieldLabel = $fieldName;
if (!empty($result['processedTca']['columns'][$fieldName]['label'])) {
$fieldLabel = $languageService->sL($result['processedTca']['columns'][$fieldName]['label']);
}
$message = sprintf($languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.items_proc_func_error'), $fieldLabel, $exception->getMessage());
/** @var FlashMessage $flashMessage */
$flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $message, '', FlashMessage::ERROR, true);
/** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(FlashMessageService::class);
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
return $items;
}
示例4: execute
function execute($commands_array)
{
// init cObj so that the template parser works inside the cli
/* @var $cObj tslib_cObj */
chdir(PATH_site);
if (!$GLOBALS['TSFE'] instanceof tslib_fe) {
$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], 0, 0);
$GLOBALS['TSFE']->config['config']['language'] = null;
$GLOBALS['TSFE']->initTemplate();
}
if (!isset($GLOBALS['TT'])) {
$GLOBALS['TT'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_TimeTrackNull');
}
$GLOBALS['TSFE']->tmpl->getFileName_backPath = PATH_site;
$this->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_cObj');
switch ($commands_array['action']) {
case 'rebuild_flat_database':
mslib_befe::rebuildFlatDatabase();
break;
}
// hook
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/cli/multishop.php']['cli_cron'])) {
$params = array('commands_array' => &$commands_array);
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/multishop/cli/multishop.php']['cli_cron'] as $funcRef) {
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
}
}
}
示例5: __construct
/**
* creates the repo
*
* @return void
* @todo missing detailed description
*/
public function __construct()
{
/**
* @var \TYPO3\CMS\Core\Log\LogManager $logger
*/
$logger = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Log\\LogManager');
// hook to recognize themes, this is the magic point, why it's possible to support so many theme formats and types :D
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Tx_Themes_Domain_Repository_ThemeRepository']['init'])) {
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Tx_Themes_Domain_Repository_ThemeRepository']['init'])) {
$hookParameters = array();
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['Tx_Themes_Domain_Repository_ThemeRepository']['init'] as $hookFunction) {
$logger->getLogger()->warning('Theme loader found ' . $hookFunction . ' - sadly this loader uses the old hook, please fix this, should be KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository nowThem');
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
}
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository']['init'])) {
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository']['init'])) {
$hookParameters = array();
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['KayStrobach\\Themes\\Domain\\Repository\\ThemeRepository']['init'] as $hookFunction) {
$logger->getLogger()->warning('Theme loader found ' . $hookFunction);
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $this);
}
}
}
}
示例6: handleRequest
/**
* Handles a frontend request based on the _GP "eID" variable.
*
* @return void
*/
public function handleRequest()
{
// Timetracking started
$configuredCookieName = trim($GLOBALS['TYPO3_CONF_VARS']['BE']['cookieName']);
if (empty($configuredCookieName)) {
$configuredCookieName = 'be_typo_user';
}
if ($_COOKIE[$configuredCookieName]) {
$GLOBALS['TT'] = new TimeTracker();
} else {
$GLOBALS['TT'] = new NullTimeTracker();
}
$GLOBALS['TT']->start();
// Hook to preprocess the current request
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/index_ts.php']['preprocessRequest'] as $hookFunction) {
$hookParameters = array();
GeneralUtility::callUserFunction($hookFunction, $hookParameters, $hookParameters);
}
unset($hookFunction);
unset($hookParameters);
}
// Remove any output produced until now
$this->bootstrap->endOutputBufferingAndCleanPreviousOutput();
require EidUtility::getEidScriptPath();
$this->bootstrap->shutdown();
exit;
}
示例7: matchUserCondition
/**
* Evaluates via the referenced user-defined method
*
* @param string $condition
* @return bool
*/
protected function matchUserCondition($condition)
{
$conditionParameters = explode(':', $condition);
$userFunction = array_shift($conditionParameters);
$parameter = array('record' => $this->record, 'flexformValueKey' => $this->flexformValueKey, 'conditionParameters' => $conditionParameters);
return (bool) GeneralUtility::callUserFunction($userFunction, $parameter, $this);
}
示例8: main
/**
* MAIN function for page information display
*
* @return string Output HTML for the module.
* @todo Define visibility
*/
public function main()
{
global $BACK_PATH, $LANG, $SOBE;
$dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\PageLayoutView');
$dblist->descrTable = '_MOD_' . $GLOBALS['MCONF']['name'];
$dblist->backPath = $BACK_PATH;
$dblist->thumbs = 0;
$dblist->script = 'index.php';
$dblist->showIcon = 0;
$dblist->setLMargin = 0;
$dblist->agePrefixes = $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.minutesHoursDaysYears');
$dblist->pI_showUser = 1;
// PAGES:
$this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
// ONLY for the sake of dblist module which uses this value.
$h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth'], 'index.php');
$h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages'], 'index.php');
$dblist->start($this->pObj->id, 'pages', 0);
$dblist->generateList();
// CSH
$theOutput .= $this->pObj->doc->header($LANG->getLL('page_title'));
$theOutput .= $this->pObj->doc->section('', \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', $GLOBALS['BACK_PATH'], '|<br />') . $h_func . $dblist->HTMLcode, 0, 1);
// Additional footer content
$footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'];
if (is_array($footerContentHook)) {
foreach ($footerContentHook as $hook) {
$params = array();
$theOutput .= \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($hook, $params, $this);
}
}
return $theOutput;
}
示例9: main
/**
* MAIN function for page information display
*
* @return string Output HTML for the module.
*/
public function main()
{
$theOutput = $this->pObj->doc->header($this->getLanguageService()->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:page_title'));
$dblist = GeneralUtility::makeInstance(PageLayoutView::class);
$dblist->descrTable = '_MOD_web_info';
$dblist->thumbs = 0;
$dblist->script = BackendUtility::getModuleUrl('web_info');
$dblist->showIcon = 0;
$dblist->setLMargin = 0;
$dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears');
$dblist->pI_showUser = 1;
// PAGES:
$this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth'];
// ONLY for the sake of dblist module which uses this value.
$h_func = BackendUtility::getDropdownMenu($this->pObj->id, 'SET[depth]', $this->pObj->MOD_SETTINGS['depth'], $this->pObj->MOD_MENU['depth']);
$h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
$dblist->start($this->pObj->id, 'pages', 0);
$dblist->generateList();
// CSH
$theOutput .= $this->pObj->doc->section('', BackendUtility::cshItem($dblist->descrTable, 'pagetree_overview', null, '|<br />') . '<div class="form-inline form-inline-spaced">' . $h_func . '</div>' . $dblist->HTMLcode, 0, 1);
// Additional footer content
$footerContentHook = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/web_info/class.tx_cms_webinfo.php']['drawFooterHook'];
if (is_array($footerContentHook)) {
foreach ($footerContentHook as $hook) {
$params = array();
$theOutput .= GeneralUtility::callUserFunction($hook, $params, $this);
}
}
return $theOutput;
}
示例10: supportsExceptionAsParameter
/**
* @test
*/
public function supportsExceptionAsParameter()
{
$userFunctionReference = $this->getClassName() . '->' . $this->methodName;
$parameters = $this->getParameters();
$parameters['fieldConf']['config']['arguments'] = array(new \Exception(self::FAKE_MESSAGE, self::FAKE_CODE));
$output = GeneralUtility::callUserFunction($userFunctionReference, $parameters, $this->getCallerInstance());
$this->assertOutputContainsExpectedMessageAndCode($output);
}
示例11: routeAction
/**
* Routes the given eID action to the related ExtDirect method with the necessary
* ajax object.
*
* @param string $ajaxID
* @return void
*/
protected function routeAction($ajaxID)
{
EidUtility::initLanguage();
$ajaxScript = $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['ExtDirect::' . $ajaxID]['callbackMethod'];
$this->ajaxObject = GeneralUtility::makeInstance(AjaxRequestHandler::class, 'ExtDirect::' . $ajaxID);
$parameters = array();
GeneralUtility::callUserFunction($ajaxScript, $parameters, $this->ajaxObject, false, true);
}
示例12: routeAction
/**
* Routes the given eID action to the related ExtDirect method with the necessary
* ajax object.
*
* @return void
*/
public function routeAction()
{
\TYPO3\CMS\Frontend\Utility\EidUtility::initLanguage();
$ajaxID = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action');
$ajaxScript = $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['ExtDirect::' . $ajaxID]['callbackMethod'];
$this->ajaxObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Http\\AjaxRequestHandler', 'ExtDirect::' . $ajaxID);
$parameters = array();
\TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($ajaxScript, $parameters, $this->ajaxObject, FALSE, TRUE);
}
示例13: dispatchUserFunction
public function dispatchUserFunction($requestArguments)
{
$result = [];
list($className) = GeneralUtility::trimExplode('->', $requestArguments['function']);
if (class_exists($className) && in_array(AjaxInterface::class, class_implements($className))) {
$parameters = true === isset($requestArguments['arguments']) ? $requestArguments['arguments'] : [];
$result = GeneralUtility::callUserFunction($requestArguments['function'], $parameters, $this);
}
return $result;
}
示例14: leavesRecordsWhichAreNotRootsUntouched
/**
* @test
*/
public function leavesRecordsWhichAreNotRootsUntouched()
{
\FluidTYPO3\Flux\Core::addStaticTypoScript(self::FIXTURE_TYPOSCRIPT_DIR);
$function = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSources']['flux'];
$template = $this->objectManager->get('t3lib_TStemplate');
$parameters = array('row' => \FluidTYPO3\Flux\Tests\Fixtures\Data\Records::$sysTemplateRoot);
$parameters['row']['root'] = 0;
GeneralUtility::callUserFunction($function, $parameters, $template);
$this->assertNotContains(self::FIXTURE_TYPOSCRIPT_DIR, $parameters['row']['include_static_file']);
$this->assertSame(\FluidTYPO3\Flux\Tests\Fixtures\Data\Records::$sysTemplateRoot['include_static_file'], $parameters['row']['include_static_file']);
}
示例15: leavesRecordsWhichAreNotRootsUntouched
/**
* @test
*/
public function leavesRecordsWhichAreNotRootsUntouched()
{
Core::addStaticTypoScript(self::FIXTURE_TYPOSCRIPT_DIR);
$function = 'FluidTYPO3\\Flux\\Backend\\TypoScriptTemplate->preprocessIncludeStaticTypoScriptSources';
$template = $this->objectManager->get('TYPO3\\CMS\\Core\\TypoScript\\TemplateService');
$parameters = array('row' => Records::$sysTemplateRoot);
$parameters['row']['root'] = 0;
GeneralUtility::callUserFunction($function, $parameters, $template);
$this->assertNotContains(self::FIXTURE_TYPOSCRIPT_DIR, $parameters['row']['include_static_file']);
$this->assertSame(Records::$sysTemplateRoot['include_static_file'], $parameters['row']['include_static_file']);
}