Neos\Flow\Persistence\Doctrine\Migrations\Version20130319131500::loadRolesFromPolicyFiles PHP Метод

loadRolesFromPolicyFiles() защищенный Метод

Reads all Policy.yaml files below Packages, extracts the roles and prepends them with the package key "guessed" from the path.
protected loadRolesFromPolicyFiles ( ) : array
Результат array
    protected function loadRolesFromPolicyFiles()
    {
        $roles = array();
        $yamlPathsAndFilenames = Files::readDirectoryRecursively(__DIR__ . '/../../../../../Packages', 'yaml', true);
        $configurationPathsAndFilenames = array_filter($yamlPathsAndFilenames, function ($pathAndFileName) {
            if (basename($pathAndFileName) === 'Policy.yaml') {
                return true;
            } else {
                return false;
            }
        });
        $yamlSource = new \Neos\Flow\Configuration\Source\YamlSource();
        foreach ($configurationPathsAndFilenames as $pathAndFilename) {
            if (preg_match('%Packages/.+/([^/]+)/Configuration/(?:Development|Production|Policy).+%', $pathAndFilename, $matches) === 0) {
                continue;
            }
            $packageKey = $matches[1];
            $configuration = $yamlSource->load(substr($pathAndFilename, 0, -5));
            if (isset($configuration['roles']) && is_array($configuration['roles'])) {
                foreach ($configuration['roles'] as $roleIdentifier => $parentRoles) {
                    $roles[$packageKey . ':' . $roleIdentifier] = true;
                }
            }
        }
        return array_keys($roles);
    }