SelectorsHandler.php in Zircon Profile 8.0
File
vendor/behat/mink/src/Selector/SelectorsHandler.php
View source
<?php
namespace Behat\Mink\Selector;
use Behat\Mink\Selector\Xpath\Escaper;
class SelectorsHandler {
private $selectors;
private $escaper;
public function __construct(array $selectors = array()) {
$this->escaper = new Escaper();
$this
->registerSelector('named_partial', new PartialNamedSelector());
$this
->registerSelector('named_exact', new ExactNamedSelector());
$this
->registerSelector('css', new CssSelector());
foreach ($selectors as $name => $selector) {
$this
->registerSelector($name, $selector);
}
}
public function registerSelector($name, SelectorInterface $selector) {
$this->selectors[$name] = $selector;
}
public function isSelectorRegistered($name) {
return isset($this->selectors[$name]);
}
public function getSelector($name) {
if ('named' === $name) {
@trigger_error('Using the "named" selector directly from the handler is deprecated as of 1.6 and will be removed in 2.0.' . ' Use the "named_partial" or use the "named" selector through the Element API instead.', E_USER_DEPRECATED);
$name = 'named_partial';
}
if (!$this
->isSelectorRegistered($name)) {
throw new \InvalidArgumentException("Selector \"{$name}\" is not registered.");
}
return $this->selectors[$name];
}
public function selectorToXpath($selector, $locator) {
if ('xpath' === $selector) {
if (!is_string($locator)) {
throw new \InvalidArgumentException('The xpath selector expects to get a string as locator');
}
return $locator;
}
return $this
->getSelector($selector)
->translateToXPath($locator);
}
public function xpathLiteral($s) {
@trigger_error('The ' . __METHOD__ . ' method is deprecated as of 1.7 and will be removed in 2.0.' . ' Use \\Behat\\Mink\\Selector\\Xpath\\Escaper::escapeLiteral instead when building Xpath' . ' or pass the unescaped value when using the named selector.', E_USER_DEPRECATED);
return $this->escaper
->escapeLiteral($s);
}
}