@param Finder $finder
@param string $bundleNamespace
@param string $suffixLogNamespace
@param string $restriction

@return array
332086
protected function getEventsByBundle(Finder $finder, $bundleNamespace, $suffixLogNamespace, $restriction)
    {
        $events = [];

        /** @var \Symfony\Component\Finder\SplFileInfo $file */
        foreach ($finder as $file) {
            $classNamespace = $bundleNamespace
                .$suffixLogNamespace
                .'\\'
                .$file->getBasename('.'.$file->getExtension());

            if (in_array('Claroline\CoreBundle\Event\Log\LogGenericEvent', class_parents($classNamespace))) {
                $events = array_merge($events, $this->getActionConstantsForClass($classNamespace, $restriction));
            }
        }

        return $events;
    }
1305022
public function getDescriptor(string $classNamespace): ?Descriptor
    {
        if (!$this->isEmpty()) {
            /** @var Descriptor $descriptor */
            foreach ($this as $rootNamespace => $descriptor) {
                $rootNamespace = $descriptor->getRootNamespace();

                $doubleSlashed = str_replace('\\', '\\\\', $rootNamespace);
                $pattern = sprintf('|^%s\\.*|', $doubleSlashed);

                if (preg_match($pattern, $classNamespace)) {
                    return $descriptor;
                }
            }
        }

        return null;
    }
500310
protected function init(DOMElement $restriction)
    {
        $conditionNodes = XmlUtil::getChildElements($restriction, 'conditions');

        foreach ($conditionNodes as $condition) {
            $conditionDescriptor = DescriptorFactory::getFactory()->createConditionsDescriptor($condition);
            $conditionDescriptor->setParent($this);
            $this->conditions->attach($conditionDescriptor);
        }
    }
372732
private function getBundle(string $locale, string $namespace)
    {
        assert(empty($locale) === false && empty($namespace) === false);

        $bundles   = $this->getBundles();
        $hasBundle = isset($bundles[$locale][$namespace]) === true;
        $result    = $hasBundle === true ? $bundles[$locale][$namespace] : null;

        return $result;
    }
423806
public function getFiles(string $location, string $pattern = null, Finder $finder = null): array
    {
        $finder = $finder ?? new Finder();
        $finder->files()->in($location);

        if (!empty($pattern)) {
            $finder->name($pattern);
        }

        $result = [];
        foreach ($finder->getIterator() as $file) {
            $result[] = $this->normalizePath((string)$file);
        }

        return $result;
    }
17342
public function load( $locale, $group, $namespace = null )
	{
		$namespace = $namespace ?: '*';

		if ( isset( $this->messages[$namespace][$locale][$group] ) )
		{
			return $this->messages[$namespace][$locale][$group];
		}

		return [];
	}
981798
public function generate($namespace, $bundle, $dir, $format, $structure, $dbDriver)
    {
        $dir .= '/'.strtr($namespace, '\\', '/');
        if (file_exists($dir)) {
            if (!is_dir($dir)) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" exists but is a file.', realpath($dir)));
            }
            $files = scandir($dir);
            if ($files != array('.', '..')) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not empty.', realpath($dir)));
            }
            if (!is_writable($dir)) {
                throw new \RuntimeException(sprintf('Unable to generate the bundle as the target directory "%s" is not writable.', realpath($dir)));
            }
        }

        $driverDir = array(
            'orm' => 'Entity',
            'mongodb' => 'Document',
            'couchdb' => 'CouchDocument',
            'custom' => 'Model',
        );

        $basename = substr($bundle, 0, -6);
        $parameters = array(
            'namespace' => $namespace,
            'bundle' => $bundle,
            'format' => $format,
            'db_driver' => $dbDriver,
            'model_namespace' => $namespace.'\\'.$driverDir[$dbDriver],
            'bundle_basename' => $basename,
            'extension_alias' => Container::underscore($basename),
        );

        $this->renderFile('bundle/Bundle.php.twig', $dir.'/'.$bundle.'.php', $parameters);
        $this->renderFile('bundle/Extension.php.twig', $dir.'/DependencyInjection/'.$basename.'Extension.php', $parameters);
        $this->renderFile('bundle/Configuration.php.twig', $dir.'/DependencyInjection/Configuration.php', $parameters);
        $this->renderFile('bundle/DefaultController.php.twig', $dir.'/Controller/DefaultController.php', $parameters);
        $this->renderFile('bundle/DefaultControllerTest.php.twig', $dir.'/Tests/Controller/DefaultControllerTest.php', $parameters);
        $this->renderFile('bundle/index.html.twig.twig', $dir.'/Resources/views/Default/index.html.twig', $parameters);
        $this->renderFile('bundle/services.'.$format.'.twig', $dir.'/Resources/config/services.'.$format, $parameters);

        $this->generateRoutes($namespace, $bundle, $dir, $format, $basename);
        $this->generateModels($namespace, $bundle, $dir, $dbDriver, $basename);
        $this->generateEventsClass($namespace, $bundle, $dir, $dbDriver, $basename);

        if ($structure) {
            $this->renderFile('bundle/messages.fr.xlf', $dir.'/Resources/translations/messages.fr.xlf', $parameters);

            $this->filesystem->mkdir($dir.'/Resources/doc');
            $this->filesystem->touch($dir.'/Resources/doc/index.rst');
            $this->filesystem->mkdir($dir.'/Resources/translations');
            $this->filesystem->mkdir($dir.'/Resources/public/css');
            $this->filesystem->mkdir($dir.'/Resources/public/images');
            $this->filesystem->mkdir($dir.'/Resources/public/js');
        }
    }
