php TYPO3-CMS-Core-Core-Bootstrap类(方法)实例源码

下面列出了php TYPO3-CMS-Core-Core-Bootstrap 类(方法)源码代码实例,从而了解它的用法。

作者:dachcom-digita    项目:TYPO3.CM   
/**
  * Set up the application and shut it down afterwards
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = null)
 {
     $this->request = \TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals();
     // see below when this option is set and Bootstrap::defineTypo3RequestTypes() for more details
     if (TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_AJAX) {
         $this->request = $this->request->withAttribute('isAjaxRequest', true);
     } elseif (isset($this->request->getQueryParams()['M'])) {
         $this->request = $this->request->withAttribute('isModuleRequest', true);
     }
     $this->bootstrap->handleRequest($this->request);
     if ($execute !== null) {
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }

作者:plan2ne    项目:TYPO3.CM   
/**
  * Execute environment and folder step:
  * - Create main folder structure
  * - Create typo3conf/LocalConfiguration.php
  *
  * @return array<\TYPO3\CMS\Install\Status\StatusInterface>
  */
 public function execute()
 {
     /** @var $folderStructureFactory \TYPO3\CMS\Install\FolderStructure\DefaultFactory */
     $folderStructureFactory = $this->objectManager->get(\TYPO3\CMS\Install\FolderStructure\DefaultFactory::class);
     /** @var $structureFacade \TYPO3\CMS\Install\FolderStructure\StructureFacade */
     $structureFacade = $folderStructureFactory->getStructure();
     $structureFixMessages = $structureFacade->fix();
     /** @var \TYPO3\CMS\Install\Status\StatusUtility $statusUtility */
     $statusUtility = $this->objectManager->get(\TYPO3\CMS\Install\Status\StatusUtility::class);
     $errorsFromStructure = $statusUtility->filterBySeverity($structureFixMessages, 'error');
     if (@is_dir(PATH_typo3conf)) {
         /** @var \TYPO3\CMS\Core\Configuration\ConfigurationManager $configurationManager */
         $configurationManager = $this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
         $configurationManager->createLocalConfigurationFromFactoryConfiguration();
         // Create a PackageStates.php with all packages activated marked as "part of factory default"
         if (!file_exists(PATH_typo3conf . 'PackageStates.php')) {
             /** @var \TYPO3\CMS\Core\Package\FailsafePackageManager $packageManager */
             $packageManager = \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->getEarlyInstance(\TYPO3\CMS\Core\Package\PackageManager::class);
             $packages = $packageManager->getAvailablePackages();
             foreach ($packages as $package) {
                 /** @var $package \TYPO3\CMS\Core\Package\PackageInterface */
                 if ($package instanceof \TYPO3\CMS\Core\Package\PackageInterface && $package->isPartOfFactoryDefault()) {
                     $packageManager->activatePackage($package->getPackageKey());
                 }
             }
             $packageManager->forceSortAndSavePackageStates();
         }
         // Create enable install tool file after typo3conf & LocalConfiguration were created
         /** @var \TYPO3\CMS\Install\Service\EnableFileService $installToolService */
         $installToolService = $this->objectManager->get(\TYPO3\CMS\Install\Service\EnableFileService::class);
         $installToolService->removeFirstInstallFile();
         $installToolService->createInstallToolEnableFile();
     }
     return $errorsFromStructure;
 }

作者:99gra    项目:TYPO3.Extbase.t3viewhelper   
/**
  * Returns a valid DatabaseConnection object that is connected and ready
  * to be used static
  *
  * @return \TYPO3\CMS\Core\Database\DatabaseConnection
  */
 public static function getDatabaseConnection()
 {
     if (!$GLOBALS['TYPO3_DB']) {
         \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeTypo3DbGlobal();
     }
     return $GLOBALS['TYPO3_DB'];
 }

