本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::getApplicationContext方法的具体用法?PHP GeneralUtility::getApplicationContext怎么用?PHP GeneralUtility::getApplicationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::getApplicationContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isDevelopmentApplicationContext
/**
* @return bool
*/
public function isDevelopmentApplicationContext()
{
if (GeneralUtility::getApplicationContext()->isDevelopment()) {
return TRUE;
}
return FALSE;
}
示例2: __construct
/**
* Constructor
*
* @param \TYPO3\CMS\Backend\Controller\BackendController $backendReference TYPO3 backend object reference
* @throws \UnexpectedValueException
*/
public function __construct(\TYPO3\CMS\Backend\Controller\BackendController &$backendReference = NULL)
{
$this->backendReference = $backendReference;
$this->cacheActions = array();
$this->optionValues = array();
$backendUser = $this->getBackendUser();
// Clear all page-related caches
if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.pages')) {
$this->cacheActions[] = array('id' => 'pages', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesTitle', TRUE), 'description' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesDescription', TRUE), 'href' => $this->backPath . 'tce_db.php?vC=' . $backendUser->veriCode() . '&cacheCmd=pages&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-low'));
$this->optionValues[] = 'pages';
}
// Clear cache for ALL tables!
if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.all')) {
$this->cacheActions[] = array('id' => 'all', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesTitle', TRUE), 'description' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesDescription', TRUE), 'href' => $this->backPath . 'tce_db.php?vC=' . $backendUser->veriCode() . '&cacheCmd=all&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-medium'));
$this->optionValues[] = 'all';
}
// Clearing of system cache (core cache, class cache etc)
// is only shown explicitly if activated for a BE-user (not activated for admins by default)
// or if the system runs in development mode
// or if $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] is set (only for admins)
if ($backendUser->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === TRUE && $backendUser->isAdmin()) {
$this->cacheActions[] = array('id' => 'system', 'title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle', TRUE), 'description' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription', TRUE), 'href' => $this->backPath . 'tce_db.php?vC=' . $backendUser->veriCode() . '&cacheCmd=system&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-high'));
$this->optionValues[] = 'system';
}
// Hook for manipulating cacheActions
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'] as $cacheAction) {
$hookObject = GeneralUtility::getUserObj($cacheAction);
if (!$hookObject instanceof \TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface) {
throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\Toolbar\\ClearCacheActionsHookInterface', 1228262000);
}
$hookObject->manipulateCacheActions($this->cacheActions, $this->optionValues);
}
}
}
示例3: manipulateCacheActions
/**
* Modifies CacheMenuItems array
*
* @param array $cacheActions Array of CacheMenuItems
* @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier)
*/
public function manipulateCacheActions(&$cacheActions, &$optionValues)
{
if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === TRUE && $this->getBackendUser()->isAdmin()) {
$cacheActions[] = array('id' => 'dyncss', 'title' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle', TRUE), 'description' => $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription', TRUE), 'href' => BackendUtility::getModuleUrl('tce_db') . '&vC=' . $this->getBackendUser()->veriCode() . '&cacheCmd=dyncss&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('actions-system-cache-clear-impact-high'));
$optionValues[] = 'dyncss';
}
}
示例4: isDevelopmentApplicationContext
/**
* @return bool
*/
public function isDevelopmentApplicationContext()
{
if (GeneralUtility::getApplicationContext()->isDevelopment()) {
return true;
}
return false;
}
示例5: manipulateCacheActions
/**
* Modifies CacheMenuItems array
*
* @param array $cacheActions Array of CacheMenuItems
* @param array $optionValues Array of AccessConfigurations-identifiers (typically used by userTS with options.clearCache.identifier)
*
* @return void
*/
public function manipulateCacheActions(&$cacheActions, &$optionValues)
{
if ($this->getBackendUser()->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === TRUE && $this->getBackendUser()->isAdmin()) {
$cacheActions[] = array('id' => 'dyncss', 'title' => $this->getLanguageService()->sL('LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.title', TRUE), 'description' => $this->getLanguageService()->sL('LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.description', TRUE), 'href' => BackendUtility::getModuleUrl('tce_db') . '&vC=' . $this->getBackendUser()->veriCode() . '&cacheCmd=dyncss&ajaxCall=1' . BackendUtility::getUrlToken('tceAction'), 'icon' => IconUtility::getSpriteIcon('extensions-dyncss-lightning-blue'));
$optionValues[] = 'dyncss';
}
}
示例6: __construct
/**
* Constructor
*
* @throws \UnexpectedValueException
*/
public function __construct()
{
$backendUser = $this->getBackendUser();
$languageService = $this->getLanguageService();
$this->iconFactory = GeneralUtility::makeInstance(IconFactory::class);
$this->getPageRenderer()->loadRequireJsModule('TYPO3/CMS/Backend/Toolbar/ClearCacheMenu');
// Clear all page-related caches
if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.pages')) {
$this->cacheActions[] = array('id' => 'pages', 'title' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesTitle', true), 'description' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushPageCachesDescription', true), 'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'pages', 'ajaxCall' => 1]), 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-low', Icon::SIZE_SMALL)->render());
$this->optionValues[] = 'pages';
}
// Clear cache for ALL tables!
if ($backendUser->isAdmin() || $backendUser->getTSConfigVal('options.clearCache.all')) {
$this->cacheActions[] = array('id' => 'all', 'title' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesTitle', true), 'description' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushGeneralCachesDescription', true), 'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'all', 'ajaxCall' => 1]), 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-medium', Icon::SIZE_SMALL)->render());
$this->optionValues[] = 'all';
}
// Clearing of system cache (core cache, class cache etc)
// is only shown explicitly if activated for a BE-user (not activated for admins by default)
// or if the system runs in development mode
// or if $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] is set (only for admins)
if ($backendUser->getTSConfigVal('options.clearCache.system') || GeneralUtility::getApplicationContext()->isDevelopment() || (bool) $GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true && $backendUser->isAdmin()) {
$this->cacheActions[] = array('id' => 'system', 'title' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesTitle', true), 'description' => $languageService->sL('LLL:EXT:lang/locallang_core.xlf:flushSystemCachesDescription', true), 'href' => BackendUtility::getModuleUrl('tce_db', ['vC' => $backendUser->veriCode(), 'cacheCmd' => 'system', 'ajaxCall' => 1]), 'icon' => $this->iconFactory->getIcon('actions-system-cache-clear-impact-high', Icon::SIZE_SMALL)->render());
$this->optionValues[] = 'system';
}
// Hook for manipulating cacheActions
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['additionalBackendItems']['cacheActions'] as $cacheAction) {
$hookObject = GeneralUtility::getUserObj($cacheAction);
if (!$hookObject instanceof ClearCacheActionsHookInterface) {
throw new \UnexpectedValueException('$hookObject must implement interface ' . ClearCacheActionsHookInterface::class, 1228262000);
}
$hookObject->manipulateCacheActions($this->cacheActions, $this->optionValues);
}
}
}
示例7: render
/**
* JavaScript file to load
*
* @param string $file
* @param bool $canBeMinified
*/
public function render($file, $canBeMinified = false)
{
// Sipped minified file in Production context.
if ($canBeMinified && (string) GeneralUtility::getApplicationContext() === 'Production') {
$file = str_replace('.js', '.min.js', $file);
}
$this->getPageRenderer()->addJsFooterFile($file);
}
示例8: addDebugInfoToBody
/**
* Get a body message when email is not in production.
*
* @param string $messageBody
* @return string
*/
protected function addDebugInfoToBody($messageBody)
{
$to = $this->getTo();
$cc = $this->getCc();
$bcc = $this->getBcc();
$messageBody = sprintf("%s CONTEXT: this message is for testing purposes. In Production, it will be sent as follows. \nto: %s\n%s%s\n%s", strtoupper((string) GeneralUtility::getApplicationContext()), implode(',', array_keys($to)), empty($cc) ? '' : sprintf("cc: %s \n", implode(',', array_keys($cc))), empty($bbc) ? '' : sprintf("bcc: %s \n", implode(',', array_keys($bcc))), $messageBody);
return $messageBody;
}
示例9: setUp
/**
* Set up
*/
protected function setUp()
{
require_once 'Fixtures/ConditionMatcherUserFuncs.php';
$this->backupApplicationContext = GeneralUtility::getApplicationContext();
$this->conditionMatcher = $this->getMockForAbstractClass(AbstractConditionMatcher::class);
$this->evaluateConditionCommonMethod = new \ReflectionMethod(AbstractConditionMatcher::class, 'evaluateConditionCommon');
$this->evaluateConditionCommonMethod->setAccessible(TRUE);
}
示例10: setUp
/**
* Set up
*
* This setUp() does not call its parent implementation to avoid database cleaning
*
* @return void
*/
protected function setUp()
{
if (!(in_array(GeneralUtility::getApplicationContext(), $this->allowedApplicationContexts) || in_array($_SERVER['HOSTNAME'], $this->allowedDomains) || in_array($_SERVER['HTTP_HOST'], $this->allowedDomains))) {
$this->markTestSkipped(sprintf('This test is only allowed in contexts "%s" or on domains "%s"', implode(', ', $this->allowedApplicationContexts), implode(', ', $this->allowedDomains)));
}
$fixtureImporter = GeneralUtility::makeInstance('Tx_PtExtbase_Testing_FixtureFramework_FixtureImporter');
/** @var Tx_PtExtbase_Testing_FixtureFramework_FixtureImporter $fixtureImporter */
$fixtureImporter->import($this->getFixtures());
}
示例11: configureAll
public static function configureAll()
{
if (!preg_match('#/Heroku$#', GeneralUtility::getApplicationContext())) {
return;
}
static::configureDatabase();
static::configureSessionStorage();
static::relaxBackendIpRestriction();
}
示例12: getPriority
/**
* If context is set to production, priority
* of this preset is raised.
*
* @return int Priority of preset
*/
public function getPriority()
{
$context = \TYPO3\CMS\Core\Utility\GeneralUtility::getApplicationContext();
$priority = $this->priority;
if ($context->isProduction()) {
$priority = $priority + 20;
}
return $priority;
}
示例13: connect
protected function connect()
{
// Load system specific configuration for Apache mode
$dpppConfiguration = __DIR__ . '/../../../../../../configurations/' . GeneralUtility::getApplicationContext() . '/AdditionalConfiguration.php';
if (file_exists($dpppConfiguration)) {
@(include $dpppConfiguration);
}
$credentials = $GLOBALS['TYPO3_CONF_VARS']['DB'];
$this->mySQLConnection = new \PDO('mysql:host=' . $credentials['host'] . ';dbname=' . $credentials['database'], $credentials['username'], $credentials['password']);
}
示例14: render
/**
* @throws \TYPO3\CMS\Fluid\Core\ViewHelper\Exception\InvalidVariableException
* @return string
*/
public function render()
{
$redirectTo = $this->getRedirectService()->redirectionForCurrentContext();
$output = '';
// Means we want to redirect email.
if (!empty($redirectTo)) {
$contentElement = $this->templateVariableContainer->get('contentElement');
$settings = $this->getFlexFormService()->extractSettings($contentElement['pi_flexform']);
$to = $this->getEmailAddressService()->parse($settings['emailAdminTo']);
#$cc = $this->getEmailAddressService()->parse($settings['emailAdminCc']);
#$bcc = $this->getEmailAddressService()->parse($settings['emailAdminBcc']);
$templateService = $this->getTemplateService($settings['template']);
$output = sprintf("<pre style='clear: both'>%s CONTEXT<br /> %s %s %s %s %s</pre>", strtoupper((string) GeneralUtility::getApplicationContext()), $this->hasEmails($settings) ? '<br />- All emails will be redirected to ' . implode(', ', array_keys($redirectTo)) . '.' : '', empty($to) ? '' : '<br />- Admin email will be sent to: ' . implode(', ', array_keys($to)), empty($settings['emailUserTo']) ? '' : '<br/>- User email will be sent using the field "' . $settings['emailUserTo'] . '"', $this->isSenderOk($settings) ? '' : '<br/>- ATTENTION! No sender could be found. This will be a problem when sending emails.', $templateService->hasPersistingTable() ? '<br/>- Submitted data will be persisted into "' . $templateService->getPersistingTable() . '"' : '');
}
return $output;
}
示例15: sendMailToWinkel
/**
* @param $subject
* @param $message
*/
public static function sendMailToWinkel($subject, $message)
{
$isDev = GeneralUtility::getApplicationContext()->isDevelopment();
if ($isDev === false) {
/* @var \TYPO3\CMS\Core\Mail\MailMessage */
$mail = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Mail\\MailMessage');
$mail->setFrom(array('noreply@winkel.de' => 'WINKEL GmbH'));
$mail->setTo(array('komponentenanfrage@winkel.de' => 'Produktanfrage'));
$mail->setSubject($subject);
$mail->setBody($message);
// if ($_FILES['tx_winkelproducts_pi1']['name']['flangeplate-pdf'] != '') {
// $attachment = Swift_Attachment::fromPath($fileName, $mimeType);
// $attachment->setFilename($_FILES['tx_winkelproducts_pi1']['name']['flangeplate-pdf']);
// $mail->attach($attachment);
// }
$mail->send();
}
}