Passed
Push — master ( a91459...e52b22 )
by Luiz Kim
02:52
created

File::getContext()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace ControleOnline\Entity;
4
5
use ApiPlatform\Metadata\GetCollection;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\GetCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use ApiPlatform\Metadata\Get;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Get was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use ApiPlatform\Metadata\Post;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Post was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use ApiPlatform\Metadata\Put;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Put was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
use ApiPlatform\Metadata\Delete;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\Delete was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use ApiPlatform\Metadata\ApiResource;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiResource was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use ApiPlatform\Metadata\ApiProperty;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiProperty was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use ApiPlatform\Metadata\ApiFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Metadata\ApiFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use ControleOnline\Controller\GetFileDataAction;
14
use ControleOnline\Controller\FileUploadController;
15
use Doctrine\ORM\Mapping as ORM;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Mapping was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
use Symfony\Component\Serializer\Annotation\Groups;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Serializer\Annotation\Groups was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
use Doctrine\Common\Collections\ArrayCollection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\ArrayCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
use Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\OrderFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\ExistsFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
21
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
0 ignored issues
show
Bug introduced by
The type ApiPlatform\Doctrine\Orm\Filter\SearchFilter was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
22
use ControleOnline\Controller\FileConvertController;
23
use Symfony\Component\Validator\Constraints as Assert;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Validator\Constraints was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
25
26
/**
27
 * File
28
 *
29
 * @ORM\EntityListeners ({ControleOnline\Listener\LogListener::class})
30
 * @ORM\Entity (repositoryClass="ControleOnline\Repository\FileRepository")
31
 * @ORM\Table (name="files", uniqueConstraints={@ORM\UniqueConstraint (name="url", columns={"url"}), @ORM\UniqueConstraint(name="path", columns={"path"})})
32
 */
33
#[ApiResource(
34
    operations: [
35
        new Get(
36
            security: 'is_granted(\'ROLE_CLIENT\')',
37
            normalizationContext: ['groups' => ['file_item:read']],
38
        ),
39
        new Get(
40
            security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')',
41
            uriTemplate: '/files/{id}/download',
42
            controller: GetFileDataAction::class
43
        ),
44
        new Delete(security: 'is_granted(\'ROLE_CLIENT\')'),
45
        new Post(
46
            security: 'is_granted(\'ROLE_CLIENT\')',
47
            uriTemplate: '/files/upload',
48
            controller: FileUploadController::class,
49
            deserialize: false
50
        ),
51
        new GetCollection(security: 'is_granted(\'ROLE_CLIENT\')'),
52
        new Post(security: 'is_granted(\'ROLE_CLIENT\')'),
53
        new Put(
54
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
55
            validationContext: ['groups' => ['file:write']],
56
            denormalizationContext: ['groups' => ['file:write']]
57
        ),
58
        new Post(
59
            security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))',
60
            uriTemplate: '/files/{id}/convert',
61
            controller: FileConvertController::class,
62
            deserialize: false
63
        ),
64
    ],
65
    normalizationContext: ['groups' => ['file:read']],
66
    denormalizationContext: ['groups' => ['file:write']]
67
)]
68
class File
69
{
70
    /**
71
     *
72
     * @ORM\Column(type="integer", nullable=false)
73
     * @ORM\Id
74
     * @ORM\GeneratedValue(strategy="IDENTITY")
75
     * @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","contract:read","model:read","people:read"})
76
     */
77
    private $id;
78
79
    /**
80
     * @ORM\Column(type="string", length=255, nullable=false)
81
     * @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"})
82
     * @Assert\NotBlank
83
     */
84
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['fileType' => 'exact'])]
85
    private $fileType;
86
87
    /**
88
     * @ORM\Column(type="string", length=255, nullable=false)
89
     * @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"})
90
     * @Assert\NotBlank
91
     */
92
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['fileName' => 'exact'])]
93
    private $fileName;
94
95
    /**
96
     * @ORM\Column(type="string", length=255, nullable=false)
97
     * @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"})
98
     * @Assert\NotBlank
99
     */
100
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['context' => 'exact'])]
101
    private $context;
102
103
    /**
104
     * @ORM\Column(type="string", length=255, nullable=false)
105
     * @Groups({"file:read","category:read","product_category:read","product_file:read","product:read","file_item:read","product:read","file:write","contract:read","model:read","people:read"})
106
     * @Assert\NotBlank
107
     */
108
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['extension' => 'exact'])]
109
    private $extension;
110
111
    /**
112
     * @ORM\Column(type="string", length=255, nullable=false)
113
     * @Groups({"file_item:read","file:write"})
114
     */
115
    private $content;
116
117
    /**
118
     * @var \ControleOnline\Entity\People
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\People was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
119
     *
120
     * @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People")
121
     * @ORM\JoinColumns({
122
     *   @ORM\JoinColumn(name="people_id", referencedColumnName="id")
123
     * })
124
     * @Groups({"file_item:read","file:write","file:read"})
125
     */
126
    #[ApiFilter(filterClass: SearchFilter::class, properties: ['people' => 'exact'])]
127
    private $people;
128
129
    public function __construct()
130
    {
131
        $this->people = new \Doctrine\Common\Collections\ArrayCollection();
132
    }
133
134
    public function getId()
135
    {
136
        return $this->id;
137
    }
138
139
140
141
    /**
142
     * Get the value of fileType
143
     */
144
    public function getFileType()
145
    {
146
        return $this->fileType;
147
    }
148
149
    /**
150
     * Set the value of fileType
151
     */
152
    public function setFileType($fileType): self
153
    {
154
        $this->fileType = $fileType;
155
156
        return $this;
157
    }
158
159
    /**
160
     * Get the value of content
161
     */
162
    public function getContent()
163
    {
164
        return $this->content;
165
    }
166
167
    /**
168
     * Set the value of content
169
     */
170
    public function setContent($content): self
171
    {
172
        $this->content = $content;
173
174
        return $this;
175
    }
176
177
    /**
178
     * Get the value of people
179
     */
180
    public function getPeople()
181
    {
182
        return $this->people;
183
    }
184
185
    /**
186
     * Set the value of people
187
     */
188
    public function setPeople($people): self
189
    {
190
        $this->people = $people;
191
192
        return $this;
193
    }
194
195
    /**
196
     * Get the value of extension
197
     */
198
    public function getExtension()
199
    {
200
        return $this->extension;
201
    }
202
203
    /**
204
     * Set the value of extension
205
     */
206
    public function setExtension($extension): self
207
    {
208
        $this->extension = $extension;
209
210
        return $this;
211
    }
212
213
    /**
214
     * Get the value of fileName
215
     */
216
    public function getFileName()
217
    {
218
        return $this->fileName;
219
    }
220
221
    /**
222
     * Set the value of fileName
223
     */
224
    public function setFileName($fileName): self
225
    {
226
        $this->fileName = $fileName;
227
228
        return $this;
229
    }
230
231
    /**
232
     * Get the value of context
233
     */
234
    public function getContext()
235
    {
236
        return $this->context;
237
    }
238
239
    /**
240
     * Set the value of context
241
     */
242
    public function setContext($context): self
243
    {
244
        $this->context = $context;
245
246
        return $this;
247
    }
248
}
249