208353
protected function getActionConstantsForClass($classNamespace, $restriction)
    {
        $constants = [];
        /** @var \Claroline\CoreBundle\Event\Log\LogGenericEvent $reflectionClass */
        $reflectionClass = new \ReflectionClass($classNamespace);

        if (!$reflectionClass->isAbstract()) {
            if ($restriction
                && ($restrictions = $classNamespace::getRestriction())
                && 1 === count($restrictions)
                && (LogGenericEvent::DISPLAYED_ADMIN === $restrictions[0]
                    || LogGenericEvent::PLATFORM_EVENT_TYPE === $restrictions[0])
                && $restriction !== $restrictions[0]) {
                return $constants; // event is admin only
            }

            $classConstants = $reflectionClass->getConstants();

            foreach ($classConstants as $key => $classConstant) {
                if (preg_match('/^ACTION/', $key)) {
                    $constants[] = $classConstant;
                }
            }
        }

        return $constants;
    }
1150456
public function getRelativeFiles(Finder $finder)
    {
        $files = [];
        foreach ($this->getFiles($finder) as $file) {
            $files[] = str_replace($this->directory.'/', '', $file);
        }

        return $files;
    }
711971
protected function searchModulePath($namespace)
    {
        $targetPath = false;
        
        // Iterate trough the module directories
        foreach ($this->moduleDirectories as $directory => $excludePattern) {
            $recursiveDirectoryIterator = new \RecursiveDirectoryIterator($directory, \RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
            $iterator = new \RecursiveIteratorIterator($recursiveDirectoryIterator);
            $regexIterator = new \RegexIterator($iterator, '/^.+\/Module\.json$/i');

            foreach ($regexIterator as $item) {
                // Ignore modules which are located inside a tests directory
                if ($excludePattern !== false && preg_match($excludePattern, $item->getPath())) {
                    continue;
                }
                
                $moduleNamespace = $this->getNamespaceFromModuleJson($item->getPath());
                
                if ($moduleNamespace === $namespace) {
                    $targetPath = $item->getPath();
                    break 2;
                }
            }
        }
        
        return $targetPath;
    }
1019189
private function find(BundleInterface $bundle)
    {
        $yamls =  array();

        if (!is_dir($bundle->getPath().'/Resources/config')) {
            return $yamls;
        }

        $finder = new Finder();
        $finder->files()
               ->name('*-generator.yml')
               ->in($bundle->getPath().'/Resources/config');

        foreach ($finder as $file) {
            $yamls[$file->getRealPath()] = $file->getRealPath();
        }

        return $yamls;
    }
1071171
public function find($term, $fields = [])
    {
        Wildcard::setMinPrefixLength($this->minPrefixLength);
        Lucene::setResultSetLimit($this->resultsLimit);

        if (empty($fields)) {
            return [
                'results' => $this->luceneIndex->find($term),
                'query' => $term
            ];
        }

        $fieldTerms[] = new IndexTerm($term);
        foreach ($fields as $field => $fieldText) {
            $fieldTerms[] = new IndexTerm($fieldText, $field);
        }
        return [
            'results' => $this->luceneIndex->find(new MultiTerm($fieldTerms)),
            'query' => $term
        ];
    }
1237560
static function Modules($bundleName, ModuleLocation $location)
    {
        $result = array();
        $modulesFolder = Path::Combine(self::BundleFolder($bundleName), 'Modules');
        $folder = Path::Combine($modulesFolder, (string)$location);
        if (!Folder::Exists($folder)) {
            return $result;
        }
        $files = Folder::GetFiles($folder);
        foreach ($files as $file)
        {
            $result[] = Path::RemoveExtension($file);
        }
        return $result;
    }
1222001
private function scanRoot(NamespaceInterface $root): Generator
    {
        foreach ($root->iterateNamespaces() as $namespace) {

            // If you find a project readme, this is a project. Scan it for packages and sub-packages.
            $readMes = new \Symfony\Component\Finder\Finder();
            $readMes->files()
                    ->in($namespace->getPaths())
                    ->depth(0)
                    ->name('project.md');

            if ($readMes->count()) {
                yield from $this->scanNamespaceForPackages($namespace);
                return;
            }

            // Otherwise, this must be a library. Scan it as a package itself.
            yield from $this->loadPackage($namespace);
        }
    }
115351
private function getFinder($fileName, ContainerBuilder $container)
    {
        $finder       = (new Finder())->files()->name($fileName);
        $resourcesDir = 'Resources'.DIRECTORY_SEPARATOR.'config';

        if (self::$directoriesCache) {
            return $finder->in(self::$directoriesCache);
        }

        foreach ($container->getParameter('kernel.bundles') as $name => $pathToBundle) {
            try {
                $reflector = new \ReflectionClass($pathToBundle);
            } catch (\ReflectionException $e) {
                continue;
            }

            $fileName = $reflector->getFileName();
            $fileName = str_replace($name.'.php', $resourcesDir, $fileName);

            try {
                $finder->in($fileName);
                self::$directoriesCache[$name] = $fileName;
            } catch (\InvalidArgumentException $e) {
                // remove invalid directories
                unset(self::$directoriesCache[$name]);
            }
        }

        return $finder;
    }
244797
public function getLog($limit = null, $skip = null)
    {
        $arguments  = array(
            '--xml',
            '--revision'    => 'HEAD:0'
        );


        $skip   = ($skip === null) ? 0 : (int)$skip;
        if ($limit !== null) {
            $arguments['--limit']    = (int)($limit + $skip);
        }

        /** @var $result CallResult */
        $result = $this->getSvn()->{'log'}($this->getRepositoryPath(), $arguments);
        $result->assertSuccess(sprintf('Cannot retrieve log from "%s"',
            $this->getRepositoryPath()
        ));

        $xml    = simplexml_load_string($result->getStdOut());
        if (!$xml) {
            throw new \RuntimeException(sprintf('Cannot read log XML for "%s"', $this->getRepositoryPath()));
        }
        $logEntries = new \ArrayIterator($xml->xpath('/log/logentry'));

        if ($limit !== null) {
            $logEntries = new \LimitIterator($logEntries, $skip, $limit);
        }

        $log = array();
        foreach ($logEntries as $item) {
            $log[]   = array(
                (string)$item['revision'],
                (string)$item->author,
                (string)$item->date,
                (string)$item->msg
            );
        }
        return $log;
    }
1053791
public function postFind(Event $event, array &$results, $finder) {
        if (!in_array($finder, ['first', 'all'])) {
            return;
        }

        $repo = $this->getRepository();
        $converters = $this->getConverters();

        foreach ($results as $i => $result) {
            foreach ($result as $key => $value) {
                if (empty($converters[$key])) {
                    continue;
                }

                $converter = $converters[$key];

                // Exit if decoding should not happen
                if (!$converter['decode']) {
                    continue;
                }

                switch ($converter['type']) {
                    case self::SERIALIZE:   $value = $this->fromSerialize($value, $converter); break;
                    case self::JSON:        $value = $this->fromJson($value, $converter); break;
                    case self::BASE64:      $value = $this->fromBase64($value, $converter); break;
                    case self::CUSTOM:
                        if (method_exists($repo, $converter['decode'])) {
                            $value = call_user_func_array([$repo, $converter['decode']], [$value, $converter]);
                        }
                    break;
                }

                $results[$i][$key] = $value;
            }
        }
    }