/**
  * @AclAncestor("pim_user_user_edit")
  */
 public function apigenAction(User $user)
 {
     if (!($api = $user->getApi())) {
         $api = new UserApi();
     }
     $api->setApiKey($api->generateKey())->setUser($user);
     $em = $this->getDoctrine()->getManager();
     $em->persist($api);
     $em->flush();
     return $this->getRequest()->isXmlHttpRequest() ? new JsonResponse($api->getApiKey()) : $this->forward('OroUserBundle:User:view', array('user' => $user));
 }
 /**
  * {@inheritDoc}
  */
 public function getApi()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getApi', array());
     return parent::getApi();
 }