Skip to content

Commit 94ee5c0

Browse files
committed
Add new OutputWalker and SqlFinalizer interfaces
1 parent 957da62 commit 94ee5c0

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\ORM\Query\Exec;
6+
7+
use Doctrine\ORM\Query;
8+
9+
/**
10+
* SqlFinalizers are created by OutputWalkers that traversed the DQL AST.
11+
* The SqlFinalizer instance can be kept in the query cache and re-used
12+
* at a later time.
13+
*
14+
* Once the SqlFinalizer has been created or retrieved from the query cache,
15+
* it receives the Query object again in order to yield the AbstractSqlExecutor
16+
* that will then be used to execute the query.
17+
*
18+
* The SqlFinalizer may assume that the DQL that was used to build the AST
19+
* and run the OutputWalker (which created the SqlFinalizer) is equivalent to
20+
* the query that will be passed to the createExecutor() method. Potential differences
21+
* are the parameter values or firstResult/maxResult settings.
22+
*/
23+
interface SqlFinalizer
24+
{
25+
public function createExecutor(Query $query): AbstractSqlExecutor;
26+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Doctrine\ORM\Query;
6+
7+
use Doctrine\ORM\Query\Exec\SqlFinalizer;
8+
9+
/**
10+
* Interface for output walkers
11+
*
12+
* Output walkers, like tree walkers, can traverse the DQL AST to perform
13+
* their purpose.
14+
*
15+
* The goal of an OutputWalker is to ultimately provide the SqlFinalizer
16+
* which produces the final, executable SQL statement in a "finalization" phase.
17+
*/
18+
interface OutputWalker extends TreeWalker
19+
{
20+
/** @param AST\DeleteStatement|AST\UpdateStatement|AST\SelectStatement $AST */
21+
public function getFinalizer($AST): SqlFinalizer;
22+
}

0 commit comments

Comments
 (0)