BusinessTemplate::setBackendName()   A
last analyzed

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\PageBundle\Entity\PageStatus;
7
use Victoire\Bundle\QueryBundle\Entity\QueryTrait;
8
use Victoire\Bundle\QueryBundle\Entity\VictoireQueryInterface;
9
use Victoire\Bundle\SeoBundle\Entity\PageSeo;
10
use Victoire\Bundle\TemplateBundle\Entity\Template;
11
12
/**
13
 * BusinessTemplate.
14
 *
15
 * @ORM\Entity(repositoryClass="Victoire\Bundle\BusinessPageBundle\Repository\BusinessTemplateRepository")
16
 * @ORM\HasLifecycleCallbacks()
17
 */
18
class BusinessTemplate extends Template implements VictoireQueryInterface
19
{
20
    //This trait add the query and business_entity_id columns
21
    use QueryTrait;
22
23
    const TYPE = 'business_template';
24
25
    /**
26
     * @ORM\OneToOne(targetEntity="\Victoire\Bundle\SeoBundle\Entity\PageSeo", cascade={"persist", "remove"})
27
     * @ORM\JoinColumn(name="seo_id", referencedColumnName="id", onDelete="SET NULL")
28
     */
29
    protected $seo;
30
31
    /**
32
     * @ORM\OneToMany(targetEntity="\Victoire\Bundle\BusinessPageBundle\Entity\BusinessPage", mappedBy="template", cascade={"remove"})
33
     */
34
    protected $inheritors;
35
36
    /**
37
     * @var bool
38
     *
39
     * @deprecated author restriction is handled by the "BUSINESS_ENTITY_OWNER" role since 1.7.7 and will be removed in the 1.8
40
     *
41
     * @ORM\Column(name="author_restricted", type="boolean")
42
     */
43
    protected $authorRestricted;
44
45
    /**
46
     * @var string
47
     *
48
     * @ORM\Column(name="backendName", type="string", length=255)
49
     */
50
    protected $backendName;
51
52
    /**
53
     * contruct.
54
     **/
55
    public function __construct()
56
    {
57
        parent::__construct();
58
        $this->publishedAt = new \DateTime();
0 ignored issues
show
Bug introduced by
The property publishedAt 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...
59
        $this->status = PageStatus::PUBLISHED;
0 ignored issues
show
Bug introduced by
The property status 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...
60
    }
61
62
    /**
63
     * @return [BusinessPage]
0 ignored issues
show
Documentation introduced by
The doc-type [BusinessPage] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
64
     */
65
    public function getInstances()
66
    {
67
        return $this->inheritors;
68
    }
69
70
    public function setInstances($inheritors)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
71
    {
72
        $this->inheritors = $inheritors;
73
74
        return $this;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getLayout()
81
    {
82
        return $this->layout ? $this->layout : $this->getTemplate()->getLayout();
83
    }
84
85
    /**
86
     * Set seo.
87
     *
88
     * @param PageSeo $seo
89
     *
90
     * @return BusinessTemplate
91
     */
92
    public function setSeo(PageSeo $seo)
93
    {
94
        $this->seo = $seo;
95
96
        return $this;
97
    }
98
99
    /**
100
     * Get seo.
101
     *
102
     * @return PageSeo
103
     */
104
    public function getSeo()
105
    {
106
        return $this->seo;
107
    }
108
109
    /**
110
     * @return bool
111
     */
112
    public function isAuthorRestricted()
113
    {
114
        return $this->authorRestricted;
0 ignored issues
show
Deprecated Code introduced by
The property Victoire\Bundle\Business...late::$authorRestricted has been deprecated with message: author restriction is handled by the "BUSINESS_ENTITY_OWNER" role since 1.7.7 and will be removed in the 1.8

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
115
    }
116
117
    /**
118
     * @param bool $authorRestricted
119
     */
120
    public function setAuthorRestricted($authorRestricted)
121
    {
122
        $this->authorRestricted = $authorRestricted;
0 ignored issues
show
Deprecated Code introduced by
The property Victoire\Bundle\Business...late::$authorRestricted has been deprecated with message: author restriction is handled by the "BUSINESS_ENTITY_OWNER" role since 1.7.7 and will be removed in the 1.8

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
123
    }
124
125
    /**
126
     * @return string
127
     */
128
    public function getBackendName()
129
    {
130
        return $this->backendName;
131
    }
132
133
    /**
134
     * @param string $backendName
135
     *
136
     * @return $this
137
     */
138
    public function setBackendName($backendName)
139
    {
140
        $this->backendName = $backendName;
141
142
        return $this;
143
    }
144
145
    /**
146
     * Get inheritors (all Templates having this object as Template).
147
     *
148
     * @return [Template]
0 ignored issues
show
Documentation introduced by
The doc-type [Template] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
149
     */
150 View Code Duplication
    public function getTemplateInheritors()
0 ignored issues
show
Duplication introduced by
This method 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...
151
    {
152
        $templateInheritors = [];
153
        foreach ($this->inheritors as $inheritor) {
154
            if ($inheritor instanceof self) {
155
                $templateInheritors[] = $inheritor;
156
            }
157
        }
158
159
        return $templateInheritors;
160
    }
161
}
162