コード例 #1
0
 public function testHierarchy()
 {
     $criteria = new ProxyTestCriteria();
     $p = new TestPropelConditionalProxy($criteria, true);
     $this->assertEquals($p->getCriteria(), $criteria, 'main object is the given one');
     $this->assertInstanceOf('PropelConditionalProxy', $p2 = $p->_if(true), '_if returns fluid interface');
     $this->assertEquals($p2->getCriteria(), $criteria, 'main object is the given one, even with nested proxies');
     $this->assertEquals($p2->getParentProxy(), $p, 'nested proxy is respected');
     $p = new PropelConditionalProxy($criteria, true);
     $this->assertEquals($criteria, $p->_if(true), '_if returns fluid interface');
 }
コード例 #2
0
 /**
  * Returns the current object
  * Allows for conditional statements in a fluid interface.
  *
  * @return Criteria
  *
  * @throws PropelException
  */
 public function _endif()
 {
     if (!$this->conditionalProxy) {
         throw new PropelException('_endif() must be called after _if()');
     }
     $this->conditionalProxy = $this->conditionalProxy->getParentProxy();
     if ($this->conditionalProxy) {
         return $this->conditionalProxy->getCriteriaOrProxy();
     }
     // reached last level
     return $this;
 }