/
EntityPropertyType.php
72 lines (63 loc) · 1.97 KB
/
EntityPropertyType.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
<?php
namespace Concrete\Core\Express\Form\Control\Type;
use Concrete\Core\Entity\Express\Control\AuthorControl;
use Concrete\Core\Entity\Express\Control\Control;
use Concrete\Core\Entity\Express\Control\PublicIdentifierControl;
use Concrete\Core\Entity\Express\Control\TextControl;
use Concrete\Core\Entity\Express\Entity;
use Concrete\Core\Express\Form\Context\ContextInterface;
use Concrete\Core\Express\Form\Control\SaveHandler\AuthorSaveHandler;
use Concrete\Core\Express\Form\Control\Template\Template;
use Concrete\Core\Express\Form\Control\Type\Item\AuthorEntityPropertyItem;
use Concrete\Core\Express\Form\Control\Type\Item\PublicIdentifierPropertyItem;
use Concrete\Core\Express\Form\Control\Type\Item\TextEntityPropertyItem;
use Concrete\Core\Import\Item\Express\Control\EntityPropertyControl;
class EntityPropertyType implements TypeInterface
{
public function getPluralDisplayName()
{
return t('Core Properties');
}
public function getType()
{
return 'entity_property';
}
public function getValidator()
{
return false;
}
public function getDisplayName()
{
return t('Core Property');
}
public function getItems(Entity $entity)
{
return array(
new TextEntityPropertyItem(),
new AuthorEntityPropertyItem(),
new PublicIdentifierPropertyItem()
);
}
public function createControlByIdentifier($id)
{
switch ($id) {
case 'text':
return new TextControl();
case 'author':
return new AuthorControl();
case 'public-identifier':
return new PublicIdentifierControl();
}
}
public function getSaveHandler(Control $control)
{
if ($control instanceof AuthorControl) {
return new AuthorSaveHandler();
}
return null;
}
public function getImporter()
{
return new EntityPropertyControl();
}
}