zend-blog-3-backend

Форк
0
/
PygmentsCode.php 
163 строки · 3.0 Кб
1
<?php
2

3
namespace App\Entity;
4

5
use App\Entity\Traits\ModifyEntityTrait;
6
use Doctrine\ORM\Mapping as ORM;
7

8
/**
9
 * @ORM\Table()
10
 * @ORM\Entity(repositoryClass="App\Repository\PygmentsCodeRepository")
11
 * @ORM\HasLifecycleCallbacks()
12
 */
13
class PygmentsCode
14
{
15
    use ModifyEntityTrait;
16

17
    /**
18
     * @var int
19
     *
20
     * @ORM\Id
21
     * @ORM\Column(type="integer")
22
     * @ORM\GeneratedValue(strategy="AUTO")
23
     */
24
    private $id;
25

26
    /**
27
     * @var PygmentsLanguage
28
     *
29
     * @ORM\ManyToOne(targetEntity="PygmentsLanguage")
30
     * @ORM\JoinColumn(referencedColumnName="id", onDelete="SET NULL")
31
     */
32
    private $language;
33

34
    /**
35
     * @var string
36
     *
37
     * @ORM\Column(type="text", length=65535)
38
     */
39
    private $sourceCode = '';
40

41
    /**
42
     * @var string|null
43
     *
44
     * @ORM\Column(type="text", length=65535, nullable=true)
45
     */
46
    private $sourceHtml;
47

48
    /**
49
     * @var string|null
50
     *
51
     * @ORM\Column(type="text", length=65535, nullable=true)
52
     */
53
    private $sourceHtmlPreview;
54

55
    /**
56
     * @return int
57
     */
58
    public function getId()
59
    {
60
        return $this->id;
61
    }
62

63
    /**
64
     * @return string
65
     */
66
    public function getLexer(): string
67
    {
68
        $result = 'text';
69
        if ($this->language) {
70
            $result = $this->language->getLexer();
71
        }
72

73
        return $result;
74
    }
75

76
    /**
77
     * @return string
78
     */
79
    public function getContentHash(): string
80
    {
81
        return sha1($this->getSourceCode() . ':' . $this->getLexer());
82
    }
83

84
    /**
85
     * @return PygmentsLanguage|null
86
     */
87
    public function getLanguage(): ?PygmentsLanguage
88
    {
89
        return $this->language;
90
    }
91

92
    /**
93
     * @param PygmentsLanguage|null $language
94
     *
95
     * @return PygmentsCode
96
     */
97
    public function setLanguage(PygmentsLanguage $language = null): self
98
    {
99
        $this->language = $language;
100

101
        return $this;
102
    }
103

104
    /**
105
     * @return string|null
106
     */
107
    public function getSourceCode(): ?string
108
    {
109
        return $this->sourceCode;
110
    }
111

112
    /**
113
     * @param mixed $sourceCode
114
     *
115
     * @return PygmentsCode
116
     */
117
    public function setSourceCode($sourceCode): self
118
    {
119
        $this->sourceCode = $sourceCode;
120

121
        return $this;
122
    }
123

124
    /**
125
     * @return string|null
126
     */
127
    public function getSourceHtml(): ?string
128
    {
129
        return $this->sourceHtml;
130
    }
131

132
    /**
133
     * @param string $sourceHtml
134
     *
135
     * @return PygmentsCode
136
     */
137
    public function setSourceHtml(string $sourceHtml): self
138
    {
139
        $this->sourceHtml = $sourceHtml;
140

141
        return $this;
142
    }
143

144
    /**
145
     * @return string|null
146
     */
147
    public function getSourceHtmlPreview(): ?string
148
    {
149
        return $this->sourceHtmlPreview;
150
    }
151

152
    /**
153
     * @param string|null $sourceHtmlPreview
154
     *
155
     * @return PygmentsCode
156
     */
157
    public function setSourceHtmlPreview(string $sourceHtmlPreview = null): PygmentsCode
158
    {
159
        $this->sourceHtmlPreview = $sourceHtmlPreview;
160

161
        return $this;
162
    }
163
}
164

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.