/**
  * Given a selector string, extract it into one or more corresponding Selector objects, iterable in this object.
  *
  */
 public function __construct($selectorStr)
 {
     if (empty(self::$selectorTypes)) {
         Selector::loadSelectorTypes();
     }
     $this->extractString($selectorStr);
 }
Exemplo n.º 2
0
        $allowed = array('session', 'page', 'user');
        // @todo make the whitelist configurable
        if (!in_array($value, $allowed)) {
            return null;
        }
        $value = $this->wire($value);
        if (is_null($value)) {
            return null;
        }
        // does not resolve to API var
        if (empty($property)) {
            return (string) $value;
        }
        // no property requested, just return string value
        if (!is_object($value)) {
            return null;
        }
        // property requested, but value is not an object
        return (string) $value->{$property};
    }
    public function __toString()
    {
        $str = '';
        foreach ($this as $selector) {
            $str .= $selector->str . ", ";
        }
        return rtrim($str, ", ");
    }
}
Selector::loadSelectorTypes();