作者:xf    项目:fluidtypo3-developmen   
/**
  * @return $this
  */
 public function initializeCmsContext()
 {
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->baseSetup('typo3/')->initializeClassLoader()->initializeCachingFramework()->initializePackageManagement('FluidTYPO3\\Development\\NullPackageManager');
     $container = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container');
     $this->setObjectContainer($container);
     return $this;
 }

作者:dachcom-digita    项目:TYPO3.CM   
/**
  * This clear cache implementation follows a pretty brutal approach.
  * Goal is to reliably get rid of cache entries, even if some broken
  * extension is loaded that would kill the backend 'clear cache' action.
  *
  * Therefor this method "knows" implementation details of the cache
  * framework and uses them to clear all file based cache (typo3temp/Cache)
  * and database caches (tables prefixed with cf_) manually.
  *
  * After that ext_tables and ext_localconf of extensions are loaded, those
  * may register additional caches in the caching framework with different
  * backend, and will then clear them with the usual flush() method.
  *
  * @return void
  */
 public function clearAll()
 {
     // Delete typo3temp/Cache
     GeneralUtility::flushDirectory(PATH_site . 'typo3temp/var/Cache', true, true);
     $bootstrap = \TYPO3\CMS\Core\Core\Bootstrap::getInstance();
     $bootstrap->initializeCachingFramework()->initializePackageManagement(\TYPO3\CMS\Core\Package\PackageManager::class);
     // Get all table names starting with 'cf_' and truncate them
     $database = $this->getDatabaseConnection();
     $tables = $database->admin_get_tables();
     foreach ($tables as $table) {
         $tableName = $table['Name'];
         if (substr($tableName, 0, 3) === 'cf_') {
             $database->exec_TRUNCATEquery($tableName);
         } elseif ($tableName === 'cache_treelist') {
             // cache_treelist is not implemented in the caching framework.
             // clear this table manually
             $database->exec_TRUNCATEquery('cache_treelist');
         }
     }
     // From this point on, the code may fatal, if some broken extension is loaded.
     // Use bootstrap to load all ext_localconf and ext_tables
     $bootstrap->loadTypo3LoadedExtAndExtLocalconf(false)->defineLoggingAndExceptionConstants()->unsetReservedGlobalVariables()->initializeTypo3DbGlobal()->loadExtensionTables(false);
     // The cache manager is already instantiated in the install tool
     // with some hacked settings to disable caching of extbase and fluid.
     // We want a "fresh" object here to operate on a different cache setup.
     // cacheManager implements SingletonInterface, so the only way to get a "fresh"
     // instance is by circumventing makeInstance and/or the objectManager and
     // using new directly!
     $cacheManager = new \TYPO3\CMS\Core\Cache\CacheManager();
     $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']);
     // Cache manager needs cache factory. cache factory injects itself to manager in __construct()
     new \TYPO3\CMS\Core\Cache\CacheFactory('production', $cacheManager);
     $cacheManager->flushCaches();
 }

