PathExpression.php 2.69 KB
Newer Older
1 2 3 4 5 6
<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

7 8
namespace Doctrine\ORM\Query\AST;

9 10 11 12 13
/**
 * Description of PathExpression
 *
 * @author robo
 */
14
class PathExpression extends Node
15 16 17 18 19 20 21
{
    private $_parts;
    // Information that is attached during semantical analysis.
    private $_isSimpleStateFieldPathExpression = false;
    private $_isSimpleStateFieldAssociationPathExpression = false;
    private $_embeddedClassFields = array();
    private $_singleValuedAssociationFields = array();
22
    private $_collectionValuedAssociationFields = array();
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66

    public function __construct(array $parts)
    {
        $this->_parts = $parts;
    }

    public function getParts() {
        return $this->_parts;
    }

    /**
     * Gets whether the path expression represents a state field that is reached
     * either directly (u.name) or  by navigating over optionally many embedded class instances
     * (u.address.zip).
     *
     * @return boolean
     */
    public function isSimpleStateFieldPathExpression()
    {
        return $this->_isSimpleStateFieldPathExpression;
    }

    /**
     * Gets whether the path expression represents a state field that is reached
     * by navigating over at least one single-valued association and optionally
     * many embedded class instances. (u.Group.address.zip, u.Group.address, ...)
     *
     * @return boolean
     */
    public function isSimpleStateFieldAssociationPathExpression()
    {
        return $this->_isSimpleStateFieldAssociationPathExpression;
    }

    public function isPartEmbeddedClassField($part)
    {
        return isset($this->_embeddedClassFields[$part]);
    }

    public function isPartSingleValuedAssociationField($part)
    {
        return isset($this->_singleValuedAssociationFields[$part]);
    }

67 68 69 70 71
    public function isPartCollectionValuedAssociationField($part)
    {
        return isset($this->_collectionValuedAssociationFields[$part]);
    }

72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    /* Setters to attach semantical information during semantical analysis. */

    public function setIsSimpleStateFieldPathExpression($bool)
    {
        $this->_isSimpleStateFieldPathExpression = $bool;
    }

    public function setIsSimpleStateFieldAssociationPathExpression($bool)
    {
        $this->_isSimpleStateFieldAssociationPathExpression = $bool;
    }

    public function setIsEmbeddedClassPart($part)
    {
        $this->_embeddedClassFields[$part] = true;
    }

    public function setIsSingleValuedAssociationPart($part)
    {
        $this->_singleValuedAssociationFields[$part] = true;
    }
93 94 95 96 97

    public function setIsCollectionValuedAssociationPart($part)
    {
        $this->_collectionValuedAssociationFields[$part] = true;
    }
98
}