Completed
Push — master ( 93f930...9a8fbb )
by Dev
08:26
created

AdminTrait   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 9
c 2
b 0
f 0
dl 0
loc 33
ccs 0
cts 18
cp 0
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getContainer() 0 3 1
A setMosaicDefaultListMode() 0 11 3
A getUser() 0 3 1
1
<?php
2
3
namespace PiedWeb\CMSBundle\Admin;
4
5
trait AdminTrait
6
{
7
    abstract public function setListMode($mode);
8
9
    /**
10
     * Must be a cookie to check before to do that
11
     * If you click one time to list, stay in liste mode.
12
     * Yes it's in the session
13
     * TODO.
14
     * */
15
    protected function setMosaicDefaultListMode(): self
16
    {
17
        if (null !== $this->request) {
18
            if ($mode = $this->request->query->get('_list_mode')) {
19
                $this->setListMode($mode);
20
            } else {
21
                $this->setListMode('mosaic');
22
            }
23
        }
24
25
        return $this;
26
    }
27
28
    abstract public function getConfigurationPool();
29
30
    protected function getContainer()
31
    {
32
        return $this->getConfigurationPool()->getContainer();
33
    }
34
35
    protected function getUser()
36
    {
37
        return $this->getContainer()->get('security.token_storage')->getToken()->getUser();
38
    }
39
}
40