Exemplo n.º 1
0
 public function testFilterParsing()
 {
     $c = array('article' => array('section' => 'News'));
     $p = new Parser('');
     $fe = new FilterExpression('article.section', $p);
     $this->assertEquals('News', $fe->resolve($c));
     $fe = new FilterExpression('article.section|upper', $p);
     $this->assertEquals('NEWS', $fe->resolve($c));
     $fe = new FilterExpression('"News"', $p);
     $this->assertEquals('News', $fe->resolve($c));
     $fe = new FilterExpression("'News'", $p);
     $this->assertEquals('News', $fe->resolve($c));
     $fe = new FilterExpression('"Some \\"Good\\" News"', $p);
     $this->assertEquals('Some "Good" News', $fe->resolve($c));
     $fe = new FilterExpression("'Some \"Good\" News'", $p);
     $this->assertEquals('Some "Good" News', $fe->resolve($c));
     $fe = new FilterExpression('"Some \\"Good\\" News"', $p);
     $this->assertEquals(array(), $fe->filters);
     $this->assertEquals('Some "Good" News', $fe->var);
     $fe = new FilterExpression("'Some \\'Bad\\' News'", $p);
     $this->assertEquals("Some 'Bad' News", $fe->resolve($c));
     // Filtered variables should reject access of attributes beginning with underscores.
     $this->setExpectedException('TemplateSyntaxError');
     new FilterExpression('article._hidden|upper', $p);
 }
Exemplo n.º 2
0
 public function matches($row)
 {
     return !parent::matches($row);
 }
Exemplo n.º 3
0
 /**
  * @param Context $context
  *
  * @return SafeString|string
  */
 public function render($context)
 {
     $output = $this->filter_expression->resolve($context);
     return DjaBase::renderValueInContext($output, $context);
 }
Exemplo n.º 4
0
 /**
  * @param $data
  * @return FilterExpression
  */
 public static function createFrom($data)
 {
     $result = new FilterExpression();
     if (isset($data['children']) && is_array($data['children'])) {
         foreach ($data['children'] as $child) {
             $result->add(FilterField::createFrom($child));
         }
     }
     return $result;
 }