Exemplo n.º 1
0
    /**
     *	Configures Essence's helpers.
     */
    protected function _setupEssence()
    {
        $this->configure(['replacerUrlPattern' => '~
					(?<!=["\']) # avoids matching URLs in HTML attributes
					(?:https?:)//
					(?:www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)?
					(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+
					(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'"\\.,<>?«»“”‘’])
				~ix', 'Replacer' => Container::unique(function ($C) {
            $Replacer = new Replacer($C->get('Extractor'));
            $Replacer->setUrlPattern($C->get('replacerUrlPattern'));
            return $Replacer;
        }), 'Crawler' => Container::unique(function ($C) {
            return new Crawler($C->get('Collection'), $C->get('Dom'));
        }), 'Extractor' => Container::unique(function ($C) {
            return new Extractor($C->get('Collection'));
        })]);
    }