|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* YAWIK |
|
4
|
|
|
* |
|
5
|
|
|
* @filesource |
|
6
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
|
7
|
|
|
* @license MIT |
|
8
|
|
|
* @author [email protected] |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Core\Paginator; |
|
12
|
|
|
|
|
13
|
|
|
use Core\Repository\RepositoryService; |
|
14
|
|
|
use Zend\ServiceManager\FactoryInterface; |
|
15
|
|
|
use Zend\ServiceManager\MutableCreationOptionsInterface; |
|
16
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
17
|
|
|
use Zend\Paginator\Paginator; |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Class PaginatorFactoryAbstract |
|
21
|
|
|
* @package Core\Paginator |
|
22
|
|
|
*/ |
|
23
|
|
|
abstract class PaginatorFactoryAbstract implements FactoryInterface, MutableCreationOptionsInterface |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
protected $options = []; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Set creation options |
|
30
|
|
|
* |
|
31
|
|
|
* @param array $options |
|
32
|
|
|
* |
|
33
|
|
|
* @return void |
|
34
|
|
|
*/ |
|
35
|
|
|
public function setCreationOptions(array $options) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->options = $options; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
|
43
|
|
|
* @return mixed|Paginator |
|
44
|
|
|
*/ |
|
45
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
|
46
|
|
|
{ |
|
47
|
|
|
/* @var PaginatorService $serviceLocator */ |
|
48
|
|
|
/* @var RepositoryService $repositories */ |
|
49
|
|
|
$repositories = $serviceLocator->getServiceLocator()->get('repositories'); |
|
|
|
|
|
|
50
|
|
|
$repository = $repositories->get($this->getRepository()); |
|
51
|
|
|
$queryBuilder = $repository->createQueryBuilder(); |
|
52
|
|
|
$filter = $serviceLocator->getServiceLocator()->get('filterManager')->get($this->getFilter()); |
|
|
|
|
|
|
53
|
|
|
$adapter = new \Core\Paginator\Adapter\DoctrineMongoLateCursor($queryBuilder, $filter, $this->options); |
|
54
|
|
|
$service = new Paginator($adapter); |
|
55
|
|
|
|
|
56
|
|
|
$this->setCreationOptions([]); |
|
57
|
|
|
return $service; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* pagination service name |
|
62
|
|
|
* |
|
63
|
|
|
* @return string |
|
64
|
|
|
*/ |
|
65
|
|
|
abstract protected function getFilter(); |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* repository name |
|
69
|
|
|
* |
|
70
|
|
|
* @return string |
|
71
|
|
|
*/ |
|
72
|
|
|
abstract protected function getRepository(); |
|
73
|
|
|
} |
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.