本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::makeInstance方法的具体用法?PHP GeneralUtility::makeInstance怎么用?PHP GeneralUtility::makeInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::makeInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getExtensionSummary
/**
* Returns information about this extension plugin
*
* @param array $params Parameters to the hook
*
* @return string Information about pi1 plugin
* @hook TYPO3_CONF_VARS|SC_OPTIONS|cms/layout/class.tx_cms_layout.php|list_type_Info|calendarize_calendar
*/
public function getExtensionSummary(array $params)
{
$relIconPath = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . ExtensionManagementUtility::siteRelPath('calendarize') . 'ext_icon.png';
$this->flexFormService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\FlexFormService');
$this->layoutService = GeneralUtility::makeInstance('HDNET\\Calendarize\\Service\\ContentElementLayoutService');
$this->layoutService->setTitle('<img src="' . $relIconPath . '" /> Calendarize');
if ($params['row']['list_type'] != 'calendarize_calendar') {
return '';
}
$this->flexFormService->load($params['row']['pi_flexform']);
if (!$this->flexFormService->isValid()) {
return '';
}
$actions = $this->flexFormService->get('switchableControllerActions', 'main');
$parts = GeneralUtility::trimExplode(';', $actions, true);
$parts = array_map(function ($element) {
$split = explode('->', $element);
return ucfirst($split[1]);
}, $parts);
$actionKey = lcfirst(implode('', $parts));
$this->layoutService->addRow(LocalizationUtility::translate('mode', 'calendarize'), LocalizationUtility::translate('mode.' . $actionKey, 'calendarize'));
$this->layoutService->addRow(LocalizationUtility::translate('configuration', 'calendarize'), $this->flexFormService->get('settings.configuration', 'main'));
if ((bool) $this->flexFormService->get('settings.hidePagination', 'main')) {
$this->layoutService->addRow(LocalizationUtility::translate('hide.pagination.teaser', 'calendarize'), '!!!');
}
$this->addPageIdsToTable();
return $this->layoutService->render();
}
示例2: render
/**
* Render the captcha image html
*
* @param string suffix to be appended to the extenstion key when forming css class names
* @return string The html used to render the captcha image
*/
public function render($suffix = '')
{
$value = '';
// Include the required JavaScript
$GLOBALS['TSFE']->additionalHeaderData[$this->extensionKey . '_freeCap'] = '<script type="text/javascript" src="' . GeneralUtility::createVersionNumberedFilename(ExtensionManagementUtility::siteRelPath($this->extensionKey) . 'Resources/Public/JavaScript/freeCap.js') . '"></script>';
// Disable caching
$GLOBALS['TSFE']->no_cache = 1;
// Get the plugin configuration
$settings = $this->configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, $this->extensionName);
// Get the translation view helper
$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$translator = $objectManager->get('SJBR\\SrFreecap\\ViewHelpers\\TranslateViewHelper');
$translator->injectConfigurationManager($this->configurationManager);
// Generate the image url
$fakeId = GeneralUtility::shortMD5(uniqid(rand()), 5);
$siteURL = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
$L = GeneralUtility::_GP('L');
$urlParams = array('eID' => 'sr_freecap_EidDispatcher', 'id' => $GLOBALS['TSFE']->id, 'vendorName' => 'SJBR', 'extensionName' => 'SrFreecap', 'pluginName' => 'ImageGenerator', 'controllerName' => 'ImageGenerator', 'actionName' => 'show', 'formatName' => 'png', 'L' => $GLOBALS['TSFE']->sys_language_uid);
if ($GLOBALS['TSFE']->MP) {
$urlParams['MP'] = $GLOBALS['TSFE']->MP;
}
$urlParams['set'] = $fakeId;
$imageUrl = $siteURL . 'index.php?' . ltrim(GeneralUtility::implodeArrayForUrl('', $urlParams), '&');
// Generate the html text
$value = '<img' . $this->getClassAttribute('image', $suffix) . ' id="tx_srfreecap_captcha_image_' . $fakeId . '"' . ' src="' . htmlspecialchars($imageUrl) . '"' . ' alt="' . $translator->render('altText') . ' "/>' . '<span' . $this->getClassAttribute('cant-read', $suffix) . '>' . $translator->render('cant_read1') . ' <a href="#" onclick="this.blur();' . $this->extensionName . '.newImage(\'' . $fakeId . '\', \'' . $translator->render('noImageMessage') . '\');return false;">' . $translator->render('click_here') . '</a>' . $translator->render('cant_read2') . '</span>';
return $value;
}
示例3: __construct
/**
* Boots up:
* - objectManager to get class instances
* - configuration manager for ts settings
* - contentObjectRenderer for generating links etc.
* - termRepository to get the Terms
*
* @return WrapperService
*/
public function __construct()
{
// Make instance of Object Manager
/** @var ObjectManager $objectManager */
$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
// Get Configuration Manager
/** @var ConfigurationManager $configurationManager */
$configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
// Inject Content Object Renderer
$this->cObj = $objectManager->get('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
// Get Query Settings
/** @var QuerySettingsInterface $querySettings */
$querySettings = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\QuerySettingsInterface');
// Get termRepository
$this->termRepository = $objectManager->get('Dpn\\DpnGlossary\\Domain\\Repository\\TermRepository');
// Get Typoscript Configuration
$this->tsConfig = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT);
// Reduce TS config to plugin
$this->tsConfig = $this->tsConfig['plugin.']['tx_dpnglossary.'];
if (FALSE === empty($this->tsConfig)) {
// Save extension settings without ts dots
$this->settings = GeneralUtility::removeDotsFromTS($this->tsConfig['settings.']);
// Set StoragePid in the query settings object
$querySettings->setStoragePageIds(GeneralUtility::trimExplode(',', $this->tsConfig['persistence.']['storagePid']));
// Set current language uid
$querySettings->setLanguageUid($GLOBALS['TSFE']->sys_language_uid);
// Assign query settings object to repository
$this->termRepository->setDefaultQuerySettings($querySettings);
}
}
示例4: getTargetUrl
/**
* Determine the url to view
*
* @return string
*/
protected function getTargetUrl()
{
$pageIdToShow = (int) \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
$adminCommand = $this->getAdminCommand($pageIdToShow);
$domainName = $this->getDomainName($pageIdToShow);
// Mount point overlay: Set new target page id and mp parameter
/** @var \TYPO3\CMS\Frontend\Page\PageRepository $sysPage */
$sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$sysPage->init(FALSE);
$mountPointMpParameter = '';
$finalPageIdToShow = $pageIdToShow;
$mountPointInformation = $sysPage->getMountPointInfo($pageIdToShow);
if ($mountPointInformation && $mountPointInformation['overlay']) {
// New page id
$finalPageIdToShow = $mountPointInformation['mount_pid'];
$mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar'];
}
// Modify relative path to protocol with host if domain record is given
$protocolAndHost = '..';
if ($domainName) {
$protocol = 'http';
$page = (array) $sysPage->getPage($finalPageIdToShow);
if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
$protocol = 'https';
}
$protocolAndHost = $protocol . '://' . $domainName;
}
$url = $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand;
return $url;
}
示例5: prepareSubject
/**
* Prepare a DatabaseConnection subject.
* Used by driver specific test cases.
*
* @param string $driver Driver to use like "mssql", "oci8" and "postgres7"
* @param array $configuration Dbal configuration array
* @return \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
*/
protected function prepareSubject($driver, array $configuration)
{
/** @var \TYPO3\CMS\Dbal\Database\DatabaseConnection|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
$subject = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\DatabaseConnection::class, array('getFieldInfoCache'), array(), '', false);
$subject->conf = $configuration;
// Disable caching
$mockCacheFrontend = $this->getMock(\TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class, array(), array(), '', false);
$subject->expects($this->any())->method('getFieldInfoCache')->will($this->returnValue($mockCacheFrontend));
// Inject SqlParser - Its logic is tested with the tests, too.
$sqlParser = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\SqlParser::class, array('dummy'), array(), '', false);
$sqlParser->_set('databaseConnection', $subject);
$sqlParser->_set('sqlCompiler', GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\SqlCompilers\Adodb::class, $subject));
$sqlParser->_set('nativeSqlCompiler', GeneralUtility::makeInstance(\TYPO3\CMS\Dbal\Database\SqlCompilers\Mysql::class, $subject));
$subject->SQLparser = $sqlParser;
// Mock away schema migration service from install tool
$installerSqlMock = $this->getMock(\TYPO3\CMS\Install\Service\SqlSchemaMigrationService::class, array('getFieldDefinitions_fileContent'), array(), '', false);
$installerSqlMock->expects($this->any())->method('getFieldDefinitions_fileContent')->will($this->returnValue(array()));
$subject->_set('installerSql', $installerSqlMock);
$subject->initialize();
// Fake a working connection
$handlerKey = '_DEFAULT';
$subject->lastHandlerKey = $handlerKey;
$adodbDriverClass = '\\ADODB_' . $driver;
$subject->handlerInstance[$handlerKey] = new $adodbDriverClass();
$subject->handlerInstance[$handlerKey]->DataDictionary = NewDataDictionary($subject->handlerInstance[$handlerKey]);
$subject->handlerInstance[$handlerKey]->_connectionID = rand(1, 1000);
return $subject;
}
示例6: getInterceptors
/**
* Returns all interceptors for a given Interception Point.
*
* @param int $interceptionPoint one of the \TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface::INTERCEPT_* constants,
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Fluid\Core\Parser\InterceptorInterface>
*/
public function getInterceptors($interceptionPoint)
{
if (isset($this->interceptors[$interceptionPoint]) && $this->interceptors[$interceptionPoint] instanceof \TYPO3\CMS\Extbase\Persistence\ObjectStorage) {
return $this->interceptors[$interceptionPoint];
}
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Persistence\ObjectStorage::class);
}
示例7: execute
/**
* Returns an URL that switches the sorting indicator according to the
* given sorting direction
*
* @param array $arguments Expects 'asc' or 'desc' as sorting direction in key 0
* @return string
* @throws \InvalidArgumentException when providing an invalid sorting direction
*/
public function execute(array $arguments = array())
{
$content = '';
$sortDirection = trim($arguments[0]);
$configuration = Util::getSolrConfiguration();
$contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$defaultImagePrefix = 'EXT:solr/Resources/Public/Images/Indicator';
$sortViewHelperConfiguration = $configuration->getViewHelpersSortIndicatorConfiguration();
switch ($sortDirection) {
case 'asc':
$imageConfiguration = $sortViewHelperConfiguration['up.'];
if (!isset($imageConfiguration['file'])) {
$imageConfiguration['file'] = $defaultImagePrefix . 'Up.png';
}
$content = $contentObject->cObjGetSingle('IMAGE', $imageConfiguration);
break;
case 'desc':
$imageConfiguration = $sortViewHelperConfiguration['down.'];
if (!isset($imageConfiguration['file'])) {
$imageConfiguration['file'] = $defaultImagePrefix . 'Down.png';
}
$content = $contentObject->cObjGetSingle('IMAGE', $imageConfiguration);
break;
case '###SORT.CURRENT_DIRECTION###':
case '':
// ignore
break;
default:
throw new \InvalidArgumentException('Invalid sorting direction "' . $arguments[0] . '", must be "asc" or "desc".', 1390868460);
}
return $content;
}
示例8: flash
public function flash($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK)
{
$flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $message, '', $severity, true);
$flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$defaultFlashMessageQueue->enqueue($flashMessage);
}
示例9: setUp
public function setUp()
{
$GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], 0);
$GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
$this->view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_gridelements_view');
$this->view->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
}
示例10: dispatchControllerAction
public function dispatchControllerAction($requestArguments)
{
$result = [];
$extensionName = true === isset($requestArguments['mvc']['extensionName']) ? $requestArguments['mvc']['extensionName'] : null;
$controllerName = true === isset($requestArguments['mvc']['controller']) ? $requestArguments['mvc']['controller'] : null;
$vendorName = true === isset($requestArguments['mvc']['vendor']) ? $requestArguments['mvc']['vendor'] : null;
$actionName = true === isset($requestArguments['mvc']['action']) ? $requestArguments['mvc']['action'] : null;
$arguments = true === isset($requestArguments['arguments']) ? $requestArguments['arguments'] : [];
if ($extensionName && $vendorName && $controllerName && $actionName) {
/** @var Request $request */
$request = GeneralUtility::makeInstance(Request::class);
$request->setControllerExtensionName($extensionName);
$request->setControllerVendorName($vendorName);
$request->setControllerName($controllerName);
$request->setControllerActionName($actionName);
$request->setArguments($arguments);
/** @var Response $response */
$response = GeneralUtility::makeInstance(Response::class);
/** @var Dispatcher $dispatcher */
$dispatcher = GeneralUtility::makeInstance(Dispatcher::class);
$dispatcher->dispatch($request, $response);
$result = $response->getContent();
}
return $result;
}
示例11: createRule
/**
* Create a rule object according to class
* and sent some arguments
*
* @param string $class Name of the validation rule
* @param array $arguments Configuration of the rule
* @return AbstractValidator The rule object
*/
public function createRule($class, $arguments = array())
{
$class = strtolower((string) $class);
$className = 'TYPO3\\CMS\\Form\\Validation\\' . ucfirst($class) . 'Validator';
$rule = GeneralUtility::makeInstance($className, $arguments);
return $rule;
}
示例12: __construct
/**
* Constructor
*/
public function __construct()
{
$this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$this->injectConfigurationService($this->objectManager->get(ConfigurationService::class));
$this->injectPageService($this->objectManager->get(PageService::class));
$this->injectWorkspacesAwareRecordService($this->objectManager->get(WorkspacesAwareRecordService::class));
}
示例13: getTables
/**
* Get tables for menu example
*
* @param int $startUid UID from selected page
* @param int $depth How many levels recursive
* @return string The tables to be displayed
*/
public function getTables($startUid, $depth = 0)
{
$deletedRecordsTotal = 0;
$lang = $this->getLanguageService();
$tables = array();
foreach (RecyclerUtility::getModifyableTables() as $tableName) {
$deletedField = RecyclerUtility::getDeletedField($tableName);
if ($deletedField) {
// Determine whether the table has deleted records:
$deletedCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', $tableName, $deletedField . '<>0');
if ($deletedCount) {
/* @var $deletedDataObject \TYPO3\CMS\Recycler\Domain\Model\DeletedRecords */
$deletedDataObject = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Recycler\Domain\Model\DeletedRecords::class);
$deletedData = $deletedDataObject->loadData($startUid, $tableName, $depth)->getDeletedRows();
if (isset($deletedData[$tableName])) {
if ($deletedRecordsInTable = count($deletedData[$tableName])) {
$deletedRecordsTotal += $deletedRecordsInTable;
$tables[] = array($tableName, $deletedRecordsInTable, RecyclerUtility::getUtf8String($lang->sL($GLOBALS['TCA'][$tableName]['ctrl']['title'])));
}
}
}
}
}
$jsonArray = $tables;
array_unshift($jsonArray, array('', $deletedRecordsTotal, $lang->sL('LLL:EXT:recycler/mod1/locallang.xlf:label_allrecordtypes')));
return $jsonArray;
}
示例14: setUp
public function setUp()
{
parent::setUp();
$this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->categoryRepository = $this->objectManager->get('Tx_News_Domain_Repository_NewsRepository');
$this->importDataSet(__DIR__ . '/../Fixtures/tx_news_domain_model_category.xml');
}
示例15: __construct
/**
* CONSTRUCTOR
*/
public function __construct()
{
$objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$this->configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\BackendConfigurationManager');
$this->configurationService = $objectManager->get('FluidTYPO3\\Fluidpages\\Service\\ConfigurationService');
$this->pageService = $objectManager->get('FluidTYPO3\\Fluidpages\\Service\\PageService');
}