Skip to content

Instantly share code, notes, and snippets.

@gpfiel
Created January 30, 2014 17:57
Show Gist options
  • Save gpfiel/8714635 to your computer and use it in GitHub Desktop.
Save gpfiel/8714635 to your computer and use it in GitHub Desktop.
Entity manager
<?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