|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Settings\Form; |
|
4
|
|
|
|
|
5
|
|
|
use Zend\ServiceManager\ServiceLocatorInterface; |
|
6
|
|
|
use Zend\Form\Form; |
|
7
|
|
|
use Zend\Hydrator\ArraySerializable; |
|
8
|
|
|
|
|
9
|
|
|
abstract class FormAbstract extends Form |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @var ServiceLocatorInterface |
|
14
|
|
|
*/ |
|
15
|
|
|
protected $formManager; |
|
16
|
|
|
|
|
17
|
|
|
public function __construct(ServiceLocatorInterface $formManager, $name = null) |
|
18
|
|
|
{ |
|
19
|
|
|
parent::__construct('settings'); |
|
20
|
|
|
$this->formManager = $formManager; |
|
21
|
|
|
$this->setAttribute('method', 'post'); |
|
22
|
|
|
$this->setBindOnValidate(Form::BIND_ON_VALIDATE); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
public function getHydrator() |
|
26
|
|
|
{ |
|
27
|
|
|
if (!$this->hydrator) { |
|
28
|
|
|
$hydrator = new ArraySerializable(); |
|
29
|
|
|
$this->setHydrator($hydrator); |
|
30
|
|
|
} |
|
31
|
|
|
return $this->hydrator; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
protected function getPlugin($name) |
|
35
|
|
|
{ |
|
36
|
|
|
$plugin = null; |
|
37
|
|
|
$factory = $this->getFormFactory(); |
|
38
|
|
|
$formElementManager = $factory->getFormElementManager(); |
|
39
|
|
|
if (isset($formElementManager)) { |
|
40
|
|
|
$serviceLocator = $formElementManager->getServiceLocator(); |
|
41
|
|
|
$viewhelpermanager = $serviceLocator->get('viewhelpermanager'); |
|
42
|
|
|
if (isset($viewhelpermanager)) { |
|
43
|
|
|
$plugin = $viewhelpermanager->get($name); |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
return $plugin; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
public function init() |
|
50
|
|
|
{ |
|
51
|
|
|
|
|
52
|
|
|
$this->setName('setting-core'); |
|
53
|
|
|
|
|
54
|
|
|
$pluginUrl = $this->getPlugin('url'); |
|
55
|
|
|
$url = call_user_func_array($pluginUrl, array(null, array(), null, true)); |
|
56
|
|
|
$this->setAttribute('action', $url); |
|
57
|
|
|
|
|
58
|
|
|
//->setHydrator(new ModelHydrator()) |
|
|
|
|
|
|
59
|
|
|
//->setObject(new SettingsEntity()); |
|
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
$coreFieldset = $this->getCoreFieldset(); |
|
62
|
|
|
if (isset($coreFieldset)) { |
|
63
|
|
|
$this->add( |
|
64
|
|
|
$this->formManager->get($coreFieldset) |
|
65
|
|
|
->setUseAsBaseFieldset(true) |
|
66
|
|
|
); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
$this->add($this->formManager->get('DefaultButtonsFieldset')); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
abstract public function getCoreFieldset(); |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* @param ServiceLocatorInterface $formManager |
|
76
|
|
|
* @return FormAbstract |
|
77
|
|
|
*/ |
|
78
|
|
|
public static function factory(ServiceLocatorInterface $formManager) |
|
79
|
|
|
{ |
|
80
|
|
|
return new static($formManager); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
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.