本文整理汇总了PHP中TYPO3\Flow\Core\Bootstrap::getObjectManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Bootstrap::getObjectManager方法的具体用法?PHP Bootstrap::getObjectManager怎么用?PHP Bootstrap::getObjectManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\Flow\Core\Bootstrap
的用法示例。
在下文中一共展示了Bootstrap::getObjectManager方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: boot
public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
{
// 1. Make Gedmo\Translatable\Entity\Translation known to Doctrine, so that it can participate in Database Schema Generation
//
// Internally, we use a MappingDriverChain for that, which delegates almost all of its behavior to the already-existing
// FlowAnnotationDriver. We additionally add the (default doctrine) Annotation Driver for the Gedmo namespace.
//
// Note: We replace FlowAnnotationDriver *on a very low level* with the *MappingDriverChain* object; because this class
// is only used inside EntityManagerFactory -- so we know quite exactly what methods are called on that object.
$bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Booting\\Sequence', 'beforeInvokeStep', function ($step) use($bootstrap) {
if ($step->getIdentifier() === 'typo3.flow:resources') {
$flowAnnotationDriver = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver');
$driverChain = new MappingDriverChainWithFlowAnnotationDriverAsDefault($flowAnnotationDriver);
$driverChain->addDriver(new AnnotationDriver(ObjectAccess::getProperty($flowAnnotationDriver, 'reader', TRUE), FLOW_PATH_PACKAGES . 'Libraries/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity'), 'Gedmo');
$bootstrap->getObjectManager()->setInstance('TYPO3\\Flow\\Persistence\\Doctrine\\Mapping\\Driver\\FlowAnnotationDriver', $driverChain);
}
});
// 2. Work around a bug in TYPO3\Flow\Persistence\Doctrine\PersistenceManager::onFlush which expects that all objects in the
// Doctrine subsystem are entities known to Flow.
//
// The line $this->reflectionService->getClassSchema($entity)->getModelType() triggers a fatal error, for get_class($entity) == 'Gedmo\Translatable\Entity\Translation'
// because this class is known only to Doctrine (see 1. above), but not to the Flow reflection service.
//
// As a workaround, we just add an empty placeholder class schema to the Class Schemata cache, right before the class schema is saved
// inside the TYPO3\Flow\Core\Bootstrap::bootstrapShuttingDown signal (which is fired directly after "finishedCompiletimeRun").
$bootstrap->getSignalSlotDispatcher()->connect('TYPO3\\Flow\\Core\\Bootstrap', 'finishedCompiletimeRun', function () use($bootstrap) {
$classSchemataCache = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Cache\\CacheManager')->getCache('Flow_Reflection_RuntimeClassSchemata');
if (!$classSchemataCache->has('Gedmo_Translatable_Entity_Translation')) {
$classSchemataCache->set('Gedmo_Translatable_Entity_Translation', new ClassSchema('Gedmo\\Translatable\\Entity\\Translation'));
}
});
}
示例2: handleRequest
/**
* Creates an event loop which takes orders from the parent process and executes
* them in runtime mode.
*
* @return void
*/
public function handleRequest()
{
$sequence = $this->bootstrap->buildRuntimeSequence();
$sequence->invoke($this->bootstrap);
$objectManager = $this->bootstrap->getObjectManager();
$systemLogger = $objectManager->get(SystemLoggerInterface::class);
$systemLogger->log('Running sub process loop.', LOG_DEBUG);
echo "\nREADY\n";
try {
while (true) {
$commandLine = trim(fgets(STDIN));
$trimmedCommandLine = trim($commandLine);
$systemLogger->log(sprintf('Received command "%s".', $trimmedCommandLine), LOG_INFO);
if ($commandLine === "QUIT\n") {
break;
}
/** @var Request $request */
$request = $objectManager->get(RequestBuilder::class)->build($trimmedCommandLine);
$response = new Response();
if ($this->bootstrap->isCompiletimeCommand($request->getCommand()->getCommandIdentifier())) {
echo "This command must be executed during compiletime.\n";
} else {
$objectManager->get(Dispatcher::class)->dispatch($request, $response);
$response->send();
$this->emitDispatchedCommandLineSlaveRequest();
}
echo "\nREADY\n";
}
$systemLogger->log('Exiting sub process loop.', LOG_DEBUG);
$this->bootstrap->shutdown(Bootstrap::RUNLEVEL_RUNTIME);
exit($response->getExitCode());
} catch (\Exception $exception) {
$this->handleException($exception);
}
}
示例3: __construct
/**
*/
public function __construct()
{
if (self::$bootstrap === NULL) {
self::$bootstrap = $this->initializeFlow();
}
$this->objectManager = self::$bootstrap->getObjectManager();
}
示例4: getAuthenticatedAccount
/**
* Retrieve current authenticated account
*
* @return \TYPO3\Flow\Security\Account|NULL
*/
public static function getAuthenticatedAccount()
{
self::initializeBootstrap();
if (self::$bootstrap) {
$objectManager = self::$bootstrap->getObjectManager();
if ($objectManager) {
$securityContext = $objectManager->get('\\TYPO3\\Flow\\Security\\Context');
if ($securityContext && $securityContext->canBeInitialized()) {
return $securityContext->getAccount();
}
}
}
return null;
}
示例5: boot
/**
* Initializes the matching boot sequence depending on the type of the command
* (runtime or compiletime) and manually injects the necessary dependencies of
* this request handler.
*
* @param string $runlevel Either "Compiletime" or "Runtime"
* @return void
*/
protected function boot($runlevel)
{
$sequence = $runlevel === 'Compiletime' ? $this->bootstrap->buildCompiletimeSequence() : $this->bootstrap->buildRuntimeSequence();
$sequence->invoke($this->bootstrap);
$this->objectManager = $this->bootstrap->getObjectManager();
$this->dispatcher = $this->objectManager->get('TYPO3\\Flow\\Mvc\\Dispatcher');
}
示例6: sendRequest
/**
* Sends the given HTTP request
*
* @param Http\Request $httpRequest
* @return Http\Response
* @throws Http\Exception
* @api
*/
public function sendRequest(Http\Request $httpRequest)
{
$requestHandler = $this->bootstrap->getActiveRequestHandler();
if (!$requestHandler instanceof FunctionalTestRequestHandler) {
throw new Http\Exception('The browser\'s internal request engine has only been designed for use within functional tests.', 1335523749);
}
$this->securityContext->clearContext();
$this->validatorResolver->reset();
$response = new Http\Response();
$requestHandler->setHttpRequest($httpRequest);
$requestHandler->setHttpResponse($response);
$objectManager = $this->bootstrap->getObjectManager();
$baseComponentChain = $objectManager->get(\TYPO3\Flow\Http\Component\ComponentChain::class);
$componentContext = new ComponentContext($httpRequest, $response);
if (version_compare(PHP_VERSION, '6.0.0') >= 0) {
try {
$baseComponentChain->handle($componentContext);
} catch (\Throwable $throwable) {
$this->prepareErrorResponse($throwable, $response);
}
} else {
try {
$baseComponentChain->handle($componentContext);
} catch (\Exception $exception) {
$this->prepareErrorResponse($exception, $response);
}
}
$session = $this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Session\SessionInterface::class);
if ($session->isStarted()) {
$session->close();
}
$this->persistenceManager->clearState();
return $response;
}
示例7: resolveDependencies
/**
* Resolves a few dependencies of this request handler which can't be resolved
* automatically due to the early stage of the boot process this request handler
* is invoked at.
*
* @return void
*/
protected function resolveDependencies()
{
$objectManager = $this->bootstrap->getObjectManager();
$this->baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain');
$configurationManager = $objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
$this->settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow');
}
示例8: refreezePackage
/**
* Refreezes a package
*
* @param string $packageKey The package to refreeze
* @return void
*/
public function refreezePackage($packageKey)
{
if (!$this->isPackageFrozen($packageKey)) {
return;
}
$this->bootstrap->getObjectManager()->get(\TYPO3\Flow\Reflection\ReflectionService::class)->unfreezePackageReflection($packageKey);
}
示例9: boot
/**
* Initializes the matching boot sequence depending on the type of the command
* (RUNLEVEL_RUNTIME or RUNLEVEL_COMPILETIME) and manually injects the necessary dependencies of
* this request handler.
*
* @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants
* @return void
*/
protected function boot($runlevel)
{
$sequence = $runlevel === Bootstrap::RUNLEVEL_COMPILETIME ? $this->bootstrap->buildCompiletimeSequence() : $this->bootstrap->buildRuntimeSequence();
$sequence->invoke($this->bootstrap);
$this->objectManager = $this->bootstrap->getObjectManager();
$this->dispatcher = $this->objectManager->get(\TYPO3\Flow\Mvc\Dispatcher::class);
}
示例10: render
/**
* @param string $path
* @return string
* @throws \Exception
*/
public function render($path = NULL)
{
if ($path === NULL) {
$path = '404';
}
/** @var RequestHandler $activeRequestHandler */
$activeRequestHandler = $this->bootstrap->getActiveRequestHandler();
$parentHttpRequest = $activeRequestHandler->getHttpRequest();
$requestPath = $parentHttpRequest->getUri()->getPath();
$language = explode('/', ltrim($requestPath, '/'))[0];
if ($language === 'neos') {
throw new \Exception('NotFoundViewHelper can not be used for neos-routes.', 1435648210);
}
$language = $this->localeDetector->detectLocaleFromLocaleTag($language)->getLanguage();
if ($this->contentDimensionPresetSource->findPresetByUriSegment('language', $language) === NULL) {
$language = '';
}
if ($language !== '') {
$language .= '/';
}
$request = Request::create(new Uri(rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path));
$matchingRoute = $this->router->route($request);
if (!$matchingRoute) {
throw new \Exception(sprintf('Uri with path "%s" could not be found.', rtrim($parentHttpRequest->getBaseUri(), '/') . '/' . $language . $path), 1426446160);
}
$response = new Response();
$objectManager = $this->bootstrap->getObjectManager();
$baseComponentChain = $objectManager->get('TYPO3\\Flow\\Http\\Component\\ComponentChain');
$componentContext = new ComponentContext($request, $response);
$baseComponentChain->handle($componentContext);
return $response->getContent();
}
示例11: registerExtractionSlot
/**
* Registers slots for signals in order to be able to index nodes
*
* @param Bootstrap $bootstrap
*/
public function registerExtractionSlot(Bootstrap $bootstrap)
{
$configurationManager = $bootstrap->getObjectManager()->get(ConfigurationManager::class);
$settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->getPackageKey());
if (isset($settings['realtimeExtraction']['enabled']) && $settings['realtimeExtraction']['enabled'] === TRUE) {
$dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect(Asset::class, 'assetCreated', ExtractionManager::class, 'extractMetaData');
}
}
示例12: prepareRealtimeIndexing
/**
* @param \TYPO3\Flow\Core\Bootstrap $bootstrap
*/
public function prepareRealtimeIndexing(\TYPO3\Flow\Core\Bootstrap $bootstrap)
{
$this->configurationManager = $bootstrap->getObjectManager()->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
$settings = $this->configurationManager->getConfiguration(\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, $this->getPackageKey());
if (isset($settings['realtimeIndexing']['enabled']) && $settings['realtimeIndexing']['enabled'] === TRUE) {
$bootstrap->getSignalSlotDispatcher()->connect('Flowpack\\ElasticSearch\\Indexer\\Object\\Signal\\SignalEmitter', 'objectUpdated', 'Flowpack\\ElasticSearch\\Indexer\\Object\\ObjectIndexer', 'indexObject');
$bootstrap->getSignalSlotDispatcher()->connect('Flowpack\\ElasticSearch\\Indexer\\Object\\Signal\\SignalEmitter', 'objectPersisted', 'Flowpack\\ElasticSearch\\Indexer\\Object\\ObjectIndexer', 'indexObject');
$bootstrap->getSignalSlotDispatcher()->connect('Flowpack\\ElasticSearch\\Indexer\\Object\\Signal\\SignalEmitter', 'objectRemoved', 'Flowpack\\ElasticSearch\\Indexer\\Object\\ObjectIndexer', 'removeObject');
}
}
示例13: boot
/**
* @param \TYPO3\Flow\Core\Bootstrap $bootstrap The current bootstrap
* @return void
*/
public function boot(\TYPO3\Flow\Core\Bootstrap $bootstrap)
{
$dispatcher = $bootstrap->getSignalSlotDispatcher();
$dispatcher->connect('TYPO3\\Flow\\Mvc\\Dispatcher', 'afterControllerInvocation', function ($request) use($bootstrap) {
if (!$request instanceof \TYPO3\Flow\Mvc\ActionRequest || $request->getHttpRequest()->isMethodSafe() !== TRUE) {
$bootstrap->getObjectManager()->get('Radmiraal\\CouchDB\\CouchDBHelper')->flush();
}
});
$dispatcher->connect('TYPO3\\Flow\\Cli\\SlaveRequestHandler', 'dispatchedCommandLineSlaveRequest', 'Radmiraal\\CouchDB\\CouchDBHelper', 'flush');
}
示例14: resolveDependencies
/**
* Resolves a few dependencies of this request handler which can't be resolved
* automatically due to the early stage of the boot process this request handler
* is invoked at.
*
* @return void
*/
protected function resolveDependencies()
{
$objectManager = $this->bootstrap->getObjectManager();
$this->dispatcher = $objectManager->get('TYPO3\\Flow\\Mvc\\Dispatcher');
$configurationManager = $objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager');
$this->settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'TYPO3.Flow');
$this->routesConfiguration = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
$this->router = $objectManager->get('TYPO3\\Flow\\Mvc\\Routing\\Router');
$this->securityContext = $objectManager->get('TYPO3\\Flow\\Security\\Context');
}
示例15: cleanupPersistentResourcesDirectory
/**
* Cleans up the directory for storing persistent resources during testing
*
* @return void
* @throws \Exception
*/
protected function cleanupPersistentResourcesDirectory()
{
$settings = self::$bootstrap->getObjectManager()->get(\TYPO3\Flow\Configuration\ConfigurationManager::class)->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS);
$resourcesStoragePath = $settings['TYPO3']['Flow']['resource']['storages']['defaultPersistentResourcesStorage']['storageOptions']['path'];
if (strpos($resourcesStoragePath, FLOW_PATH_DATA) === false) {
throw new \Exception(sprintf('The storage path for persistent resources for the Testing context is "%s" but it must point to a directory below "%s". Please check the Flow settings for the Testing context.', $resourcesStoragePath, FLOW_PATH_DATA), 1382018388);
}
if (file_exists($resourcesStoragePath)) {
Files::removeDirectoryRecursively($resourcesStoragePath);
}
}