{@inheritDoc}

Setup the autoloader for namespaces and prevent modification of the readonly namespaces

@throws \LogicException Trying to change a readonly namespace
489931
protected function search( StorageMeta $meta, bool $build = false, bool $is_read = true ): StorageMetaSearch {
    $namespace = $this->getNamespace( $meta->namespace );

    // prevent every write operation if the namespace is 'readonly'
    if( !$is_read && ( $namespace[ 'readonly' ] ?? false ) ) {
      throw new \LogicException( "Failed to edit the storage, the '{$meta->namespace}' is readonly" );
    }

    // try to load the storage data if there is no already
    if( ( $namespace[ 'autoload' ] ?? true ) && !in_array( $meta->namespace, $this->protect ) ) {
      $this->protect[] = $meta->namespace;

      if( !isset( $this[ $meta->namespace . static::SEPARATOR_NAMESPACE ] ) ) {
        $this->load( [ $meta->namespace ] );
      }

      // release protection
      array_pop( $this->protect );
    }

    // delegate problem to the parent
    return parent::search( $meta, $build, $is_read );
  }
127586
protected function initializeBundles()
    {
        // init bundles
        $this->bundles = [];
        foreach ($this->registerBundles() as $bundle) {
            $name = $bundle->getName();
            if (isset($this->bundles[$name])) {
                throw new \LogicException(sprintf('Trying to register two bundles with the same name "%s"', $name));
            }
            $this->bundles[$name] = $bundle;
        }
    }
1077509
public function setNamespace($v)
    {
        if ($v == $this->namespace) {
            return;
        }
        $this->namespace = $v;
        if ($v && (!$this->pkg || $this->pkgOverridden) && $this->getBuildProperty('namespaceAutoPackage')) {
            $this->pkg = str_replace('\\', '.', $v);
            $this->pkgOverridden = true;
        }
    }
579308
protected function add($class, $friendlyName, $supportsEntityLevelPermissions, array $supportedAttributes, array $options = [])
    {
        if (array_key_exists($class, $this->configuration) === true) {
            throw new LogicException(vsprintf(self::CLASS_ALREADY_ADDED, [$this->getFriendlyName(), $class]));
        }

        $this->configuration[$class] = ['friendly_name' => $friendlyName, 'code_name' => $this->convertClassPathToUnderscoredPath($class), 'entity_level_permissions' => $supportsEntityLevelPermissions, 'attributes' => $supportedAttributes, 'options' => $options];

        return $this;
    }
604299
public function autoload( $class ) {

		// Iterate over namespaces to find a match.
		foreach ( $this->namespaces as $namespace ) {

			// Move on if the object does not belong to the current namespace.
			if ( 0 !== strpos( $class, $namespace['root'] ) ) {
				continue;
			}

			// Remove namespace root level to correspond with root filesystem, and
			// replace the namespace separator "\" by the system-dependent directory separator.
			$filename = str_replace(
				array( $namespace['root'], '\\' ),
				array( '', DIRECTORY_SEPARATOR ),
				$class
			);

			// Remove a leading backslash from the class name.
			$filename = $this->remove_leading_backslash( $filename );

			// Change to lower case if requested.
			if ( $namespace['lowercase'] ) {
				$filename = strtolower( $filename );
			}

			// Change underscores into hyphens if requested.
			if ( $namespace['underscores'] ) {
				$filename = str_replace( '_', '-', $filename );
			}

			// Add base_dir, prefix and suffix.
			$filepath = $namespace['base_dir']
				. $namespace['prefix']
				. $filename
				. $namespace['suffix'];

			// Throw an exception if the file does not exist or is not readable.
			if ( is_readable( $filepath ) ) {
				require_once $filepath;
			}
		}
	}
760545
public static function setNamespaces($namespaces)
    {
        $called = get_called_class();

        if (!$namespaces instanceof PriorityQueue) {
            $namespaces = new PriorityQueue();
        }

        static::$namespaces[$called] = $namespaces;
    }
411105
private function updateNamespace(): void
    {
        //now path is totally sorted, update namespace based on path
        foreach ($this->filesCreated as $filePath) {
            $this->findAndReplaceHelper->setNamespaceFromPath(
                $filePath,
                $this->srcSubFolderName,
                $this->projectRootNamespace
            );
        }
    }
1193376
public function beforeCompile()
	{
		$builder = $this->getContainerBuilder();

		if (!$builder->getByType(Application::class)) {
			throw new LogicException(sprintf('Service of type "%s" is needed. Please register it.', Application::class));
		}

		if (!$builder->getByType(EventDispatcher::class)) {
			throw new LogicException(sprintf('Service of type "%s" is needed. Please register it.', EventDispatcher::class));
		}

		$application = $builder->getDefinition($builder->getByType(Application::class));
		$dispatcher = $builder->getDefinition($builder->getByType(EventDispatcher::class));

		$application->addSetup('?->onStartup[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			ApplicationEvents::ON_STARTUP,
			new PhpLiteral(StartupEvent::class),
		]);
		$application->addSetup('?->onError[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			ApplicationEvents::ON_ERROR,
			new PhpLiteral(ErrorEvent::class),
		]);
		$application->addSetup('?->onPresenter[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			ApplicationEvents::ON_PRESENTER,
			new PhpLiteral(PresenterEvent::class),
		]);
		$application->addSetup('?->onRequest[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			ApplicationEvents::ON_REQUEST,
			new PhpLiteral(RequestEvent::class),
		]);
		$application->addSetup('?->onResponse[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			ApplicationEvents::ON_RESPONSE,
			new PhpLiteral(ResponseEvent::class),
		]);
		$application->addSetup('?->onShutdown[] = function() {?->dispatch(?, new ?(...func_get_args()));}', [
			'@self',
			$dispatcher,
			ApplicationEvents::ON_SHUTDOWN,
			new PhpLiteral(ShutdownEvent::class),
		]);
	}
