Ejemplo n.º 1
0
 public function data($name, $value = null)
 {
     $first = $this->qp->eq(0);
     $hash = spl_object_hash($first->get(0));
     if (!isset(self::$data[$hash])) {
         self::$data[$hash] = array();
         // Import any data-* attributes and store as element data
         foreach ($first->attr() as $attrName => $attrValue) {
             if (substr($attrName, 0, 5) === 'data-') {
                 self::$data[$hash][substr($attrName, 5)] = $attrValue;
             }
         }
     }
     if ($value === null) {
         return isset(self::$data[$hash][$name]) ? self::$data[$hash][$name] : null;
     }
     self::$data[$hash][$name] = $value;
     return $this->qp;
 }
Ejemplo n.º 2
0
 /**
  * Handles reads of properties not defined by Query
  * Will delegate to the wrapped QueryPath query
  *
  * @param $method
  * @param $args
  * @return Query|mixed
  */
 public function __get($name)
 {
     if (is_numeric($name)) {
         return $this->wrappedQuery->get($name);
     }
     if (!property_exists($this->wrappedQuery, $name)) {
         throw new Exception('Invalid property get "' . $name . '"');
     }
     $result = $this->wrappedQuery->{$name};
     if ($result instanceof QueryPathQueryInterface) {
         return $this->createQuery($result);
     }
     return $result;
 }