38 $this->collectIdentifiedElements();
39 $this->processReferences();
52 foreach ($this->subjects as $subject) {
54 $element === $subject->getElement()
75 function (
Subject $subject) use ($elementId) {
84 protected function collectIdentifiedElements()
87 $elements = $this->xPath->query(
'//*[@id]');
88 foreach ($elements as $element) {
89 $this->subjects[$element->getAttribute(
'id')] =
new Subject($element, $this->useNestingLimit);
97 protected function processReferences()
99 $useNodeName = $this->xPath->createNodeName(
'use');
100 foreach ($this->subjects as $subject) {
101 $useElements = $this->xPath->query(
102 $useNodeName .
'[@href or @xlink:href]',
103 $subject->getElement()
107 foreach ($useElements as $useElement) {
111 if ($useId === null || !isset($this->subjects[$useId])) {
114 $subject->addUse($this->subjects[$useId]);
115 $this->subjects[$useId]->addUsedIn($subject);
125 foreach ($this->subjects as $subject) {
136 if ($useId === $subject->getElementId()) {
138 } elseif ($subject->hasInfiniteLoop()) {
164 $this->elementsToRemove = array_merge(
165 $this->elementsToRemove,
static getElementHref(\DOMElement $element)
static extractIdReferenceFromHref($href)
markSubjectAsInvalid(Subject $subject)
The Subject is invalid for some reason, therefore we should remove it and all it's child usages...
getElementsToRemove()
Get all the elements that caused a nesting exception.
static isElementContainedIn(\DOMElement $needle, \DOMElement $haystack)
findByElementId($elementId)
Resolves subjects (plural!) by element id - in theory malformed DOM might have same ids assigned to d...
determineInvalidSubjects()
Determines and tags infinite loops.
clearInternalAndGetAffectedElements()
Clear the internal arrays (to free up memory as they can get big) and return all the child usages DOM...
findByElement(\DOMElement $element, $considerChildren=false)
Resolves one subject by element.
__construct(XPath $xPath, $useNestingLimit)
getElement()
Get the element that caused the exception.