rroek / doctrine-tools-bundle
A small bundle that give you some class & traits to faster make yours entities
Installs: 33
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 5
Type:symfony-bundle
Requires
- php: >=7.0
- doctrine/doctrine-bundle: ^2.8.3
- doctrine/orm: ^2.14.1
- gedmo/doctrine-extensions: ^3.11.0
- ramsey/uuid-doctrine: ^2.0.0
- stof/doctrine-extensions-bundle: ^1.7.1
- symfony/validator: 5.4.*
This package is auto-updated.
Last update: 2025-03-20 01:12:10 UTC
README
Features
- Give you some traits to build faster yours Doctrine2 Entities
- Give you a listener that override
Gedmo\Loggable\LoggableListener
(instof/doctrine-extensions-bundle
) which make that all fields of your entity is loggable without declare them one peer one manually.
Introduction
This small bundle give you the ability to build faster your Doctrine2 Entities with some PHP Traits. This bundle depends on
stof/doctrine-extensions-bundle
(&gedmo/doctrine-extensions included with
) -> in Dependencies ;ramsey/uuid-doctrine
-> in Dependencies ;vich/uploader-bundle
( for traits with files) -> Caution this bundle is not included in dependencies to not force users that don't need it.
List of traits
GenderTrait
-> for gender Mr, Mrs, Mister, etc.IdTrait
-> for idUuidTrait
-> for uuid field (use ramsey/uuid-doctrine)IsActiveTrait
-> for a boolean active/inactiveIsEnabledTrait
-> for a boolean enabled/disabledLabelTrait
-> for classic labelNameTrait
-> for classic fields firstname & lastnameIntegerNumberTrait
-> for a int number fieldFloatNumberTrait
-> for a float number fieldTitleTrait
-> for classic title fieldTypeTrait
-> for classic typeYearTrait
-> for year fieldVichUploaderFileTrait
-> for a file with its upload (use VichUploaderBundle)VichUploaderImageTrait
-> for a image file with its upload (use VichUploaderBundle)SingleImageFileUploadTrait
-> Same but if you don't want to use VichUploaderBundle.SingleFileUploadTrait
-> Same but if you don't want to use VichUploaderBundle.
Share yours
Feel free to share yours to add its in this bundle :)
Uses
Activate bundle
To use it, simply composer require rroek/doctrine-tools-bundle
Use it in your Entity
<?php namespace Acme\MyBundle\Manager; use RRoek\DoctrineToolsBundle\Traits\Entity\IdTrait; /** * @ORM\Entity() */ class MyAwesomeEntity { use IdTrait; }
Give you this in your entity :
/** * @var int * * @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=true) * @ORM\Id * @ORM\GeneratedValue(strategy="IDENTITY") * JMS\Expose */ private $id;
And it's Getter & Setter
And its all ! Your entity have auto-increment Id without rewrite another time that common field.
Use the LoggableListener
The LoggableListener simply extends Gedmo\Loggable\LoggableListener
of stof/doctrine-extensions-bundle
.
It just override one method to permit to write this :
/** * Parameter. * * @ORM\Entity() * @Gedmo\Loggable */ class MyEntity {...}
Instead of this :
/** * Parameter. * * @ORM\Entity() * @Gedmo\Loggable */ class MyEntity { /** * @ORM\Column(type="text") * @Gedmo\Versioned() */ private $name; /** * @ORM\Column(type="text") * @Gedmo\Versioned() */ private $label; /** * @ORM\Column(type="text") * @Gedmo\Versioned() */ private $type; [...] }