diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php
index 981bf64..fd23457 100644
--- a/vendor/composer/autoload_classmap.php
+++ b/vendor/composer/autoload_classmap.php
@@ -107,6 +107,7 @@
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\FacultyRepository' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/FacultyRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\IdGenerator' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/IdGenerator.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\StickyDegreeProgramRepository' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/StickyDegreeProgramRepository.php',
+ 'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\TimestampRepository' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/TimestampRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\WordPressDatabaseDegreeProgramCollectionRepository' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramCollectionRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\WordPressDatabaseDegreeProgramRepository' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\WordPressDatabaseDegreeProgramViewRepository' => $vendorDir . '/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramViewRepository.php',
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index 6922f9c..7a7024e 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -187,6 +187,7 @@ class ComposerStaticInitcaf37a9a7e03b5b4a8fa1ed8a636e1ce
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\FacultyRepository' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/FacultyRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\IdGenerator' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/IdGenerator.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\StickyDegreeProgramRepository' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/StickyDegreeProgramRepository.php',
+ 'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\TimestampRepository' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/TimestampRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\WordPressDatabaseDegreeProgramCollectionRepository' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramCollectionRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\WordPressDatabaseDegreeProgramRepository' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramRepository.php',
'Fau\\DegreeProgram\\Common\\Infrastructure\\Repository\\WordPressDatabaseDegreeProgramViewRepository' => __DIR__ . '/..' . '/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramViewRepository.php',
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index d205e73..f679936 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -427,12 +427,12 @@
"source": {
"type": "git",
"url": "https://github.com/RRZE-Webteam/FAU-Studium-Common.git",
- "reference": "d8cb53c2cf24a6f28b07109cec9bb67c1d51d743"
+ "reference": "2314da111571d795a3f3d3dbe194680737a26e07"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/RRZE-Webteam/FAU-Studium-Common/zipball/d8cb53c2cf24a6f28b07109cec9bb67c1d51d743",
- "reference": "d8cb53c2cf24a6f28b07109cec9bb67c1d51d743",
+ "url": "https://api.github.com/repos/RRZE-Webteam/FAU-Studium-Common/zipball/2314da111571d795a3f3d3dbe194680737a26e07",
+ "reference": "2314da111571d795a3f3d3dbe194680737a26e07",
"shasum": ""
},
"require": {
@@ -454,7 +454,8 @@
"suggest": {
"inpsyde/modularity": "Modular PSR-11 implementation for WordPress Plugins, Themes or Libraries"
},
- "time": "2024-07-23T13:46:52+00:00",
+ "time": "2024-09-04T13:20:56+00:00",
+ "default-branch": true,
"type": "library",
"installation-source": "dist",
"autoload": {
diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php
index 5f24213..0022506 100644
--- a/vendor/composer/installed.php
+++ b/vendor/composer/installed.php
@@ -3,7 +3,7 @@
'name' => 'rrze/fau-studium-embed',
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '98ddde8cbf05002397083867addb16b6f27aeec8',
+ 'reference' => '4c080352a968dd3739c0809a1fe10fcf177f3f32',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@@ -76,16 +76,18 @@
'rrze/fau-studium-common' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => 'd8cb53c2cf24a6f28b07109cec9bb67c1d51d743',
+ 'reference' => '2314da111571d795a3f3d3dbe194680737a26e07',
'type' => 'library',
'install_path' => __DIR__ . '/../rrze/fau-studium-common',
- 'aliases' => array(),
+ 'aliases' => array(
+ 0 => '9999999-dev',
+ ),
'dev_requirement' => false,
),
'rrze/fau-studium-embed' => array(
'pretty_version' => 'dev-main',
'version' => 'dev-main',
- 'reference' => '98ddde8cbf05002397083867addb16b6f27aeec8',
+ 'reference' => '4c080352a968dd3739c0809a1fe10fcf177f3f32',
'type' => 'wordpress-plugin',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
diff --git a/vendor/rrze/fau-studium-common/.github/workflows/build.yml b/vendor/rrze/fau-studium-common/.github/workflows/build.yml
deleted file mode 100644
index 3420996..0000000
--- a/vendor/rrze/fau-studium-common/.github/workflows/build.yml
+++ /dev/null
@@ -1,57 +0,0 @@
-name: Build package
-
-on:
- workflow_call:
- secrets:
- DEPLOYBOT_EMAIL:
- required: true
- DEPLOYBOT_USER:
- required: true
-
-jobs:
- build-package:
- runs-on: ubuntu-latest
- env:
- CHANGES: 'yes'
-
- steps:
- - name: Checkout
- uses: actions/checkout@v3
- with:
- fetch-depth: 0
- ref: main
-
- - name: Install Composer dependencies
- uses: ramsey/composer-install@v2
- with:
- composer-options: "--no-dev"
-
- - name: Build assets
- run: |
- yarn install --frozen-lockfile
- yarn build
-
- - name: Setup Git
- run: |
- git config --global user.email "${{ secrets.DEPLOYBOT_EMAIL }}"
- git config --global user.name "${{ secrets.DEPLOYBOT_USER }}"
- git config --global advice.addIgnoredFile false
- git config --global push.autoSetupRemote true
-
- - name: Git add, commit
- run: |
- git add -f assets/ vendor/
- git commit -m "[BOT] Build package" --no-verify || ((echo "CHANGES=no" >> $GITHUB_ENV) && (echo "No changes to commit"))
-
- - name: Git push to "main" branch
- if: ${{ env.CHANGES == 'yes' }}
- run: git push
-
- - name: Move tag
- if: ${{ github.ref_type == 'tag'}}
- run: |
- git tag -d ${{ github.ref_name }}
- git push origin :refs/tags/${{ github.ref_name }}
- git tag ${{ github.ref_name }}
- git push origin --tags
-
diff --git a/vendor/rrze/fau-studium-common/psalm-baseline.xml b/vendor/rrze/fau-studium-common/psalm-baseline.xml
index 7f8c7f4..24e38e5 100644
--- a/vendor/rrze/fau-studium-common/psalm-baseline.xml
+++ b/vendor/rrze/fau-studium-common/psalm-baseline.xml
@@ -11,11 +11,6 @@
-
-
-
-
-
diff --git a/vendor/rrze/fau-studium-common/src/Application/Cache/CacheInvalidator.php b/vendor/rrze/fau-studium-common/src/Application/Cache/CacheInvalidator.php
index 5528a98..601ff5b 100644
--- a/vendor/rrze/fau-studium-common/src/Application/Cache/CacheInvalidator.php
+++ b/vendor/rrze/fau-studium-common/src/Application/Cache/CacheInvalidator.php
@@ -11,6 +11,9 @@
use Psr\SimpleCache\CacheInterface;
use Psr\SimpleCache\InvalidArgumentException;
+/**
+ * @psalm-import-type Reason from CacheInvalidated
+ */
final class CacheInvalidator
{
public function __construct(
@@ -21,7 +24,10 @@ public function __construct(
) {
}
- public function invalidateFully(): bool
+ /**
+ * @psalm-param Reason $reason
+ */
+ public function invalidateFully(string $reason = CacheInvalidated::ENFORCED): bool
{
$result = $this->cache->clear();
if (!$result) {
@@ -30,16 +36,17 @@ public function invalidateFully(): bool
}
$this->logger->info('Successful degree program full cache invalidation.');
- $this->eventDispatcher->dispatch(CacheInvalidated::fully());
+ $this->eventDispatcher->dispatch(CacheInvalidated::fully($reason));
return true;
}
/**
* @psalm-param array $ids
+ * @psalm-param Reason $reason
*
* @throws InvalidArgumentException
*/
- public function invalidatePartially(array $ids): bool
+ public function invalidatePartially(array $ids, string $reason = CacheInvalidated::ENFORCED): bool
{
if (count($ids) === 0) {
$this->logger->debug(
@@ -81,7 +88,7 @@ public function invalidatePartially(array $ids): bool
implode(', ', $ids)
)
);
- $this->eventDispatcher->dispatch(CacheInvalidated::partially($ids));
+ $this->eventDispatcher->dispatch(CacheInvalidated::partially($ids, $reason));
return true;
}
diff --git a/vendor/rrze/fau-studium-common/src/Application/DegreeProgramViewTranslated.php b/vendor/rrze/fau-studium-common/src/Application/DegreeProgramViewTranslated.php
index e1d50cd..5137e17 100644
--- a/vendor/rrze/fau-studium-common/src/Application/DegreeProgramViewTranslated.php
+++ b/vendor/rrze/fau-studium-common/src/Application/DegreeProgramViewTranslated.php
@@ -79,11 +79,15 @@
* }
* @psalm-type DegreeProgramViewTranslatedArrayType = DegreeProgramTranslation & array{
* id: int,
+ * date: string,
+ * modified: string,
* translations: array,
* }
*/
final class DegreeProgramViewTranslated implements JsonSerializable
{
+ public const DATE = 'date';
+ public const MODIFIED = 'modified';
public const LINK = 'link';
public const LANG = 'lang';
public const ADMISSION_REQUIREMENT_LINK = 'admission_requirement_link';
@@ -94,6 +98,8 @@ final class DegreeProgramViewTranslated implements JsonSerializable
public function __construct(
private DegreeProgramId $id,
+ private string $date,
+ private string $modified,
private string $link,
private string $slug,
/**
@@ -160,6 +166,8 @@ public static function empty(int $id, string $languageCode): self
{
return new self(
DegreeProgramId::fromInt($id),
+ date: '',
+ modified: '',
link: '',
slug: '',
lang: $languageCode,
@@ -220,6 +228,8 @@ public static function empty(int $id, string $languageCode): self
/**
* @psalm-param DegreeProgramTranslation & array{
* id: int | numeric-string,
+ * date: string,
+ * modified: string,
* translations?: array,
* } $data
*
@@ -229,6 +239,8 @@ public static function fromArray(array $data): self
{
$main = new self(
id: DegreeProgramId::fromInt((int) $data[DegreeProgram::ID]),
+ date: $data[self::DATE] ?? '',
+ modified: $data[self::MODIFIED] ?? '',
link: $data[self::LINK],
slug: $data[DegreeProgram::SLUG],
lang: $data[self::LANG],
@@ -285,12 +297,14 @@ public static function fromArray(array $data): self
campoKeys: CampoKeys::fromArray($data[DegreeProgram::CAMPO_KEYS] ?? []),
);
- if (empty($data[self::TRANSLATIONS])) {
+ if (!isset($data[self::TRANSLATIONS]) || count($data[self::TRANSLATIONS]) === 0) {
return $main;
}
foreach ($data[self::TRANSLATIONS] as $translationData) {
$translationData[DegreeProgram::ID] = $data[DegreeProgram::ID];
+ $translationData[self::DATE] = $data[self::DATE];
+ $translationData[self::MODIFIED] = $data[self::MODIFIED];
$main = $main->withTranslation(self::fromArray($translationData), $translationData[self::LANG]);
}
@@ -304,6 +318,8 @@ public function asArray(): array
{
return [
DegreeProgram::ID => $this->id->asInt(),
+ self::DATE => $this->date,
+ self::MODIFIED => $this->modified,
self::LINK => $this->link,
DegreeProgram::SLUG => $this->slug,
self::LANG => $this->lang,
@@ -361,6 +377,18 @@ public function asArray(): array
];
}
+ public function asSimplifiedArray(): array
+ {
+ return [
+ DegreeProgram::ID => $this->id->asInt(),
+ DegreeProgram::SLUG => $this->slug,
+ self::LINK => $this->link,
+ DegreeProgram::CAMPO_KEYS => $this->campoKeys->asArray(),
+ self::DATE => $this->date,
+ self::MODIFIED => $this->modified,
+ ];
+ }
+
public function jsonSerialize(): array
{
return $this->asArray();
@@ -408,7 +436,12 @@ private function translationsAsArray(): array
{
return array_map(static function (DegreeProgramViewTranslated $view): array {
$result = $view->asArray();
- unset($result[DegreeProgram::ID], $result[self::TRANSLATIONS]);
+ unset(
+ $result[DegreeProgram::ID],
+ $result[self::DATE],
+ $result[self::MODIFIED],
+ $result[self::TRANSLATIONS]
+ );
return $result;
}, $this->translations);
@@ -419,6 +452,16 @@ public function id(): int
return $this->id->asInt();
}
+ public function date(): string
+ {
+ return $this->date;
+ }
+
+ public function modified(): string
+ {
+ return $this->modified;
+ }
+
public function link(): string
{
return $this->link;
diff --git a/vendor/rrze/fau-studium-common/src/Application/Event/CacheInvalidated.php b/vendor/rrze/fau-studium-common/src/Application/Event/CacheInvalidated.php
index c94b7da..a333745 100644
--- a/vendor/rrze/fau-studium-common/src/Application/Event/CacheInvalidated.php
+++ b/vendor/rrze/fau-studium-common/src/Application/Event/CacheInvalidated.php
@@ -6,30 +6,41 @@
use Stringable;
+/**
+ * @psalm-type Reason = self::ENFORCED | self::DATA_CHANGED
+ */
final class CacheInvalidated implements Stringable
{
public const NAME = 'degree_program_cache_invalidated';
+ public const ENFORCED = 'enforced';
+ public const DATA_CHANGED = 'data_changed';
/**
* @param array $ids
+ * @param Reason $reason
*/
private function __construct(
private bool $isFully,
private array $ids,
+ private string $reason,
) {
}
- public static function fully(): self
+ /**
+ * @param Reason $reason
+ */
+ public static function fully(string $reason): self
{
- return new self(true, []);
+ return new self(true, [], $reason);
}
/**
* @param array $ids
+ * @param Reason $reason
*/
- public static function partially(array $ids): self
+ public static function partially(array $ids, string $reason): self
{
- return new self(false, $ids);
+ return new self(false, $ids, $reason);
}
public function isFully(): bool
@@ -45,6 +56,14 @@ public function ids(): array
return $this->ids;
}
+ /**
+ * @return Reason
+ */
+ public function reason(): string
+ {
+ return $this->reason;
+ }
+
public function __toString(): string
{
return self::NAME;
diff --git a/vendor/rrze/fau-studium-common/src/Domain/CampoKeys.php b/vendor/rrze/fau-studium-common/src/Domain/CampoKeys.php
index 7788684..48128bd 100644
--- a/vendor/rrze/fau-studium-common/src/Domain/CampoKeys.php
+++ b/vendor/rrze/fau-studium-common/src/Domain/CampoKeys.php
@@ -5,7 +5,7 @@
namespace Fau\DegreeProgram\Common\Domain;
/**
- * @psalm-type CampoKeysMap = array, string>
+ * @psalm-type CampoKeysMap = array, array>
*/
final class CampoKeys
{
@@ -13,13 +13,13 @@ final class CampoKeys
'type' => 'object',
'properties' => [
DegreeProgram::DEGREE => [
- 'type' => 'string',
+ 'type' => 'array',
],
DegreeProgram::AREA_OF_STUDY => [
- 'type' => 'string',
+ 'type' => 'array',
],
DegreeProgram::LOCATION => [
- 'type' => 'string',
+ 'type' => 'array',
],
],
];
@@ -28,13 +28,13 @@ final class CampoKeys
'type' => 'object',
'properties' => [
DegreeProgram::DEGREE => [
- 'type' => 'string',
+ 'type' => 'array',
],
DegreeProgram::AREA_OF_STUDY => [
- 'type' => 'string',
+ 'type' => 'array',
],
DegreeProgram::LOCATION => [
- 'type' => 'string',
+ 'type' => 'array',
],
],
];
@@ -45,8 +45,6 @@ final class CampoKeys
DegreeProgram::LOCATION,
];
- private const HIS_CODE_DELIMITER = '|';
-
private function __construct(
/**
* @var CampoKeysMap $map
@@ -68,18 +66,6 @@ public static function fromArray(array $map): self
return new self($map);
}
- public static function fromHisCode(string $hisCode): self
- {
- $parts = explode(self::HIS_CODE_DELIMITER, $hisCode);
- $map = [
- DegreeProgram::DEGREE => $parts[0] ?? null,
- DegreeProgram::AREA_OF_STUDY => $parts[1] ?? null,
- DegreeProgram::LOCATION => $parts[6] ?? null,
- ];
-
- return new self(array_filter($map, fn($value) => !is_null($value)));
- }
-
/**
* @return CampoKeysMap
*/
diff --git a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/CampoKeysRepository.php b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/CampoKeysRepository.php
index 3031a45..3cd6f3e 100644
--- a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/CampoKeysRepository.php
+++ b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/CampoKeysRepository.php
@@ -24,6 +24,8 @@ final class CampoKeysRepository
public const CAMPO_KEY_TERM_META_KEY = 'uniquename';
+ private const HIS_CODE_DELIMITER = '|';
+
public function degreeProgramCampoKeys(DegreeProgramId $degreeProgramId): CampoKeys
{
/** @var WP_Error|array $terms */
@@ -51,7 +53,7 @@ public function degreeProgramCampoKeys(DegreeProgramId $degreeProgramId): CampoK
continue;
}
- $map[$campoKeyType] = $campoKey;
+ $map[$campoKeyType][$term->term_id] = $campoKey;
}
return CampoKeys::fromArray($map);
@@ -60,29 +62,23 @@ public function degreeProgramCampoKeys(DegreeProgramId $degreeProgramId): CampoK
/**
* Return a map of taxonomy keys to terms based on a given HIS code.
*
- * @throws RuntimeException
* @return array
*/
- public function taxonomyToTermsMapFromCampoKeys(CampoKeys $campoKeys): array
+ public function taxonomyToTermsMapFromHisCode(string $hisCode): array
{
$result = [];
- $campoKeys = $campoKeys->asArray();
+ $campoKeys = $this->campoKeysFromHisCode($hisCode);
foreach (self::TAXONOMY_TO_CAMPO_KEY_MAP as $taxonomy => $campoKeyType) {
- $campoKey = $campoKeys[$campoKeyType] ?? '';
+ $campoKey = $campoKeys[$campoKeyType] ?? null;
- if ($campoKey === '') {
+ if (!is_string($campoKey) || $campoKey === '') {
continue;
}
$term = $this->findTermByCampoKey($taxonomy, $campoKey);
-
- if (! $term instanceof WP_Term) {
- throw new RuntimeException('Could not find term for Campo key: ' . $campoKey);
- }
-
- $result[$taxonomy] = $term->term_id;
+ $result[$taxonomy] = $term instanceof WP_Term ? $term->term_id : 0;
}
return $result;
@@ -107,4 +103,16 @@ private function findTermByCampoKey(string $taxonomy, string $campoKey): ?WP_Ter
return $terms[0] ?? null;
}
+
+ public function campoKeysFromHisCode(string $hisCode): array
+ {
+ $parts = explode(self::HIS_CODE_DELIMITER, $hisCode);
+ $map = [
+ DegreeProgram::DEGREE => $parts[0] ?? null,
+ DegreeProgram::AREA_OF_STUDY => $parts[1] ?? null,
+ DegreeProgram::LOCATION => $parts[6] ?? null,
+ ];
+
+ return array_filter($map, fn($value) => !is_null($value));
+ }
}
diff --git a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/TimestampRepository.php b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/TimestampRepository.php
new file mode 100644
index 0000000..7affc30
--- /dev/null
+++ b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/TimestampRepository.php
@@ -0,0 +1,49 @@
+asInt());
+
+ return $postDateTime instanceof DateTimeInterface ? $postDateTime : null;
+ }
+
+ /**
+ * The custom field is updated when the degree program or related settings or terms are updated.
+ * If the custom field does not exist,
+ * we fall back to the core WordPress "post modified" property.
+ */
+ public function modified(DegreeProgramId $id): ?DateTimeInterface
+ {
+ $timestamp = (int) get_post_meta($id->asInt(), self::MODIFIED_META_KEY, true);
+
+ if ($timestamp < 1) {
+ $timestamp = get_post_timestamp($id->asInt(), 'modified');
+ }
+
+ if (!is_int($timestamp)) {
+ return null;
+ }
+
+ $dateTime = new DateTimeImmutable();
+ $dateTime = $dateTime->setTimestamp($timestamp);
+
+ return $dateTime->setTimezone(wp_timezone());
+ }
+
+ public function updateModified(DegreeProgramId $id): void
+ {
+ update_post_meta($id->asInt(), self::MODIFIED_META_KEY, time());
+ }
+}
diff --git a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramViewRepository.php b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramViewRepository.php
index 7d32c54..efdb713 100644
--- a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramViewRepository.php
+++ b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WordPressDatabaseDegreeProgramViewRepository.php
@@ -4,6 +4,7 @@
namespace Fau\DegreeProgram\Common\Infrastructure\Repository;
+use DateTimeInterface;
use Fau\DegreeProgram\Common\Application\AdmissionRequirementsTranslated;
use Fau\DegreeProgram\Common\Application\AdmissionRequirementTranslated;
use Fau\DegreeProgram\Common\Application\ConditionalFieldsFilter;
@@ -33,11 +34,14 @@
*/
final class WordPressDatabaseDegreeProgramViewRepository implements DegreeProgramViewRepository
{
+ private const DATE_TIME_FORMAT = DateTimeInterface::RFC3339;
+
public function __construct(
private DegreeProgramRepository $degreeProgramRepository,
private HtmlDegreeProgramSanitizer $htmlContentSanitizer,
private ConditionalFieldsFilter $conditionalFieldsFilter,
private FacultyRepository $facultyRepository,
+ private TimestampRepository $timestampRepository,
) {
}
@@ -100,6 +104,8 @@ private function translateDegreeProgram(
return new DegreeProgramViewTranslated(
id: $raw->id(),
+ date: (string) $this->timestampRepository->created($raw->id())?->format(self::DATE_TIME_FORMAT),
+ modified: (string) $this->timestampRepository->modified($raw->id())?->format(self::DATE_TIME_FORMAT),
link: $this->link(
$raw->id()->asInt(),
$raw->slug(),
diff --git a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WpQueryArgsBuilder.php b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WpQueryArgsBuilder.php
index 4fe1d87..8f3f41d 100644
--- a/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WpQueryArgsBuilder.php
+++ b/vendor/rrze/fau-studium-common/src/Infrastructure/Repository/WpQueryArgsBuilder.php
@@ -107,13 +107,7 @@ public function applyHisCodes(array $hisCodes, WpQueryArgs $queryArgs): WpQueryA
'relation' => 'AND',
];
- try {
- $taxonomyToTermMapping = $this->campoKeysRepository->taxonomyToTermsMapFromCampoKeys(
- CampoKeys::fromHisCode($hisCode)
- );
- } catch (RuntimeException) {
- continue;
- }
+ $taxonomyToTermMapping = $this->campoKeysRepository->taxonomyToTermsMapFromHisCode($hisCode);
if (count($taxonomyToTermMapping) === 0) {
continue;
diff --git a/vendor/rrze/fau-studium-common/src/Infrastructure/RestApi/TranslatedDegreeProgramController.php b/vendor/rrze/fau-studium-common/src/Infrastructure/RestApi/TranslatedDegreeProgramController.php
index 5248144..333f593 100644
--- a/vendor/rrze/fau-studium-common/src/Infrastructure/RestApi/TranslatedDegreeProgramController.php
+++ b/vendor/rrze/fau-studium-common/src/Infrastructure/RestApi/TranslatedDegreeProgramController.php
@@ -70,6 +70,16 @@ public function register_routes(): void
'args' => $this->get_collection_params(),
],
]);
+ register_rest_route($this->namespace, '/' . $this->rest_base . '/index', [
+ [
+ 'methods' => WP_REST_Server::READABLE,
+ 'callback' => [$this, 'getIndex'],
+ 'permission_callback' => [$this, 'get_items_permissions_check'],
+ 'args' => [
+ 'lang' => self::languageParam(),
+ ],
+ ],
+ ]);
register_rest_route($this->namespace, '/' . $this->rest_base . '/(?P[\d]+)', [
[
'methods' => WP_REST_Server::READABLE,
@@ -176,6 +186,38 @@ public function get_items($request): WP_Error|WP_REST_Response
return $response;
}
+ public function getIndex(WP_REST_Request $request): WP_Error|WP_REST_Response
+ {
+ $criteria = CollectionCriteria::new()
+ ->withoutPagination();
+
+ $views = $this->degreeProgramCollectionRepository->findTranslatedCollection(
+ $criteria,
+ $this->requestedLanguage($request)
+ );
+
+ if (!$views instanceof PaginationAwareCollection) {
+ return new WP_Error(
+ 'unexpected_error',
+ _x(
+ 'Something went wrong. Please try again later.',
+ 'rest_api: response status',
+ 'fau-degree-program-common'
+ ),
+ ['status' => 500]
+ );
+ }
+
+ $data = [];
+ foreach ($views as $view) {
+ $data[] = $this->prepare_response_for_collection(
+ new WP_REST_Response($view->asSimplifiedArray())
+ );
+ }
+
+ return new WP_REST_Response($data);
+ }
+
/**
* @param WP_REST_Request $request Full data about the request.
*/
@@ -315,6 +357,24 @@ public function get_item_schema(): array
),
'type' => 'integer',
],
+ DegreeProgramViewTranslated::DATE => [
+ 'description' => _x(
+ 'The date the degree program was created.',
+ 'rest_api: schema item description',
+ 'fau-degree-program-common'
+ ),
+ 'type' => 'string',
+ 'format' => 'date-time',
+ ],
+ DegreeProgramViewTranslated::MODIFIED => [
+ 'description' => _x(
+ 'The date the degree program was last modified.',
+ 'rest_api: schema item description',
+ 'fau-degree-program-common'
+ ),
+ 'type' => 'string',
+ 'format' => 'date-time',
+ ],
DegreeProgram::FEATURED_IMAGE => [
'description' => _x(
'Feature image.',