getEarlyInstance() public method

Returns an instance which was registered earlier through setEarlyInstance()
public getEarlyInstance ( string $objectName ) : object
$objectName string Object name of the registered instance
return object
 /**
  * Adds an HTTP header to the Response which indicates that the application is powered by Flow.
  *
  * @param Response $response
  * @return void
  */
 protected function addPoweredByHeader(Response $response)
 {
     if ($this->settings['http']['applicationToken'] === 'Off') {
         return;
     }
     $applicationIsFlow = $this->settings['core']['applicationPackageKey'] === 'Neos.Flow';
     if ($this->settings['http']['applicationToken'] === 'ApplicationName') {
         if ($applicationIsFlow) {
             $response->getHeaders()->set('X-Flow-Powered', 'Flow');
         } else {
             $response->getHeaders()->set('X-Flow-Powered', 'Flow ' . $this->settings['core']['applicationName']);
         }
         return;
     }
     /** @var Package $applicationPackage */
     /** @var Package $flowPackage */
     $flowPackage = $this->bootstrap->getEarlyInstance(PackageManagerInterface::class)->getPackage('Neos.Flow');
     $applicationPackage = $this->bootstrap->getEarlyInstance(PackageManagerInterface::class)->getPackage($this->settings['core']['applicationPackageKey']);
     if ($this->settings['http']['applicationToken'] === 'MajorVersion') {
         $flowVersion = $this->renderMajorVersion($flowPackage->getInstalledVersion());
         $applicationVersion = $this->renderMajorVersion($applicationPackage->getInstalledVersion());
     } else {
         $flowVersion = $this->renderMinorVersion($flowPackage->getInstalledVersion());
         $applicationVersion = $this->renderMinorVersion($applicationPackage->getInstalledVersion());
     }
     if ($applicationIsFlow) {
         $response->getHeaders()->set('X-Flow-Powered', 'Flow/' . ($flowVersion ?: 'dev'));
     } else {
         $response->getHeaders()->set('X-Flow-Powered', 'Flow/' . ($flowVersion ?: 'dev') . ' ' . $this->settings['core']['applicationName'] . '/' . ($applicationVersion ?: 'dev'));
     }
 }
