codemonkeys-ru / repository-alias-bundle
Symfony2 bundle providing alias syntax for working with entity repositories
Installs: 48
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.2
- symfony/framework-bundle: ~2.0
This package is not auto-updated.
Last update: 2024-04-27 11:51:37 UTC
README
Bundle provides alternative syntax for working with entity repositories. See Example section for more.
Installation
Install thru composer
php composer.phar require codemonkeys-ru/repository-alias-bundle
And add bundle to your AppKernel.php
class AppKernel extends Kernel
{
public function registerBundles()
{
...
new CodeMonkeysRu\RepositoryAliasBundle\RepositoryAliasBundle(),
...
}
}
Example
config.yml
repository_alias:
repository_key: "project.repo"
repository:
blogpost: AcmeBundle:Blog\Post
blogcomment: AcmeBundle:Blog\Comment
Instead of:
$repo = $this->getDoctrine()->getRepository('AcmeBundle:Blog\Post');
$post = new Acme\AcmeBundle\Blog\Post('title', 'post', $author);
Use:
$repo = $this->get('project.repo.blogpost'); //Note repository_key "project.repo" usage.
$post = $this->get('project.repo.blogpost')->newEntity('title', 'post', $author);
ChangeLog
v0.1.3
- Added getOriginalRepository decorator. Useful while configuring repos thru di container
v0.1.2
- Added getAliasFor() method
v0.1.1
- Added backloop interface
v0.1.0
- Initial version