{@inheritdoc}

@throws \eZ\Publish\Core\Base\Exceptions\NotFoundException
971756
public function setUserPreference(UserPreferenceSetStruct $setStruct): UserPreference
    {
        $this->gateway->setUserPreference($setStruct);

        return $this->getUserPreferenceByUserIdAndName($setStruct->userId, $setStruct->name);
    }
821648
public function showFileAction()
    {
        $id = $this->getRequest()->get($this->admin->getIdParameter());
        $invoice = $this->admin->getObject($id);

        if (!$invoice) {
            throw $this->createNotFoundException(sprintf('Unable to find the invoice with id : %s', $id));
        }

        $this->admin->checkAccess('show', $invoice);

        return new Response(
            $invoice->getFile(),
            200,
            ['Content-Type' => 'application/pdf']
        );
    }
284393
public function execute(InputInterface $input, OutputInterface $output)
    {
        /** @var QuestionHelper $helper */
        $helper = $this->getHelper('question');

        $copyrightYear = date('Y');
        $packageName = 'Unknown';
        $packageOwner = 'Contributors';
        $packageOwnerEmail = '';

        if ($input->hasOption('name')) {
            $packageName = $input->getOption('name');
        } else {
            $packageName = $helper->ask($input, $output, new Question(
                'What is the package name? '
            ));
        }

        if ($input->hasOption('owner')) {
            $packageOwner = $input->getOption('owner');
        } else {
            $packageOwner = $helper->ask($input, $output, new Question(
                'Who is the package owner? '
            ));
        }

        if ($input->hasOption('email')) {
            $packageOwnerEmail = $input->getOption('email');
        } else {
            $packageOwnerEmail = $helper->ask($input, $output, new Question(
                'What is the contact email of the owner? (Optional) ',
                ''
            ));
        }

        $template = file_get_contents(
            __DIR__ . '/../../../../resources/project/formatter.yml'
        );

        $template = str_replace('<year>', $copyrightYear, $template);
        $template = str_replace('<owner>', $packageOwner, $template);
        $template = str_replace('<package>', $packageName, $template);
        $template = str_replace('<email>', $packageOwnerEmail, $template);

        $filesystem = new Filesystem();

        if ($filesystem->exists('.formatter.yml')) {
            if ($helper->ask($input, $output, new ConfirmationQuestion(
                '.formatter.yml already exists. Overwrite? (y/N) ',
                false
            ))) {
                $filesystem->dumpFile('.formatter.yml', $template);
                $output->writeln('Wrote .formatter.yml');
            }
        } else {
            $filesystem->dumpFile('.formatter.yml', $template);
            $output->writeln('Wrote .formatter.yml');
        }

        if (!$filesystem->exists('.editorconfig')) {
            $filesystem->dumpFile(
                '.editorconfig',
                file_get_contents(
                    __DIR__ . '/../../../../resources/project/editorconfig'
                )
            );
            $output->writeln('Wrote .editorconfig');
        }

        return 0;
    }
357251
public function view($projectId)
    {
        $project = $this->projectStore->getById($projectId);

        if (empty($project)) {
            throw new NotFoundException('Project with id: ' . $projectId . ' not found');
        }

        if (!$project->getAllowPublicStatus()) {
            throw new NotFoundException('Project with id: ' . $projectId . ' not found');
        }

        $builds = $this->getLatestBuilds($projectId);

        if (count($builds)) {
            $this->view->latest = $builds[0];
        }

        $this->view->builds = $builds;
        $this->view->project = $project;

        return $this->view->render();
    }
657653
public function get($id)
    {
        /** @var ContainerInterface $container */
        foreach ($this->containers as $container) {
            if ($container->has($id)) {
                return $container->get($id);
            }
        }

        throw NotFoundException::fromPrevious($id);
    }
1201715
public function run()
    {
        $clientId = Yii::$app->getRequest()->getQueryParam($this->clientIdGetParamName);
        if (!empty($clientId)) {
            /* @var $collection \yii\authclient\Collection */
            $collection = Yii::$app->get($this->clientCollection);
            if (!$collection->hasClient($clientId)) {
                throw new NotFoundHttpException("Unknown auth client '{$clientId}'");
            }
            $client = $collection->getClient($clientId);

            return $this->auth($client);
        }

        throw new NotFoundHttpException();
    }