Exemplo n.º 2
0
    /**
     * Display a message. As we cannot rely on any Flow requirements being fulfilled here,
     * we have to statically include the CSS styles at this point, and have to in-line the TYPO3 logo.
     *
     * @param array <\Neos\Error\Messages\Message> $messages Array of messages (at least one message must be passed)
     * @param string $extraHeaderHtml extra HTML code to include at the end of the head tag
     * @return void This method never returns.
     */
    public function showMessages(array $messages, $extraHeaderHtml = '')
    {
        if ($messages === []) {
            throw new \InvalidArgumentException('No messages given for rendering', 1416914970);
        }
        /** @var \Neos\Flow\Package\PackageManagerInterface $packageManager */
        $packageManager = $this->bootstrap->getEarlyInstance(\Neos\Flow\Package\PackageManagerInterface::class);
        $css = '';
        if ($packageManager->isPackageAvailable('Neos.Twitter.Bootstrap')) {
            $css .= file_get_contents($packageManager->getPackage('Neos.Twitter.Bootstrap')->getResourcesPath() . 'Public/3/css/bootstrap.min.css');
            $css = str_replace('url(../', 'url(/_Resources/Static/Packages/Neos.Twitter.Bootstrap/3.0/', $css);
        }
        if ($packageManager->isPackageAvailable('Neos.Setup')) {
            $css .= file_get_contents($packageManager->getPackage('Neos.Setup')->getResourcesPath() . 'Public/Styles/Setup.css');
            $css = str_replace('url(\'../', 'url(\'/_Resources/Static/Packages/Neos.Setup/', $css);
        }
        echo '<html>';
        echo '<head>';
        echo '<title>Setup message</title>';
        echo '<style type="text/css">';
        echo $css;
        echo '</style>';
        echo $extraHeaderHtml;
        echo '</head>';
        echo '<body>';
        $renderedMessages = $this->renderMessages($messages);
        $lastMessage = end($messages);
        echo sprintf('
			<div class="logo"></div>
			<div class="well">
				<div class="container">
					<ul class="breadcrumb">
						<li><a class="active">Setup</a></li>
					</ul>
					<h3>%s</h3>
					<div class="t3-module-container indented">
						%s
					</div>
				</div>
			</div>
			', $lastMessage->getTitle(), $renderedMessages);
        echo '</body></html>';
        exit(0);
    }
 /**
  * Emits a signal when package states have been changed (e.g. when a package was created or activated)
  *
  * The advice is not proxyable, so the signal is dispatched manually here.
  *
  * @return void
  * @Flow\Signal
  */
 protected function emitPackageStatesUpdated()
 {
     if ($this->bootstrap === null) {
         return;
     }
     if ($this->dispatcher === null) {
         $this->dispatcher = $this->bootstrap->getEarlyInstance(Dispatcher::class);
     }
     $this->dispatcher->dispatch(PackageManager::class, 'packageStatesUpdated');
 }
Exemplo n.º 4
0
 /**
  * @param Bootstrap $bootstrap The current bootstrap
  * @return void
  */
 public function boot(Bootstrap $bootstrap)
 {
     $dispatcher = $bootstrap->getSignalSlotDispatcher();
     $flushConfigurationCache = function () use($bootstrap) {
         $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
         $cacheManager->getCache('TYPO3_Neos_Configuration_Version')->flush();
     };
     $flushXliffServiceCache = function () use($bootstrap) {
         $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
         $cacheManager->getCache('TYPO3_Neos_XliffToJsonTranslations')->flush();
     };
     $dispatcher->connect(FileMonitor::class, 'filesHaveChanged', function ($fileMonitorIdentifier, array $changedFiles) use($flushConfigurationCache, $flushXliffServiceCache) {
         switch ($fileMonitorIdentifier) {
             case 'TYPO3CR_NodeTypesConfiguration':
             case 'Flow_ConfigurationFiles':
                 $flushConfigurationCache();
                 break;
             case 'Flow_TranslationFiles':
                 $flushConfigurationCache();
                 $flushXliffServiceCache();
         }
     });
     $dispatcher->connect(Site::class, 'siteChanged', $flushConfigurationCache);
     $dispatcher->connect(Site::class, 'siteChanged', RouterCachingService::class, 'flushCaches');
     $dispatcher->connect(Node::class, 'nodeUpdated', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodeAdded', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodeRemoved', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'beforeNodeMove', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(AssetService::class, 'assetResourceReplaced', ContentCacheFlusher::class, 'registerAssetResourceChange');
     $dispatcher->connect(Node::class, 'nodeAdded', NodeUriPathSegmentGenerator::class, '::setUniqueUriPathSegment');
     $dispatcher->connect(Node::class, 'nodePropertyChanged', Service\ImageVariantGarbageCollector::class, 'removeUnusedImageVariant');
     $dispatcher->connect(Node::class, 'nodePropertyChanged', function (NodeInterface $node, $propertyName) use($bootstrap) {
         if ($propertyName === 'uriPathSegment') {
             NodeUriPathSegmentGenerator::setUniqueUriPathSegment($node);
             $bootstrap->getObjectManager()->get(RouteCacheFlusher::class)->registerNodeChange($node);
         }
     });
     $dispatcher->connect(Node::class, 'nodePathChanged', function (NodeInterface $node, $oldPath, $newPath, $recursion) {
         if (!$recursion) {
             NodeUriPathSegmentGenerator::setUniqueUriPathSegment($node);
         }
     });
     $dispatcher->connect(PublishingService::class, 'nodePublished', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodeDiscarded', ContentCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodePathChanged', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(Node::class, 'nodeRemoved', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodeDiscarded', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodePublished', RouteCacheFlusher::class, 'registerNodeChange');
     $dispatcher->connect(PublishingService::class, 'nodePublished', function ($node, $targetWorkspace) use($bootstrap) {
         $cacheManager = $bootstrap->getObjectManager()->get(CacheManager::class);
         if ($cacheManager->hasCache('Flow_Persistence_Doctrine')) {
             $cacheManager->getCache('Flow_Persistence_Doctrine')->flush();
         }
     });
     $dispatcher->connect(PersistenceManager::class, 'allObjectsPersisted', RouteCacheFlusher::class, 'commit');
     $dispatcher->connect(SiteService::class, 'sitePruned', ContentCache::class, 'flush');
     $dispatcher->connect(SiteService::class, 'sitePruned', RouterCachingService::class, 'flushCaches');
     $dispatcher->connect(SiteImportService::class, 'siteImported', ContentCache::class, 'flush');
     $dispatcher->connect(SiteImportService::class, 'siteImported', RouterCachingService::class, 'flushCaches');
     // Eventlog
     $dispatcher->connect(Node::class, 'beforeNodeCreate', ContentRepositoryIntegrationService::class, 'beforeNodeCreate');
     $dispatcher->connect(Node::class, 'afterNodeCreate', ContentRepositoryIntegrationService::class, 'afterNodeCreate');
     $dispatcher->connect(Node::class, 'nodeUpdated', ContentRepositoryIntegrationService::class, 'nodeUpdated');
     $dispatcher->connect(Node::class, 'nodeRemoved', ContentRepositoryIntegrationService::class, 'nodeRemoved');
     $dispatcher->connect(Node::class, 'beforeNodePropertyChange', ContentRepositoryIntegrationService::class, 'beforeNodePropertyChange');
     $dispatcher->connect(Node::class, 'nodePropertyChanged', ContentRepositoryIntegrationService::class, 'nodePropertyChanged');
     $dispatcher->connect(Node::class, 'beforeNodeCopy', ContentRepositoryIntegrationService::class, 'beforeNodeCopy');
     $dispatcher->connect(Node::class, 'afterNodeCopy', ContentRepositoryIntegrationService::class, 'afterNodeCopy');
     $dispatcher->connect(Node::class, 'beforeNodeMove', ContentRepositoryIntegrationService::class, 'beforeNodeMove');
     $dispatcher->connect(Node::class, 'afterNodeMove', ContentRepositoryIntegrationService::class, 'afterNodeMove');
     $dispatcher->connect(Context::class, 'beforeAdoptNode', ContentRepositoryIntegrationService::class, 'beforeAdoptNode');
     $dispatcher->connect(Context::class, 'afterAdoptNode', ContentRepositoryIntegrationService::class, 'afterAdoptNode');
     $dispatcher->connect(Workspace::class, 'beforeNodePublishing', ContentRepositoryIntegrationService::class, 'beforeNodePublishing');
     $dispatcher->connect(Workspace::class, 'afterNodePublishing', ContentRepositoryIntegrationService::class, 'afterNodePublishing');
     $dispatcher->connect(PersistenceManager::class, 'allObjectsPersisted', ContentRepositoryIntegrationService::class, 'updateEventsAfterPublish');
     $dispatcher->connect(NodeDataRepository::class, 'repositoryObjectsPersisted', ContentRepositoryIntegrationService::class, 'updateEventsAfterPublish');
 }
<?php

/*
 * This file configures dynamic return type support for factory methods in PhpStorm
 */
namespace PHPSTORM_META;

$STATIC_METHOD_TYPES = [\Neos\Flow\ObjectManagement\ObjectManagerInterface::get('') => ['' == '@'], \Neos\Flow\Core\Bootstrap::getEarlyInstance('') => ['' == '@']];
 /**
  * Update Doctrine 2 proxy classes
  *
  * This is not simply bound to the finishedCompilationRun signal because it
  * needs the advised proxy classes to run. When that signal is fired, they
  * have been written, but not loaded.
  *
  * @param Bootstrap $bootstrap
  * @return void
  */
 protected static function compileDoctrineProxies(Bootstrap $bootstrap)
 {
     $cacheManager = $bootstrap->getEarlyInstance(CacheManager::class);
     $objectConfigurationCache = $cacheManager->getCache('Flow_Object_Configuration');
     $coreCache = $cacheManager->getCache('Flow_Core');
     $systemLogger = $bootstrap->getEarlyInstance(SystemLoggerInterface::class);
     $configurationManager = $bootstrap->getEarlyInstance(ConfigurationManager::class);
     $settings = $configurationManager->getConfiguration(ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, 'Neos.Flow');
     if ($objectConfigurationCache->has('doctrineProxyCodeUpToDate') === false && $coreCache->has('doctrineSetupRunning') === false) {
         $coreCache->set('doctrineSetupRunning', 'White Russian', [], 60);
         $systemLogger->log('Compiling Doctrine proxies', LOG_DEBUG);
         self::executeCommand('neos.flow:doctrine:compileproxies', $settings);
         $coreCache->remove('doctrineSetupRunning');
         $objectConfigurationCache->set('doctrineProxyCodeUpToDate', true);
     }
 }
 /**
  * Helper method to create a FileMonitor instance during boot sequence as injections have to be done manually.
  *
  * @param string $identifier
  * @param Bootstrap $bootstrap
  * @return FileMonitor
  */
 public static function createFileMonitorAtBoot($identifier, Bootstrap $bootstrap)
 {
     $fileMonitorCache = $bootstrap->getEarlyInstance(CacheManager::class)->getCache('Flow_Monitor');
     // The change detector needs to be instantiated and registered manually because
     // it has a complex dependency (cache) but still needs to be a singleton.
     $fileChangeDetector = new ChangeDetectionStrategy\ModificationTimeStrategy();
     $fileChangeDetector->injectCache($fileMonitorCache);
     $bootstrap->getObjectManager()->registerShutdownObject($fileChangeDetector, 'shutdownObject');
     $fileMonitor = new FileMonitor($identifier);
     $fileMonitor->injectCache($fileMonitorCache);
     $fileMonitor->injectChangeDetectionStrategy($fileChangeDetector);
     $fileMonitor->injectSignalDispatcher($bootstrap->getEarlyInstance(Dispatcher::class));
     $fileMonitor->injectSystemLogger($bootstrap->getEarlyInstance(SystemLoggerInterface::class));
     return $fileMonitor;
 }