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