1<?php 2/** 3 * Zend Framework (http://framework.zend.com/) 4 * 5 * @link http://github.com/zendframework/zf2 for the canonical source repository 6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 7 * @license http://framework.zend.com/license/new-bsd New BSD License 8 */ 9 10namespace Zend\Form\Annotation; 11 12use Zend\Filter\Boolean as BooleanFilter; 13 14/** 15 * AllowEmpty annotation 16 * 17 * Presence of this annotation is a hint that the associated 18 * \Zend\InputFilter\Input should enable the allowEmpty flag. 19 * 20 * @Annotation 21 * @deprecated 2.4.8 Use `@Validator({"name":"NotEmpty"})` instead. 22 */ 23class AllowEmpty 24{ 25 /** 26 * @var bool 27 */ 28 protected $allowEmpty = true; 29 30 /** 31 * Receive and process the contents of an annotation 32 * 33 * @param array $data 34 */ 35 public function __construct(array $data) 36 { 37 if (!isset($data['value'])) { 38 $data['value'] = false; 39 } 40 41 $allowEmpty = $data['value']; 42 43 if (!is_bool($allowEmpty)) { 44 $filter = new BooleanFilter(); 45 $allowEmpty = $filter->filter($allowEmpty); 46 } 47 48 $this->allowEmpty = $allowEmpty; 49 } 50 51 /** 52 * Get value of required flag 53 * 54 * @return bool 55 */ 56 public function getAllowEmpty() 57 { 58 return $this->allowEmpty; 59 } 60} 61