Simple manager abstract class service for entity
composer require gollumsf/manager
Register service by autowire.
namespace App\Manager;
use GolumSF\Manager\Manager;
class UserManager extends Manager {
}
namespace App\Controler;
use App\Manager\UserManager;
class MyControler {
myAction(UserManager $userManager) {
return Response($userManager->getEntityClass());
}
}
Display:
App\Entity\User
* public getEntityClass(): string // Return class name fo entity
* protected getEntityManager(): string // Return entity manager
* public getRepository(): ?ObjectRepository // Return repository of entity
* public delete($entity): Entity // Delete the doctrine entity
* public update($entity): Entity // Persist and flush the entity
* public find($id): Entity|null // Return the entity of id (wrapper of repository->find)
* public findOneBy(array $criteria): Entity|null // Return the entity of criteria (wrapper of repository->findOneBy)
* public findBy( // Return the entities of criteria (wrapper of repository->findBy)
array $criteria,
array $orderBy = null,
$limit = null,
$offset = null
): Entity[]