-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OP-321: Init update block functionality
- Loading branch information
Showing
26 changed files
with
453 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
final class BlockContent implements BlockContentInterface | ||
{ | ||
protected ?int $id; | ||
|
||
protected ?string $type; | ||
|
||
protected array $configuration = []; | ||
|
||
protected ?BlockInterface $block; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getType(): ?string | ||
{ | ||
return $this->type; | ||
} | ||
|
||
public function setType(?string $type): void | ||
{ | ||
$this->type = $type; | ||
} | ||
|
||
public function getConfiguration(): array | ||
{ | ||
return $this->configuration; | ||
} | ||
|
||
public function setConfiguration(array $configuration): void | ||
{ | ||
$this->configuration = $configuration; | ||
} | ||
|
||
public function getBlock(): ?BlockInterface | ||
{ | ||
return $this->block; | ||
} | ||
|
||
public function setBlock(?BlockInterface $block): void | ||
{ | ||
$this->block = $block; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
use Doctrine\Common\Collections\Collection; | ||
|
||
interface BlockContentAwareInterface | ||
{ | ||
public function initializeContentsCollection(): void; | ||
|
||
public function getContents(): Collection; | ||
|
||
public function hasContent(BlockContentInterface $contentItem): bool; | ||
|
||
public function addContent(BlockContentInterface $contentItem): void; | ||
|
||
public function removeContent(BlockContentInterface $contentItem): void; | ||
} |
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,48 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Doctrine\Common\Collections\Collection; | ||
|
||
trait BlockContentAwareTrait | ||
{ | ||
protected Collection $contents; | ||
|
||
public function initializeContentsCollection(): void | ||
{ | ||
$this->contents = new ArrayCollection(); | ||
} | ||
|
||
public function getContents(): Collection | ||
{ | ||
return $this->contents; | ||
} | ||
|
||
public function hasContent(BlockContentInterface $contentItem): bool | ||
{ | ||
return $this->contents->contains($contentItem); | ||
} | ||
|
||
public function addContent(BlockContentInterface $contentItem): void | ||
{ | ||
if (!$this->hasContent($contentItem)) { | ||
$this->contents->add($contentItem); | ||
} | ||
} | ||
|
||
public function removeContent(BlockContentInterface $contentItem): void | ||
{ | ||
if ($this->hasContent($contentItem)) { | ||
$this->contents->removeElement($contentItem); | ||
} | ||
} | ||
} |
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,30 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Entity; | ||
|
||
use Sylius\Component\Resource\Model\ResourceInterface; | ||
|
||
interface BlockContentInterface extends ResourceInterface | ||
{ | ||
public function getId(): ?int; | ||
|
||
public function getType(): ?string; | ||
|
||
public function setType(?string $type): void; | ||
|
||
public function getConfiguration(): array; | ||
|
||
public function setConfiguration(array $configuration): void; | ||
|
||
public function getBlock(): ?BlockInterface; | ||
|
||
public function setBlock(?BlockInterface $block): void; | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/Form/Type/BlockContent/BlockContentTextConfigurationType.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,32 @@ | ||
<?php | ||
|
||
/* | ||
* This file was created by developers working at BitBag | ||
* Do you need more information about us and what we do? Visit our https://bitbag.io website! | ||
* We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BitBag\SyliusCmsPlugin\Form\Type\BlockContent; | ||
|
||
use BitBag\SyliusCmsPlugin\Form\Type\WysiwygType; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\OptionsResolver\OptionsResolver; | ||
|
||
final class BlockContentTextConfigurationType extends AbstractType | ||
{ | ||
public const TYPE = 'content_text'; | ||
|
||
public function configureOptions(OptionsResolver $resolver): void | ||
{ | ||
$resolver->setDefaults([ | ||
'label' => 'bitbag_sylius_cms_plugin.ui.text', | ||
]); | ||
} | ||
|
||
public function getParent(): string | ||
{ | ||
return WysiwygType::class; | ||
} | ||
} |
Oops, something went wrong.