diff --git a/src/Entity/Course.php b/src/Entity/Course.php index fbeae68468cd033a37f6bc61834b2172d2209bb5..3daaa07071420b376ec28335b01f0a0ccfd70b2c 100644 --- a/src/Entity/Course.php +++ b/src/Entity/Course.php @@ -4,7 +4,6 @@ declare(strict_types=1); namespace Dbp\Relay\CourseBundle\Entity; -use ApiPlatform\Core\Annotation\ApiProperty; use ApiPlatform\Core\Annotation\ApiResource; use Dbp\Relay\CourseBundle\Controller\GetCoursesByOrganization; use Symfony\Component\Serializer\Annotation\Groups; @@ -47,77 +46,9 @@ use Symfony\Component\Serializer\Annotation\Groups; * }, * iri="https://schema.org/Course", * normalizationContext={"groups" = {"Course:output"}, "jsonld_embed_context" = true}, - * denormalizationContext={"groups" = {"Course:input"}, "jsonld_embed_context" = true} * ) */ -class Course +class Course implements CourseInterface { - /** - * @ApiProperty(identifier=true) - */ - private $identifier; - - /** - * @ApiProperty(iri="https://schema.org/name") - * @Groups({"Course:output"}) - * - * @var string - */ - private $name; - - /** - * @ApiProperty - * @Groups({"Course:output"}) - * - * @var string - */ - private $type; - - /** - * @ApiProperty(iri="https://schema.org/description") - * @Groups({"Course:output"}) - * - * @var string - */ - private $description; - - public function getIdentifier(): string - { - return $this->identifier; - } - - public function setIdentifier(string $identifier): void - { - $this->identifier = $identifier; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): void - { - $this->name = $name; - } - - public function getType(): string - { - return $this->type; - } - - public function setType(string $type): void - { - $this->type = $type; - } - - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): void - { - $this->description = $description; - } + use CourseTrait; } diff --git a/src/Entity/CourseInterface.php b/src/Entity/CourseInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..e080e211818abcd77fba0ad0b42e85865fc3bba0 --- /dev/null +++ b/src/Entity/CourseInterface.php @@ -0,0 +1,24 @@ +<?php + +declare(strict_types=1); + +namespace Dbp\Relay\CourseBundle\Entity; + +interface CourseInterface +{ + public function getIdentifier(): string; + + public function setIdentifier(string $identifier): void; + + public function getName(): string; + + public function setName(string $name): void; + + public function getType(): string; + + public function setType(string $type): void; + + public function getDescription(): string; + + public function setDescription(string $description): void; +} diff --git a/src/Entity/CourseTrait.php b/src/Entity/CourseTrait.php new file mode 100644 index 0000000000000000000000000000000000000000..fee2a484b41ef8442dff934c6606840a446c3e88 --- /dev/null +++ b/src/Entity/CourseTrait.php @@ -0,0 +1,80 @@ +<?php + +declare(strict_types=1); + +namespace Dbp\Relay\CourseBundle\Entity; + +use ApiPlatform\Core\Annotation\ApiProperty; +use Symfony\Component\Serializer\Annotation\Groups; + +trait CourseTrait +{ + /** + * @ApiProperty(identifier=true) + */ + private $identifier; + + /** + * @ApiProperty(iri="https://schema.org/name") + * @Groups({"Course:output"}) + * + * @var string + */ + private $name; + + /** + * @ApiProperty + * @Groups({"Course:output"}) + * + * @var string + */ + private $type; + + /** + * @ApiProperty(iri="https://schema.org/description") + * @Groups({"Course:output"}) + * + * @var string + */ + private $description; + + public function getIdentifier(): string + { + return $this->identifier; + } + + public function setIdentifier(string $identifier): void + { + $this->identifier = $identifier; + } + + public function getName(): string + { + return $this->name; + } + + public function setName(string $name): void + { + $this->name = $name; + } + + public function getType(): string + { + return $this->type; + } + + public function setType(string $type): void + { + $this->type = $type; + } + + public function getDescription(): string + { + return $this->description; + } + + public function setDescription(string $description): void + { + $this->description = $description; + } +}