作者:pitscribbl    项目:typo3-upgraderepor   
/**
  * @return void
  */
 public function execute()
 {
     // check for the Bootstrap class to check if the current TYPO3 version meets our requirements
     if (class_exists('TYPO3\\CMS\\Core\\Core\\Bootstrap')) {
         /** @var \TYPO3\CMS\Install\Sql\SchemaMigrator $schemaMigrator */
         $schemaMigrator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\Sql\\SchemaMigrator');
         /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $databaseConnection */
         $databaseConnection = $GLOBALS['TYPO3_DB'];
         \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadExtensionTables(FALSE);
         $tableDefinitionsString = $this->resolveTableDefinitions();
         $currentFieldDefinitions = $schemaMigrator->getFieldDefinitions_database();
         $updatedFieldDefinitions = $schemaMigrator->getFieldDefinitions_fileContent($tableDefinitionsString);
         $fieldDefinitionsDifferences = $schemaMigrator->getDatabaseExtra($updatedFieldDefinitions, $currentFieldDefinitions);
         $updateStatements = $schemaMigrator->getUpdateSuggestions($fieldDefinitionsDifferences);
         $allowedStatementTypes = array('add', 'create_table');
         if (!empty($updateStatements)) {
             $this->messageService->warningMessage('Difference detected in table definitions. Statement types: ' . implode(',', array_keys($updateStatements)), TRUE);
             foreach ($allowedStatementTypes as $statementType) {
                 if (array_key_exists($statementType, $updateStatements) && is_array($updateStatements[$statementType])) {
                     foreach ($updateStatements[$statementType] as $statement) {
                         $this->messageService->infoMessage('Executing "' . $statement . '"');
                         $result = $databaseConnection->admin_query($statement);
                         if ($result !== TRUE) {
                             $this->messageService->warningMessage('Executing query failed!');
                         }
                     }
                 }
             }
         }
     }
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * Generates the action menu
  *
  * @return void
  */
 protected function generateMenu()
 {
     $menuItems = ['installedExtensions' => ['controller' => 'List', 'action' => 'index', 'label' => $this->translate('installedExtensions')]];
     if (!$this->settings['offlineMode'] && !Bootstrap::usesComposerClassLoading()) {
         $menuItems['getExtensions'] = ['controller' => 'List', 'action' => 'ter', 'label' => $this->translate('getExtensions')];
         $menuItems['distributions'] = ['controller' => 'List', 'action' => 'distributions', 'label' => $this->translate('distributions')];
         if ($this->actionMethodName === 'showAllVersionsAction') {
             $menuItems['showAllVersions'] = ['controller' => 'List', 'action' => 'showAllVersions', 'label' => $this->translate('showAllVersions') . ' ' . $this->request->getArgument('extensionKey')];
         }
     }
     $uriBuilder = $this->objectManager->get(UriBuilder::class);
     $uriBuilder->setRequest($this->request);
     $menu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
     $menu->setIdentifier('ExtensionManagerModuleMenu');
     foreach ($menuItems as $menuItemConfig) {
         if ($this->request->getControllerName() === $menuItemConfig['controller']) {
             $isActive = $this->request->getControllerActionName() === $menuItemConfig['action'] ? true : false;
         } else {
             $isActive = false;
         }
         $menuItem = $menu->makeMenuItem()->setTitle($menuItemConfig['label'])->setHref($this->getHref($menuItemConfig['controller'], $menuItemConfig['action']))->setActive($isActive);
         $menu->addMenuItem($menuItem);
     }
     $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($menu);
     $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());
 }

作者:plan2ne    项目:TYPO3.CM   
/**
  * Set up
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setUpBackendUserFromFixture(1);
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
     $this->importDataSet(__DIR__ . '/../Fixtures/sys_workspace.xml');
 }

作者:TYPO3Incubato    项目:TYPO3.CM   
/**
  * Set up for set up the backend user, initialize the language object
  * and creating the Export instance
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setUpBackendUserFromFixture(1);
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
     $this->export = GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\Export::class);
     $this->export->init(0, 'export');
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * @return bool
  */
 public static function isFirstInstallAllowed()
 {
     $files = self::getFirstInstallFilePaths();
     if (!empty($files) && !\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->checkIfEssentialConfigurationExists()) {
         return true;
     }
     return false;
 }

作者:TYPO3Incubato    项目:TYPO3.CM   
/**
  * Return 'this' as singleton
  *
  * @return Bootstrap
  * @internal This is not a public API method, do not use in own extensions
  */
 public static function getInstance()
 {
     if (is_null(static::$instance)) {
         $applicationContext = getenv('TYPO3_CONTEXT') ?: (getenv('REDIRECT_TYPO3_CONTEXT') ?: 'Production');
         self::$instance = new static($applicationContext);
         self::$instance->defineTypo3RequestTypes();
     }
     return static::$instance;
 }

