symfony complete
Этот коммит содержится в:
@@ -1,12 +1,36 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="ru-RU">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>{% block title %}Welcome!{% endblock %}</title>
|
||||
<title>{% block title %}Welcome!{% endblock %}—Тест</title>
|
||||
<meta name="viewport"
|
||||
content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet"
|
||||
href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
|
||||
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T"
|
||||
crossorigin="anonymous">
|
||||
{% block stylesheets %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div class="container pt-5 pb-3 mb-5">
|
||||
<h1>
|
||||
<svg style="width: 50px;height: 50px;" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 1000 1000" enable-background="new 0 0 1000 1000" xml:space="preserve"> <g> <path d="M978.3,610.6c-3.9,4-7.4,7.6-10.5,11.1c-3.1,3.5-5.8,6.4-8.2,8.8c-3.1,3.2-5.8,5.5-8.1,7l-98.8-97.9c4.6-3.9,9.9-8.6,15.7-14c5.8-5.5,10.6-9.8,14.6-12.9c9.3-8.6,19.4-12.2,30.2-11.1c10.8,1.2,19.7,3.7,26.7,7.6c7.8,3.9,16.1,10.7,25,20.4c8.9,9.8,15.7,20,20.3,31c2.3,6.2,3.9,14,4.7,23.3C990.7,593.1,986.8,602.1,978.3,610.6L978.3,610.6L978.3,610.6z M799.2,789L719,869.4c-10.9,10.9-20,20.2-27.3,28c-7.4,7.7-11.4,12-12.2,12.8c-3.9,3.1-8.1,6.4-12.8,10c-4.6,3.4-9.3,6.4-13.9,8.7c-4.6,2.3-11.8,5.2-21.5,8.8c-9.7,3.5-19.6,6.7-29.6,9.9c-10.1,3.1-19.8,5.8-29.1,8.1c-9.3,2.4-16.3,3.9-20.9,4.7c-9.3,1.6-15.5,0.4-18.6-3.5c-3.1-3.9-3.9-10.5-2.3-19.8c0.8-4.7,2.3-11.7,4.6-21c2.3-9.4,5-18.9,8.2-28.6c3.1-9.8,6-18.9,8.7-27.5c2.7-8.5,4.8-14.4,6.3-17.4c4.7-10.1,10.9-19,18.6-26.8l15.1-15.2l29-29.1c11.6-11.7,24.4-24.7,38.3-39c13.9-14.4,27.9-28.6,41.8-42.5c33.4-33.4,70.9-70.8,112.8-111.9l97.6,97.9L799.2,789L799.2,789z M702.2,183.2c0-15.9-12.9-28.9-28.8-28.9h-57.7V96.7h115.4c15.9,0,28.8,12.9,28.8,28.9v392.2l-57.7,63.5V183.2L702.2,183.2L702.2,183.2z M558,212h-28.9c-15.9,0-28.8-12.9-28.8-28.9V67.8c0-15.9,12.9-28.9,28.8-28.9H558c15.9,0,28.8,12.9,28.8,28.9v115.4C586.8,199.1,573.9,212,558,212L558,212z M298.4,96.7h173.1v57.7H298.4V96.7z M240.7,212h-28.8c-15.9,0-28.9-12.9-28.9-28.9V67.8c0-15.9,12.9-28.9,28.9-28.9h28.8c15.9,0,28.9,12.9,28.9,28.9v115.4C269.6,199.1,256.7,212,240.7,212L240.7,212z M67.7,183.2v634.5c0,15.9,12.9,28.9,28.9,28.9H461l-52.4,57.7H38.8c-15.9,0-28.8-12.9-28.8-28.8V125.5c0-16,12.9-28.9,28.8-28.9h115.4v57.7H96.5C80.6,154.3,67.7,167.3,67.7,183.2L67.7,183.2L67.7,183.2z M615.7,659.1c0,7.9-6.5,14.4-14.4,14.4H168.6c-8,0-14.4-6.5-14.4-14.4v-28.8c0-8,6.4-14.4,14.4-14.4h432.6c8,0,14.4,6.4,14.4,14.4V659.1z M601.3,442.8H168.6c-8,0-14.4-6.5-14.4-14.4v-28.9c0-8,6.4-14.4,14.4-14.4h432.7c8,0,14.4,6.4,14.4,14.4v28.9C615.7,436.3,609.2,442.8,601.3,442.8L601.3,442.8L601.3,442.8z"/> </g> </svg>
|
||||
{{ block('title') }} — Тест
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
{% block body %}{% endblock %}
|
||||
<footer style="background-color: #232425;" class="mt-5 pt-2">
|
||||
<div class="container pt-5 pb-4">
|
||||
<div class="text-white text-right pb-4">
|
||||
{{ "now"|date("Y") }}г.
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
{% block javascripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
17
templates/index.html.twig
Обычный файл
17
templates/index.html.twig
Обычный файл
@@ -0,0 +1,17 @@
|
||||
{% extends "base.html.twig" %}
|
||||
{% block title %}
|
||||
Главная
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
{% if app.user == null %}
|
||||
<a href="{{ path('app_login') }}" class="btn btn-primary">Войти</a>
|
||||
{% else %}
|
||||
<a href="{{ path('app_logout') }}" class="btn btn-primary">Выйти</a>
|
||||
{% endif %}
|
||||
<br class="mb-5">
|
||||
{% if is_granted('ROLE_ADMIN') %}
|
||||
<a href="{{ path('user_index') }}" class="btn btn-primary">Список пользователей</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
21
templates/registration/register.html.twig
Обычный файл
21
templates/registration/register.html.twig
Обычный файл
@@ -0,0 +1,21 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Регистрация{% endblock %}
|
||||
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<a href="{{ path('app_login') }}" class="btn btn-primary mb-5">← Вход</a>
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col-md-4">
|
||||
{{ form_start(registrationForm) }}
|
||||
|
||||
{{ form_row(registrationForm.username, {'label': 'Имя пользователя'}) }}
|
||||
{{ form_row(registrationForm.plainPassword, {'label': 'Пароль'}) }}
|
||||
|
||||
<button class="btn btn-primary">Зарегистрироваться</button>
|
||||
{{ form_end(registrationForm) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
40
templates/security/login.html.twig
Обычный файл
40
templates/security/login.html.twig
Обычный файл
@@ -0,0 +1,40 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Вход{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<a href="{{ path('index_page') }}" class="btn btn-primary mb-5">← Главная</a>
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col-md-4">
|
||||
<form method="post">
|
||||
{% if error %}
|
||||
<div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
|
||||
{% endif %}
|
||||
|
||||
<h1 class="h3 mb-3 font-weight-normal">Войдите</h1>
|
||||
<div class="form-group">
|
||||
<label for="inputUsername" class="sr-only">Пользователь</label>
|
||||
<input type="text" value="{{ last_username }}" name="username" id="inputUsername" class="form-control" placeholder="Пользователь" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="inputPassword" class="sr-only">Пароль</label>
|
||||
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Пароль" required>
|
||||
</div>
|
||||
<input type="hidden" name="_csrf_token"
|
||||
value="{{ csrf_token('authenticate') }}"
|
||||
>
|
||||
|
||||
|
||||
<button class="btn btn-primary" type="submit">
|
||||
Войти
|
||||
</button>
|
||||
<a href="{{ path('app_register') }}"
|
||||
class="btn btn-outline-primary float-right">Регистрация</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
5
templates/user/_delete_form.html.twig
Обычный файл
5
templates/user/_delete_form.html.twig
Обычный файл
@@ -0,0 +1,5 @@
|
||||
<form method="post" action="{{ path('user_delete', {'id': user.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_method" value="DELETE">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ user.id) }}">
|
||||
<button class="btn btn-danger float-right">Удалить</button>
|
||||
</form>
|
4
templates/user/_form.html.twig
Обычный файл
4
templates/user/_form.html.twig
Обычный файл
@@ -0,0 +1,4 @@
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn btn-success float-left">{{ button_label|default('Сохранить') }}</button>
|
||||
{{ form_end(form) }}
|
17
templates/user/edit.html.twig
Обычный файл
17
templates/user/edit.html.twig
Обычный файл
@@ -0,0 +1,17 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit User{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<a href="{{ path('user_index') }}" class="btn btn-primary mb-5">← к списку</a>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ include('user/_form.html.twig', {'button_label': 'Обновить'}) }}
|
||||
|
||||
{{ include('user/_delete_form.html.twig') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
48
templates/user/index.html.twig
Обычный файл
48
templates/user/index.html.twig
Обычный файл
@@ -0,0 +1,48 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Список пользователей{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
|
||||
<a href="{{ path('index_page') }}" class="btn btn-primary float-left mb-4">← Главная</a>
|
||||
<a href="{{ path('user_new') }}" class="btn btn-success float-right mb-4">Добавить пользователя</a>
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Username</th>
|
||||
<th>Роли</th>
|
||||
<th>Хеш пароля</th>
|
||||
<th>Активный</th>
|
||||
<th>Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.username }}</td>
|
||||
<td>
|
||||
{% for role in user.roles %}
|
||||
{{ role }},<br>
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td style="max-width: 18.75rem;"><div class="d-inline-block w-100 text-truncate" title="{{ user.password }}">{{ user.password }}</div></td>
|
||||
<td>{{ user.active ? 'Да' : 'Нет' }}</td>
|
||||
<td>
|
||||
<a href="{{ path('user_show', {'id': user.id}) }}" class="btn btn-outline-primary float-right ml-2">Просмотр</a>
|
||||
<a href="{{ path('user_edit', {'id': user.id}) }}" class="btn btn-outline-success float-right">Правка</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="6">нет записей</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
14
templates/user/new.html.twig
Обычный файл
14
templates/user/new.html.twig
Обычный файл
@@ -0,0 +1,14 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New User{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<a href="{{ path('user_index') }}" class="btn btn-primary mb-5">← к списку</a>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{{ include('user/_form.html.twig') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
42
templates/user/show.html.twig
Обычный файл
42
templates/user/show.html.twig
Обычный файл
@@ -0,0 +1,42 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Просмотр пользователя{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container">
|
||||
<a href="{{ path('user_index') }}" class="btn btn-primary mb-5">← к списку</a>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ user.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<td>{{ user.username }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Roles</th>
|
||||
<td>{% for role in user.roles %}
|
||||
{{ role }},<br>
|
||||
{% endfor %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Password</th>
|
||||
<td>{{ user.password }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Active</th>
|
||||
<td>{{ user.active ? 'Yes' : 'No' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
<a href="{{ path('user_edit', {'id': user.id}) }}" class="btn btn-success float-left">Правка</a>
|
||||
{{ include('user/_delete_form.html.twig') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
Ссылка в новой задаче
Block a user