public function on_list_bundles($pars)
{
$bundle_dir_path = $this->configuration['support-path'] . '/bundles/';
if (!is_dir($bundle_dir_path)) {
throw new Exception('There is no bundles directory available.');
}
$bundles = array();
if (false !== ($d = opendir($bundle_dir_path))) {
while (false !== ($f = readdir($d))) {
if (0 == strncmp('.', $f, 1) || !is_dir($bundle_dir_path . $f)) {
continue;
}
$yaml = YAML::load($bundle_dir_path . $f . '/info.amBundle');
$yaml['id'] = $f;
// getting list of bundle templates
$templates_path = $bundle_dir_path . $f . '/templates/';
$templates = array();
if (is_dir($templates_path)) {
if (false !== ($d_templates = opendir($templates_path))) {
while (false !== ($ff = readdir($d_templates))) {
if (0 == strncmp('.', $ff, 1)) {
continue;
}
$content = explode("\n", @file_get_contents($templates_path . $ff));
$templates[] = $content[0];
}
closedir($d_templates);
}
}
$yaml['templates'] = $templates;
$bundles[] = $yaml;
}
closedir($d);
}
self::setResult($bundles);
}