Elastica\QueryBuilder::addDSL PHP Method

addDSL() public method

Adds a new DSL object.
public addDSL ( Elastica\QueryBuilder\DSL $dsl )
$dsl Elastica\QueryBuilder\DSL
    public function addDSL(DSL $dsl)
    {
        $this->_facades[$dsl->getType()] = new Facade($dsl, $this->_version);
    }

Usage Example

 /**
  * @group unit
  */
 public function testCustomDSL()
 {
     $qb = new QueryBuilder();
     // test custom DSL
     $qb->addDSL(new CustomDSL());
     $this->assertTrue($qb->custom()->custom_method(), 'custom DSL execution failed');
     // test custom DSL exception message
     $exceptionMessage = '';
     try {
         $qb->invalid();
     } catch (QueryBuilderException $exception) {
         $exceptionMessage = $exception->getMessage();
     }
     $this->assertEquals('DSL "invalid" not supported', $exceptionMessage);
 }