protected function getFirstAncestorOfType($className) { $result = null; $current = $this; while (!ClassUtil::isSubclassOf(get_class($current), $className)) { $parent = $current->getParent(); if (get_class($parent) === "View" && $className !== "View") { throw new NoSuchAnchestorComponentException(get_class($this), $className); } $current = $parent; } return $current; }
private function parseNode(XmlElement $node) { $className = ucfirst($node->getName()); if (!ClassCache::exists($className)) { $instance = new HtmlComponent($node->getName(), $node->getText(), $node->getAttributes()); } else { if (!ClassUtil::isSubclassOf($className, "Component")) { throw new ComponentNotExistsException($className); } $instance = new $className(); foreach ($node->getAttributes() as $attrName => $attrValue) { $setterName = "set" . ucfirst($attrName); $setter = new ReflectionMethod($instance, $setterName); $setter->invoke($instance, (string) $attrValue); } } foreach ($node->getChildren() as $child) { $instance->addChild($this->parseNode($child)); } return $instance; }
public static function isApplicationBean($className) { return ClassUtil::isSubclassOf($className, "ApplicationBean"); }