PageRenderTime 44ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/module/Admin/src/Admin/Model/Clients.php

https://gitlab.com/my-application.bjoernbartels.earth/my-application
PHP | 322 lines | 258 code | 26 blank | 38 comment | 2 complexity | 00107605ea69a5f61d38648899877e5f MD5 | raw file
  1. <?php
  2. /**
  3. * BB's Zend Framework 2 Components
  4. *
  5. * AdminModule
  6. *
  7. * @package [MyApplication]
  8. * @package BB's Zend Framework 2 Components
  9. * @package AdminModule
  10. * @author Björn Bartels <coding@bjoernbartels.earth>
  11. * @link https://gitlab.bjoernbartels.earth/groups/zf2
  12. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
  13. * @copyright copyright (c) 2016 Björn Bartels <coding@bjoernbartels.earth>
  14. */
  15. namespace Admin\Model;
  16. use Zend\Crypt\Password\Bcrypt;
  17. use Zend\InputFilter\InputFilter;
  18. use Zend\InputFilter\Factory as InputFactory;
  19. use Zend\InputFilter\InputFilterAwareInterface;
  20. use Zend\InputFilter\InputFilterInterface;
  21. use Zend\ServiceManager\ServiceLocatorInterface;
  22. use Zend\ServiceManager\ServiceLocatorAwareInterface;
  23. class Clients implements InputFilterAwareInterface, ServiceLocatorAwareInterface
  24. {
  25. public $clients_id;
  26. public $scope;
  27. public $ref_id;
  28. public $type;
  29. public $name;
  30. public $value;
  31. protected $inputFilter;
  32. protected $userService;
  33. protected $serviceManager;
  34. protected $serviceLocator;
  35. public function exchangeArray($data)
  36. {
  37. $this->clients_id = (isset($data['clients_id'])) ? $data['clients_id'] : null;
  38. $this->name = (isset($data['name'])) ? $data['name'] : null;
  39. $this->extraname = (isset($data['extraname'])) ? $data['extraname'] : null;
  40. $this->homepage = (isset($data['homepage'])) ? $data['homepage'] : null;
  41. $this->email = (isset($data['email'])) ? $data['email'] : null;
  42. $this->contact = (isset($data['contact'])) ? $data['contact'] : null;
  43. $this->phone = (isset($data['phone'])) ? $data['phone'] : null;
  44. $this->statistics = (isset($data['statistics'])) ? $data['statistics'] : null;
  45. }
  46. public function getArrayCopy()
  47. {
  48. return get_object_vars($this);
  49. }
  50. public function setInputFilter(InputFilterInterface $inputFilter)
  51. {
  52. throw new \Exception("Not used");
  53. }
  54. public function getInputFilter()
  55. {
  56. if (!$this->inputFilter) {
  57. $inputFilter = new InputFilter();
  58. $factory = new InputFactory();
  59. $inputFilter->add(
  60. $factory->createInput(
  61. array(
  62. 'name' => 'clients_id',
  63. 'required' => true,
  64. 'filters' => array(
  65. array('name' => 'Int'),
  66. ),
  67. )
  68. )
  69. );
  70. $inputFilter->add(
  71. $factory->createInput(
  72. array(
  73. 'name' => 'name',
  74. 'required' => true,
  75. 'filters' => array(
  76. array('name' => 'StripTags'),
  77. array('name' => 'StringTrim'),
  78. ),
  79. 'validators' => array(
  80. array(
  81. 'name' => 'StringLength',
  82. 'options' => array(
  83. 'encoding' => 'UTF-8',
  84. 'min' => 1,
  85. 'max' => 255,
  86. ),
  87. ),
  88. ),
  89. )
  90. )
  91. );
  92. $inputFilter->add(
  93. $factory->createInput(
  94. array(
  95. 'name' => 'extraname',
  96. 'required' => false,
  97. 'filters' => array(
  98. array('name' => 'StripTags'),
  99. array('name' => 'StringTrim'),
  100. ),
  101. 'validators' => array(
  102. array(
  103. 'name' => 'StringLength',
  104. 'options' => array(
  105. 'encoding' => 'UTF-8',
  106. 'min' => 1,
  107. 'max' => 255,
  108. ),
  109. ),
  110. ),
  111. )
  112. )
  113. );
  114. $inputFilter->add(
  115. $factory->createInput(
  116. array(
  117. 'name' => 'homepage',
  118. 'required' => false,
  119. 'filters' => array(
  120. array('name' => 'StripTags'),
  121. array('name' => 'StringTrim'),
  122. ),
  123. 'validators' => array(
  124. array(
  125. 'name' => 'StringLength',
  126. 'options' => array(
  127. 'encoding' => 'UTF-8',
  128. 'min' => 1,
  129. 'max' => 255,
  130. ),
  131. ),
  132. ),
  133. )
  134. )
  135. );
  136. $inputFilter->add(
  137. $factory->createInput(
  138. array(
  139. 'name' => 'email',
  140. 'required' => false,
  141. 'filters' => array(
  142. array('name' => 'StripTags'),
  143. array('name' => 'StringTrim'),
  144. ),
  145. 'validators' => array(
  146. array(
  147. 'name' => 'StringLength',
  148. 'options' => array(
  149. 'encoding' => 'UTF-8',
  150. 'min' => 1,
  151. 'max' => 255,
  152. ),
  153. ),
  154. ),
  155. )
  156. )
  157. );
  158. $inputFilter->add(
  159. $factory->createInput(
  160. array(
  161. 'name' => 'contact',
  162. 'required' => false,
  163. 'filters' => array(
  164. array('name' => 'StripTags'),
  165. array('name' => 'StringTrim'),
  166. ),
  167. 'validators' => array(
  168. array(
  169. 'name' => 'StringLength',
  170. 'options' => array(
  171. 'encoding' => 'UTF-8',
  172. 'min' => 1,
  173. 'max' => 255,
  174. ),
  175. ),
  176. ),
  177. )
  178. )
  179. );
  180. $inputFilter->add(
  181. $factory->createInput(
  182. array(
  183. 'name' => 'phone',
  184. 'required' => false,
  185. 'filters' => array(
  186. array('name' => 'StripTags'),
  187. array('name' => 'StringTrim'),
  188. ),
  189. 'validators' => array(
  190. array(
  191. 'name' => 'StringLength',
  192. 'options' => array(
  193. 'encoding' => 'UTF-8',
  194. 'min' => 1,
  195. 'max' => 255,
  196. ),
  197. ),
  198. ),
  199. )
  200. )
  201. );
  202. $inputFilter->add(
  203. $factory->createInput(
  204. array(
  205. 'name' => 'statistics',
  206. 'required' => false,
  207. 'filters' => array(
  208. array('name' => 'StripTags'),
  209. array('name' => 'StringTrim'),
  210. ),
  211. 'validators' => array(
  212. array(
  213. 'name' => 'StringLength',
  214. 'options' => array(
  215. 'encoding' => 'UTF-8',
  216. 'min' => 1,
  217. 'max' => 255,
  218. ),
  219. ),
  220. ),
  221. )
  222. )
  223. );
  224. $inputFilter->add(
  225. $factory->createInput(
  226. array(
  227. 'name' => 'value',
  228. 'required' => false,
  229. 'filters' => array(
  230. array('name' => 'StripTags'),
  231. array('name' => 'StringTrim'),
  232. ),
  233. 'validators' => array(
  234. ),
  235. )
  236. )
  237. );
  238. $this->inputFilter = $inputFilter;
  239. }
  240. return $this->inputFilter;
  241. }
  242. /**
  243. * Getters/setters for DI stuff
  244. */
  245. public function getUserService()
  246. {
  247. if (!$this->userService) {
  248. $this->userService = $this->getServiceManager()->get('zfcuser_user_service');
  249. }
  250. return $this->userService;
  251. }
  252. public function setUserService(UserService $userService)
  253. {
  254. $this->userService = $userService;
  255. return $this;
  256. }
  257. /**
  258. * Retrieve service manager instance
  259. *
  260. * @return ServiceManager
  261. */
  262. public function getServiceManager()
  263. {
  264. return $this->serviceManager;
  265. }
  266. /**
  267. * Set service manager instance
  268. *
  269. * @param ServiceManager $serviceManager
  270. * @return User
  271. */
  272. public function setServiceManager(ServiceManager $serviceManager)
  273. {
  274. $this->serviceManager = $serviceManager;
  275. return $this;
  276. }
  277. /**
  278. * Set serviceManager instance
  279. *
  280. * @param ServiceLocatorInterface $serviceLocator
  281. * @return void
  282. */
  283. public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
  284. {
  285. $this->serviceLocator = $serviceLocator;
  286. }
  287. /**
  288. * Retrieve serviceManager instance
  289. *
  290. * @return ServiceLocatorInterface
  291. */
  292. public function getServiceLocator()
  293. {
  294. return $this->serviceLocator;
  295. }
  296. }