Refactor
This commit is contained in:
parent
3c4b053e0e
commit
4715d02ae0
2 changed files with 11 additions and 12 deletions
|
@ -4,6 +4,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace Drupal\Tests\opd_presentations\Traits;
|
||||
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Tests\node\Traits\NodeCreationTrait;
|
||||
use Drupal\opd_presentations\Entity\Presentation;
|
||||
use Drupal\paragraphs\Entity\Paragraph;
|
||||
|
@ -27,14 +28,13 @@ trait PresentationCreationTrait {
|
|||
return $presentation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<non-empty-string, mixed> $values
|
||||
*/
|
||||
private function createEvent(array $values = []): ParagraphInterface {
|
||||
return Paragraph::create(array_merge(
|
||||
['type' => 'event'],
|
||||
$values,
|
||||
));
|
||||
private function createEvent(string $eventDate): ParagraphInterface {
|
||||
return Paragraph::create(
|
||||
[
|
||||
'field_date' => (new DrupalDateTime($eventDate))->getTimestamp(),
|
||||
'type' => 'event',
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue