Traits to help now write same code again.
Install via composer:
composer require asjustas/doctrine-traits
Trait add add
method to doctrine repository.
class UserRepository extends EntityRepository
{
use AddRepositoryTrait;
}
persist and flush object:
$userRepository->add($object);
only persist object:
$userRepository->add($object, false);
Trait add addMany
method to doctrine repository.
class UserRepository extends EntityRepository
{
use AddManyRepositoryTrait;
}
persist and flush objects array:
$userRepository->addMany($objects);
only persist objects array:
$userRepository->addMany($object, false);
Trait add remove
method to doctrine repository.
class UserRepository extends EntityRepository
{
use RemoveRepositoryTrait;
}
remove and flush object:
$userRepository->remove($object);
only remove object:
$userRepository->remove($object, false);
Trait add addMany
method to doctrine repository.
class UserRepository extends EntityRepository
{
use RemoveManyRepositoryTrait;
}
remove and flush objects array:
$userRepository->removeMany($objects);
only remove objects array:
$userRepository->removeMany($object, false);