Commit 733556b6 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Minor change in *Walker to be able to be used by custom assigned Walkers

parent 0a497062
......@@ -257,7 +257,8 @@ class Parser
}
// Create TreeWalker who creates the SQL from the AST
$treeWalker = $this->_treeWalker ?: new SqlWalker(
$treeWalker = $this->_treeWalker ?: new SqlWalker();
$treeWalker->init(
$this->_query, $this->_parserResult, $this->_queryComponents
);
......
......@@ -72,12 +72,9 @@ class SqlWalker implements TreeWalker
private $_useSqlTableAliases = true;
/**
* Initializes a new SqlWalker instance with the given Query and ParserResult.
*
* @param Query $query The parsed Query.
* @param ParserResult $parserResult The result of the parsing process.
* @inheritdoc
*/
public function __construct($query, $parserResult, array $queryComponents)
public function init($query, $parserResult, array $queryComponents)
{
$this->_rsm = $parserResult->getResultSetMapping();
$this->_query = $query;
......
......@@ -29,6 +29,15 @@ namespace Doctrine\ORM\Query;
*/
interface TreeWalker
{
/**
* Initializes TreeWalker with important information about the ASTs to be walked
*
* @param Query $query The parsed Query.
* @param ParserResult $parserResult The result of the parsing process.
* @param array $queryComponents Query components (symbol table)
*/
function init($query, $parserResult, array $queryComponents);
/**
* Walks down a SelectStatement AST node, thereby generating the appropriate SQL.
*
......
......@@ -30,6 +30,11 @@ namespace Doctrine\ORM\Query;
*/
abstract class TreeWalkerAdapter implements TreeWalker
{
/**
* @inheritdoc
*/
public function init($query, $parserResult, array $queryComponents) {}
/**
* Walks down a SelectStatement AST node, thereby generating the appropriate SQL.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment