Completed
Pull Request — master (#71)
by Arnaud
03:13
created

AdminTrait::getUniqueEntityLabel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
3
namespace LAG\AdminBundle\Admin\Behaviors;
4
5
use Pagerfanta\Pagerfanta;
6
7
trait AdminTrait
8
{
9
    use EntityLabelTrait;
10
    use TranslationKeyTrait;
11
12
    /**
13
     * @var Pagerfanta
14
     */
15
    protected $pager;
16
17
    /**
18
     * Return the current unique entity.
19
     *
20
     * @return object
21
     */
22
    public abstract function getUniqueEntity();
23
24
    /**
25
     * @return Pagerfanta
26
     */
27
    public function getPager()
28
    {
29
        return $this->pager;
30
    }
31
32
    /**
33
     * Try to find a property to get a label from an entity. If found, it returns the property value through the
34
     * property accessor.
35
     *
36
     * @return string
37
     */
38
    public function getUniqueEntityLabel()
39
    {
40
        $entity = $this->getUniqueEntity();
41
        $label = $this->getEntityLabel($entity);
42
43
        return $label;
44
    }
45
}
46