Skip to content

Commit

Permalink
Remove TranslatableInterface::getLocale
Browse files Browse the repository at this point in the history
  • Loading branch information
franmomu authored and VincentLanglet committed Nov 2, 2021
1 parent ae4b7f1 commit de5ec62
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
6 changes: 4 additions & 2 deletions src/Admin/Extension/Gedmo/TranslatableAdminExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ public function __construct(

public function alterNewInstance(AdminInterface $admin, object $object): void
{
if (null === $object->getLocale()) {
$object->setLocale($this->getTranslatableLocale());
if (!$this->getTranslatableChecker()->isTranslatable($object)) {
return;
}

$object->setLocale($this->getTranslatableLocale());
}

public function alterObject(AdminInterface $admin, object $object): void
Expand Down
2 changes: 0 additions & 2 deletions src/Model/TranslatableInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,4 @@
interface TranslatableInterface
{
public function setLocale(string $locale): void;

public function getLocale(): ?string;
}
7 changes: 2 additions & 5 deletions tests/App/Entity/GedmoCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class GedmoCategory implements TranslatableInterface
*
* @var string|null
*/
private $locale;
private $locale = null;

public function __construct(string $id = '', string $name = '')
{
Expand Down Expand Up @@ -75,10 +75,7 @@ public function setName(string $name): void
$this->name = $name;
}

/**
* @param string $locale
*/
public function setLocale($locale): void
public function setLocale(string $locale): void
{
$this->locale = $locale;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Fixtures/Model/ModelTranslatable.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ModelTranslatable implements TranslatableInterface
*
* @var string|null
*/
private $locale;
private $locale = null;

public function setLocale(string $locale): void
{
Expand Down

0 comments on commit de5ec62

Please sign in to comment.