1
0
mirror of synced 2025-01-10 11:07:10 +03:00

Merge pull request #1031 from mnapoli/custom-functions-callback-documentation

Documentation for #991
This commit is contained in:
Marco Pivetta 2014-05-16 14:40:17 +02:00
commit 8babb77d37
3 changed files with 20 additions and 9 deletions

View File

@ -53,6 +53,17 @@ DQL query. ``$class`` is a string of a class-name which has to
extend ``Doctrine\ORM\Query\Node\FunctionNode``. This is a class extend ``Doctrine\ORM\Query\Node\FunctionNode``. This is a class
that offers all the necessary API and methods to implement a UDF. that offers all the necessary API and methods to implement a UDF.
Instead of providing the function class name, you can also provide
a callable that returns the function object:
.. code-block:: php
<?php
$config = new \Doctrine\ORM\Configuration();
$config->addCustomStringFunction($name, function () {
return new MyCustomFunction();
});
In this post we will implement some MySql specific Date calculation In this post we will implement some MySql specific Date calculation
methods, which are quite handy in my opinion: methods, which are quite handy in my opinion:

View File

@ -401,8 +401,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
* *
* DQL function names are case-insensitive. * DQL function names are case-insensitive.
* *
* @param string $name * @param string $name Function name.
* @param string $className * @param string|callable $className Class name or a callable that returns the function.
* *
* @return void * @return void
* *
@ -459,8 +459,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
* *
* DQL function names are case-insensitive. * DQL function names are case-insensitive.
* *
* @param string $name * @param string $name Function name.
* @param string $className * @param string|callable $className Class name or a callable that returns the function.
* *
* @return void * @return void
* *
@ -517,8 +517,8 @@ class Configuration extends \Doctrine\DBAL\Configuration
* *
* DQL function names are case-insensitive. * DQL function names are case-insensitive.
* *
* @param string $name * @param string $name Function name.
* @param string $className * @param string|callable $className Class name or a callable that returns the function.
* *
* @return void * @return void
* *

View File

@ -3411,7 +3411,7 @@ class Parser
$function = is_string($functionClass) $function = is_string($functionClass)
? new $functionClass($functionName) ? new $functionClass($functionName)
: $functionClass($functionName); : call_user_func($functionClass, $functionName);
$function->parse($this); $function->parse($this);
@ -3450,7 +3450,7 @@ class Parser
$function = is_string($functionClass) $function = is_string($functionClass)
? new $functionClass($functionName) ? new $functionClass($functionName)
: $functionClass($functionName); : call_user_func($functionClass, $functionName);
$function->parse($this); $function->parse($this);
@ -3490,7 +3490,7 @@ class Parser
$function = is_string($functionClass) $function = is_string($functionClass)
? new $functionClass($functionName) ? new $functionClass($functionName)
: $functionClass($functionName); : call_user_func($functionClass, $functionName);
$function->parse($this); $function->parse($this);