public function validate() { $errors = parent::validate(); if (empty($errors)) { $email = $this->getData()['email']; $password = $this->getData()['password']; $user = User::findOneBy(array('email' => $email)); if (!$user) { $errors['email'] = new Error('Неправильно введен логин или пароль'); } else { /** @var Security $security */ $security = Application::getInstance()->getComponent('security'); if ($user->password != $security->getPasswordHash($password, $user->salt)) { $errors['email'] = new Error('Неправильно введен логин или пароль'); } } } return $errors; }
protected function get($componentId) { return Application::getInstance()->getComponent($componentId); }
protected function generateUrl($route, $params = [], $absolute = false, $secure = false) { return Application::getInstance()->getComponent('router')->generateUrl($route, $params, $absolute, $secure); }
<?php mb_internal_encoding('UTF-8'); require_once __DIR__ . '/../vendor/autoload.php'; $configProvider = (require_once __DIR__ . '/../config/config.php'); $application = new \nigma\component\application\WebApplication($configProvider); \nigma\component\application\Application::setInstance($application); $application->run();