Example #1
0
 /**
  * @param $name
  * @return ComponentAssert
  */
 public function getComponent($name)
 {
     $c = $this->getObject();
     $assert = new self($c[$name]);
     $assert->setParent($this);
     return $assert;
 }
Example #2
0
 public function addTextChild($text)
 {
     $child = new self();
     $child->setParent($this);
     $child->setText($text);
     $this->addChild($child);
 }
Example #3
0
	public static function getInstanceById($reportModel) {
		$self = new self();
		$db = PearDatabase::getInstance();
		$result = $db->pquery('SELECT * FROM vtiger_reporttype WHERE reportid = ?', array($reportModel->getId()));
		$data = $db->query_result($result, 0, 'data');
		if(!empty($data)) {
			$decodeData = Zend_Json::decode(decode_html($data));
			$self->setData($decodeData);
			$self->setParent($reportModel);
			$self->setId($reportModel->getId());
		}
		return $self;
	}
Example #4
0
 function add($idobj)
 {
     if (!is_object($idobj)) {
         $idobj = new self($idobj);
     } else {
         if (!$idobj instanceof self) {
             throw new Exception("type mismatch");
         }
     }
     $idobj->setParent($this);
     $this->and = $idobj;
     return $idobj;
 }
 /**
  * @param $options
  * @param callable $callback
  * @return RouteCollection
  */
 public function group($options, callable $callback = null)
 {
     if (!isset($callback) && is_callable($options)) {
         $callback = $options;
         $options = [];
     }
     $child = new self($options);
     $child->setParent($this);
     $this->children[] = $child;
     if (isset($callback)) {
         call_user_func($callback, $child);
     }
     return $child;
 }
Example #6
0
 static function manualLoad($file, &$obj, $params = [])
 {
     $apply = new self();
     $apply->setParent($obj);
     $apply->parseFile($file, $params, 'apply');
     foreach ($apply->childNodes as $i => $extender) {
         if ($extender instanceof COMMENT || $extender instanceof TEXT || $extender instanceof PHP) {
             unset($apply->childNodes[$i]);
             continue;
         }
         if (method_exists($extender, 'applyLoad')) {
             $extender->applyLoad($obj);
         } else {
             $selector = $extender->nodeName;
             foreach ($extender->attributes as $k => $v) {
                 $selector .= '[' . $k . '="' . $v . '"]';
             }
             $obj->children($selector, true)->write($extender);
         }
     }
 }
Example #7
0
    /**
     * Map variable access onto the underlying entry representation.
     *
     * Get-style access returns a Zend_Feed_Element representing the
     * child element accessed. To get string values, use method syntax
     * with the __call() overriding.
     *
     * @param  string $var The property to access.
     * @return mixed
     */
    public function __get($var)
    {
        $nodes = $this->_children($var);
        $length = count($nodes);

        if ($length == 1) {
            return new Zend_Feed_Element($nodes[0]);
        } elseif ($length > 1) {
            return array_map(create_function('$e', 'return new Zend_Feed_Element($e);'), $nodes);
        } else {
            // When creating anonymous nodes for __set chaining, don't
            // call appendChild() on them. Instead we pass the current
            // element to them as an extra reference; the child is
            // then responsible for appending itself when it is
            // actually set. This way "if ($foo->bar)" doesn't create
            // a phantom "bar" element in our tree.
            if (strpos($var, ':') !== false) {
                list($ns, $elt) = explode(':', $var, 2);
                $node = $this->_element->ownerDocument->createElementNS(Zend_Feed::lookupNamespace($ns), $elt);
            } else {
                $node = $this->_element->ownerDocument->createElement($var);
            }
            $node = new self($node);
            $node->setParent($this);
            return $node;
        }
    }
Example #8
0
File: Chain.php Project: jyxo/php
 /**
  * Adds a new subchain and returns its instance.
  *
  * @return \Jyxo\Input\Chain
  */
 public function addWalk() : self
 {
     $chain = new self();
     $chain->setParent($this);
     $this->chain[] = [self::WALK, $chain];
     return $chain;
 }
