Refactor
This commit is contained in:
parent
14cd79a960
commit
0871649c05
3 changed files with 4 additions and 2 deletions
|
@ -12,7 +12,7 @@ use Drupal\opd_presentations\Entity\Presentation;
|
||||||
*/
|
*/
|
||||||
function opd_presentations_entity_bundle_info_alter(array &$bundles): void {
|
function opd_presentations_entity_bundle_info_alter(array &$bundles): void {
|
||||||
if (isset($bundles['node'])) {
|
if (isset($bundles['node'])) {
|
||||||
$bundles['node']['presentation']['class'] = Presentation::class;
|
$bundles['node'][Presentation::NODE_TYPE]['class'] = Presentation::class;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($bundles['paragraph'])) {
|
if (isset($bundles['paragraph'])) {
|
||||||
|
|
|
@ -12,6 +12,8 @@ use Drupal\opd_presentations\Entity\Event;
|
||||||
|
|
||||||
final class Presentation extends Node implements NodeInterface {
|
final class Presentation extends Node implements NodeInterface {
|
||||||
|
|
||||||
|
public const NODE_TYPE = 'presentation';
|
||||||
|
|
||||||
public function getPastEvents(): EventCollection {
|
public function getPastEvents(): EventCollection {
|
||||||
$events = $this->get('field_events')->referencedEntities();
|
$events = $this->get('field_events')->referencedEntities();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ trait PresentationCreationTrait {
|
||||||
private function createPresentation(array $events): Presentation {
|
private function createPresentation(array $events): Presentation {
|
||||||
$presentation = $this->createNode([
|
$presentation = $this->createNode([
|
||||||
'field_events' => $events,
|
'field_events' => $events,
|
||||||
'type' => 'presentation',
|
'type' => Presentation::NODE_TYPE,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert($presentation instanceof Presentation);
|
assert($presentation instanceof Presentation);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue