-
Notifications
You must be signed in to change notification settings - Fork 103
Manage AppBundle:MyEntity
#20
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
Comments
Care to elaborate? Where can this definition be obtained and is it suitable from the point of a static analyzer? |
$config = $entityManager->getConfiguration()
$config->addEntityNamespace('Foo', 'Foo\\Bar');
// Use later as:
$entityManager->getRepository('Foo::Author');
// where Author is in the `Foo\Bar` namespace. We don't use the Symfony framework but needed to add a namespace to be used by tools expecting it. So this could be used even outside the context of bundles. |
I need a way how to translate |
@ondrejmirtes Sure! Based on the above example: $alias = 'Foo';
$namespace = $config->getEntityNamespace('Foo');
echo $namespace;
// Foo\Bar |
And now how to share configuration between the app and PHPStan 🤔 cc
@lookyman do you think it’s possible?
On Tue, 23 Jan 2018 at 18:23, Haralan Dobrev ***@***.***> wrote:
@ondrejmirtes <https://github.com/ondrejmirtes> Sure! Based on the above
example:
$alias = 'Foo';$namespace = $config->getEntityNamespace('Foo');echo $namespace;// Foo\Bar
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuAXvq6DvlpoQimz42-OjdKDtp8asks5tNhWdgaJpZM4Roqgx>
.
--
Ondřej Mirtes
|
An alternative: // this recognises both aliases and namespace
$metadata = $entityManager->getClassMetadata('Foo::Author');
echo $metadata->getName();
// Foo\Bar\Author |
For this and other advanced Doctrine introspections to work in PHPStan, I'd think one needs to load the entity manager or registry in the PHPStan bootstrap. |
Isn't it possible to pass a entity classname to I think I have seen a PR deprecating this "aliasing" functionality in some of the Doctrine repositories, but I can't find it right now. Maybe @Majkl578 would know? |
@mhujer It is definitely possible to pass the entity FQCN everywhere including
Thanks for that! Here is the PR: doctrine/orm#6935 This would be a breaking change in Doctrine 3. I guess it's up to @ondrejmirtes to decide whether a functionality from Doctrine 2 which is being removed is worth supporting. Doctrine 3 is not out yet and I guess a lot of Doctrine-based projects would not be upgraded immediately. |
Actually you should always use |
I agree, if you want statically analyzable code, you should always |
Looks fair enough. Thanks for the tip! 👍 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
This is a valid notation for
getRepository
, but it's not managed.The text was updated successfully, but these errors were encountered: