final class PublishableLoader implements LoaderInterface
28
{
29
private Reader $reader;
30
31
public function __construct(Reader $reader)
32
{
33
$this->reader = $reader;
34
}
35
36
/**
37
* {@inheritdoc}
38
*/
39
public function loadClassMetadata(ClassMetadataInterface $classMetadata)
40
{
41
/** @var Publishable $annotation */
42
if (!$annotation = $this->reader->getClassAnnotation($classMetadata->getReflectionClass(), Publishable::class)) {
43
return true;
44
}
45
46
if (!$attributeMetadata = ($classMetadata->getAttributesMetadata()[$annotation->fieldName] ?? null)) {
47
throw new MappingException(sprintf('Groups on "%s::%s" cannot be added because the field does not exist.', $classMetadata->getName(), $annotation->fieldName));