Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

Commit

Permalink
Merge pull request #138 from symfony-cmf/revert_translateable
Browse files Browse the repository at this point in the history
revert adding TranslatableInterface to AbstractBlock
  • Loading branch information
lsmith77 committed Sep 11, 2013
2 parents 35c1166 + dd8caa5 commit 77d91f1
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 15 deletions.
10 changes: 8 additions & 2 deletions Doctrine/Phpcr/ImagineBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

use Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image;
use Symfony\Cmf\Bundle\MediaBundle\ImageInterface;
use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;
use Symfony\Component\HttpFoundation\File\UploadedFile;

/**
* Block to hold an image
*/
class ImagineBlock extends AbstractBlock
class ImagineBlock extends AbstractBlock implements TranslatableInterface
{
/**
* @var Image
Expand Down Expand Up @@ -38,6 +39,11 @@ class ImagineBlock extends AbstractBlock
*/
protected $node;

/**
* @var string
*/
protected $locale;

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -120,7 +126,7 @@ public function getFilter()
*/
public function setImage($image = null)
{
if (! $image) {
if (!$image) {
return;
}

Expand Down
9 changes: 8 additions & 1 deletion Doctrine/Phpcr/SimpleBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

namespace Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr;

use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;

/**
* Block that contains hypertext and a title
*/
class SimpleBlock extends AbstractBlock
class SimpleBlock extends AbstractBlock implements TranslatableInterface
{
/**
* @var string
Expand All @@ -17,6 +19,11 @@ class SimpleBlock extends AbstractBlock
*/
protected $body;

/**
* @var string
*/

This comment has been minimized.

Copy link
@dbu

dbu Sep 11, 2013

Member

i think the base class is already providing this field (as it is the getter and setter we are using). the idea was that the base class provides the infrastructure even though it does not implement the interface itself, to avoid the copy paste. i can live with saying we do not want this mixup and copy the locale things into each block, but then we should be consistent and have field and methods both.

This comment has been minimized.

Copy link
@lsmith77

lsmith77 Sep 11, 2013

Author Member

hmm ... maybe i dont understand something there .. but with the default value of false the tests were failing.

This comment has been minimized.

Copy link
@dbu

dbu Sep 11, 2013

Member

so we sorted this out. we have validation on locale and false is not a valid locale, while null is ok and phpcr-odm will use the current session locale in that case.

protected $locale;

/**
* {@inheritdoc}
*/
Expand Down
8 changes: 7 additions & 1 deletion Doctrine/Phpcr/SlideshowBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,25 @@
namespace Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr;

use Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ContainerBlock;
use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;

/**
* Special container block that renders child items in a way suitable for a
* slideshow. Note that you need to add some javascript to actually get the
* blocks to do a slideshow.
*/
class SlideshowBlock extends ContainerBlock
class SlideshowBlock extends ContainerBlock implements TranslatableInterface
{
/**
* @var string
*/
protected $title;

/**
* @var string
*/
protected $locale;

/**
* {@inheritdoc}
*/
Expand Down
9 changes: 8 additions & 1 deletion Doctrine/Phpcr/StringBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,23 @@

namespace Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr;

use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;

/**
* Block that contains only text
*/
class StringBlock extends AbstractBlock
class StringBlock extends AbstractBlock implements TranslatableInterface
{
/**
* @var string
*/
protected $body;

/**
* @var string
*/
protected $locale;

/**
* {@inheritdoc}
*/
Expand Down
4 changes: 1 addition & 3 deletions Model/AbstractBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Symfony\Cmf\Bundle\BlockBundle\Model;

use Sonata\BlockBundle\Model\BlockInterface;
use Symfony\Cmf\Bundle\CoreBundle\Translatable\TranslatableInterface;

use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishableInterface;
use Symfony\Cmf\Bundle\CoreBundle\PublishWorkflow\PublishTimePeriodInterface;
Expand All @@ -19,8 +18,7 @@
abstract class AbstractBlock implements
BlockInterface,
PublishableInterface,
PublishTimePeriodInterface,
TranslatableInterface
PublishTimePeriodInterface
{
/**
* @var string
Expand Down
35 changes: 28 additions & 7 deletions Resources/config/validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@
xsi:schemaLocation="http://symfony.com/schema/dic/constraint-mapping
http://symfony.com/schema/dic/constraint-mapping/constraint-mapping-1.0.xsd">

<class name="Symfony\Cmf\Bundle\BlockBundle\Model\AbstractBlock">
<!-- either a valid locale or empty -->
<property name="locale">
<constraint name="Locale"/>
</property>
</class>

<class name="Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\AbstractBlock">
<constraint name="Doctrine\Bundle\PHPCRBundle\Validator\Constraints\ValidPhpcrOdm" />
<constraint name="Callback">
Expand All @@ -34,12 +27,40 @@
<property name="body">
<constraint name="NotBlank" />
</property>

<property name="locale">
<constraint name="Locale"/>
</property>
</class>

<class name="Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\StringBlock">
<property name="body">
<constraint name="NotBlank" />
</property>

<property name="locale">
<constraint name="Locale"/>
</property>
</class>

<class name="Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\ImagineBlock">
<property name="body">
<constraint name="NotBlank" />
</property>

<property name="locale">
<constraint name="Locale"/>
</property>
</class>

<class name="Symfony\Cmf\Bundle\BlockBundle\Doctrine\Phpcr\SlideshowBlock">
<property name="body">
<constraint name="NotBlank" />
</property>

<property name="locale">
<constraint name="Locale"/>
</property>
</class>

</constraint-mapping>

0 comments on commit 77d91f1

Please sign in to comment.