Completed
Push — master ( b8f763...47a15d )
by Craig
14:22 queued 07:28
created

RouteEntity::getPathWithBundlePrefix()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 16
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 7
nc 3
nop 1
dl 16
loc 16
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * Routes.
4
 *
5
 * @copyright Zikula contributors (Zikula)
6
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License
7
 * @author Zikula contributors <[email protected]>.
8
 * @link http://www.zikula.org
9
 * @link http://zikula.org
10
 * @version Generated by ModuleStudio 0.7.0 (http://modulestudio.de).
11
 */
12
13
namespace Zikula\RoutesModule\Entity\Historical\v110;
14
15
use Zikula\RoutesModule\Entity\Historical\v110\Base\AbstractRouteEntity as BaseEntity;
16
17
use Doctrine\ORM\Mapping as ORM;
18
use Gedmo\Mapping\Annotation as Gedmo;
19
use DoctrineExtensions\StandardFields\Mapping\Annotation as ZK;
20
use Symfony\Component\Validator\Constraints as Assert;
21
22
/**
23
 * Entity class that defines the entity structure and behaviours.
24
 *
25
 * This is the concrete entity class for route entities.
26
 * @ORM\Entity(repositoryClass="\Zikula\RoutesModule\Entity\Repository\RouteRepository")
27
 * @ORM\Table(name="zikula_routes_route",
28
 *     indexes={
29
 *         @ORM\Index(name="workflowstateindex", columns={"workflowState"})
30
 *     }
31
 * )
32
 */
33 View Code Duplication
class RouteEntity extends BaseEntity
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
{
35
    const POSITION_FIXED_TOP = 3;
36
37
    const POSITION_MIDDLE = 5;
38
39
    const POSITION_FIXED_BOTTOM = 7;
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function __construct()
45
    {
46
        parent::__construct();
47
48
        // Always add route to the end of the list.
49
        $this->sort = -1;
50
    }
51
52
    /**
53
     * Returns the route's path prepended with the bundle prefix.
54
     *
55
     * @param null $container Used to set the container for \ServiceUtil in case it is not already set
56
     *
57
     * @return string
58
     */
59
    public function getPathWithBundlePrefix($container = null)
60
    {
61
        if (isset($this->options['zkNoBundlePrefix']) && $this->options['zkNoBundlePrefix']) {
0 ignored issues
show
Bug introduced by
The property options does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
62
            // return path only
63
            return $this->path;
64
        }
65
66
        $bundle = $this->getBundle();
67
68
        if (!\ServiceUtil::hasContainer()) {
69
            \ServiceUtil::setContainer($container);
70
        }
71
72
        // return path prepended with bundle prefix
73
        return '/' . $bundle->getMetaData()->getUrl() . $this->path;
0 ignored issues
show
Bug introduced by
The method getMetaData cannot be called on $bundle (of type string).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
74
    }
75
}
76