1348123
public function loadNamespaces()
    {
        $data       = json_decode(file_get_contents(base_path('composer.json')), JSON_OBJECT_AS_ARRAY);
        $namespaces = array_get($data, 'autoload.psr-4');
        $this->setNamespaces($namespaces);
        return $this;
    }
689594
private function initLoaders()
    {
        $namespace = sprintf('%s\\ServiceLoader', __NAMESPACE__);
        $classes = ['MetadataCache', 'MetadataDrivers', 'MetadataFactory', 'Persisters', 'Rest', 'SearchClients'];

        foreach ($classes as $class) {
            $fqcn = sprintf('%s\\%s', $namespace, $class);
            $this->addLoader(new $fqcn);
        }
        return $this;
    }
1032786
protected function updateIndex()
    {
        $configurator = $this->getIndexConfigurator();

        $indexPayload = (new IndexPayload($configurator))->get();

        $indices = ElasticClient::indices();

        if (! $indices->exists($indexPayload)) {
            throw new LogicException(sprintf(
                'Index %s doesn\'t exist',
                $configurator->getName()
            ));
        }

        try {
            $indices->close($indexPayload);

            if ($settings = $configurator->getSettings()) {
                $indexSettingsPayload = (new IndexPayload($configurator))
                    ->set('body.settings', $settings)
                    ->get();

                $indices->putSettings($indexSettingsPayload);
            }

            if ($defaultMapping = $configurator->getDefaultMapping()) {
                $indexMappingPayload = (new IndexPayload($configurator))
                    ->set('type', '_default_')
                    ->set('body._default_', $defaultMapping)
                    ->get();

                $indices->putMapping($indexMappingPayload);
            }

            $indices->open($indexPayload);
        } catch (Exception $exception) {
            $indices->open($indexPayload);

            throw $exception;
        }

        $this->info(sprintf(
            'The index %s was updated!',
            $configurator->getName()
        ));
    }
109820
protected function initialize()
    {
        if ('input' !== $this->node->nodeName) {
            throw new \LogicException(sprintf('A FileFormField can only be created from an input tag (%s given).', $this->node->nodeName));
        }

        if ('file' !== strtolower($this->node->getAttribute('type'))) {
            throw new \LogicException(sprintf('A FileFormField can only be created from an input tag with a type of file (given type is %s).', $this->node->getAttribute('type')));
        }

        $this->setValue(null);
    }
631994
function initAutoload(LoaderAutoloadAggregate $baseAutoloader)
    {
        #$nameSpaceLoader = \Poirot\Loader\Autoloader\LoaderAutoloadNamespace::class;
        $nameSpaceLoader = 'Poirot\Loader\Autoloader\LoaderAutoloadNamespace';
        /** @var LoaderAutoloadNamespace $nameSpaceLoader */
        $nameSpaceLoader = $baseAutoloader->loader($nameSpaceLoader);
        $nameSpaceLoader->addResource(__NAMESPACE__, __DIR__);


        require_once __DIR__.'/_functions.php';
    }
1249645
public function setNamespace($namespace)
    {
        if ($namespace === null || $namespace === '' || $namespace === '\\') {
            $this->namespace = null;

            return;
        }

        if ($namespace[0] === '\\') {
            $namespace = substr($namespace, 1);
        }

        if ($this->isNamespaceValid($namespace) !== true) {
            throw new InvalidArgumentException('Namespace name is not valid.');
        }

        $this->namespace = $namespace;
    }
706469
public function toModel()
    {
        $nodeClass = $this->getElement()->NodeClass;
        if ($nodeClass === 'Node') {
            throw new LogicException('You must set a custom node in <node_class/> for element: ' . $this->getElement()->getSlug());
        } else {
            throw new LogicException('You must create a toModel method in: ' . $nodeClass);
        }
    }
374740
private function setup()
    {
        $loader = new FilesystemLoader(GeneratorHelper::getTemplatePath());
        $this->tpl = new Environment($loader, array(
            'cache' => CACHE_DIR . DIRECTORY_SEPARATOR . 'twig',
            'debug' => (bool)$this->debug,
            'auto_reload' => Config::getParam('twig.autoreload', TRUE),
        ));
        $this->loadDomains();
    }
1012486
public function renderLoader(): void
    {
        if (!$this->useSession) {
            throw new \LogicException('Start session before Tracy is enabled.');
        }
        $contentId = $this->contentId = $this->contentId ?: \substr(\md5(\uniqid('', true)), 0, 10);
        $nonce = Helpers::getNonce();
        $async = true;
        require __DIR__ . '/assets/Bar/loader.phtml';
    }