| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace steevanb\SymfonyFormOptionsBuilder\OptionsBuilder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use steevanb\SymfonyFormOptionsBuilder\Behavior; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 7 |  |  | abstract class AbstractOptionsBuilder implements OptionsBuilderInterface | 
            
                                                                        
                            
            
                                    
            
            
                | 8 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 9 |  |  |     use Behavior\OptionTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 10 |  |  |     use Behavior\AttrTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 11 |  |  |     use Behavior\BlockNameTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 12 |  |  |     use Behavior\CompoundTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 13 |  |  |     use Behavior\ConstraintsTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 14 |  |  |     use Behavior\DataTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 15 |  |  |     use Behavior\DisabledTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  |     use Behavior\EmptyDataTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  |     use Behavior\ErrorBubblingTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     use Behavior\InheritDataTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |     use Behavior\InvalidMessageTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |     use Behavior\InvalidMessageParametersTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     use Behavior\LabelTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     use Behavior\LabelAttrTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     use Behavior\MappedTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     use Behavior\PropertyPathTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     use Behavior\RequiredTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     use Behavior\TranslationDomainTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     use Behavior\TrimTrait; | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |      * @return static | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public static function create() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         return new static(); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     public function asArray() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         return $this->options; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |      * @param string|null $child | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |      * @return array | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     public function asVariadic($child = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         if ($child === null) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             return array(static::getBuilderType(), $this->asArray()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         return array($child, static::getBuilderType(), $this->asArray()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 56 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |      * @param string|null $action | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |      * @link http://symfony.com/doc/2.8/reference/forms/types/form.html#action | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     public function setAction($action) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         return $this->setOption('action', $action); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |      * @return string|null | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     public function getAction() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |         return $this->getOption('action'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 77 |  |  |      * @param string $method | 
            
                                                                        
                            
            
                                    
            
            
                | 78 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 79 |  |  |      * @link http://symfony.com/doc/current/reference/forms/types/form.html#method | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |     public function setMethod($method) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |         return $this->setOption('method', $method); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |     public function getMethod() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |         return $this->getOption('method'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 92 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |      * @param bool $allow | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |      * @link http://symfony.com/doc/current/reference/forms/types/form.html#allow-extra-fields | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |      * @since 2.6 | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     public function setAllowExtraFields($allow = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |         return $this->setOption('allow_extra_fields', $allow); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 103 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |      * @return bool | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |      * @since 2.6 | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     public function getAllowExtraFields() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |         return $this->getOption('allow_extra_fields'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 112 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |      * @param string $message | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |      * @link http://symfony.com/doc/current/reference/forms/types/form.html#extra-fields-message | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |     public function setExtraFieldsMessage($message) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |         return $this->setOption('extra_fields_message', $message); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 122 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 123 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 124 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 125 |  |  |      * @return string | 
            
                                                                        
                            
            
                                    
            
            
                | 126 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     public function getExtraFieldsMessage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         return $this->getOption('extra_fields_message'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 130 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 132 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 133 |  |  |      * @param bool $autoInitialize | 
            
                                                                        
                            
            
                                    
            
            
                | 134 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 135 |  |  |      * @link http://symfony.com/doc/current/reference/forms/types/form.html#auto-initialize | 
            
                                                                        
                            
            
                                    
            
            
                | 136 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     public function setAutoInitialize($autoInitialize = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |         return $this->setOption('auto_initialize', $autoInitialize); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 140 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 142 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 143 |  |  |      * @return bool | 
            
                                                                        
                            
            
                                    
            
            
                | 144 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     public function getAutoInitialize() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         return $this->getOption('auto_initialize'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 148 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 149 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 150 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 151 |  |  |      * @param string|null $message | 
            
                                                                        
                            
            
                                    
            
            
                | 152 |  |  |      * @return $this | 
            
                                                                        
                            
            
                                    
            
            
                | 153 |  |  |      * @link http://symfony.com/doc/current/reference/forms/types/form.html#post-max-size-message | 
            
                                                                        
                            
            
                                    
            
            
                | 154 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |     public function setPostMaxSizeMessage($message) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return $this->setOption('post_max_size_message', $message); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 159 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 160 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 161 |  |  |      * @return string|null | 
            
                                                                        
                            
            
                                    
            
            
                | 162 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     public function getPostMaxSizeMessage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |         return $this->getOption('post_max_size_message'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 166 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 167 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 168 |  |  |  |