| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * (c) FSi sp. z o.o. <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | namespace FSi\FixturesBundle\Admin; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use FSi\Bundle\AdminBundle\Doctrine\Admin\FormElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use FSi\Bundle\AdminBundle\Form\TypeSolver; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Symfony\Component\Form\FormFactoryInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class SubscriberForm extends FormElement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     public function getClassName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         return 'FSi\FixturesBundle\Entity\Subscriber'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     public function getId() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         return 'subscriber_form'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     public function getName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         return 'admin.subscriber.name'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |     public function getSuccessRoute() | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         return 'fsi_admin_list'; | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     public function getSuccessRouteParameters() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         return array('element' => 'subscriber'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |     protected function initForm(FormFactoryInterface $factory, $data = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $builder = $factory->createNamedBuilder( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             'subscriber', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\FormType', 'form'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |             $data, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                 'data_class' => $this->getClassName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $builder->add( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |             'email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\EmailType', 'email'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 'label' => 'admin.subscriber.list.email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $builder->add( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             'created_at', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\DateType', 'date'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                 'label' => 'admin.subscriber.list.created_at', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                 'widget' => 'single_text' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $builder->add( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |             'active', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             TypeSolver::getFormType('Symfony\Component\Form\Extension\Core\Type\CheckboxType', 'checkbox'), | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                 'label' => 'admin.subscriber.list.active', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |         return $builder->getForm(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 81 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 82 |  |  |  | 
            
                        
This check looks at variables that are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.