Source for file Hook.php
Documentation is available at Hook.php
* $Id: Hook.php 2149 2007-08-02 21:27:42Z zYne $
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.phpdoctrine.com>.
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @category Object Relational Mapping
* @link www.phpdoctrine.com
* @version $Revision: 2149 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @var Doctrine_Query $query the base query
* @var array $joins the optional joins of the base query
* @var array $hooks hooks array
* @var array $fieldParsers custom field parsers array
* keys as field names in the format componentAlias.FieldName
* values as parser names / objects
* @var array $typeParsers type parsers array
* keys as type names and values as parser names / objects
'char' =>
'Doctrine_Hook_WordLike',
'string' =>
'Doctrine_Hook_WordLike',
'varchar' =>
'Doctrine_Hook_WordLike',
'integer' =>
'Doctrine_Hook_Integer',
'enum' =>
'Doctrine_Hook_Integer',
'time' =>
'Doctrine_Hook_Time',
'date' =>
'Doctrine_Hook_Date',
* @param Doctrine_Query $query the base query
throw
new Doctrine_Exception('Constructor argument should be either Doctrine_Query object or valid DQL query');
* @return Doctrine_Query returns the query object associated with this hook
* @param string $type type name
* @param string|object $parser parser name or custom parser object
* @param string $field field name
* @param string|object $parser parser name or custom parser object
* builds DQL query where part from given parameter array
* @param array $params an associative array containing field
* @return boolean whether or not the hooking was
foreach ($params as $name =>
$value) {
if ($value ===
'' ||
$value ===
'-') {
list
($alias, $column) =
$e;
$map =
$this->query->getAliasDeclaration($alias);
if ($def =
$table->getDefinitionOf($column)) {
$parser->parse($alias, $column, $value);
$this->query->addWhere($parser->getCondition(), $parser->getParams());
* builds DQL query orderby part from given parameter array
* @param array $params an array containing all fields which the built query
* @return boolean whether or not the hooking was successful
foreach ($params as $name) {
$order =
($e[1] ==
'DESC') ?
'DESC' :
'ASC';
list
($alias, $column) =
$e;
$map =
$this->query->getAliasDeclaration($alias);
if ($def =
$table->getDefinitionOf($column)) {
$this->query->addOrderBy($alias .
'.' .
$column .
' ' .
$order);
$this->query->limit((int)
$limit);
$this->query->offset((int)
$offset);