em = $em; } /** * Gebe alle {@see Category}-Objekte, nach id absteigend sortiert, zurück. * * @return Category[] */ function getCategories(): array { $criteria = $this->em->createSimpleCriteria(Category::getClass(), array(), array('id' => 'DESC')); return $criteria->toQuery()->fetchArray(); } /** * Gebe den {@see Category} mit der enstprechenden ID zurück. */ function getCategoryById(int $id): ?Category { return $this->em->find(Category::getClass(), $id); } function saveCategory(Category $newCategory): void { $this->em->persist($newCategory); } function removeCategory(int $articleId): void { $category = $this->getCategoryById($articleId); $this->em->remove($category); } }