diff options
author | Jonathan Tschanter <jmtw@tutanota.de> | 2022-01-21 00:14:34 +0100 |
---|---|---|
committer | Jonathan Tschanter <jmtw@tutanota.de> | 2022-01-21 00:14:34 +0100 |
commit | 2bde1b0660585e16116fbd12c86b53e886b6f3be (patch) | |
tree | 8c23fbad83e8b947c60a50b7af6be2c8b0d4867a /src/Model | |
parent | c2b0ebcdbb23a38a31b4d8c9e39f2a2be4cc862b (diff) |
Add first layout with simplecss
Diffstat (limited to 'src/Model')
-rw-r--r-- | src/Model/Card.php | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/src/Model/Card.php b/src/Model/Card.php index abaa06e..59d2639 100644 --- a/src/Model/Card.php +++ b/src/Model/Card.php @@ -104,24 +104,71 @@ class Card // 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(); - + #->findFirst(fn (CardMeta $item) => $item->key === $key); + ->filter(fn ($item) => $item->key === $key)->first(); return $meta->value ?? 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' + 'SELECT cm.value + FROM Elements\Model\CardMeta cm + WHERE cm.key = :key AND cm.card = :card' ) ->setParameter('key', $key) ->setParameter('card', $this) ->getOneOrNullResult(); - return $result['value'] ?? null; + return $result['value'] ?? null; + } + + /** + * @return CardMeta[] + */ + public function getAllMeta() + { + // TODO: do we need this? + // if meta is already hydrated + if ($this->meta->isInitialized()) { + return $this->meta; + } + + // get directly from db otherwise + $result = DB::$entityManager + ->createQuery( + 'SELECT cm + FROM Elements\Model\CardMeta cm + WHERE cm.card = :card' + ) + ->setParameter('card', $this) + ->getArrayResult(); + + return $result; + } + + /** + * @return Artwork[] + */ + public function getAllArtworks() + { + // TODO: do we need this? + // if artworks are already hydrated + if ($this->artworks->isInitialized()) { + return $this->artworks; + } + + // get directly from db otherwise + $result = DB::$entityManager + ->createQuery( + 'SELECT aw + FROM Elements\Model\Artwork aw + WHERE aw.card = :card' + ) + ->setParameter('card', $this) + ->getArrayResult(); + + return $result; } /** |