Browse Source

Merge remote-tracking branch 'origin/is/markus' into is/markus

# Conflicts:
#	src-php/app/internship/controller/ArticleApiController.php
#	src-php/app/internship/model/ArticleDao.php
markus 2 months ago
parent
commit
bf4c0c121f

+ 16 - 17
composer.lock

@@ -73,22 +73,22 @@
         },
         {
             "name": "n2n/n2n-batch",
-            "version": "v7.4.0",
+            "version": "v7.4.2",
             "source": {
                 "type": "git",
                 "url": "https://github.com/n2n/n2n-batch.git",
-                "reference": "5731bbfd1c30c650a2d39d4e1c28656a732be846"
+                "reference": "358614ea779b56d8c655110ee48363751f9d0b29"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/n2n/n2n-batch/zipball/5731bbfd1c30c650a2d39d4e1c28656a732be846",
-                "reference": "5731bbfd1c30c650a2d39d4e1c28656a732be846",
+                "url": "https://api.github.com/repos/n2n/n2n-batch/zipball/358614ea779b56d8c655110ee48363751f9d0b29",
+                "reference": "358614ea779b56d8c655110ee48363751f9d0b29",
                 "shasum": ""
             },
             "require": {
-                "n2n/n2n": "~7.4",
-                "n2n/n2n-reflection": "~7.4",
-                "n2n/n2n-util": "~7.4"
+                "n2n/n2n": "~7.4.0",
+                "n2n/n2n-reflection": "~7.4.0",
+                "n2n/n2n-util": "~7.4.0"
             },
             "require-dev": {
                 "phpunit/phpunit": "^9.5"
@@ -118,9 +118,9 @@
             ],
             "support": {
                 "issues": "https://github.com/n2n/n2n-batch/issues",
-                "source": "https://github.com/n2n/n2n-batch/tree/v7.4.0"
+                "source": "https://github.com/n2n/n2n-batch/tree/v7.4.2"
             },
-            "time": "2024-12-04T10:36:13+00:00"
+            "time": "2026-07-02T15:16:24+00:00"
         },
         {
             "name": "n2n/n2n-cache",
@@ -1744,20 +1744,19 @@
         },
         {
             "name": "nikic/php-parser",
-            "version": "v5.7.0",
+            "version": "v5.8.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/nikic/PHP-Parser.git",
-                "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82"
+                "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82",
-                "reference": "dca41cd15c2ac9d055ad70dbfd011130757d1f82",
+                "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/044a6a392ff8ad0d61f14370a5fbbd0a0107152f",
+                "reference": "044a6a392ff8ad0d61f14370a5fbbd0a0107152f",
                 "shasum": ""
             },
             "require": {
-                "ext-ctype": "*",
                 "ext-json": "*",
                 "ext-tokenizer": "*",
                 "php": ">=7.4"
@@ -1796,9 +1795,9 @@
             ],
             "support": {
                 "issues": "https://github.com/nikic/PHP-Parser/issues",
-                "source": "https://github.com/nikic/PHP-Parser/tree/v5.7.0"
+                "source": "https://github.com/nikic/PHP-Parser/tree/v5.8.0"
             },
-            "time": "2025-12-06T11:56:16+00:00"
+            "time": "2026-07-04T14:30:18+00:00"
         },
         {
             "name": "phar-io/manifest",
@@ -3417,5 +3416,5 @@
     "prefer-lowest": false,
     "platform": {},
     "platform-dev": {},
-    "plugin-api-version": "2.9.0"
+    "plugin-api-version": "2.6.0"
 }

+ 10 - 30
src-php/app/internship/controller/ArticleApiController.php

@@ -75,28 +75,12 @@ class ArticleApiController extends ControllerAdapter {
 	 */
 	function getDoArticles(?string $categoryName = null): void {
 		if ($categoryName == null) {
-			$articlesToShow = $this->articleDao->getArticles();
+			$articles = $this->articleDao->getArticles();
 		} else {
-			$articlesToShow = $this->articleDao->getArticlesByCategoryName($categoryName);
+			$articles = $this->articleDao->getArticlesByCategoryName($categoryName);
 		}
 
-		$this->sendJson($articlesToShow);
-
-		/*
-		$articles = $this->articleDao->getArticles();
-		$articlesToShow = [];
-		if ($categoryName !== null) {
-			foreach ($articles as $article) {
-				if($article->getCategoryName() === $categoryName) {
-					array_push($articlesToShow, $article);
-				}
-			}
-		}
-		else {
-			$articlesToShow = $articles;
-		}
-		$this->sendJson($articlesToShow);
-		*/
+		$this->sendJson($articles);
 	}
 
 	/**
@@ -127,20 +111,16 @@ class ArticleApiController extends ControllerAdapter {
         $text = $httpData->reqString('text');
         $categoryName = $httpData->reqString('categoryName');
 
-        $isValidCategory = $this->isValidArticleCategory($categoryName);
+        if (!$this->isValidArticleCategory($categoryName)) {
+			throw new BadRequestException();
 
-        if ($isValidCategory) {
+        }
 
             $articleToAdd = $this->prepareArticle($title, $text, $categoryName);
 
-            $this->beginTransaction();
-            $this->articleDao->saveArticle($articleToAdd);
-            $this->commit();
-
-        } else {
-            throw new BadRequestException();
-        }
-
+		$this->beginTransaction();
+		$this->articleDao->saveArticle($articleToAdd);
+		$this->commit();
 	}
 
 
@@ -208,7 +188,7 @@ class ArticleApiController extends ControllerAdapter {
 	 * Überprüft, ob die Article Category einen gültigen Wert enthält.
 	 * @return boolean
 	 */
-	function isValidArticleCategory($category){
+	function isValidArticleCategory($category): bool {
 		$categories = array('international', 'national', 'sport');
 		return in_array($category, $categories);
 	}

+ 1 - 3
src-php/app/internship/model/ArticleDao.php

@@ -56,10 +56,8 @@ class ArticleDao {
 	}
 
 
-	function saveArticle(Article $newArticle) {
-		// $tx = $this->tm->createTransaction();
+	function saveArticle(Article $newArticle): void {
 		$this->em->persist($newArticle);
-		// $tx->commit();
 	}
 
 	function removeArticle(int $articleId): void {