Compare commits
2 Commits
849aa6d5b1
...
c801608fe8
| Author | SHA1 | Date | |
|---|---|---|---|
| c801608fe8 | |||
| 1ead7f5741 |
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
namespace App\Model\Database\Entity;
|
namespace App\Model\Database\Entity;
|
||||||
|
|
||||||
@@ -8,7 +8,9 @@ use Doctrine\Common\Collections\ArrayCollection;
|
|||||||
use Doctrine\Common\Collections\Collection;
|
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
|
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>
|
* @var Collection&iterable<Translation>
|
||||||
*/
|
*/
|
||||||
protected Collection $translations;
|
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")
|
* @ORM\JoinColumn(name="lang1_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected ?Language $lang1;
|
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")
|
* @ORM\JoinColumn(name="lang2_id", referencedColumnName="id")
|
||||||
*/
|
*/
|
||||||
protected ?Language $lang2;
|
protected ?Language $lang2;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
namespace App\Model\Database\Entity;
|
namespace App\Model\Database\Entity;
|
||||||
|
|
||||||
@@ -42,13 +42,13 @@ class Language extends AbstractEntity
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @var Collection&iterable<Dictionary>
|
* @var Collection&iterable<Dictionary>
|
||||||
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
|
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Dictionary", mappedBy="language")
|
||||||
*/
|
*/
|
||||||
protected Collection $dictionaries1;
|
protected Collection $dictionaries1;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @var Collection&iterable<Dictionary>
|
* @var Collection&iterable<Dictionary>
|
||||||
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
|
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Dictionary", mappedBy="language")
|
||||||
*/
|
*/
|
||||||
protected Collection $dictionaries2;
|
protected Collection $dictionaries2;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
|
|
||||||
namespace App\Model\Database\Entity;
|
namespace App\Model\Database\Entity;
|
||||||
|
|
||||||
@@ -6,7 +7,9 @@ use Doctrine\ORM\Mapping as ORM;
|
|||||||
use App\Model\Database\Entity\Attributes\TId;
|
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
|
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;
|
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;
|
protected $lang1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Language", inversedBy="translations2")
|
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations2")
|
||||||
*/
|
*/
|
||||||
protected $lang2;
|
protected $lang2;
|
||||||
|
|
||||||
@@ -48,16 +51,17 @@ class Translation extends AbstractEntity
|
|||||||
*/
|
*/
|
||||||
protected $lang_name1;
|
protected $lang_name1;
|
||||||
|
|
||||||
public function getLangName1()
|
public function getLangName1(): String
|
||||||
{
|
{
|
||||||
return $this->lang_name1;
|
return $this->lang_name1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string")
|
* @ORM\Column(type="string")
|
||||||
*/
|
*/
|
||||||
protected $lang_name2;
|
protected $lang_name2;
|
||||||
|
|
||||||
public function getLangName2()
|
public function getLangName2(): String
|
||||||
{
|
{
|
||||||
return $this->lang_name2;
|
return $this->lang_name2;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,19 +35,19 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
protected function startup()
|
protected function startup()
|
||||||
{
|
{
|
||||||
$trs = $this->em->getRepository(Translation::class)->findBy([],['id' => 'ASC','direction'=>'ASC']);
|
$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 = [];
|
$select = [];
|
||||||
foreach ($trs as $t) {
|
foreach ($trs as $t) {
|
||||||
$lang1 = $t->langName1;
|
$lang1 = $t->getLangName1();
|
||||||
$lang2 = $t->langName2;
|
$lang2 = $t->getLangName2();
|
||||||
|
|
||||||
$lang = mb_substr($lang1,0,-1);
|
$lang = mb_substr($lang1,0,-1);
|
||||||
$lang .= "o-".$lang2;
|
$lang .= "o-".$lang2;
|
||||||
$slug = Strings::webalize($lang);
|
$slug = Strings::webalize($lang);
|
||||||
$select[$drs[$t->dictionary->id]][$t->id] = $lang;
|
$select[$drs[$t->getDictionary()->getId()]][$t->getId()] = $lang;
|
||||||
$translations[$t->id]["slug"] = $slug;
|
$translations[$t->getId()]["slug"] = $slug;
|
||||||
$translations[$t->id]["lang"] = $lang;
|
$translations[$t->getId()]["lang"] = $lang;
|
||||||
$translations[$t->id]["t"] = $t;
|
$translations[$t->getId()]["t"] = $t;
|
||||||
$slugs[$slug] = $t;
|
$slugs[$slug] = $t;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -154,7 +154,7 @@ final class HomePresenter extends BaseFrontPresenter
|
|||||||
|
|
||||||
public function beforeRender()
|
public function beforeRender()
|
||||||
{
|
{
|
||||||
$dicttypes = $this->repoDictTypes->findAssoc([],'id');
|
$dicttypes = $this->em->getDictTypeRepository()->findPairs('id');
|
||||||
$this->template->dicttypes = $dicttypes;
|
$this->template->dicttypes = $dicttypes;
|
||||||
$this->template->dictionaries = $this->dictionaries;
|
$this->template->dictionaries = $this->dictionaries;
|
||||||
$this->template->translations = $this->translations;
|
$this->template->translations = $this->translations;
|
||||||
|
|||||||
Reference in New Issue
Block a user