/
AddonTableViews.php
62 lines (55 loc) · 1.75 KB
/
AddonTableViews.php
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
<?php namespace Anomaly\AddonsModule\Addon\Table;
use Anomaly\AddonsModule\Addon\Command\GetOutdatedAddons;
use Anomaly\AddonsModule\Addon\Table\Entries\AllEntries;
use Anomaly\AddonsModule\Addon\Table\Entries\DownloadedEntries;
use Anomaly\AddonsModule\Addon\Table\Entries\RepositoryEntries;
use Anomaly\AddonsModule\Addon\Table\Entries\UpdatesEntries;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Bus\DispatchesJobs;
/**
* Class AddonTableViews
*
* @link http://pyrocms.com/
* @author PyroCMS, Inc. <support@pyrocms.com>
* @author Ryan Thompson <ryan@pyrocms.com>
*/
class AddonTableViews
{
use DispatchesJobs;
/**
* Handle the views.
*
* @param AddonTableBuilder $builder
*/
public function handle(AddonTableBuilder $builder, Repository $config)
{
$updates = $this->dispatch(new GetOutdatedAddons($builder->getType()));
$builder->setViews(
[
'downloaded' => [
'entries' => DownloadedEntries::class,
],
'updates' => [
'entries' => UpdatesEntries::class,
'label' => count($updates) ?: false,
],
]
);
foreach ($config->get('anomaly.module.addons::repository', []) as $slug => $repository) {
$builder->addView(
$slug,
[
'text' => $repository['name'],
'entries' => RepositoryEntries::class,
]
);
}
$builder->addView(
'all',
[
'entries' => AllEntries::class,
'text' => 'anomaly.module.addons::repository.all.name',
]
);
}
}