|
|
@ -26,52 +26,131 @@ use Stringable; |
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
|
|
|
|
|
|
|
|
|
|
#[ApiResource(operations: [new Put(controller: UpdatePersonalFileAction::class, deserialize: false, security: 'is_granted(\'EDIT\', object.resourceNode)'), new Get(security: 'is_granted(\'VIEW\', object.resourceNode)'), new Delete(security: 'is_granted(\'DELETE\', object.resourceNode)'), new Post(controller: CreatePersonalFileAction::class, deserialize: false, security: 'is_granted(\'ROLE_USER\')', validationContext: ['groups' => ['Default', 'media_object_create', 'personal_file:write']], openapiContext: ['requestBody' => ['content' => ['multipart/form-data' => ['schema' => ['type' => 'object', 'properties' => ['title' => ['type' => 'string'], 'comment' => ['type' => 'string'], 'contentFile' => ['type' => 'string'], 'uploadFile' => ['type' => 'string', 'format' => 'binary'], 'parentResourceNodeId' => ['type' => 'integer'], 'resourceLinkList' => ['type' => 'array', 'items' => ['type' => 'object', 'properties' => ['visibility' => ['type' => 'integer'], 'c_id' => ['type' => 'integer'], 'session_id' => ['type' => 'integer']]]]]]]]]]), new GetCollection(security: 'is_granted(\'ROLE_USER\')')], normalizationContext: ['groups' => ['personal_file:read', 'resource_node:read']], denormalizationContext: ['groups' => ['personal_file:write']])] |
|
|
|
#[ApiResource( |
|
|
|
|
|
|
|
operations: [ |
|
|
|
|
|
|
|
new Put( |
|
|
|
|
|
|
|
controller: UpdatePersonalFileAction::class, |
|
|
|
|
|
|
|
security: "is_granted('EDIT', object.resourceNode)", |
|
|
|
|
|
|
|
deserialize: false |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
new Get(security: "is_granted('VIEW', object.resourceNode)"), |
|
|
|
|
|
|
|
new Delete(security: "is_granted('DELETE', object.resourceNode)"), |
|
|
|
|
|
|
|
new Post( |
|
|
|
|
|
|
|
controller: CreatePersonalFileAction::class, |
|
|
|
|
|
|
|
openapiContext: [ |
|
|
|
|
|
|
|
'requestBody' => [ |
|
|
|
|
|
|
|
'content' => [ |
|
|
|
|
|
|
|
'multipart/form-data' => [ |
|
|
|
|
|
|
|
'schema' => [ |
|
|
|
|
|
|
|
'type' => 'object', |
|
|
|
|
|
|
|
'properties' => [ |
|
|
|
|
|
|
|
'title' => ['type' => 'string'], |
|
|
|
|
|
|
|
'comment' => ['type' => 'string'], |
|
|
|
|
|
|
|
'contentFile' => ['type' => 'string'], |
|
|
|
|
|
|
|
'uploadFile' => ['type' => 'string', 'format' => 'binary'], |
|
|
|
|
|
|
|
'parentResourceNodeId' => ['type' => 'integer'], |
|
|
|
|
|
|
|
'resourceLinkList' => [ |
|
|
|
|
|
|
|
'type' => 'array', |
|
|
|
|
|
|
|
'items' => [ |
|
|
|
|
|
|
|
'type' => 'object', |
|
|
|
|
|
|
|
'properties' => [ |
|
|
|
|
|
|
|
'visibility' => ['type' => 'integer'], |
|
|
|
|
|
|
|
'c_id' => ['type' => 'integer'], |
|
|
|
|
|
|
|
'session_id' => ['type' => 'integer'] |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
security: "is_granted('ROLE_USER')", |
|
|
|
|
|
|
|
validationContext: [ |
|
|
|
|
|
|
|
'groups' => ['Default', 'media_object_create', 'personal_file:write'], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
deserialize: false |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
new GetCollection(security: "is_granted('ROLE_USER')"), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
normalizationContext: [ |
|
|
|
|
|
|
|
'groups' => ['personal_file:read', 'resource_node:read'], |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
denormalizationContext: [ |
|
|
|
|
|
|
|
'groups' => ['personal_file:write'], |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
)] |
|
|
|
#[ORM\Table(name: 'personal_file')] |
|
|
|
#[ORM\Table(name: 'personal_file')] |
|
|
|
#[ORM\EntityListeners([ResourceListener::class])] |
|
|
|
#[ORM\EntityListeners([ResourceListener::class])] |
|
|
|
#[ORM\Entity(repositoryClass: PersonalFileRepository::class)] |
|
|
|
#[ORM\Entity(repositoryClass: PersonalFileRepository::class)] |
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['title' => 'partial', 'resourceNode.parent' => 'exact'])] |
|
|
|
#[ApiFilter( |
|
|
|
#[ApiFilter(filterClass: PropertyFilter::class)] |
|
|
|
filterClass: SearchFilter::class, |
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['id', 'resourceNode.title', 'resourceNode.createdAt', 'resourceNode.resourceFile.size', 'resourceNode.updatedAt'])] |
|
|
|
properties: [ |
|
|
|
|
|
|
|
'title' => 'partial', |
|
|
|
|
|
|
|
'resourceNode.parent' => 'exact', |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
)] |
|
|
|
|
|
|
|
#[ApiFilter( |
|
|
|
|
|
|
|
filterClass: PropertyFilter::class |
|
|
|
|
|
|
|
)] |
|
|
|
|
|
|
|
#[ApiFilter( |
|
|
|
|
|
|
|
filterClass: OrderFilter::class, |
|
|
|
|
|
|
|
properties: [ |
|
|
|
|
|
|
|
'id', |
|
|
|
|
|
|
|
'resourceNode.title', |
|
|
|
|
|
|
|
'resourceNode.createdAt', |
|
|
|
|
|
|
|
'resourceNode.resourceFile.size', |
|
|
|
|
|
|
|
'resourceNode.updatedAt', |
|
|
|
|
|
|
|
] |
|
|
|
|
|
|
|
)] |
|
|
|
class PersonalFile extends AbstractResource implements ResourceInterface, Stringable |
|
|
|
class PersonalFile extends AbstractResource implements ResourceInterface, Stringable |
|
|
|
{ |
|
|
|
{ |
|
|
|
use TimestampableEntity; |
|
|
|
use TimestampableEntity; |
|
|
|
|
|
|
|
|
|
|
|
#[Groups(['personal_file:read'])] |
|
|
|
#[Groups(['personal_file:read'])] |
|
|
|
#[ORM\Column(name: 'id', type: 'integer')] |
|
|
|
#[ORM\Column(name: 'id', type: 'integer')] |
|
|
|
#[ORM\Id] |
|
|
|
#[ORM\Id] |
|
|
|
#[ORM\GeneratedValue(strategy: 'AUTO')] |
|
|
|
#[ORM\GeneratedValue(strategy: 'AUTO')] |
|
|
|
protected ?int $id = null; |
|
|
|
protected ?int $id = null; |
|
|
|
|
|
|
|
|
|
|
|
#[Assert\NotBlank] |
|
|
|
#[Assert\NotBlank] |
|
|
|
#[Groups(['personal_file:read'])] |
|
|
|
#[Groups(['personal_file:read'])] |
|
|
|
#[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)] |
|
|
|
#[ORM\Column(name: 'title', type: 'string', length: 255, nullable: false)] |
|
|
|
protected string $title; |
|
|
|
protected string $title; |
|
|
|
public function __construct() {} |
|
|
|
|
|
|
|
public function __toString(): string |
|
|
|
public function __toString(): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->getTitle(); |
|
|
|
return $this->getTitle(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getId(): int |
|
|
|
public function getId(): int |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->id; |
|
|
|
return $this->id; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getTitle(): string |
|
|
|
public function getTitle(): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->title; |
|
|
|
return $this->title; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setTitle(string $title): self |
|
|
|
public function setTitle(string $title): self |
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->title = $title; |
|
|
|
$this->title = $title; |
|
|
|
|
|
|
|
|
|
|
|
return $this; |
|
|
|
return $this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getResourceIdentifier(): int |
|
|
|
public function getResourceIdentifier(): int |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->getId(); |
|
|
|
return $this->getId(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function getResourceName(): string |
|
|
|
public function getResourceName(): string |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->getTitle(); |
|
|
|
return $this->getTitle(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setResourceName(string $name): self |
|
|
|
public function setResourceName(string $name): self |
|
|
|
{ |
|
|
|
{ |
|
|
|
return $this->setTitle($name); |
|
|
|
return $this->setTitle($name); |
|
|
|