-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Better overridability for WebResponses
- Loading branch information
1 parent
b4f6863
commit 1dff926
Showing
4 changed files
with
115 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
lib/RoadizCoreBundle/src/Api/Model/WebResponseTrait.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace RZ\Roadiz\CoreBundle\Api\Model; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use Doctrine\Common\Collections\Collection; | ||
use RZ\Roadiz\Core\AbstractEntities\PersistableInterface; | ||
use RZ\Roadiz\CoreBundle\Api\Breadcrumbs\BreadcrumbsInterface; | ||
use RZ\Roadiz\CoreBundle\Model\RealmInterface; | ||
use RZ\TreeWalker\WalkerInterface; | ||
use Symfony\Component\Serializer\Annotation as Serializer; | ||
|
||
trait WebResponseTrait | ||
{ | ||
#[ApiProperty(identifier: true)] | ||
public ?string $path = null; | ||
|
||
#[Serializer\Groups(["web_response"])] | ||
public ?PersistableInterface $item = null; | ||
|
||
#[Serializer\Groups(["web_response"])] | ||
public ?BreadcrumbsInterface $breadcrumbs = null; | ||
|
||
#[Serializer\Groups(["web_response"])] | ||
public ?NodesSourcesHeadInterface $head = null; | ||
/** | ||
* @var Collection<int, WalkerInterface>|null | ||
*/ | ||
#[Serializer\Groups(["web_response"])] | ||
private ?Collection $blocks = null; | ||
/** | ||
* @var array<RealmInterface>|null | ||
*/ | ||
#[Serializer\Groups(["web_response"])] | ||
private ?array $realms = null; | ||
|
||
#[Serializer\Groups(["web_response"])] | ||
private bool $hidingBlocks = false; | ||
|
||
/** | ||
* @return PersistableInterface|null | ||
*/ | ||
public function getItem(): ?PersistableInterface | ||
{ | ||
return $this->item; | ||
} | ||
|
||
/** | ||
* @return Collection<int, WalkerInterface>|null | ||
*/ | ||
public function getBlocks(): ?Collection | ||
{ | ||
return $this->blocks; | ||
} | ||
|
||
/** | ||
* @param Collection<int, WalkerInterface>|null $blocks | ||
* @return $this | ||
*/ | ||
public function setBlocks(?Collection $blocks): self | ||
{ | ||
$this->blocks = $blocks; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return RealmInterface[]|null | ||
*/ | ||
public function getRealms(): ?array | ||
{ | ||
return $this->realms; | ||
} | ||
|
||
/** | ||
* @param RealmInterface[]|null $realms | ||
* @return $this | ||
*/ | ||
public function setRealms(?array $realms): self | ||
{ | ||
$this->realms = $realms; | ||
return $this; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function isHidingBlocks(): bool | ||
{ | ||
return $this->hidingBlocks; | ||
} | ||
|
||
/** | ||
* @param bool $hidingBlocks | ||
* @return $this | ||
*/ | ||
public function setHidingBlocks(bool $hidingBlocks): self | ||
{ | ||
$this->hidingBlocks = $hidingBlocks; | ||
return $this; | ||
} | ||
} |