Permalink
Browse files

provider

  • Loading branch information...
1 parent a379b80 commit 3e1263da903f236e1bb82740ac392dd8af813741 mparaiso committed Mar 25, 2013
@@ -0,0 +1,36 @@
+<?php
+
+/*
+ * @author M.paraiso
+ */
+
+namespace Mparaiso\Doctrine\ORM\Functions;
+
+use Doctrine\ORM\Query\Lexer;
+use Doctrine\ORM\Query\AST\Functions\FunctionNode;
+
+class Date extends FunctionNode
+{
+ public $date;
+
+ /**
+ * @override
+ */
+ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
+ {
+ return "DATE(" .$this->date->dispatch($sqlWalker) . ")";
+ }
+
+ /**
+ * @override
+ */
+ public function parse(\Doctrine\ORM\Query\Parser $parser)
+ {
+ $parser->match(Lexer::T_IDENTIFIER);
+ $parser->match(Lexer::T_OPEN_PARENTHESIS);
+
+ $this->date = $parser->ArithmeticPrimary();
+
+ $parser->match(Lexer::T_CLOSE_PARENTHESIS);
+ }
+}
@@ -47,11 +47,12 @@ function getDriver($type, array $paths, Configuration $config)
public function register(Application $app)
{
- $self = $this;
- $app["orm.proxy_dir"] = NULL;
- $app["orm.cache"] = NULL;
- $app["orm.is_dev_mode"] = $app["debug"];
- $app["orm.chain_driver"] = $app->share(function () {
+ $self = $this;
+ $app["orm.proxy_dir"] = NULL;
+ $app["orm.cache"] = NULL;
+ $app["orm.is_dev_mode"] = $app["debug"];
+ $app['orm.driver.configs'] = array();
+ $app["orm.chain_driver"] = $app->share(function () {
return new MappingDriverChain();
});
/**
@@ -66,13 +67,14 @@ public function register(Application $app)
if (isset($app["orm.logger"])) {
$config->setSQLLogger($app["orm.logger"]);
}
+ $config->addCustomDatetimeFunction("DATE", '\Mparaiso\Doctrine\ORM\Function\Date');
return $config;
});
/**
* EN : create the entity manager
* FR : créer l'entity manager
*/
- $app["orm.em"] = $app->share(function ($app)use($self) {
+ $app["orm.em"] = $app->share(function ($app) use ($self) {
foreach ($app["orm.driver.configs"] as $key => $config) {
if ($key == "default") {
$app["orm.chain_driver"]->setDefaultDriver($self->getDriver($config['type'], $config['paths'], $app["orm.config"]));

0 comments on commit 3e1263d

Please sign in to comment.