Enable Gedmo Doctrine Extensions

@param array $namespaces
@param bool  $all
347552
public function bootGedmoExtensions($namespaces = ['App'], $all = true)
    {
        if ($all) {
            DoctrineExtensions::registerMappingIntoDriverChainORM(
                $this->chain,
                $this->reader
            );
        } else {
            DoctrineExtensions::registerAbstractMappingIntoDriverChainORM(
                $this->chain,
                $this->reader
            );
        }

        $driver = $this->metadata->getMetadataDriverImpl();
        foreach ($namespaces as $namespace) {
            $this->chain->addDriver($driver, $namespace);
        }
        $this->metadata->setMetadataDriverImpl($this->chain);

        $this->dispatcher->fire('doctrine.driver-chain::booted', [
            $driver,
            $this->chain
        ]);
    }
626436
public function enableFilters(array $names) {
        foreach ($names as $name) {
            $filter = array_get($this->filters, $name);

            if ( ! $filter instanceof IRouteFilter) {
                throw new FilterNotFoundException(
                    s('Filter with name %s not found.', $name)
                );
            }

            $filter->setEnabled(true);
        }
    }
525659
private function createGroups(array $namespaces)
    {
        $groups = [];

        foreach ($this->groups as $group) {
            if (is_array($group)) {
                $groups[] = array_fill_keys($group, []);
            } else {
                $groups[$group] = [];
            }
        }

        if (!array_key_exists('_main', $groups)) {
            $groups = array_merge(
                ['_main' => []],
                $groups
            );
        }

        foreach ($namespaces as $namespace) {
            foreach ($groups as $groupKey => $group) {
                if (is_int($groupKey)) {
                    foreach ($group as $subGroupKey => $subGroup) {
                        if (strpos($namespace, $subGroupKey) === 0) {
                            array_push($groups[$groupKey][$subGroupKey], $namespace);

                            continue 3;
                        }
                    }
                } elseif (is_string($groupKey) && strpos($namespace, $groupKey) === 0) {
                    array_push($groups[$groupKey], $namespace);

                    continue 2;
                }
            }

            array_push($groups['_main'], $namespace);
        }

        return $groups;
    }
672645
public function autodiscover(): void
    {
        $entityMappings = [];
        foreach ($this->fileSystem->getEntityDirectories() as $entityDirectory) {
            $namespace = $this->namespaceDetector->detectFromDirectory($entityDirectory);
            if (! $namespace) {
                continue;
            }

            $entityMappings[] = [
                'name' => $namespace, // required name
                'prefix' => $namespace,
                'type' => 'annotation',
                'dir' => $entityDirectory->getRealPath(),
                'is_bundle' => false, // performance
            ];
        }

        $xmlNamespaces = [];

        $directoryByNamespace = $this->resolveDirectoryByNamespace($this->fileSystem->getEntityXmlFiles());
        foreach ($directoryByNamespace as $namespace => $directory) {
            if (in_array($namespace, $xmlNamespaces, true)) {
                continue;
            }

            $xmlNamespaces[] = $namespace;

            $entityMappings[] = [
                'name' => $namespace, // required name
                'prefix' => $namespace,
                'type' => 'xml',
                'dir' => $directory,
                'is_bundle' => false,
            ];
        }

        if (! count($entityMappings)) {
            return;
        }

        // @see https://symfony.com/doc/current/reference/configuration/doctrine.html#mapping-entities-outside-of-a-bundle
        $this->containerBuilder->prependExtensionConfig('doctrine', [
            'orm' => ['mappings' => $entityMappings],
        ]);
    }
74411
public static function AddHelpersNamespaces ($helperNamespaces) {
		if (!static::$helpersNamespaces) self::_initHelpersNamespaces();
		$args = func_get_args();
		if (count($args) === 1 && is_array($args[0])) $args = $args[0];
		foreach ($args as $arg)
			static::$helpersNamespaces[] = '\\' . trim($arg, '\\') . '\\';
	}
1276177
public static function add_namespaces(array $namespaces, $prepend = false)
	{
		if ( ! $prepend)
		{
			static::$namespaces = array_merge(static::$namespaces, $namespaces);
		}
		else
		{
			static::$namespaces = $namespaces + static::$namespaces;
		}
	}
