'Alias must be unique', ]; public function __construct($options = []) { if (is_array($options) && !empty($options)) { $this->setOptions($options); } } public function setOptions($options) { if (isset($options['options'])) { unset($options['options']); } foreach ($options as $key => $value) { $method = 'set' . ucfirst($key); if (method_exists($this, $method)) { // Setter exists; use it $this->$method($value); } } } public function setParentAlias($alias) { $this->_parentAlias = $alias; return $this; } public function getParentAlias() { return $this->_parentAlias; } public function isValid($value, $context = null) { $value = (string) $value; $fullAlias = $this->_parentAlias . ((empty($this->_parentAlias)) ? '' : '/') . $value; $pages = Qs_SiteMap::find(['source' => 'xml', 'fullAlias' => $fullAlias]); if (empty($pages)) { return true; } $this->_error(self::NOT_UNIQUE); return false; } }