Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDC-3054: [GH-991] Ability to define custom functions with callback instead of class name #3825

Closed
doctrinebot opened this issue Mar 27, 2014 · 2 comments
Assignees
Labels
Milestone

Comments

@doctrinebot
Copy link

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of mnapoli:

Url: #991

Message:

Right now the only way to define custom DQL functions is by giving the class name, and Doctrine will create the class:

$config->addCustomNumericFunction('FOO', 'My\Custom\DqlFunction');

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:

$config->addCustomNumericFunction('FOO', function($funcName) {
    return new My\Custom\DqlFunction($funcName);
});

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.

@doctrinebot
Copy link
Author

Comment created by @doctrinebot:

A related Github Pull-Request [GH-991] was closed:
#991

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants