I'm using sonata Mongodb AdminBundle for my back-end, in my case I need to create a new action for my user model ( sending a mail to him ), I followed the documentation literally https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_custom_action.html but I got a weird error :
Compile Error: Cannot use Sonata\AdminBundle\Controller\CRUDController as Controller because the name is already in use
and this is my CRUDController Code :
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Session\UserBundle\Document\User;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Sonata\AdminBundle\Controller\CRUDController as Controller;
class CrudController extends Controller
{
public function inscriptionAction()
{
$mail = 'towho@someone.com';
$pinCode = '1klm8';
$sender = 'Mymail@gmail.com';
$dm = $this->get('doctrine_mongodb')->getManager();
$userManager = $this->container->get('fos_user.user_manager');
$user = $userManager->createUser();
$user->setEmail($mail);
$user->setUsername($mail);
$user->setPlainPassword($pinCode);
$user->setEnabled(true);
$userManager->updateUser($user, true);
$message = \Swift_Message::newInstance()
->setSubject('Test de recrutement')
->setFrom($sender)
->setTo($mail)
->setCharset('utf-8')
->setContentType('text/html')
->setBody(
$this->renderView(
'ATSQuizzBundle:Default:SwiftLayout/createUser.html.twig',
array('user' => $user, 'pinCode' => $pinCode)
)
);
$this->get('mailer')->send($message);
$this->addFlash('sonata_flash_success', 'mail sent to the candidate');
return new RedirectResponse($this->admin->generateUrl('list'));
}
}
any one knows the origin of this error please ?