236128
protected function generateNamespaceContext(array & $tokens)
	{
		$namespaceContext = new NamespaceContext();
		
		for($size = count($tokens), $i = 0; $i < $size; $i++)
		{
			if(is_array($tokens[$i]))
			{
				switch($tokens[$i][0])
				{
					case T_NAMESPACE:
						
						$namespace = '';
						
						for($i++; $i < $size; $i++)
						{
							if(is_array($tokens[$i]))
							{
								switch($tokens[$i][0])
								{
									case T_WHITESPACE:
									case T_COMMENT:
									case T_DOC_COMMENT:
										continue 2;
									case T_NS_SEPARATOR:
									case T_STRING:
										$namespace .= $tokens[$i][1];
										continue 2;
								}
							}
							
							break;
						}
						
						$namespaceContext = new NamespaceContext($namespace);
						
						break;
					case T_USE:
						do
						{
							$i++;
							$this->readImport($tokens, $i, $namespaceContext);
						}
						while($tokens[$i] == ',');
						
						break;
					case T_CLASS:
					case T_INTERFACE:
					case T_TRAIT:
						// Abort namespace detection as soon as code declaring a type is reached.
						break 2;
				}
			}
		}
		
		return $namespaceContext;
	}
364313
public function setPaths($paths, $namespace = self::DEFAULT_NAMESPACE)
    {
        if (! is_array($paths)) {
            $paths = [$paths];
        }
        $this->paths[$namespace] = [];
        foreach ($paths as $path) {
            $this->addPath($path, $namespace);
        }
    }
373219
public function registerComposerNamespaces(array $namespaces) {
		foreach ($namespaces as $namespace => $dirs) {
			$namespaceDir = trim($namespace, '\ ');
			$namespaceDir = str_replace('\\', DIRECTORY_SEPARATOR, $namespaceDir);
			
			foreach ($dirs as $dir) {
				$dir .= DIRECTORY_SEPARATOR . $namespaceDir;
				
				$this->registerNamespace($namespace, $dir);
			}
		}
		
		return $this;
	}
466644
function setResources(array $namespaces)
    {
        # previous registered keys not replaced
        $this->_t_loader_namespacestack_Namespaces = array_merge_recursive(
            $this->_t_loader_namespacestack_Namespaces
            , $namespaces
        );

        ## clear matched resource cache
        $this->_t_loader_namespacestack_cache_Matched = array();

        return $this;
    }
585807
public function setNamespaces($namespaces)
    {
        if (!$namespaces instanceof PriorityQueue) {
            $namespaces = new PriorityQueue($namespaces);
        }

        $this->namespaces = $namespaces;

        return $this;
    }
99615
public function addNamespace (string $namespace, string $directory, bool $failOnMissingDir = self::THROW_ON_MISSING) : void
    {
        if (isset($this->namespaces[$namespace]))
        {
            throw new AssetsException(sprintf(
                "Duplicate registration of namespace '%s'.",
                $namespace
            ));
        }

        if (!is_dir($directory))
        {
            if (self::THROW_ON_MISSING === $failOnMissingDir)
            {
                throw new AssetsException(sprintf(
                    "Can't find assets dir when registering namespace '%s': %s",
                    $namespace,
                    $directory
                ));
            }

            return;
        }

        $this->namespaces[$namespace] = $directory;
    }
447661
public function registerCommandNamespaces(array $commandNamespaces)
    {
        foreach ($commandNamespaces as $command => $responsible) {
            $this->registerCommandNamespace($commandNamespaces, $responsible);
        }

        return $this;
    }
749863
public function register_namespace( $namespace, $paths )
    {
        if ( isset( $this->namespaces[ $namespace ] ) )
        {
            $this->namespaces[ $namespace ] = array_merge(
                $this->namespaces[ $namespace ],
                (array) $paths
            );
        } 
        else 
        {
            $this->namespaces[ $namespace ] = (array) $paths;
            
            // Register PSR_0 as the first autoload filter for every namespace
            $this->register_autoload_filter( $namespace, array( $this, "PSR_0" ) );
        }
    }
485503
public function hasClassExtension(string $namespace): bool
    {
        $hasClassExtension = false;

        if ($this->hasSetting(ModuleSetting::CLASS_EXTENSIONS)) {
            $classExtensions = $this
                ->getSetting(ModuleSetting::CLASS_EXTENSIONS)
                ->getValue();

            $hasClassExtension = in_array($namespace, $classExtensions, true);
        }

        return $hasClassExtension;
    }
538805
public function addNamespaces(array $namespaces): void
    {
        //loop for add single namespace
        foreach ($namespaces as $namespace) {

            // normalize namespace prefix
            $prefix = \trim($namespace[0], '\\');

            // normalize the base directory with a trailing separator
            $baseDir = \rtrim($namespace[1], DIRECTORY_SEPARATOR).'/';

            //add namespace
            $this->prefixes[$prefix] = $baseDir;
        }
    }
1073404
public function setNamespaces($namespaces)
    {
        $this->set(self::KEY_NAMESPACES, $namespaces);
        $this->provisioningMode = self::PROVISIONING_MODE_NAMESPACES;
        return $this;
    }