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/)?[^/]+%', $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);
    }
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/)?[^/]+%', $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);
    }
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/)?[^/]+%' , $ 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 ) ; }
Reads all Policy.yaml files below Packages, extracts the roles and prepends
them with the package key "guessed" from the path.

@return array
Reads all Policy . yaml files below Packages extracts the roles and prepends them with the package key guessed from the path .