Created
January 30, 2014 17:57
-
-
Save gpfiel/8714635 to your computer and use it in GitHub Desktop.
Entity manager
This file contains hidden or 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 Application\Controller; | |
use Zend\Mvc\Controller\AbstractActionController; | |
class AcessarEntidadeController extends AbstractActionController | |
{ | |
/** | |
* @var EntityManager | |
*/ | |
protected $entityManager; | |
/** | |
* Sets the EntityManager | |
* | |
* @param EntityManager $em | |
* @access protected | |
* @return PostController | |
*/ | |
protected function setEntityManager(\Doctrine\ORM\EntityManager $em) | |
{ | |
$this->entityManager = $em; | |
return $this; | |
} | |
/** | |
* Returns the EntityManager | |
* | |
* Fetches the EntityManager from ServiceLocator if it has not been initiated | |
* and then returns it | |
* | |
* @access protected | |
* @return EntityManager | |
*/ | |
protected function getEntityManager() | |
{ | |
if (null === $this->entityManager) { | |
$this->setEntityManager($this->getServiceLocator()->get('Doctrine\ORM\EntityManager')); | |
} | |
return $this->entityManager; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment