protected function parseTemplate($template)
	{
		$this->references = [
			'anywhere' => [],
			'asUrl'    => [],
			'inText'   => []
		];

		preg_match_all($this->referencesRegexp, $template, $matches);
		foreach ($matches[0] as $match)
		{
			$key = trim($match, '\\${}');
			$this->references['anywhere'][$key] = $key;
		}

		$dom   = TemplateLoader::load($template);
		$xpath = new DOMXPath($dom);
		foreach ($xpath->query('//text()') as $node)
		{
			preg_match_all($this->referencesRegexp, $node->textContent, $matches);
			foreach ($matches[0] as $match)
			{
				$key = trim($match, '\\${}');
				$this->references['inText'][$key] = $key;
			}
		}

		foreach (NodeLocator::getURLNodes($dom) as $node)
		{
			// We only bother with literal attributes that start with a capture
			if ($node instanceof DOMAttr
			 && preg_match('(^(?:[$\\\\]\\d+|\\$\\{\\d+\\}))', trim($node->value), $m))
			{
				$key = trim($m[0], '\\${}');
				$this->references['asUrl'][$key] = $key;
			}
		}

		$this->removeUnknownReferences();
	}
protected function parseTemplate($template)
	{
		$this->references = [
			'anywhere' => [],
			'asUrl'    => [],
			'inText'   => []
		];

		preg_match_all($this->referencesRegexp, $template, $matches);
		foreach ($matches[0] as $match)
		{
			$key = trim($match, '\\${}');
			$this->references['anywhere'][$key] = $key;
		}

		$dom   = TemplateLoader::load($template);
		$xpath = new DOMXPath($dom);
		foreach ($xpath->query('//text()') as $node)
		{
			preg_match_all($this->referencesRegexp, $node->textContent, $matches);
			foreach ($matches[0] as $match)
			{
				$key = trim($match, '\\${}');
				$this->references['inText'][$key] = $key;
			}
		}

		foreach (NodeLocator::getURLNodes($dom) as $node)
		{
			// We only bother with literal attributes that start with a capture
			if ($node instanceof DOMAttr
			 && preg_match('(^(?:[$\\\\]\\d+|\\$\\{\\d+\\}))', trim($node->value), $m))
			{
				$key = trim($m[0], '\\${}');
				$this->references['asUrl'][$key] = $key;
			}
		}

		$this->removeUnknownReferences();
	}
protected function parseTemplate ( $ template ) { $ this -> references = [ 'anywhere' => [ ] , 'asUrl' => [ ] , 'inText' => [ ] ] ; preg_match_all ( $ this -> referencesRegexp , $ template , $ matches ) ; foreach ( $ matches [ 0 ] as $ match ) { $ key = trim ( $ match , '\\${}' ) ; $ this -> references [ 'anywhere' ] [ $ key ] = $ key ; } $ dom = TemplateLoader :: load ( $ template ) ; $ xpath = new DOMXPath ( $ dom ) ; foreach ( $ xpath -> query ( '//text()' ) as $ node ) { preg_match_all ( $ this -> referencesRegexp , $ node -> textContent , $ matches ) ; foreach ( $ matches [ 0 ] as $ match ) { $ key = trim ( $ match , '\\${}' ) ; $ this -> references [ 'inText' ] [ $ key ] = $ key ; } } foreach ( NodeLocator :: getURLNodes ( $ dom ) as $ node ) { // We only bother with literal attributes that start with a capture if ( $ node instanceof DOMAttr && preg_match ( '(^(?:[$\\\\]\\d+|\\$\\{\\d+\\}))' , trim ( $ node -> value ) , $ m ) ) { $ key = trim ( $ m [ 0 ] , '\\${}' ) ; $ this -> references [ 'asUrl' ] [ $ key ] = $ key ; } } $ this -> removeUnknownReferences ( ) ; }
Parse given template and store the references it contains

@param  string $template
@return void
Parse given template and store the references it contains