-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathFinnaAdditionsListBuilder.php
More file actions
52 lines (46 loc) · 1.71 KB
/
FinnaAdditionsListBuilder.php
File metadata and controls
52 lines (46 loc) · 1.71 KB
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
<?php
namespace App\Module\Finna\Entity\ListBuilder;
use App\Entity\ListBuilder\EntityListBuilder;
use Doctrine\ORM\QueryBuilder;
class FinnaAdditionsListBuilder extends EntityListBuilder
{
protected function createQueryBuilder() : QueryBuilder
{
$builder = parent::createQueryBuilder()
->addSelect('c')
->addSelect('cd')
->addSelect('sp')
->addSelect('ug')
->join('e.consortium', 'c')
->join('c.translations', 'cd', 'WITH', 'cd.langcode = e.default_langcode')
->leftJoin('e.service_point', 'sp')
->join('e.group', 'ug')
->andWhere('c.state >= 0')
;
return $builder;
}
public function build(iterable $entities) : iterable
{
$table = parent::build($entities)
->setColumns([
'state' => '',
'name' => ['mapping' => ['cd.name']],
'finna_id' => 'Finna ID',
'group' => ['mapping' => ['c.group']]
])
->useAsTemplate('state')
->useAsTemplate('name')
->setSortable('name')
->transform('state', function ($o) {
if ($o->isPublished()) {
return '<i class="fa fa-square text-success" title="{{ \'Published\'|trans }}"></i>';
} else {
return '<i class="fa fa-square text-warning" title="{{ \'Draft\'|trans }}"></i>';
}
})
->transform('name', function () {
return '<a href="{{ path("entity.finna_organisation.edit", {finna_organisation: row.id}) }}">{{ row.consortium.name }}</a>';
});
return $table;
}
}