490659
public function index($key = null)
    {
        if (!$key) {
            $key = 'App';
        }
        $this->Menu->active($this->prefixes[$key]);

        if (!$this->__prefixExists($key)) {
            throw new NotFoundException("The prefix-setting " . $key . " could not be found");
        }

        $prefix = Hash::get($this->prefixes, ucfirst($key));

        $settings = $this->Configurations->find('all')->where([
            'name LIKE' => $key . '%',
            'editable' => 1,
        ])->order(['weight', 'id']);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $settings = $this->Configurations->patchEntities($settings, $this->request->data);
            foreach ($settings as $setting) {
                $this->Flash->success('The settings has been saved.');
                if (!$this->Configurations->save($setting)) {
                    $this->Flash->error('The settings could not be saved. Please, try again.');
                }
            }
            Setting::clear(true);
            Setting::autoLoad();
            return $this->redirect([]);
        }

        $this->set(compact('prefix', 'settings'));
    }
887735
public function getQuestion($id)
    {
        /** @var TemplateInterface $template */
        foreach ($this->data as $template) {
            if ($template->getQuestion()->getId() == $id) {
                return $template;
            }
        }

        throw new NotFoundHttpException(sprintf('Id question %s not found', $id));
    }
67736
public function edit($id = null) {
		if (!$this->IvaResponsabilidad->exists($id)) {
			throw new NotFoundException(__('Invalid iva responsabilidad'));
		}
		if ($this->request->is(array('post', 'put'))) {
			if ($this->IvaResponsabilidad->save($this->request->data)) {
				$this->Session->setFlash(__('The iva responsabilidad has been saved.'));
				return $this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The iva responsabilidad could not be saved. Please, try again.'));
			}
		} else {
			$options = array('conditions' => array('IvaResponsabilidad.' . $this->IvaResponsabilidad->primaryKey => $id));
			$this->request->data = $this->IvaResponsabilidad->find('first', $options);
		}
		$tipoFacturas = $this->IvaResponsabilidad->TipoFactura->find('list');
		$this->set(compact('tipoFacturas'));
	}
1101634
public function find($storageName, $key)
    {
        $qb = $this->conn->createQueryBuilder();

        $qb->select('s.' . $this->dataColumn)
            ->from($this->table, 's')
            ->where($this->keyColumn . ' = ?')
            ->setParameters([$key]);

        $stmt = $qb->execute();

        $data = $stmt->fetchColumn();

        if (! $data) {
            throw new NotFoundException();
        }

        return unserialize($data);
    }
91555
public function edit($id = null) {
		if (!$this->Cliente->exists($id)) {
			throw new NotFoundException(__('Invalid %s', Configure::read('Mesa.tituloCliente')));
		}
		if ($this->request->is(array('post', 'put'))) {
			if ($this->Cliente->save($this->request->data)) {
				$this->Session->setFlash(__('The %s has been saved.', Configure::read('Mesa.tituloCliente')));
				return $this->redirect(array('action' => 'index'));
			} else {
				$this->Session->setFlash(__('The %s could not be saved. Please, try again.', Configure::read('Mesa.tituloCliente')));
			}
		} else {
			$options = array('conditions' => array('Cliente.' . $this->Cliente->primaryKey => $id));
			$this->request->data = $this->Cliente->find('first', $options);
		}
		$descuentos = $this->Cliente->Descuento->find('list');
		$tipoDocumentos = $this->Cliente->TipoDocumento->find('list');
		$ivaResponsabilidades = $this->Cliente->IvaResponsabilidad->find('list');
		$this->set(compact('descuentos', 'tipoDocumentos', 'ivaResponsabilidades'));
		$this->render('form');
	}
171542
public function actionView($id)
    {
        $user = $this->findModel(Yii::$app->user->id);
        /** @var DatabaseNotification $notification */
        if (($notification = $user->getNotifications()->andWhere(['id' => $id])->one()) != null) {
            $notification->setRead();
            return $notification;
        } else {
            throw new NotFoundHttpException("Notification not found: $id");
        }
    }
209624
public function delete($id = null) {
		$this->Cliente->id = $id;
		if (!$this->Cliente->exists()) {
			throw new NotFoundException(__('Invalid %s', Configure::read('Mesa.tituloCliente')));
		}
		$this->request->allowMethod('post', 'delete');
		if ($this->Cliente->delete()) {
			$this->Session->setFlash(__('The %s has been deleted.', Configure::read('Mesa.tituloCliente')));
		} else {
			$this->Session->setFlash(__('The %s could not be deleted. Please, try again.', Configure::read('Mesa.tituloCliente')));
		}
		return $this->redirect(array('action' => 'index'));
	}
