ksieren преди 2 години
родител
ревизия
a2486d9802

+ 1 - 1
Classes/Controller/CategoryController.php

@@ -15,7 +15,7 @@ class CategoryController extends ActionController
 
 
     public function createAction(string $title) {
     public function createAction(string $title) {
         $category = $this->categoryRepository->findByTitle($title);
         $category = $this->categoryRepository->findByTitle($title);
-        if(!$category){
+        if(!$category && $title !== ''){
             $category = new Category();
             $category = new Category();
             $category->setTitle($title);
             $category->setTitle($title);
             $this->categoryRepository->add($category);
             $this->categoryRepository->add($category);

+ 8 - 6
Classes/Controller/TermController.php

@@ -15,12 +15,14 @@ class TermController extends ActionController
 
 
     public function createAction($terms, $categoryObj, $typeObj, $urlObj): void {
     public function createAction($terms, $categoryObj, $typeObj, $urlObj): void {
         foreach ($terms as $term) {
         foreach ($terms as $term) {
-            $termObj = new Term();
-            $termObj->setTerm($term);
-            $termObj->setCategory($categoryObj);
-            $termObj->setType($typeObj);
-            $termObj->setUrl($urlObj);
-            $this->termRepository->add($termObj);
+            if($term !== '') {
+                $termObj = new Term();
+                $termObj->setTerm($term);
+                $termObj->setCategory($categoryObj);
+                $termObj->setType($typeObj);
+                $termObj->setUrl($urlObj);
+                $this->termRepository->add($termObj);
+            }
         }
         }
     }
     }
 
 

+ 1 - 1
Classes/Controller/TypeController.php

@@ -15,7 +15,7 @@ class TypeController extends ActionController
 
 
     public function createAction(string $title) {
     public function createAction(string $title) {
         $type = $this->typeRepository->findByTitle($title);
         $type = $this->typeRepository->findByTitle($title);
-        if(!$type && $type !== ''){
+        if(!$type && $title !== ''){
             $type = new Type();
             $type = new Type();
             $type->setTitle($title);
             $type->setTitle($title);
             $this->typeRepository->add($type);
             $this->typeRepository->add($type);

+ 1 - 1
Classes/Controller/UrlController.php

@@ -16,7 +16,7 @@ class UrlController extends ActionController
     public function createAction(string $title) {
     public function createAction(string $title) {
         $url = $this->urlRepository->findByTitle($title);
         $url = $this->urlRepository->findByTitle($title);
 
 
-        if(!$url && $url !== ''){
+        if(!$url && $title !== ''){
             $url = new Url();
             $url = new Url();
             $url->setTitle($title);
             $url->setTitle($title);
             $this->urlRepository->add($url);
             $this->urlRepository->add($url);