1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* YAWIK |
4
|
|
|
* |
5
|
|
|
* @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de) |
6
|
|
|
* @license MIT |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Solr\Paginator; |
10
|
|
|
|
11
|
|
|
use Core\Paginator\PaginatorService; |
12
|
|
|
use Solr\Paginator\Adapter\SolrAdapter; |
13
|
|
|
use Zend\Paginator\Paginator; |
14
|
|
|
use Zend\ServiceManager\FactoryInterface; |
15
|
|
|
use Zend\ServiceManager\MutableCreationOptionsInterface; |
16
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
17
|
|
|
|
18
|
|
View Code Duplication |
abstract class PaginatorFactoryAbstract implements FactoryInterface,MutableCreationOptionsInterface |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
protected $options = []; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Set creation options |
24
|
|
|
* |
25
|
|
|
* @param array $options |
26
|
|
|
* |
27
|
|
|
* @return void |
28
|
|
|
*/ |
29
|
|
|
public function setCreationOptions(array $options) |
30
|
|
|
{ |
31
|
|
|
$this->options = $options; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function getCreationOptions() |
35
|
|
|
{ |
36
|
|
|
return $this->options; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param ServiceLocatorInterface $serviceLocator |
41
|
|
|
* @return mixed|Paginator |
42
|
|
|
*/ |
43
|
|
|
public function createService(ServiceLocatorInterface $serviceLocator) |
44
|
|
|
{ |
45
|
|
|
/* @var PaginatorService $serviceLocator */ |
46
|
|
|
$filter = $serviceLocator->getServiceLocator()->get('filterManager')->get($this->getFilter()); |
47
|
|
|
$connectPath = $this->getConnectPath(); |
48
|
|
|
$solrClient = $serviceLocator->getServiceLocator()->get('Solr/Manager')->getClient($connectPath); |
49
|
|
|
$resultConverter = $serviceLocator->getServiceLocator()->get('Solr/ResultConverter'); |
50
|
|
|
$adapter = new SolrAdapter($solrClient,$filter,$resultConverter,$this->options); |
|
|
|
|
51
|
|
|
$service = new Paginator($adapter); |
52
|
|
|
|
53
|
|
|
$this->setCreationOptions([]); |
54
|
|
|
return $service; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* pagination service name |
59
|
|
|
* |
60
|
|
|
* @return string |
61
|
|
|
*/ |
62
|
|
|
abstract protected function getFilter(); |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* Get Solr Connect Path for this paginator |
66
|
|
|
* |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
abstract protected function getConnectPath(); |
70
|
|
|
} |
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.