431455
public function edit($id)
    {
        if (!$this->request->is(['get', 'put'])) {
            throw new MethodNotAllowedException();
        }

        /** @var User $user */
        $user = $this->Users->getUserAndGroups($id);

        if ($this->request->is('put')) {
            $user = $this->Users->patchEntity($user, $this->request->data, ['associated' => 'Groups']);
            $userActivated = ($user->dirty('active') && $user->active);
            if ($userActivated) {
                // do not allow a user to be activated if his email address is not verified
                if (!$user->verified) {
                    $user->active = false;
                    $userActivated = false;
                } else {
                    $user->activate();
                }
            }
            $userDeactivated = ($user->dirty('active') && !$user->active);
            if ($userDeactivated) {
                // do not allow a user to deactivate his own account
                if ($user->id === Wasabi::user()->id) {
                    $user->active = true;
                    $userDeactivated = false;
                } else {
                    $user->deactivate();
                }
            }
            if ($this->Users->save($user, ['associated' => 'Groups'])) {
                if ($user->id === Wasabi::user()->id) {
                    $updateUser = $this->Users->get($user->id);
                    $updateUser->group_id = $this->Users->UsersGroups->getGroupIds($updateUser->id);
                    $this->Auth->setUser($updateUser->toArray());
                    Wasabi::user($updateUser);
                }
                if ($userActivated && $user->verified) {
                    $this->getMailer('Wasabi/Core.User')->send('activatedEmail', [$user]);
                }
                if ($userDeactivated && $user->verified) {
                    $this->getMailer('Wasabi/Core.User')->send('deactivatedEmail', [$user]);
                }
                $this->Flash->success(__d('pb', 'The user <strong>{0}</strong> has been updated.', $user->fullName()));
                $this->redirect($this->Filter->getBacklink(['action' => 'index'], $this->request));
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }

        $groups = $this->Users->Groups->find('list')->order('id ASC');

        // users that are no admin, may not select the admin group
        if (Wasabi::user()->hasAccessLevel(Permission::OWN)) {
            $groups->where(['id <>' => 1]);
        }

        $this->set([
            'user' => $user,
            'groups' => $groups,
            'languages' => Hash::map(Configure::read('languages.backend'), '{n}', function ($language) {
                return [
                    'value' => $language->id,
                    'text' => $language->name
                ];
            })
        ]);

        $this->render('add');
    }
898114
public function execute($request)
    {
        RequestNotSupportedException::assertSupports($this, $request);

        /** @var PaymentInterface $payment */
        $payment = $request->getModel();

        if (in_array($payment->getState(), array(PaymentInterface::STATE_APPROVED, PaymentInterface::STATE_DEPOSITED))) {
            $request->markCaptured();

            return;
        }

        if (in_array($payment->getState(), array(PaymentInterface::STATE_DEPOSITING))) {
            $request->markPending();

            return;
        }

        if (in_array($payment->getState(), array(PaymentInterface::STATE_CANCELED))) {
            $request->markCanceled();

            return;
        }

        if (in_array($payment->getState(), array(PaymentInterface::STATE_EXPIRED))) {
            $request->markExpired();

            return;
        }

        if (in_array($payment->getState(), array(PaymentInterface::STATE_FAILED))) {
            $request->markFailed();

            return;
        }

        if (in_array($payment->getState(), array(PaymentInterface::STATE_NEW, PaymentInterface::STATE_APPROVING))) {
            $request->markNew();

            return;
        }

        $request->markUnknown();
    }
100190
protected function notFound(NotFoundException $e)
    {
        if (isset($this->hooks['not.found'])) {
            return $this->hooks['not.found']($e);
        } else {
            return (new Response())
                ->setStatusCode(404)
                ->setBody($e->getMessage());
        }
    }
1139844
public function view($id = null) {
		$this->layout = 'Printers.factura';
		if (!$this->AfipFactura->exists($id)) {
			throw new NotFoundException(__('Factura inexistente'));
		}		
		$options = array(
			'conditions' => array(
				'AfipFactura.' . $this->AfipFactura->primaryKey => $id
				),
			'contain' => array(
				'Mesa' => array('Cliente' => array('TipoDocumento', 'IvaResponsabilidad'), 'Mozo')
				)
			);
		$factura = $this->AfipFactura->find('first', $options);		
		$this->set('factura', $factura);		
	}