initFromComponentInfo() публичный Метод

Initializes the snippet from a CMS component information.
public initFromComponentInfo ( string $componentClass, string $componentCode )
$componentClass string Specifies the component class.
$componentCode string Specifies the component code.
Пример #1
0
 /**
  * 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;
 }