ServiceLocator deprecated
This commit is contained in:
parent
1f87bac0f4
commit
100d9fe7d0
@ -6,6 +6,7 @@ use Zend\Console\Request as ConsoleRequest;
|
||||
use Zend\Mvc\Controller\AbstractActionController;
|
||||
use Zend\Stdlib\RequestInterface;
|
||||
use Zend\Stdlib\ResponseInterface;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class FileController extends AbstractActionController
|
||||
{
|
||||
@ -19,13 +20,19 @@ class FileController extends AbstractActionController
|
||||
*/
|
||||
protected $appConfig;
|
||||
|
||||
/**
|
||||
* @var \Doctrine\ORM\EntityManager object
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* @param Console $console
|
||||
* @param array $appConfig
|
||||
*/
|
||||
public function __construct(Console $console, array $appConfig)
|
||||
public function __construct(Console $console, EntityManager $em, array $appConfig)
|
||||
{
|
||||
$this->console = $console;
|
||||
$this->entityManager = $em;
|
||||
$this->appConfig = $appConfig;
|
||||
}
|
||||
|
||||
@ -53,10 +60,11 @@ class FileController extends AbstractActionController
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$verbose = $request->getParam('verbose', false) || $request->getParam('v', false);
|
||||
$dryrun = $request->getParam('dry-run', false) || $request->getParam('n', false);
|
||||
|
||||
|
||||
// Get file not sent
|
||||
$em = $this->getServiceLocator()->get('Doctrine\ORM\EntityManager');
|
||||
$results = $em->getRepository('Application\Entity\FluxFileout')->getNotSent();
|
||||
$results = $this->entityManager->getRepository('Application\Entity\FluxFileout')->getNotSent();
|
||||
if (count($results) == 0) {
|
||||
$this->output("Rien à traiter.", $verbose);
|
||||
} else {
|
||||
@ -69,6 +77,8 @@ class FileController extends AbstractActionController
|
||||
$this->output("", $verbose);
|
||||
}
|
||||
}
|
||||
|
||||
// Last line blank to always add a carrier return in console
|
||||
$this->output("", $verbose);
|
||||
}
|
||||
|
||||
|
@ -11,8 +11,9 @@ class FileControllerFactory implements FactoryInterface
|
||||
{
|
||||
$serviceLocator = $serviceLocator->getServiceLocator();
|
||||
$console = $serviceLocator->get('Console');
|
||||
$appConfig = $serviceLocator->get('config');
|
||||
$config = $serviceLocator->get('config');
|
||||
$em = $serviceLocator->get('Doctrine\ORM\EntityManager');
|
||||
|
||||
return new FileController($console, $appConfig);
|
||||
return new FileController($console, $em, $config);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user