0

DQL 用のカスタム DATE 関数を実装しようとしています。コードは次のとおりです。

namespace SwingBy\SwingByBundle\DQL; 

use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;

/**
 * Date  ::= "DATE" "(" ArithmeticPrimary ")"
 */

class Date extends FunctionNode {

    public $dateTimeExpression = null;

    public function parse(\Doctrine\ORM\Query\Parser $parser){

         $parser->match(Lexxer::T_IDENTIFIER);
         $parser->match(Lexxer::T_OPEN_PARENTHESIS);
         $this->dateTimeExpression = $parser->ArithmeticPrimary();
         $parser->match(Lexxer::T_CLOSE_PARENTHESIS);
    }

    public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker){

        return "DATE(" . $this->dateTimeExpression . ")";
    }
}

config.yml の構成は次のとおりです。

doctrine:
    orm:
        dql:
            datetime_functions:
                date: SwingBy\SwingByBundle\DQL\Date

そして、ここにエラーがあります:

The autoloader expected class "SwingBy\SwingByBundle\DQL\Date" to be defined in file 
"/Applications/MAMP/htdocs/swingby_dev2.3/src/SwingBy/SwingByBundle/DQL/Date.php". The 
file was found but the class was not in it, the class name or namespace probably has a   
typo.

解決策を見つけることができません。いくつかの異なる名前空間を試しましたが、何も機能しませんでした。

symfony バージョン: 2.3

4

1 に答える 1