-
Notifications
You must be signed in to change notification settings - Fork 3
/
GetConfiguredTableBuilder.php
60 lines (50 loc) · 1.45 KB
/
GetConfiguredTableBuilder.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
<?php namespace Anomaly\StreamsModule\Entry\Command;
use Anomaly\Streams\Platform\Stream\Contract\StreamInterface;
use Anomaly\Streams\Platform\Support\Hydrator;
use Anomaly\Streams\Platform\Ui\Table\TableBuilder;
use Illuminate\Contracts\Config\Repository;
use Illuminate\Foundation\Bus\DispatchesJobs;
/**
* Class GetConfiguredTableBuilder
*
* @link http://pyrocms.com/
* @author PyroCMS, Inc. <support@pyrocms.com>
* @author Ryan Thompson <ryan@pyrocms.com>
*/
class GetConfiguredTableBuilder
{
use DispatchesJobs;
/**
* The stream instance.
*
* @var StreamInterface
*/
protected $stream;
/**
* Create a new GetConfiguredTableBuilder instance.
*
* @param StreamInterface $stream
*/
public function __construct(StreamInterface $stream)
{
$this->stream = $stream;
}
/**
* Handle the command.
*
* @param Hydrator $hydrator
* @param Repository $config
* @return TableBuilder|null
*/
public function handle(Hydrator $hydrator, Repository $config)
{
$stream = $this->stream->getSlug();
$namespace = $this->stream->getNamespace();
if (!$parameters = $config->get("anomaly.module.streams::table.{$namespace}.{$stream}")) {
return null;
}
$builder = $this->dispatch(new GetDefaultTableBuilder($this->stream));
$hydrator->hydrate($builder, $parameters);
return $builder;
}
}