forked from Sylius/Stack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBook.php
More file actions
124 lines (108 loc) · 2.91 KB
/
Book.php
File metadata and controls
124 lines (108 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace App\Entity;
use App\Grid\BookGrid;
use App\Repository\BookRepository;
use App\Responder\ExportGridToCsvResponder;
use Doctrine\ORM\Mapping as ORM;
use Sylius\Component\Resource\Annotation\SyliusCrudRoutes;
use Sylius\Component\Resource\Model\ResourceInterface;
use Sylius\Resource\Metadata\AsResource;
use Sylius\Resource\Metadata\BulkDelete;
use Sylius\Resource\Metadata\Create;
use Sylius\Resource\Metadata\Delete;
use Sylius\Resource\Metadata\Index;
use Sylius\Resource\Metadata\Show;
use Sylius\Resource\Metadata\Update;
use Symfony\Component\Validator\Constraints\NotBlank;
#[ORM\Entity(repositoryClass: BookRepository::class)]
#[AsResource(
section: 'admin',
templatesDir: '@SyliusAdminUi/crud',
routePrefix: '/admin',
operations: [
new Create(),
new Update(),
new Index(grid: BookGrid::class),
new Index(
template: '@SyliusAdminUi/crud/index.html.twig',
shortName: 'withoutGrid',
),
new Index(
shortName: 'export',
responder: ExportGridToCsvResponder::class,
grid: BookGrid::class,
),
new Delete(),
new BulkDelete(),
new Show(),
],
)]
#[SyliusCrudRoutes(
alias: 'app.book',
path: '/admin/legacy/books',
section: 'admin_legacy',
redirect: 'update',
templates: '@SyliusAdminUi/crud',
grid: 'app_book',
vars: [
'all' => [
'subheader' => 'app.ui.manage_your_books',
],
],
)]
class Book implements ResourceInterface
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private ?int $id = null;
#[ORM\Column(type: 'string', length: 255)]
#[NotBlank]
private ?string $title = null;
#[ORM\Column(type: 'string', length: 255)]
#[NotBlank]
private ?string $authorName = null;
#[ORM\Column(type: 'datetime_immutable')]
private \DateTimeImmutable $createdAt;
public function __construct()
{
$this->createdAt = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(?string $title): void
{
$this->title = $title;
}
public function getAuthorName(): ?string
{
return $this->authorName;
}
public function setAuthorName(?string $authorName): void
{
$this->authorName = $authorName;
}
public function getCreatedAt(): ?\DateTimeImmutable
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeImmutable $createdAt): void
{
$this->createdAt = $createdAt;
}
}