mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-26 16:45:01 +00:00
refactor: improve property checks
- use ClassUtils for real class name resolution in ActivityType
This commit is contained in:
@@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\ActivityBundle\Entity;
|
namespace Chill\ActivityBundle\Entity;
|
||||||
|
|
||||||
|
use Doctrine\Common\Util\ClassUtils;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
@@ -461,11 +462,13 @@ class ActivityType
|
|||||||
{
|
{
|
||||||
$property = $field.'Visible';
|
$property = $field.'Visible';
|
||||||
|
|
||||||
if (!property_exists($this, $property)) {
|
// Get the real class name (not the proxy)
|
||||||
|
$realClass = ClassUtils::getClass($this);
|
||||||
|
|
||||||
|
if (!property_exists($realClass, $property)) {
|
||||||
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
throw new \InvalidArgumentException('Field "'.$field.'" not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* @phpstan-ignore-next-line */
|
|
||||||
return self::FIELD_INVISIBLE !== $this->{$property};
|
return self::FIELD_INVISIBLE !== $this->{$property};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,10 +42,8 @@ class TranslatableStringTwig extends AbstractExtension
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the extension.
|
* Returns the name of the extension.
|
||||||
*
|
|
||||||
* @return The name of the extension
|
|
||||||
*/
|
*/
|
||||||
public function getName()
|
public function getName(): string
|
||||||
{
|
{
|
||||||
return 'chill_main_localize';
|
return 'chill_main_localize';
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user