Example #9
0
 /**
  * Creates a copy of this node including its pages
  *
  * This does not persist anything.
  * @todo This is untested!
  * @param boolean $recursive (optional) Wheter copy all children to the new node or not, default false
  * @param Node $newParent (optional) New parent node for the copy, default is parent of this
  * @param boolean $persist (optional) Wheter to persist new entities or not, default true, if set to false, be sure to persist everything
  * @return \Cx\Core\ContentManager\Model\Entity\Node Copy of this node
  */
 public function copy($recursive = false, Node $newParent = null, $persist = true)
 {
     $em = \Env::get('cx')->getDb()->getEntityManager();
     if (!$newParent) {
         $newParent = $this->getParent();
     }
     $copy = new self();
     $copy->setParent($newParent);
     if ($persist) {
         $em->persist($copy);
     }
     foreach ($this->getPages(true) as $page) {
         $pageCopy = $page->copyToNode($copy);
         if ($persist) {
             $em->persist($pageCopy);
         }
     }
     if (!$recursive) {
         return $copy;
     }
     foreach ($this->getChildren() as $child) {
         $copy->addParsedChild($child->copy(true, $copy));
     }
     return $copy;
 }
Example #10
0
 /**
  * Adds a new subchain and returns its instance.
  *
  * @return \Jyxo\Input\Chain
  */
 public function addWalk()
 {
     $chain = new self();
     $chain->setParent($this);
     $this->chain[] = array(self::WALK, $chain);
     return $chain;
 }
Example #11
0
File: Context.php Project: fwk/core
 /**
  * Returns a new parent Context
  * 
  * @return Context 
  */
 public function newParent()
 {
     $ctx = new self($this->request);
     $ctx->setParent($this);
     return $ctx;
 }
Example #12
0
 /**
  * @param string $selector
  *
  * @return Element
  */
 public function hasChild($selector)
 {
     $this->assertAtLeast($this->valueIsSet()->value);
     $asserter = new self($this->getGenerator(), $this->getAnalyzer(), $this->getLocale());
     $asserter->setParent($this)->setWith($this->valueIsSet()->value->filter($selector));
     return $asserter;
 }
Example #13
0
 /**
  * Mount a Mux or a Controller object on a specific path.
  *
  * @param string         $pattern
  * @param Mux|Controller $mux
  * @param array          $options
  */
 public function mount($pattern, $mux, array $options = array())
 {
     // Save the mount path in options array
     $options['mount_path'] = $pattern;
     if ($mux instanceof Expandable) {
         $mux = $mux->expand($options);
     } else {
         if ($mux instanceof Closure) {
             // we pass the newly created Mux object to the builder closure to initialize routes.
             if ($ret = $mux($mux = new Mux())) {
                 if ($ret instanceof Mux) {
                     $mux = $ret;
                 } else {
                     throw new LogicException('Invalid object returned from Closure.');
                 }
             }
         } elseif ((!is_object($mux) || !$mux instanceof self) && is_callable($mux)) {
             $mux($mux = new self());
         }
     }
     // Save the constructed mux object in options array, so we can fetch
     // the expanded mux object in controller object later.
     $mux->setParent($this);
     $options['mux'] = $mux;
     if ($this->expand) {
         $pcre = strpos($pattern, ':') !== false;
         // rewrite submux routes
         foreach ($mux->routes as $route) {
             // process for pcre
             if ($route[0] || $pcre) {
                 $newPattern = $pattern . ($route[0] ? $route[3]['pattern'] : $route[1]);
                 $routeArgs = PatternCompiler::compile($newPattern, array_replace_recursive($options, $route[3]));
                 $this->appendPCRERoute($routeArgs, $route[2]);
             } else {
                 $this->routes[] = array(false, $pattern . $route[1], $route[2], isset($route[3]) ? array_replace_recursive($options, $route[3]) : $options);
             }
         }
     } else {
         $muxId = $mux->getId();
         $this->add($pattern, $muxId, $options);
         $this->submux[$muxId] = $mux;
     }
 }
Example #14
0
 public function insert(Comparable $element)
 {
     $compareResult = $this->compareToValue($element);
     if ($compareResult !== 0) {
         foreach ($this->children as $child) {
             if ($child->getValue()->compareTo($element) === 0) {
                 throw new DuplicateEntryException('Value is already present - cannot insert two elements with same value.');
             }
         }
         $item = new self($element);
         $item->setParent($this);
         $this->children[] = $item;
         return $item;
     } else {
         throw new DuplicateEntryException('Value is already present - cannot insert two elements with same value.');
     }
 }
Example #15
0
 /**
  * Overrides Entity's setData to process the replies and package them as
  * objects
  *
  * @access public
  * @param  array $data
  */
 public function setData(array $data)
 {
     parent::setData($data);
     if (isset($data['replies']['data']['children'])) {
         foreach ($data['replies']['data']['children'] as $reply) {
             $comment = new self($this->reddit);
             $comment->setData($reply['data']);
             $comment->setParent($this);
             $this->replies[] = $comment;
         }
     }
 }