. * * @file * @ingroup Skins */ namespace Skins\Chameleon\Components; use DOMElement; /** * The Structure class. * * @author Stephan Gambke * @since 1.0 * @ingroup Skins */ class Structure extends Component { private $subcomponents; /** * Builds the HTML code for the component * * @return String the HTML code */ public function getHtml(){ $ret = ''; foreach ( $this->getSubcomponents() as $component ) { $ret .= $component->getHtml(); } return $ret; } /** * @return string[] the resource loader modules needed by this component */ public function getResourceLoaderModules() { $modules = array(); foreach ( $this->getSubcomponents() as $component ) { $modules = array_merge( $modules, $component->getResourceLoaderModules() ); } return $modules; } /** * @return Component[] */ protected function getSubcomponents() { if ( !isset ( $this->subcomponents ) ) { $this->subcomponents = array(); $domElement = $this->getDomElement(); if ( $domElement !== null && $domElement instanceof DOMElement ) { $children = $this->getDomElement()->childNodes; foreach ( $children as $child ) { if ( $child instanceof DOMElement ) { $this->subcomponents[] = $this->getSkin()->getComponentFactory()->getComponent( $child, $this->getIndent() + 1 ); } } } } return $this->subcomponents; } }