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 ...@@ -257,7 +257,8 @@ class Parser
} }
// Create TreeWalker who creates the SQL from the AST // 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 $this->_query, $this->_parserResult, $this->_queryComponents
); );
......
...@@ -72,12 +72,9 @@ class SqlWalker implements TreeWalker ...@@ -72,12 +72,9 @@ class SqlWalker implements TreeWalker
private $_useSqlTableAliases = true; private $_useSqlTableAliases = true;
/** /**
* Initializes a new SqlWalker instance with the given Query and ParserResult. * @inheritdoc
*
* @param Query $query The parsed Query.
* @param ParserResult $parserResult The result of the parsing process.
*/ */
public function __construct($query, $parserResult, array $queryComponents) public function init($query, $parserResult, array $queryComponents)
{ {
$this->_rsm = $parserResult->getResultSetMapping(); $this->_rsm = $parserResult->getResultSetMapping();
$this->_query = $query; $this->_query = $query;
......
...@@ -29,6 +29,15 @@ namespace Doctrine\ORM\Query; ...@@ -29,6 +29,15 @@ namespace Doctrine\ORM\Query;
*/ */
interface TreeWalker 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. * Walks down a SelectStatement AST node, thereby generating the appropriate SQL.
* *
......
...@@ -30,6 +30,11 @@ namespace Doctrine\ORM\Query; ...@@ -30,6 +30,11 @@ namespace Doctrine\ORM\Query;
*/ */
abstract class TreeWalkerAdapter implements TreeWalker abstract class TreeWalkerAdapter implements TreeWalker
{ {
/**
* @inheritdoc
*/
public function init($query, $parserResult, array $queryComponents) {}
/** /**
* Walks down a SelectStatement AST node, thereby generating the appropriate SQL. * 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