defaultNormalizations; } $this->collection = new TemplateNormalizationList; foreach ($normalizations as $normalization) { $this->collection->append($normalization); } } /** * Normalize a tag's template * * @param Tag $tag Tag whose template will be normalized * @return void */ public function normalizeTag(Tag $tag) { if (isset($tag->template) && !$tag->template->isNormalized()) { $tag->template->normalize($this); } } /** * Normalize a template * * @param string $template Original template * @return string Normalized template */ public function normalizeTemplate($template) { $dom = TemplateLoader::load($template); // Apply all the normalizations until no more change is made or we've reached the maximum // number of loops $i = 0; do { $old = $template; foreach ($this->collection as $k => $normalization) { $normalization->normalize($dom->documentElement); } $template = TemplateLoader::save($dom); } while (++$i < $this->maxIterations && $template !== $old); return $template; } }