/** * Checks if a tag is a subtag of the current component or it is a child component. * * @param string $tagName * @return bool true if it is a subtag. */ private function subtag_check($tagName) { $propName = lcfirst($tagName); if ($this->current instanceof Metadata) { switch ($this->current->type) { // All descendants of a metadata property are always metadata. case type::metadata: return true; } // Descendants of a content property are children, not properties. return false; } // If the current component defines an property with the same name as the tag being checked, and if that property // supports begin specified as a tag, the tag is a subtag. return $this->current->supportsProperties() && $this->current->props->defines($propName, true); }
/** * Checks if the given component matches the preset's selector. * * @param Component $component * @return bool */ function matches(Component $component) { if ($this->matchTag && $this->matchTag !== $component->getTagName()) { return false; } if ($this->matchClass && (!$component instanceof HtmlComponent || !preg_match($this->matchClass, $component->props->class))) { return false; } if ($component->supportsProperties() && ($prop = $this->matchPropName)) { if (!$component->props->defines($prop)) { return false; } if ($this->matchPropValue !== '') { if ($component->props->{$prop} != $this->matchPropValue) { return false; } } else { if (!exists($component->props->{$prop})) { return false; } } } return true; }