Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Konfiguration
- {
- public function __construct($entityManager)
- {
- $this->em = $entityManager;
- }
- public function getAll()
- {
- $config = $this->getCached();
- if ($config === NULL) {
- $config = $this->em->getRepository('Config')->getAll();
- $this->cache($config);
- }
- return $config;
- }
- }
- // službu zaregistruju do Containeru ...
- // pracuju se službou, nezajímá mě, že pracuji s nějakými entitami
- $container->konfiguration->getAll();
- # kdežto podle tvého postupu
- class Konfiguration extends Model\Service
- {
- function __construct($entityManager, $entity)
- {
- // ...
- }
- public function getAll()
- {
- $config = $this->getCached();
- if ($config === NULL) {
- $config = $this->em->getRepository($this->entity)->getAll();
- $this->cache($config);
- }
- return $config;
- }
- }
- // zaregistruju ...
- $container->doctrine->setEntityServiceClass('Config', 'Konfiguration');
- $container->doctrine->getEntityService('config')->getAll();
- // pracuji s entitami, které mají přidělené služby. Služba ztrácí svůj původní význam obalení několika (n repozitářů a n entit) do voňavého API, se kterým bude radost pracovat.
Advertisement
Add Comment
Please, Sign In to add comment