Created
July 26, 2012 20:36
-
-
Save bakura10/3184348 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Common\Service; | |
use Doctrine\ORM\EntityManager; | |
use Zend\Authentication\AuthenticationService; | |
use Zend\ServiceManager\ServiceManager; | |
use Zend\ServiceManager\ServiceManagerAwareInterface; | |
abstract class AbstractService implements ServiceManagerAwareInterface | |
{ | |
/** | |
* @var ServiceManager | |
*/ | |
protected $serviceManager; | |
/** | |
* @var EntityManager | |
*/ | |
protected $entityManager; | |
/** | |
* @var AuthenticationService | |
*/ | |
protected $authenticationService; | |
/** | |
* @param ServiceManager $serviceManager | |
* @return AbstractService | |
*/ | |
public function setServiceManager(ServiceManager $serviceManager) | |
{ | |
$this->serviceManager = $serviceManager; | |
return $this; | |
} | |
/** | |
* @return ServiceManager | |
*/ | |
public function getServiceManager() | |
{ | |
return $this->serviceManager; | |
} | |
/** | |
* @return AuthenticationService | |
*/ | |
public function getAuthenticationService() | |
{ | |
if (!$this->authenticationService) { | |
$this->authenticationService = $this->serviceManager->get('common.service.authentication'); | |
} | |
return $this->authenticationService; | |
} | |
/** | |
* @return EntityManager | |
*/ | |
public function getEntityManager() | |
{ | |
if (!$this->entityManager) { | |
$this->entityManager = $this->serviceManager->get('doctrine.entitymanager.orm_default'); | |
} | |
return $this->entityManager; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment