Completed
Push — master ( 5d51b4...87fdd9 )
by Paul
10s
created

BusinessPage::setStaticUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace Victoire\Bundle\BusinessPageBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use Victoire\Bundle\CoreBundle\Entity\BaseEntityProxy;
7
use Victoire\Bundle\PageBundle\Entity\Page;
8
9
/**
10
 * BusinessPage.
11
 *
12
 * @ORM\Entity(repositoryClass="Victoire\Bundle\BusinessPageBundle\Repository\BusinessPageRepository")
13
 * @ORM\HasLifecycleCallbacks()
14
 */
15
class BusinessPage extends Page
16
{
17
    const TYPE = 'business_page';
18
19
    /**
20
     * Auto simple mode: joined entity.
21
     *
22
     * @var BaseEntityProxy
23
     *
24
     * @ORM\ManyToOne(targetEntity="\Victoire\Bundle\CoreBundle\Entity\EntityProxy", cascade={"persist", "remove"})
25
     * @ORM\JoinColumn(name="entityProxy_id", referencedColumnName="id", onDelete="CASCADE")
26
     */
27
    protected $entityProxy;
28
29
    /**
30
     * The entity linked to the page.
31
     *
32
     * @var object
33
     */
34
    protected $businessEntity;
35
36
    /**
37
     * Set the entity proxy.
38
     *
39
     * @param BaseEntityProxy $entityProxy
40
     */
41
    public function setEntityProxy($entityProxy)
42
    {
43
        $this->entityProxy = $entityProxy;
44
    }
45
46
    /**
47
     * Get the entity proxy.
48
     *
49
     * @return BaseEntityProxy
50
     */
51
    public function getEntityProxy()
52
    {
53
        return $this->entityProxy;
54
    }
55
56
    /**
57
     * Get the business entity name (PagePattern proxy).
58
     *
59
     * @return string
60
     **/
61
    public function getBusinessEntityId()
62
    {
63
        return $this->getTemplate()->getBusinessEntityId();
0 ignored issues
show
Bug introduced by
The method getBusinessEntityId cannot be called on $this->getTemplate() (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...
64
    }
65
66
    /**
67
     * Get the business entity.
68
     *
69
     * @return number
70
     */
71
    public function getBusinessEntity()
72
    {
73
        //if there is no entity
74
        if ($this->businessEntity === null) {
75
            //if there is a proxy
76
            if ($this->getEntityProxy() !== null) {
77
                $this->businessEntity = $this->getEntityProxy()->getEntity($this->getBusinessEntityId());
78
79
                return $this->businessEntity;
80
            }
81
        }
82
83
        return $this->businessEntity;
84
    }
85
}
86