| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <?php
- namespace internship\model;
- use n2n\context\attribute\RequestScoped;
- use n2n\persistence\orm\EntityManager;
- use internship\bo\Article;
- use internship\bo\ArticleGroup;
- #[RequestScoped]
- class ArticleGroupDao {
- private EntityManager $em;
- private function _init(EntityManager $em): void {
- $this->em = $em;
- }
- /**
- * Gebe alle {@see ArticleGroup}-Objekte, nach id absteigend sortiert, zurück.
- *
- * @return ArticleGroup[]
- */
- function getArticleGroups(): array {
- $criteria = $this->em->createNqlCriteria("SELECT ag FROM ArticleGroup ag");
- return $criteria->toQuery()->fetchArray();
- }
- /**
- * Gebe den {@see ArticleGroup} mit der enstprechenden ID zurück.
- *
- * @param int $id
- * @return ArticleGroup
- */
- function getArticleGroupById(int $id): ?ArticleGroup {
- return $this->em->find(ArticleGroup::getClass(), $id);
- }
- /**
- * Speichere den {@see ArticleGroup}.
- *
- * @param ArticleGroup $articleGroup
- * @return null
- */
- function saveArticleGroup(ArticleGroup $articleGroup) {
- $this->em->persist($articleGroup);
- }
- /**
- * Entferne den {@see ArticleGroup} mit der entsprechenden Id.
- *
- * @param int $id
- * @return void
- */
- function removeArticleGroup(int $id): void{
- $articleGroupToRemove = $this->em->find(ArticleGroup::getClass(), $id);
- $this->em->remove($articleGroupToRemove);
- }
- }
|