/
attributes.php
115 lines (102 loc) · 3.57 KB
/
attributes.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
namespace Concrete\Controller\SinglePage\Dashboard\System\Express\Entities;
use Concrete\Core\Attribute\CategoryObjectInterface;
use Concrete\Core\Attribute\TypeFactory;
use Concrete\Core\Page\Controller\DashboardAttributesPageController;
class Attributes extends DashboardAttributesPageController
{
/**
* The current express entity.
*
* @var \Concrete\Core\Entity\Express\Entity|null
*/
protected $category;
public function view($id = null)
{
$entity = $this->getEntity($id);
$typeFactory = $this->app->make(TypeFactory::class);
$this->set('entity', $entity);
$this->renderList($entity->getAttributes(), $typeFactory->getList());
}
public function edit($id = null, $akID = null)
{
$this->set('entity', $this->getEntity($id));
$r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Key\Key');
$key = $r->findOneBy(['akID' => $akID]);
$this->renderEdit($key,
\URL::to('/dashboard/system/express/entities/attributes', 'view', $id)
);
}
public function update($id = null, $akID = null)
{
$this->edit($id, $akID);
$entity = $this->getEntity($id);
$this->set('entity', $entity);
$r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Key\Key');
$key = $r->findOneBy(['akID' => $akID]);
$this->executeUpdate($key,
\URL::to('/dashboard/system/express/entities/attributes', 'view', $id)
);
}
public function select_type($id = null, $type = null)
{
$this->set('entity', $this->getEntity($id));
$typeFactory = $this->app->make(TypeFactory::class);
$type = $typeFactory->getByID($type);
$this->renderAdd($type,
\URL::to('/dashboard/system/express/entities/attributes', 'view', $id)
);
}
public function add($id = null, $type = null)
{
$this->select_type($id, $type);
$typeFactory = $this->app->make(TypeFactory::class);
$type = $typeFactory->getByID($type);
$entity = $this->getEntity($id);
$this->set('entity', $entity);
$this->executeAdd($type, \URL::to('/dashboard/system/express/entities/attributes', 'view', $id));
}
public function delete($id = null, $akID = null)
{
$entity = $this->getEntity($id);
$factory = $this->app->make('Concrete\Core\Attribute\Category\ExpressCategory');
$key = $factory->getAttributeKeyByID($akID);
$this->set('entity', $entity);
$this->executeDelete($key,
\URL::to('/dashboard/system/express/entities/attributes', 'view', $id)
);
}
/**
* Get the express entity given its ID.
*
* @param string $id the entity ID
*
* @return \Concrete\Core\Entity\Express\Entity|null
*/
protected function getEntity($id)
{
$r = $this->entityManager->getRepository('\Concrete\Core\Entity\Express\Entity');
$this->category = $r->findOneById($id);
return $this->category;
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Page\Controller\DashboardAttributesPageController::getCategoryObject()
*
* @return \Concrete\Core\Entity\Express\Entity|null
*/
protected function getCategoryObject()
{
return $this->category;
}
/**
* {@inheritdoc}
*
* @see \Concrete\Core\Page\Controller\DashboardAttributesPageController::getHeaderMenu()
*/
protected function getHeaderMenu(CategoryObjectInterface $category)
{
return false;
}
}