public function createAction()
 {
     $user = $this->identity();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $data = $request->getPost();
         if (isset($data['uid'])) {
             $id = $data['uid'];
             $friend = $this->dm->getRepository('User\\Document\\User')->findOneBy(array('id' => $id));
             // If no User was found flashMessage and Redirect
             if (!$friend) {
                 $this->flashMessenger()->addErrorMessage("Your request failed. Invalid User ID!");
                 return $this->redirect()->toRoute('user_dashboard/connections');
             }
             $connection = new Connection($user);
             $system = $this->dm->getRepository('User\\Document\\User')->findOneBy(array('userName' => 'System'));
             $notification = new Notification($system, "New relationship verification.", $user->getFullName() . " has sent you a relationship request that needs your verification.\n                    <a href='/user/dashboard/connection/verify/" . $connection->getId() . "'>");
             $notification->setRecipients($friend);
             try {
                 $this->dm->persist($connection);
                 $this->dm->persist($user);
                 $this->dm->persist($notification);
                 $this->dm->persist($friend);
                 $this->dm->flush();
             } catch (MongoDBException $e) {
                 $this->flashMessenger()->addErrorMessage("Your request failed. Error: " . $e->getCode());
                 return $this->redirect()->toRoute('user_dashboard/connections');
             }
             $this->flashMessenger()->addSuccessMessage("A connection request was sent. Now all you have to do is wait for verification!");
             return $this->redirect()->toRoute('user_dashboard/connections');
         }
     }
 }
 /**
  * {@inheritDoc}
  */
 public function setRecipients(\User\Document\User $recipient)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setRecipients', array($recipient));
     return parent::setRecipients($recipient);
 }