Completed
Pull Request — 2.1 (#242)
by Łukasz
02:44
created

DependentElementsVisitor::visitManager()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
/**
4
 * (c) FSi sp. z o.o. <[email protected]>
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace FSi\Bundle\AdminBundle\Admin\Manager;
11
12
use FSi\Bundle\AdminBundle\Admin\DependentElement;
13
use FSi\Bundle\AdminBundle\Admin\ManagerInterface;
14
15
class DependentElementsVisitor implements Visitor
16
{
17
    /**
18
     * @param ManagerInterface $manager
19
     */
20
    public function visitManager(ManagerInterface $manager)
21
    {
22
        foreach ($manager->getElements() as $element) {
23
            if (!($element instanceof DependentElement)) {
24
                continue;
25
            }
26
27
            $element->setParentElement($manager->getElement($element->getParentId()));
28
        }
29
    }
30
}
31