/**
* Returns a list of snippets created from components.
* @return array Returns an array of Snippet objects.
*/
protected function listComponentSnippets()
{
$result = [];
$pluginManager = PluginManager::instance();
$plugins = $pluginManager->getPlugins();
foreach ($plugins as $id => $plugin) {
if (!method_exists($plugin, 'registerPageSnippets')) {
continue;
}
$snippets = $plugin->registerPageSnippets();
if (!is_array($snippets)) {
continue;
}
foreach ($snippets as $componentClass => $componentCode) {
// TODO: register snippet components later, during
// the page life cycle.
$snippet = new Snippet();
$snippet->initFromComponentInfo($componentClass, $componentCode);
$result[] = $snippet;
}
}
return $result;
}