dcs / user-persistence-orm-bundle
The DCSUserPersistenceORMBundle adds functionality to DCSUserCoreBundle and provides the implementation of the persistence on database using Doctrine ORM
Installs: 9
Dependents: 0
Suggesters: 1
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=5.3.9
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
Requires (Dev)
- dcs/user-core-bundle: ~1.0@dev
- phpunit/phpcov: 3.*
- phpunit/phpunit: ^5
- satooshi/php-coveralls: ~1.0
- symfony/security: ~2.8|~3.0
This package is not auto-updated.
Last update: 2024-11-09 20:39:20 UTC
README
DCSUserPersistenceORMBundle
The DCSUserPersistenceORMBundle provides the final implementation of the persistence through DoctrineORM.
To do that this bundle will listen to two particular events emitted by Save and Delete methods of the DCSUserCoreBundle. The idea at the basis of related packages to DCS is to add functionality listening to emitted events.
This bundle provides the implementation of the repository service and performs a mapping of the User class.
The repository
The dcs_user.persistence.orm.repository
service is the implementation of the interface DCS\User\CoreBundle\Repository\UserRepositoryInterface
. This service can be sets at the repository_service parameter in the dcs_user_core settings.
dcs_user_core:
repository_service: dcs_user.persistence.orm.repository
Events
The complete list of events is within the class DCS\User\Persistence\ORMBundle\DCSUserPersistenceORMEvents
.
Installation
Prerequisites
This bundle requires DCSUserCoreBundle.
Require the bundle
Run the following command:
$ composer require dcs/user-persistence-orm-bundle "~1.0@dev"
Composer will install the bundle to your project's vendor/dcs/user-persistence-orm-bundle
directory.
Enable the bundle
Enable the bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new DCS\User\Persistence\ORMBundle\DCSUserPersistenceORMBundle(),
// ...
);
}
Create your User class
You must provide a concrete User class. You must extend the abstract model DCS\User\CoreBundle\Model\User
provided by the DCSUserCoreBundle and create the appropriate mapping.
Annotations
<?php
// src/AcmeBundle/Entity/User.php
namespace AcmeBundle\Entity;
use DCS\User\CoreBundle\Model\User as UserBase;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="dcs_user")
*/
class User extends UserBase
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
}
Yaml
# src/AcmeBundle/Resources/config/doctrine/User.orm.yml
AcmeBundle\Entity\User:
type: entity
table: dcs_user
id:
id:
type: integer
generator:
strategy: AUTO
Xml
<?xml version="1.0" encoding="utf-8"?>
<!-- src/AcmeBundle/Resources/config/doctrine/User.orm.xml -->
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="AcmeBundle\Entity\User" table="dcs_user">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
</entity>
</doctrine-mapping>
Configure
Now that you have properly enabled this bundle, the next step is to configure it.
Add the following configuration to your config.yml
.
dcs_user_core:
model_class: AcmeBundle\Entity\User
repository_service: dcs_user.persistence.orm.repository