|
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 |
|
|
|
|
|
|
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']) { |
|
|
|
|
|
|
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; |
|
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|
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.