-2

i have

class examController{
     public function regMail(){

     }
}

i want to call regMail() in authController

class authController{
    // i want regMail() here

} 
  • Controllers should contain actions. Sending mails looks like a job for a service. http://symfony.com/doc/current/book/service_container.html – Jakub Matczak Apr 29 '16 at 11:00
  • put your action in modal instead and then call it from controller – Pardeep Poria Apr 29 '16 at 11:10
  • 2
    You should look at the documentation and try to understand how to use services and what is the service container provided by Symfony. – COil Apr 29 '16 at 11:17

1 Answers1

1

To doing that, you have 2 solutions :

1 - Use forwarding (the good practice) ;

    //In your controllor
    public function indexAction($name) {

      $response = $this->forward('AppBundle:Something:fancy', array(
          'name'  => $name,
          'color' => 'green',
      ));

      // ... further modify the response or return it directly

      return $response;
     }

2 - Define your controller as service (the bad practice) ;

Try to look a this post for more details and (of course) the official documentation. Good luck ^^!

Community
  • 1
  • 1
Houssem ZITOUN
  • 644
  • 1
  • 8
  • 23