Skip to content
This repository has been archived by the owner on Apr 30, 2024. It is now read-only.

Commit

Permalink
Merge pull request #23 from 21TORR/next
Browse files Browse the repository at this point in the history
Add support to load unpublished documents
  • Loading branch information
apfelbox authored Dec 14, 2021
2 parents 8292e87 + 6e88ed0 commit 6d6501b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 17 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
4.0.0-beta.7
============

* (improvement) Add support to load unpublished documents.


4.0.0-beta.6
============

Expand Down
20 changes: 10 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "21torr/prismic-api",
"type": "symfony-bundle",
"description": "Symfony API bundle for integration into Prismic.",
"homepage": "https://github.com/21TORR/prismic-api",
"license": "MIT",
"type": "symfony-bundle",
"authors": [
{
"name": "21TORR",
"homepage": "https://www.21torr.com/"
}
],
"homepage": "https://github.com/21TORR/prismic-api",
"require": {
"php": "^8.0",
"21torr/bundle-helpers": "^2.1",
Expand All @@ -27,14 +27,6 @@
"roave/security-advisories": "dev-latest",
"symfony/phpunit-bridge": "^5.3"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-next": "4.x-dev"
}
},
"autoload": {
"psr-4": {
"Torr\\PrismicApi\\": "src/"
Expand All @@ -45,6 +37,14 @@
"Tests\\Torr\\PrismicApi\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-next": "4.x-dev"
}
},
"scripts": {
"post-install-cmd": [
"@composer bin all install --ansi"
Expand Down
17 changes: 10 additions & 7 deletions src/Data/DocumentAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

final class DocumentAttributes
{
private \DateTimeImmutable $firstPublicationDate;
private \DateTimeImmutable $lastPublicationDate;
private ?\DateTimeImmutable $firstPublicationDate;
private ?\DateTimeImmutable $lastPublicationDate;

/**
*/
Expand Down Expand Up @@ -71,14 +71,14 @@ public function getTags () : array

/**
*/
public function getFirstPublicationDate () : \DateTimeImmutable
public function getFirstPublicationDate () : ?\DateTimeImmutable
{
return $this->firstPublicationDate;
}

/**
*/
public function getLastPublicationDate () : \DateTimeImmutable
public function getLastPublicationDate () : ?\DateTimeImmutable
{
return $this->lastPublicationDate;
}
Expand Down Expand Up @@ -114,12 +114,10 @@ public static function getValidationConstraints () : array
]),
],
"first_publication_date" => [
new Assert\NotNull(),
new Assert\Type("string"),
new Assert\DateTime(\DateTimeInterface::RFC3339),
],
"last_publication_date" => [
new Assert\NotNull(),
new Assert\Type("string"),
new Assert\DateTime(\DateTimeInterface::RFC3339),
],
Expand All @@ -138,8 +136,13 @@ public static function getValidationConstraints () : array
/**
* Parses the given date
*/
private function parseDate (string $date) : \DateTimeImmutable
private function parseDate (?string $date) : ?\DateTimeImmutable
{
if (null === $date)
{
return null;
}

$parsed = \DateTimeImmutable::createFromFormat(\DateTimeInterface::RFC3339, $date);
\assert($parsed instanceof \DateTimeImmutable);
return $parsed;
Expand Down

0 comments on commit 6d6501b

Please sign in to comment.