mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #991] [MERGED] Ability to define custom functions with callback instead of class name #9005
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/991
Author: @mnapoli
Created: 3/27/2014
Status: ✅ Merged
Merged: 5/16/2014
Merged by: @guilhermeblanco
Base:
master← Head:custom-functions-callback📝 Commits (1)
c7eb42bAbility to define custom functions with callback + tests📊 Changes
2 files changed (+90 additions, -9 deletions)
View changed files
📝
lib/Doctrine/ORM/Query/Parser.php(+18 -9)➕
tests/Doctrine/Tests/ORM/Functional/CustomFunctionsTest.php(+72 -0)📄 Description
Right now the only way to define custom DQL functions is by giving the class name, and Doctrine will create the class:
This is very limiting when the custom functions has dependencies, for example it can't be created by a DI container.
The approach I have taken here is very simple: it allows to define a callback instead of the class name: the callback will be called and it should return the instance:
On a side note, I think it would be great to generalize that approach because currently there are a lot of places where the same constraints apply.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.