本文整理汇总了PHP中TYPO3\CMS\Core\Core\Bootstrap::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap::getInstance方法的具体用法?PHP Bootstrap::getInstance怎么用?PHP Bootstrap::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Core\Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDatabaseConnection
/**
* 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'];
}
示例2: execute
/**
* 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;
}
示例3: initializeCmsContext
/**
* @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;
}
示例4: setUp
/**
* Set up
*/
protected function setUp()
{
parent::setUp();
$this->setUpBackendUserFromFixture(1);
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
$this->importDataSet(__DIR__ . '/../Fixtures/sys_workspace.xml');
}
示例5: execute
/**
* @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!');
}
}
}
}
}
}
}
示例6: clearAll
/**
* 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();
}
示例7: isFirstInstallAllowed
/**
* @return bool
*/
public static function isFirstInstallAllowed()
{
$files = self::getFirstInstallFilePaths();
if (!empty($files) && !\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->checkIfEssentialConfigurationExists()) {
return true;
}
return false;
}
示例8: __construct
/**
* Constructor setting up legacy constant and register available Request Handlers
*
* @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
*/
public function __construct($classLoader)
{
$this->defineLegacyConstants();
$this->bootstrap = Bootstrap::getInstance()->initializeClassLoader($classLoader)->baseSetup($this->entryPointPath);
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);
}
}
示例9: setUp
/**
* 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');
}
示例10: setUp
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();
}
示例11: __construct
/**
* Constructor setting up legacy constant and register available Request Handlers
*
* @param \Composer\Autoload\ClassLoader $classLoader an instance of the class loader
*/
public function __construct($classLoader)
{
$this->defineLegacyConstants();
$this->bootstrap = Bootstrap::getInstance()->initializeClassLoader($classLoader)->baseSetup($this->entryPointPath);
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);
}
$this->bootstrap->startOutputBuffering()->loadConfigurationAndInitialize(false, \TYPO3\CMS\Core\Package\FailsafePackageManager::class);
}
示例12: setUp
/**
* Set up for set up the backend user, initialize the language object
* and creating the ImportExport instance
*
* @return void
*/
protected function setUp()
{
parent::setUp();
$this->setUpBackendUserFromFixture(1);
// Needed to avoid PHP Warnings
$GLOBALS['TBE_STYLES']['spriteIconApi']['iconsAvailable'] = array();
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
$this->export = GeneralUtility::makeInstance(\TYPO3\CMS\Impexp\ImportExport::class);
$this->export->init(0, 'export');
}
示例13: initTCA
/**
* Makes TCA available inside eID
*
* @return void
*/
public static function initTCA()
{
// Some badly made extensions attempt to manipulate TCA in a wrong way
// (inside ext_localconf.php). Therefore $GLOBALS['TCA'] may become an array
// but in fact it is not loaded. The check below ensure that
// TCA is still loaded if such bad extensions are installed
if (!is_array($GLOBALS['TCA']) || !isset($GLOBALS['TCA']['pages'])) {
Bootstrap::getInstance()->loadCachedTca();
}
}
示例14: setUp
/**
* Sets up this test case.
*
* @return void
*/
protected function setUp()
{
parent::setUp();
$this->setUpBackendUserFromFixture(1);
Bootstrap::getInstance()->initializeLanguageObject();
$this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Fixtures/pages.xml');
$this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/sys_language.xml');
$this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/backend/Tests/Functional/Controller/Page/Fixtures/tt_content-default-language.xml');
$this->subject = new LocalizationController();
}
示例15: __construct
/**
* Constructor setting up legacy constants and register available Request Handlers
*
* @param \Composer\Autoload\ClassLoader|\Helhum\ClassAliasLoader\Composer\ClassAliasLoader $classLoader an instance of the class loader
*/
public function __construct($classLoader)
{
$this->defineLegacyConstants();
\TYPO3\CMS\Core\Core\CliBootstrap::checkEnvironmentOrDie();
$this->bootstrap = Bootstrap::getInstance()->initializeClassLoader($classLoader)->baseSetup($this->entryPointPath);
foreach ($this->availableRequestHandlers as $requestHandler) {
$this->bootstrap->registerRequestHandlerImplementation($requestHandler);
}
$this->bootstrap->configure();
}