当前位置: 首页>>代码示例>>PHP>>正文


PHP Bootstrap::getObjectManager方法代码示例

本文整理汇总了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'));
         }
     });
 }
开发者ID:sandstorm,项目名称:gedmotranslatableconnector,代码行数:32,代码来源:Package.php

示例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);
     }
 }
开发者ID:mkeitsch,项目名称:flow-development-collection,代码行数:41,代码来源:SlaveRequestHandler.php

示例3: __construct

 /**
  */
 public function __construct()
 {
     if (self::$bootstrap === NULL) {
         self::$bootstrap = $this->initializeFlow();
     }
     $this->objectManager = self::$bootstrap->getObjectManager();
 }
开发者ID:HofUniversityIWS,项目名称:backend,代码行数:9,代码来源:FlowContext.php

示例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;
 }
开发者ID:sixty-nine,项目名称:CDSRC.Libraries,代码行数:19,代码来源:GeneralUtility.php

示例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');
 }
开发者ID:sokunthearith,项目名称:Intern-Project-Week-2,代码行数:15,代码来源:CommandRequestHandler.php

示例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;
 }
开发者ID:vjanoch,项目名称:flow-development-collection,代码行数:42,代码来源:InternalRequestEngine.php

示例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');
 }
开发者ID:sengkimlong,项目名称:Flow3-Authentification,代码行数:14,代码来源:RequestHandler.php

示例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);
 }
开发者ID:cerlestes,项目名称:flow-development-collection,代码行数:13,代码来源:PackageManager.php

示例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);
 }
开发者ID:Weissheiten,项目名称:flow-development-collection,代码行数:15,代码来源:CommandRequestHandler.php

示例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();
 }
开发者ID:neos-helpers,项目名称:Helper.NotFound,代码行数:37,代码来源:NotFoundViewHelper.php

示例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');
     }
 }
开发者ID:neos,项目名称:metadata-extractor,代码行数:14,代码来源:Package.php

示例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');
     }
 }
开发者ID:johannessteu,项目名称:Flowpack.ElasticSearch,代码行数:13,代码来源:Package.php

示例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');
 }
开发者ID:rfyio,项目名称:Radmiraal.CouchDB,代码行数:14,代码来源:Package.php

示例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');
 }
开发者ID:animaltool,项目名称:webinterface,代码行数:17,代码来源:RequestHandler.php

示例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);
     }
 }
开发者ID:robertlemke,项目名称:flow-development-collection,代码行数:17,代码来源:FunctionalTestCase.php


注:本文中的TYPO3\Flow\Core\Bootstrap::getObjectManager方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。