作者:plan2ne    项目:TYPO3.CM   
protected function setUp()
 {
     parent::setUp();
     $this->backendUser = $this->setUpBackendUserFromFixture(self::VALUE_BackendUserId);
     // By default make tests on live workspace
     $this->backendUser->workspace = 0;
     $this->actionService = $this->getActionService();
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
 }

作者:rickymathe    项目:TYPO3.CM   
/**
  * Sets up this test case.
  *
  * @return void
  */
 protected function setUp()
 {
     parent::setUp();
     $this->setUpBackendUserFromFixture(1);
     \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
     $this->expectedLogEntries = 0;
     $GLOBALS['TYPO3_CONF_VARS']['SYS']['sqlDebug'] = 1;
     $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
     $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/sys_language.xml');
 }

作者:adroll    项目:TYPO3.CM   
/**
  * 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;
 }

作者:dachcom-digita    项目:TYPO3.CM   
/**
  * Set up the application and shut it down afterwards
  * Failsafe minimal setup mode for the install tool
  * Does not call "run()" therefore
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = null)
 {
     $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals());
     if ($execute !== null) {
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }

作者:TYPO3Incubato    项目:TYPO3.CM   
/**
  * Set up the application and shut it down afterwards
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = null)
 {
     $this->bootstrap->handleRequest(new \Symfony\Component\Console\Input\ArgvInput());
     if ($execute !== null) {
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }

作者:adroll    项目:TYPO3.CM   
/**
  * Handles any backend request
  *
  * @return void
  */
 public function handleRequest()
 {
     // Evaluate the constant for skipping the BE user check for the bootstrap
     if (defined('TYPO3_PROCEED_IF_NO_USER') && TYPO3_PROCEED_IF_NO_USER) {
         $proceedIfNoUserIsLoggedIn = TRUE;
     } else {
         $proceedIfNoUserIsLoggedIn = FALSE;
     }
     $this->bootstrap->checkLockedBackendAndRedirectOrDie()->checkBackendIpOrDie()->checkSslBackendAndRedirectIfNeeded()->checkValidBrowserOrDie()->loadExtensionTables(TRUE)->initializeSpriteManager()->initializeBackendUser()->initializeBackendAuthentication($proceedIfNoUserIsLoggedIn)->initializeLanguageObject()->initializeBackendTemplate()->endOutputBufferingAndCleanPreviousOutput()->initializeOutputCompression()->sendHttpHeaders();
 }

作者:plan2ne    项目:TYPO3.CM   
/**
  * Set up the application and shut it down afterwards
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = NULL)
 {
     $this->bootstrap->handleRequest(\TYPO3\CMS\Core\Http\ServerRequestFactory::fromGlobals());
     if ($execute !== NULL) {
         if ($execute instanceof \Closure) {
             $execute->bindTo($this);
         }
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }

作者:adroll    项目:TYPO3.CM   
/**
  * Set up the application and shut it down afterwards
  * Failsafe minimal setup mode for the install tool
  * Does not call "run()" therefore
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = NULL)
 {
     $this->bootstrap->startOutputBuffering()->loadConfigurationAndInitialize(FALSE, \TYPO3\CMS\Core\Package\FailsafePackageManager::class)->handleRequest();
     if ($execute !== NULL) {
         if ($execute instanceof \Closure) {
             $execute->bindTo($this);
         }
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }

作者:adroll    项目:TYPO3.CM   
/**
  * Set up the application and shut it down afterwards
  *
  * @param callable $execute
  * @return void
  */
 public function run(callable $execute = NULL)
 {
     $this->bootstrap->run();
     if ($execute !== NULL) {
         if ($execute instanceof \Closure) {
             $execute->bindTo($this);
         }
         call_user_func($execute);
     }
     $this->bootstrap->shutdown();
 }


问题


面经


文章

微信
公众号

扫码关注公众号