|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace AbterPhp\Files\Grid\Factory; |
|
6
|
|
|
|
|
7
|
|
|
use AbterPhp\Admin\Grid\Factory\BaseFactory; |
|
8
|
|
|
use AbterPhp\Admin\Grid\Factory\GridFactory; |
|
9
|
|
|
use AbterPhp\Admin\Grid\Factory\PaginationFactory; |
|
10
|
|
|
use AbterPhp\Admin\Helper\DateHelper; |
|
11
|
|
|
use AbterPhp\Files\Domain\Entities\FileDownload as Entity; |
|
12
|
|
|
use AbterPhp\Files\Grid\Factory\Table\FileDownload as TableFactory; |
|
13
|
|
|
use AbterPhp\Files\Grid\Factory\Table\Header\FileDownload as HeaderFactory; |
|
14
|
|
|
use AbterPhp\Files\Grid\Filters\FileDownload as Filters; |
|
15
|
|
|
use Opulence\Routing\Urls\UrlGenerator; |
|
16
|
|
|
|
|
17
|
|
|
class FileDownload extends BaseFactory |
|
18
|
|
|
{ |
|
19
|
|
|
private const GETTER_FILE = 'getFile'; |
|
20
|
|
|
private const GETTER_USER = 'getUser'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* FileDownload constructor. |
|
24
|
|
|
* |
|
25
|
|
|
* @param UrlGenerator $urlGenerator |
|
26
|
|
|
* @param PaginationFactory $paginationFactory |
|
27
|
|
|
* @param TableFactory $tableFactory |
|
28
|
|
|
* @param GridFactory $gridFactory |
|
29
|
|
|
* @param Filters $filters |
|
30
|
|
|
*/ |
|
31
|
|
|
public function __construct( |
|
32
|
|
|
UrlGenerator $urlGenerator, |
|
33
|
|
|
PaginationFactory $paginationFactory, |
|
34
|
|
|
TableFactory $tableFactory, |
|
35
|
|
|
GridFactory $gridFactory, |
|
36
|
|
|
Filters $filters |
|
37
|
|
|
) { |
|
38
|
|
|
parent::__construct($urlGenerator, $paginationFactory, $tableFactory, $gridFactory, $filters); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @return array |
|
43
|
|
|
*/ |
|
44
|
|
|
public function getGetters(): array |
|
45
|
|
|
{ |
|
46
|
|
|
return [ |
|
47
|
|
|
HeaderFactory::GROUP_FILE => static::GETTER_FILE, |
|
48
|
|
|
HeaderFactory::GROUP_USER => static::GETTER_USER, |
|
49
|
|
|
/** @see FileDownload::getDownloadedAt() */ |
|
50
|
|
|
HeaderFactory::GROUP_DOWNLOADED_AT => [$this, 'getDownloadedAt'], |
|
51
|
|
|
]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @param Entity $entity |
|
56
|
|
|
* |
|
57
|
|
|
* @return string |
|
58
|
|
|
*/ |
|
59
|
|
|
public function getDownloadedAt(Entity $entity): string |
|
60
|
|
|
{ |
|
61
|
|
|
return DateHelper::mysqlDateTime($entity->getDownloadedAt()); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
|