AMYBundle::getSnippetsInDirectory PHP Méthode

getSnippetsInDirectory() private méthode

private getSnippetsInDirectory ( $path, $relativePath )
    private function getSnippetsInDirectory($path, $relativePath)
    {
        $snippets = array();
        if (false !== ($d = opendir($path))) {
            while (false !== ($f = readdir($d))) {
                $new_path = $path . '/' . $f;
                $new_relative_path = $relativePath . '/' . $f;
                if ('.amSnippet' == substr($f, -10) || is_dir($new_path) && 0 != strncmp('.', $f, 1)) {
                    if (is_dir($new_path) && file_exists($new_path . '/group.amGroup')) {
                        $yaml = YAML::load($new_path . '/group.amGroup');
                        $yaml['filename'] = $f;
                        $yaml['is_collection'] = '1';
                        $yaml['path'] = $relativePath;
                        $snippets[] = $yaml;
                        $snippets = array_merge($snippets, $this->getSnippetsInDirectory($new_path, $new_relative_path));
                        continue;
                    }
                    $def_file = $new_path . 'Def';
                    if (!file_exists($def_file)) {
                        throw new Exception('Missing snippet definition file `' . $def_file . '`.');
                    }
                    $yaml = YAML::load($new_path);
                    $yaml['code'] = file_get_contents($def_file);
                    $yaml['filename'] = substr($f, 0, -10);
                    $yaml['path'] = $relativePath;
                    $snippets[] = $yaml;
                }
            }
            closedir($d);
        }
        return $snippets;
    }