1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ZfcDatagrid\Service; |
4
|
|
|
|
5
|
|
|
use Interop\Container\ContainerInterface; |
6
|
|
|
use InvalidArgumentException; |
7
|
|
|
use Zend\ServiceManager\FactoryInterface; |
8
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
9
|
|
|
use ZfcDatagrid\Datagrid; |
10
|
|
|
|
11
|
|
|
abstract class AbstractDatagrid extends Datagrid implements FactoryInterface |
|
|
|
|
12
|
|
|
{ |
13
|
|
|
/** |
14
|
|
|
* @param ContainerInterface $container |
15
|
|
|
* @param string $requestedName |
16
|
|
|
* @param array|null $options |
17
|
|
|
* |
18
|
|
|
* @return $this |
19
|
|
|
*/ |
20
|
|
|
public function __invoke(ContainerInterface $container, $requestedName, array $options = null) |
21
|
|
|
{ |
22
|
|
|
$this->setServiceLocator($container); |
23
|
|
|
$config = $container->get('config'); |
24
|
|
|
|
25
|
|
|
if (!isset($config['ZfcDatagrid'])) { |
26
|
|
|
throw new InvalidArgumentException('Config key "ZfcDatagrid" is missing'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/* @var $application \Zend\Mvc\Application */ |
30
|
|
|
$application = $container->get('application'); |
31
|
|
|
|
32
|
|
|
parent::setOptions($config['ZfcDatagrid']); |
|
|
|
|
33
|
|
|
parent::setMvcEvent($application->getMvcEvent()); |
|
|
|
|
34
|
|
|
|
35
|
|
|
if ($container->has('translator') === true) { |
36
|
|
|
parent::setTranslator($container->get('translator')); |
|
|
|
|
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
parent::setRendererService($container->get('zfcDatagrid.renderer.'.parent::getRendererName())); |
|
|
|
|
40
|
|
|
parent::init(); |
|
|
|
|
41
|
|
|
|
42
|
|
|
return $this; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
47
|
|
|
* |
48
|
|
|
* @return Datagrid |
49
|
|
|
*/ |
50
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
51
|
|
|
{ |
52
|
|
|
return $this($serviceLocator, Datagrid::class); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Call initGrid on rendering. |
57
|
|
|
*/ |
58
|
|
|
public function render() |
59
|
|
|
{ |
60
|
|
|
$this->initGrid(); |
61
|
|
|
|
62
|
|
|
parent::render(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
abstract public function initGrid(); |
66
|
|
|
} |
67
|
|
|
|
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.