/
FileCategory.php
73 lines (60 loc) · 2.08 KB
/
FileCategory.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
<?php
namespace Concrete\Core\Attribute\Category;
use Concrete\Core\Attribute\Category\SearchIndexer\StandardSearchIndexerInterface;
use Concrete\Core\Entity\Attribute\Key\FileKey;
use Concrete\Core\Entity\Attribute\Key\Key;
use Concrete\Core\Entity\Attribute\Type;
class FileCategory extends AbstractStandardCategory
{
public function createAttributeKey()
{
return new FileKey();
}
public function getIndexedSearchTable()
{
return 'FileSearchIndexAttributes';
}
public function getIndexedSearchPrimaryKeyValue($mixed)
{
return $mixed->getFileID();
}
public function getSearchIndexFieldDefinition()
{
return array(
'columns' => array(
array(
'name' => 'fID',
'type' => 'integer',
'options' => array('unsigned' => true, 'default' => 0, 'notnull' => true),
),
),
'primary' => array('fID'),
);
}
public function getAttributeKeyRepository()
{
return $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Key\FileKey');
}
public function getAttributeValueRepository()
{
return $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Value\FileValue');
}
public function getAttributeValues($version)
{
$query = $this->entityManager->createQuery('select fav from Concrete\Core\Entity\Attribute\Value\FileValue fav
where fav.fvID = :fvID and fav.fID = :fID');
$query->setParameter('fID', $version->getFile()->getFileID());
$query->setParameter('fvID', $version->getFileVersionID());
return $query->getResult();
}
public function getAttributeValue(Key $key, $file)
{
$r = $this->entityManager->getRepository('\Concrete\Core\Entity\Attribute\Value\FileValue');
$value = $r->findOneBy(array(
'fID' => $file->getFileID(),
'fvID' => $file->getFileVersionID(),
'attribute_key' => $key,
));
return $value;
}
}