|
1
|
|
|
<?php namespace Anomaly\UsersModule\Http\Controller\Admin; |
|
2
|
|
|
|
|
3
|
|
|
use Anomaly\Streams\Platform\Addon\FieldType\FieldTypeCollection; |
|
4
|
|
|
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentInterface; |
|
5
|
|
|
use Anomaly\Streams\Platform\Assignment\Contract\AssignmentRepositoryInterface; |
|
6
|
|
|
use Anomaly\Streams\Platform\Assignment\Table\AssignmentTableBuilder; |
|
7
|
|
|
use Anomaly\Streams\Platform\Field\Form\FieldAssignmentFormBuilder; |
|
8
|
|
|
use Anomaly\Streams\Platform\Field\Form\FieldFormBuilder; |
|
9
|
|
|
use Anomaly\Streams\Platform\Field\Table\FieldTableBuilder; |
|
10
|
|
|
use Anomaly\Streams\Platform\Http\Controller\AdminController; |
|
11
|
|
|
use Anomaly\UsersModule\User\UserModel; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class FieldsController |
|
15
|
|
|
* |
|
16
|
|
|
* @link http://pyrocms.com/ |
|
17
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
|
18
|
|
|
* @author Ryan Thompson <[email protected]> |
|
19
|
|
|
*/ |
|
20
|
|
|
class FieldsController extends AdminController |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Return an index of existing fields. |
|
25
|
|
|
* |
|
26
|
|
|
* @param FieldTableBuilder $table |
|
27
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
28
|
|
|
*/ |
|
29
|
|
|
public function index(AssignmentTableBuilder $table, UserModel $users) |
|
30
|
|
|
{ |
|
31
|
|
|
$table->setOption('sortable', true)->setStream($users->getStream()); |
|
32
|
|
|
|
|
33
|
|
|
return $table->render(); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Choose a field type for creating a field. |
|
38
|
|
|
* |
|
39
|
|
|
* @param FieldTypeCollection $fieldTypes |
|
40
|
|
|
* @return \Illuminate\View\View |
|
41
|
|
|
*/ |
|
42
|
|
|
public function choose(FieldTypeCollection $fieldTypes) |
|
43
|
|
|
{ |
|
44
|
|
|
return $this->view->make('anomaly.module.users::admin/fields/choose', ['field_types' => $fieldTypes]); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Return the form for a new field. |
|
49
|
|
|
* |
|
50
|
|
|
* @param FieldFormBuilder $form |
|
51
|
|
|
* @param UserModel $users |
|
52
|
|
|
* @param FieldTypeCollection $fieldTypes |
|
53
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
54
|
|
|
*/ |
|
55
|
|
|
public function create(FieldFormBuilder $form, UserModel $users, FieldTypeCollection $fieldTypes) |
|
56
|
|
|
{ |
|
57
|
|
|
$form |
|
58
|
|
|
->setStream($users->getStream()) |
|
59
|
|
|
->setOption('auto_assign', true) |
|
60
|
|
|
->setFieldType($fieldTypes->get($this->request->get('field_type'))); |
|
61
|
|
|
|
|
62
|
|
|
return $form->render(); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Return a form to edit the field. |
|
67
|
|
|
* |
|
68
|
|
|
* @param AssignmentRepositoryInterface $assignments |
|
69
|
|
|
* @param FieldFormBuilder $form |
|
70
|
|
|
* @param UserModel $model |
|
71
|
|
|
* @param $id |
|
72
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
|
73
|
|
|
*/ |
|
74
|
|
|
public function edit(AssignmentRepositoryInterface $assignments, FieldFormBuilder $form, UserModel $model, $id) |
|
75
|
|
|
{ |
|
76
|
|
|
/* @var AssignmentInterface $assignment */ |
|
77
|
|
|
$assignment = $assignments->find($id); |
|
78
|
|
|
|
|
79
|
|
|
return $form |
|
80
|
|
|
->setStream($model->getStream()) |
|
81
|
|
|
->render($assignment->getFieldId()); |
|
82
|
|
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|