summaryrefslogtreecommitdiff
path: root/src/Model/Card.php
diff options
context:
space:
mode:
authorJonathan Tschanter <jmtw@tutanota.de>2022-01-22 21:24:24 +0100
committerJonathan Tschanter <jmtw@tutanota.de>2022-01-22 21:24:24 +0100
commit10c86197f1f63e222dfc9e937911e35ab500a208 (patch)
tree388ca37920808a66697385c6d69cf6a76e5aaf7b /src/Model/Card.php
parent432bba3dee1d9be25b9626ac45115929a6422961 (diff)
Adds edit cards and templates to include
Diffstat (limited to 'src/Model/Card.php')
-rw-r--r--src/Model/Card.php33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/Model/Card.php b/src/Model/Card.php
index 59d2639..934fc2d 100644
--- a/src/Model/Card.php
+++ b/src/Model/Card.php
@@ -99,28 +99,35 @@ class Card
*
* @return string
*/
- public function getMeta(string $key): ?string
+ public function getMetaValue(string $key): ?string
+ {
+ return $this->getMeta($key)->value ?? null;
+ }
+
+ /**
+ * @param string $key
+ *
+ * @return CardMeta
+ */
+ public function getMeta(string $key): ?CardMeta
{
// if meta is already hydrated
if ($this->meta->isInitialized()) {
$meta = $this->meta->unwrap()
#->findFirst(fn (CardMeta $item) => $item->key === $key);
->filter(fn ($item) => $item->key === $key)->first();
- return $meta->value ?? null;
+ return $meta ?? null;
}
// get directly from db otherwise
$result = DB::$entityManager
- ->createQuery(
- 'SELECT cm.value
- FROM Elements\Model\CardMeta cm
- WHERE cm.key = :key AND cm.card = :card'
- )
- ->setParameter('key', $key)
- ->setParameter('card', $this)
- ->getOneOrNullResult();
+ ->getRepository(CardMeta::class)
+ ->findOneBy([
+ 'key' => $key,
+ 'card' => $this
+ ]);
- return $result['value'] ?? null;
+ return $result ?? null;
}
/**
@@ -128,7 +135,7 @@ class Card
*/
public function getAllMeta()
{
- // TODO: do we need this?
+ // TODO: change!
// if meta is already hydrated
if ($this->meta->isInitialized()) {
return $this->meta;
@@ -152,7 +159,7 @@ class Card
*/
public function getAllArtworks()
{
- // TODO: do we need this?
+ // TODO: change!
// if artworks are already hydrated
if ($this->artworks->isInitialized()) {
return $this->artworks;