SiteController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace app\controllers;
  3. use yii\filters\AccessControl;
  4. use yii\web\Controller;
  5. use yii\filters\VerbFilter;
  6. class SiteController extends Controller {
  7. /**
  8. * {@inheritdoc}
  9. */
  10. public function behaviors() {
  11. return [
  12. 'access' => [
  13. 'class' => AccessControl::className(),
  14. 'only' => ['asignar-descarga', 'index', 'consulta', 'logout'],
  15. 'rules' => [
  16. [
  17. 'actions' => ['asignar-descarga', 'index', 'consulta', 'logout'],
  18. 'allow' => true,
  19. 'roles' => ['@'],
  20. ],
  21. ],
  22. ],
  23. ];
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function actions() {
  29. return [
  30. 'error' => [
  31. 'class' => 'yii\web\ErrorAction',
  32. ],
  33. 'captcha' => [
  34. 'class' => 'yii\captcha\CaptchaAction',
  35. 'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
  36. ],
  37. ];
  38. }
  39. public function actionLogout() {
  40. \Yii::$app->getUser()->logout();
  41. return $this->redirect("/");
  42. }
  43. /**
  44. * Displays homepage.
  45. *
  46. * @return string
  47. */
  48. public function actionIndex() {
  49. return $this->redirect('inicio');
  50. }
  51. public function actionAsignarDescarga() {
  52. return $this->render('asignar-descarga');
  53. }
  54. public function actionConsulta() {
  55. return $this->render('consulta');
  56. }
  57. }