/** * Register a new tag * * * h2o::addTag('tag_name', 'ClassName'); * * h2o::addTag(array( * 'tag_name' => 'MagClass', * 'tag_name2' => 'TagClass2' * )); * * h2o::addTag('tag_name'); // Tag_name_Tag * * h2o::addTag(array('tag_name', * @param unknown_type $tag * @param unknown_type $class */ static function addTag($tag, $class = null) { $tags = array(); if (is_string($tag)) { if (is_null($class)) { $class = ucwords("{$tag}_Tag"); } $tags[$tag] = $class; } elseif (is_array($tag)) { $tags = $tag; } foreach ($tags as $tag => $tagClass) { if (is_integer($tag)) { unset($tags[$tag]); $tag = $tagClass; $tagClass = ucwords("{$tagClass}_Tag"); } if (!class_exists($tagClass, false)) { throw new H2o_Error("{$tagClass} tag is not found"); } $tags[$tag] = $tagClass; } self::$tags = array_merge(self::$tags, $tags); }