/
PageCategory.php
72 lines (58 loc) · 1.83 KB
/
PageCategory.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\Attribute\Category;
use Concrete\Core\Attribute\Category\SearchIndexer\StandardSearchIndexerInterface;
use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Attribute\Key\PageKey;
class PageCategory extends AbstractStandardCategory
{
public function createAttributeKey()
{
return new PageKey();
}
public function getIndexedSearchTable()
{
return 'CollectionSearchIndexAttributes';
}
public function getIndexedSearchPrimaryKeyValue($mixed)
{
return $mixed->getCollectionID();
}
public function getSearchIndexFieldDefinition()
{
return array(
'columns' => array(
array(
'name' => 'cID',
'type' => 'integer',
'options' => array('unsigned' => true, 'default' => 0, 'notnull' => true),
),
),
'primary' => array('cID'),
);
}
public function getAttributeKeyRepository()
{
return $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Key\PageKey');
}
public function getAttributeValueRepository()
{
return $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Value\PageValue');
}
public function getAttributeValues($page)
{
$values = $this->getAttributeValueRepository()->findBy(array(
'cID' => $page->getCollectionID(),
'cvID' => $page->getVersionID(),
));
return $values;
}
public function getAttributeValue(Key $key, $page)
{
$value = $this->getAttributeValueRepository()->findOneBy(array(
'cID' => $page->getCollectionID(),
'cvID' => $page->getVersionID(),
'attribute_key' => $key,
));
return $value;
}
}