initFromPartial() public method

Initializes the snippet from a CMS partial.
public initFromPartial ( $partial )
Ejemplo n.º 1
0
 /**
  * Returns a list of snippets in the specified theme.
  * @param \Cms\Classes\Theme $theme Specifies a parent theme.
  * @return array Returns an array of Snippet objects.
  */
 protected function listThemeSnippets($theme)
 {
     $result = [];
     $partials = Partial::listInTheme($theme, true);
     foreach ($partials as $partial) {
         $viewBag = $partial->getViewBag();
         if (strlen($viewBag->property('snippetCode'))) {
             $snippet = new Snippet();
             $snippet->initFromPartial($partial);
             $result[] = $snippet;
         }
     }
     return $result;
 }