Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1731 #1740

Merged
merged 2 commits into from
Jun 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 72 additions & 4 deletions src/Block/GalleryBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\Doctrine\Model\ManagerInterface;
use Sonata\Form\Type\ImmutableArrayType;
use Sonata\Form\Validator\ErrorElement;
use Sonata\MediaBundle\Model\GalleryInterface;
use Sonata\MediaBundle\Model\MediaInterface;
use Sonata\MediaBundle\Provider\Pool;
Expand Down Expand Up @@ -113,7 +114,10 @@ public function configureSettings(OptionsResolver $resolver)
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
Expand Down Expand Up @@ -226,23 +230,30 @@ public function load(BlockInterface $block)
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function prePersist(BlockInterface $block)
{
$block->setSetting('galleryId', \is_object($block->getSetting('galleryId')) ? $block->getSetting('galleryId')->getId() : null);
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function preUpdate(BlockInterface $block)
{
$block->setSetting('galleryId', \is_object($block->getSetting('galleryId')) ? $block->getSetting('galleryId')->getId() : null);
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function getBlockMetadata($code = null)
{
Expand All @@ -251,6 +262,63 @@ public function getBlockMetadata($code = null)
]);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function buildCreateForm(FormMapper $formMapper, BlockInterface $block)
{
$this->buildEditForm($formMapper, $block);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postPersist(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postUpdate(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function preRemove(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postRemove(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
{
}

private function buildElements(GalleryInterface $gallery): array
{
$elements = [];
Expand Down
86 changes: 84 additions & 2 deletions src/Block/GalleryListBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Sonata\BlockBundle\Meta\Metadata;
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\Form\Type\ImmutableArrayType;
use Sonata\Form\Validator\ErrorElement;
use Sonata\MediaBundle\Model\GalleryManagerInterface;
use Sonata\MediaBundle\Provider\Pool;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
Expand Down Expand Up @@ -58,7 +59,10 @@ public function __construct($twigOrName, ?EngineInterface $templating, GalleryMa
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
Expand Down Expand Up @@ -171,12 +175,90 @@ public function configureSettings(OptionsResolver $resolver)
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function getBlockMetadata($code = null)
{
return new Metadata($this->getName(), (null !== $code ? $code : $this->getName()), false, 'SonataMediaBundle', [
'class' => 'fa fa-picture-o',
]);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function buildCreateForm(FormMapper $formMapper, BlockInterface $block)
{
$this->buildEditForm($formMapper, $block);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function prePersist(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postPersist(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function preUpdate(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postUpdate(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function preRemove(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postRemove(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
{
}
}
68 changes: 66 additions & 2 deletions src/Block/MediaBlockService.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Sonata\BlockBundle\Model\BlockInterface;
use Sonata\Doctrine\Model\ManagerInterface;
use Sonata\Form\Type\ImmutableArrayType;
use Sonata\Form\Validator\ErrorElement;
use Sonata\MediaBundle\Admin\BaseMediaAdmin;
use Sonata\MediaBundle\Model\MediaInterface;
use Sonata\MediaBundle\Provider\Pool;
Expand Down Expand Up @@ -112,7 +113,10 @@ public function configureSettings(OptionsResolver $resolver)
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function buildEditForm(FormMapper $formMapper, BlockInterface $block)
{
Expand Down Expand Up @@ -204,7 +208,10 @@ public function preUpdate(BlockInterface $block)
}

/**
* {@inheritdoc}
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function getBlockMetadata($code = null)
{
Expand All @@ -213,6 +220,63 @@ public function getBlockMetadata($code = null)
]);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function buildCreateForm(FormMapper $formMapper, BlockInterface $block)
{
$this->buildEditForm($formMapper, $block);
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postPersist(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postUpdate(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function preRemove(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0.
*/
public function postRemove(BlockInterface $block)
{
}

/**
* NEXT_MAJOR: Remove this method.
*
* @deprecated since sonata-project/media-bundle 3.x, to be removed in 4.0. You should use
* `Sonata\BlockBundle\Block\Service\EditableBlockService` interface instead.
*/
public function validateBlock(ErrorElement $errorElement, BlockInterface $block)
{
}

/**
* @return array
*/
Expand Down