Skip to content

Commit

Permalink
Merge branch 'master' of github.com:bitbag-commerce/CmsPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbager committed Nov 11, 2017
2 parents 6bb4827 + 0c6958f commit 2c7e112
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
6 changes: 3 additions & 3 deletions features/admin/adding_block.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ Feature: Adding blocks
And I try to add it
Then I should be notified that there is already an existing block with provided code

@todo
@ui
Scenario: Trying to add text block with blank data
When I go to the create "text" block page
And I try to add it
Then I should be notified that "Code, Content" cannot be blank

@todo
@ui
Scenario: Trying to add html block with blank data
When I go to the create "html" block page
And I try to add it
Then I should be notified that "Code, Content" cannot be blank

@todo
@ui
Scenario: Trying to add image block with blank data
When I go to the create "image" block page
And I try to add it
Expand Down
13 changes: 13 additions & 0 deletions src/Form/Type/BlockType.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints\Valid;

/**
* @author Patryk Drapik <patryk.drapik@bitbag.pl>
Expand Down Expand Up @@ -68,6 +69,10 @@ private function resolveBlockType(BlockInterface $block, FormBuilderInterface $b
$builder->add('translations', ResourceTranslationsType::class, [
'label' => 'bitbag.ui.contents',
'entry_type' => TextBlockTranslationType::class,
'validation_groups' => ['bitbag_content'],
'constraints' => [
new Valid(),
],
]);

return;
Expand All @@ -77,6 +82,10 @@ private function resolveBlockType(BlockInterface $block, FormBuilderInterface $b
$builder->add('translations', ResourceTranslationsType::class, [
'label' => 'bitbag.ui.contents',
'entry_type' => HtmlBlockTranslationType::class,
'validation_groups' => ['bitbag_content'],
'constraints' => [
new Valid(),
],
]);

return;
Expand All @@ -86,6 +95,10 @@ private function resolveBlockType(BlockInterface $block, FormBuilderInterface $b
$builder->add('translations', ResourceTranslationsType::class, [
'label' => 'bitbag.ui.images',
'entry_type' => ImageBlockTranslationType::class,
'validation_groups' => null === $block->getId() ? ['bitbag_image'] : [],
'constraints' => [
new Valid(),
],
]);

return;
Expand Down
15 changes: 6 additions & 9 deletions src/Resources/config/services/form.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,20 @@ services:
class: BitBag\CmsPlugin\Form\Type\Translation\TextBlockTranslationType
arguments:
- "%bitbag.model.block_translation.class%"
- ['bitbag', 'bitbag_content']
tags:
- { name: form.type }

bitbag.form.type.translation.html_block:
class: BitBag\CmsPlugin\Form\Type\Translation\HtmlBlockTranslationType
arguments:
- "%bitbag.model.block_translation.class%"
- ['bitbag', 'bitbag_content']
tags:
- { name: form.type }

bitbag.form.type.translation.image_block:
class: BitBag\CmsPlugin\Form\Type\Translation\ImageBlockTranslationType
arguments:
- "%bitbag.model.block_translation.class%"
- ['bitbag', 'bitbag_image']
tags:
- { name: form.type }

Expand Down Expand Up @@ -72,12 +69,12 @@ services:
- { name: form.type }

bitbag.form.type.section:
class: BitBag\CmsPlugin\Form\Type\SectionType
arguments:
- "%bitbag.model.section.class%"
- ['bitbag']
tags:
- { name: form.type }
class: BitBag\CmsPlugin\Form\Type\SectionType
arguments:
- "%bitbag.model.section.class%"
- ['bitbag']
tags:
- { name: form.type }

bitbag.form.type.translation.section:
class: BitBag\CmsPlugin\Form\Type\Translation\SectionTranslationType
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/validation/BlockImage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ BitBag\CmsPlugin\Entity\BlockImage:
properties:
file:
- NotBlank:
message: 'bitbag.cms.block.image.not_blank'
message: 'bitbag.block.image.not_blank'
groups: ['bitbag_image']
2 changes: 1 addition & 1 deletion src/Resources/translations/validators.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ bitbag:
block:
image:
mime_types: Only PNG and JPEG files are allowed.
not_blank: Upload an image.
not_blank: Image cannot be blank.
code:
unique: There is an existing block with this code.
not_blank: Code cannot be blank.
Expand Down

0 comments on commit 2c7e112

Please sign in to comment.