Ejemplo n.º 1
0
 public function handleSave(Form $form)
 {
     $values = $form->values;
     if ($values['file']->isOk()) {
         if ($values['cleanout']) {
             foreach ($this->userRepository->findAll() as $user) {
                 $this->userRepository->delete($user);
             }
         }
         /** @var FileUpload $file */
         $file = $values['file'];
         $data = file_get_contents($file->getTemporaryFile());
         foreach (explode("\n", $data) as $row) {
             if (!$row) {
                 continue;
             }
             $items = explode(',', $row);
             if (!count($items)) {
                 continue;
             }
             try {
                 $user = new UserEntity(trim($items[0]));
             } catch (InvalidArgumentException $e) {
                 $form->addError($e->getMessage());
             }
             $this->userRepository->save($user);
         }
     }
 }
Ejemplo n.º 2
0
 protected function startup()
 {
     parent::startup();
     if ($this->key) {
         if (($user = $this->userRepository->findOneBy(array('userKey' => $this->key))) === NULL) {
             throw new BadRequestException();
         }
         $this->userRepository->delete($user);
         $this->flashMessage('Byl jste odhlášen z newsletteru.', 'success');
         $this->redirect('this', array('key' => NULL));
     }
 }
Ejemplo n.º 3
0
 public function userDelete($userId, \UserRepository $userRepository)
 {
     $userRepository->delete($userId);
 }