1
|
|
|
<?php namespace Anomaly\Streams\Platform\Ui\Form\Command; |
2
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; |
4
|
|
|
use Anomaly\Streams\Platform\Support\Presenter; |
5
|
|
|
use Anomaly\Streams\Platform\Ui\Form\FormCriteria; |
6
|
|
|
use Anomaly\Streams\Platform\Ui\Form\FormFactory; |
7
|
|
|
use Illuminate\Contracts\Bus\SelfHandling; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class GetFormCriteria |
11
|
|
|
* |
12
|
|
|
* @link http://anomaly.is/streams-platform |
13
|
|
|
* @author AnomalyLabs, Inc. <[email protected]> |
14
|
|
|
* @author Ryan Thompson <[email protected]> |
15
|
|
|
* @package Anomaly\Streams\Platform\Ui\Form\Command |
16
|
|
|
*/ |
17
|
|
|
class GetFormCriteria implements SelfHandling |
18
|
|
|
{ |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* The builder parameters. |
22
|
|
|
* |
23
|
|
|
* @var array |
24
|
|
|
*/ |
25
|
|
|
protected $parameters; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Create a new GetFormCriteria instance. |
29
|
|
|
* |
30
|
|
|
* @param array $parameters |
31
|
|
|
*/ |
32
|
|
|
public function __construct($parameters) |
33
|
|
|
{ |
34
|
|
|
$this->parameters = $parameters; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Handle the command. |
39
|
|
|
* |
40
|
|
|
* @param FormFactory $factory |
41
|
|
|
* @return FormCriteria |
42
|
|
|
*/ |
43
|
|
|
public function handle(FormFactory $factory) |
44
|
|
|
{ |
45
|
|
|
if (is_string($this->parameters)) { |
46
|
|
|
$this->parameters = [ |
47
|
|
|
'builder' => $this->parameters |
48
|
|
|
]; |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
if ($this->parameters instanceof Presenter) { |
52
|
|
|
$this->parameters = $this->parameters->getObject(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
if ($this->parameters instanceof EntryInterface) { |
56
|
|
|
$this->parameters = [ |
57
|
|
|
'entry' => $this->parameters->getId(), |
58
|
|
|
'stream' => $this->parameters->getStreamSlug(), |
59
|
|
|
'namespace' => $this->parameters->getStreamNamespace(), |
60
|
|
|
]; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
return $factory->make($this->parameters); |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
|