title: Call to a member function on null
body: <p>I create service for add formType then persist object and in controller I invoke data but I have error shown on below image:</p>
  
  <p>in controller i extend class abstractController content getHandler and I have view newskill.html.twig</p>
  
  <p><a href="https://i.stack.imgur.com/OL5bv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OL5bv.png" alt="enter image description here"></a></p>
  
  <p>Code SkillController.php:</p>
  
  <pre><code>&lt;?php 
  
      namespace AppBundle\Controller\Condidate;
  
      use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
      use Symfony\Bundle\FrameworkBundle\Controller\Controller;
      use Symfony\Component\HttpFoundation\Request;
      use AppBundle\Entity\Skill;
      use AppBundle\Controller\AbstractController;
      use AppBundle\Form\SkillType;
  
      /**
       *Class SkillController.
       */
      class SkillController extends AbstractController
      {
  
           /**
           *function handler.
           */
           protected function getHandler(){
              //var_dump('test');
          }
  
          /**
           *function addSkill
           * @param Request $request
           * @return \Symfony\Component\Form\Form The form
           */
          public function addSkillAction(Request $request) {
               $skill = $this-&gt;getHandler()-&gt;post();
  
               if ($skill instanceof \AppBundle\Entity\Skill) {
                  return $this-&gt;redirectToRoute('ajouter_info');
  
          }
  
             return $this-&gt;render('skills/newskill.html.twig', array(
              'form' =&gt; $form-&gt;createView(),));
  
          }
  
  
          }
  </code></pre>
  
  <p>Code SkillHandler.php:</p>
  
  <pre><code>&lt;?php 
  
  namespace AppBundle\Handler;
  
  use AppBundle\Handler\HandlerInterface;
  use Symfony\Component\HttpFoundation\Request;
  use AppBundle\Entity\Skill;
  use Doctrine\ORM\EntityManager;
  use Symfony\Component\DependencyInjection\Container;
  use Symfony\Component\Form\formFactory;
  
  /**
   * SkillHandler.
   */
  class SkillHandler implements HandlerInterface {
  
      /**
       *
       * @var EntityManager 
       */
      protected $em;
  
      /**
       *
       * @var formFactory 
       */
      private $formFactory;
  
  
      /**
       *function construct.
       */
      public function __construct(EntityManager $entityManager, formFactory $formFactory)
          {
              $this-&gt;em = $entityManager;
              $this-&gt;formFactory = $formFactory;
          }
  
       /**
         *function post
         */
      public function post(array $parameters, array $options = []) {
          $form = $this-&gt;formFactory-&gt;create(\AppBundle\Form\SkillType::class, $object, $options);
          $form-&gt;submit($parameters);
          if ($form-&gt;isValid()) {
              $skill = $form-&gt;getData();
              $this-&gt;persistAndFlush($skill);
              return $skill;
          }
  
          return $form-&gt;getData();
      }
  
      /**
       *function persisteAndFlush
       */
  
      protected function persistAndFlush($object) {
         $this-&gt;em-&gt;persist($object);
         $this-&gt;em-&gt;flush();
      }
  
  
      /**
       *function get
       */
       public function get($id){
          throw new \DomainException('Method SkillHandler::get not implemented');
  
       }
  
       /**
        *function all
        */
        public function all($limit = 10, $offset = 0){
          throw new \DomainException('Method SkillHandler::all not implemented');
        }
  
  
      /**
       *function put
       */
      public function put($resource, array $parameters, array $options){
          throw new \DomainException('Method SkillHandler::put not implemented');
      }
  
      /**
       *function patch
       */
      public function patch($resource, array $parameters, array $options){
          throw new \DomainException('Method SkillHandler::patch not implemented');
      }
  
      /**
       *function delete
       */
       public function delete($resource){
          throw new \DomainException('Method SkillHandler::delete not implemented');
           }
  }
  </code></pre>
  
  <p>code services.yml:</p>
  
  <pre><code>skill_add:
      class: AppBundle\Handler\SkillHandler
      arguments: 
          - "@doctrine.orm.entity_manager"
          - "@form.factory"
      public: true
  </code></pre>
  
  <p>Any help would be appreciated.</p>