Compare commits

...

2 Commits

Author SHA1 Message Date
c801608fe8 Fix 2022-01-16 22:48:42 +01:00
1ead7f5741 some Fix 2022-01-16 22:48:28 +01:00
4 changed files with 29 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);
namespace App\Model\Database\Entity;
@@ -8,7 +8,9 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\DictionaryRepository")
* @ORM\Table(name="`dictionary`")
* @ORM\HasLifecycleCallbacks
*/
class Dictionary extends AbstractEntity
{
@@ -23,7 +25,7 @@ class Dictionary extends AbstractEntity
}
/**
* @ORM\OneToMany(targetEntity="App\Model\Database\Entity\Translation", mappedBy="dictionary", cascade={"persist"})
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Translation", mappedBy="dictionary", cascade={"persist"})
* @var Collection&iterable<Translation>
*/
protected Collection $translations;
@@ -35,13 +37,13 @@ class Dictionary extends AbstractEntity
/**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries1")
* @ORM\ManyToOne(targetEntity="\App\Model\Database\Entity\Language", inversedBy="dictionaries1")
* @ORM\JoinColumn(name="lang1_id", referencedColumnName="id")
*/
protected ?Language $lang1;
/**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries2")
* @ORM\ManyToOne(targetEntity="\App\Model\Database\Entity\Language", inversedBy="dictionaries2")
* @ORM\JoinColumn(name="lang2_id", referencedColumnName="id")
*/
protected ?Language $lang2;

View File

@@ -1,4 +1,4 @@
<?php
<?php declare(strict_types = 1);
namespace App\Model\Database\Entity;
@@ -42,13 +42,13 @@ class Language extends AbstractEntity
/*
* @var Collection&iterable<Dictionary>
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Dictionary", mappedBy="language")
*/
protected Collection $dictionaries1;
/*
* @var Collection&iterable<Dictionary>
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Dictionary", mappedBy="language")
*/
protected Collection $dictionaries2;

View File

@@ -1,4 +1,5 @@
<?php
<?php declare(strict_types = 1);
namespace App\Model\Database\Entity;
@@ -6,7 +7,9 @@ use Doctrine\ORM\Mapping as ORM;
use App\Model\Database\Entity\Attributes\TId;
/**
* @ORM\Entity
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\TermRepository")
* @ORM\Table(name="`translation`")
* @ORM\HasLifecycleCallbacks
*/
class Translation extends AbstractEntity
{
@@ -24,7 +27,7 @@ class Translation extends AbstractEntity
}
/**
* @ORM\ManyToOne(targetEntity="Dictionary", inversedBy="translations")
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Dictionary", inversedBy="translations")
*/
protected $dictionary;
@@ -34,12 +37,12 @@ class Translation extends AbstractEntity
}
/**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="translations1")
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations1")
*/
protected $lang1;
/**
* @ORM\ManyToOne(targetEntity="Language", inversedBy="translations2")
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations2")
*/
protected $lang2;
@@ -48,16 +51,17 @@ class Translation extends AbstractEntity
*/
protected $lang_name1;
public function getLangName1()
public function getLangName1(): String
{
return $this->lang_name1;
}
/**
* @ORM\Column(type="string")
*/
protected $lang_name2;
public function getLangName2()
public function getLangName2(): String
{
return $this->lang_name2;
}

View File

@@ -35,19 +35,19 @@ final class HomePresenter extends BaseFrontPresenter
protected function startup()
{
$trs = $this->em->getRepository(Translation::class)->findBy([],['id' => 'ASC','direction'=>'ASC']);
$drs = $this->em->getRepository(Dictionary::class)->findPairs([],'name',[],'id');
$drs = $this->em->getRepository(Dictionary::class)->findPairs('id','name');
$select = [];
foreach ($trs as $t) {
$lang1 = $t->langName1;
$lang2 = $t->langName2;
$lang1 = $t->getLangName1();
$lang2 = $t->getLangName2();
$lang = mb_substr($lang1,0,-1);
$lang .= "o-".$lang2;
$slug = Strings::webalize($lang);
$select[$drs[$t->dictionary->id]][$t->id] = $lang;
$translations[$t->id]["slug"] = $slug;
$translations[$t->id]["lang"] = $lang;
$translations[$t->id]["t"] = $t;
$select[$drs[$t->getDictionary()->getId()]][$t->getId()] = $lang;
$translations[$t->getId()]["slug"] = $slug;
$translations[$t->getId()]["lang"] = $lang;
$translations[$t->getId()]["t"] = $t;
$slugs[$slug] = $t;
}
@@ -154,7 +154,7 @@ final class HomePresenter extends BaseFrontPresenter
public function beforeRender()
{
$dicttypes = $this->repoDictTypes->findAssoc([],'id');
$dicttypes = $this->em->getDictTypeRepository()->findPairs('id');
$this->template->dicttypes = $dicttypes;
$this->template->dictionaries = $this->dictionaries;
$this->template->translations = $this->translations;