Basic functionality
This commit is contained in:
8
app/model/Database/Entity/AbstractEntity.php
Executable file
8
app/model/Database/Entity/AbstractEntity.php
Executable file
@@ -0,0 +1,8 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
abstract class AbstractEntity
|
||||
{
|
||||
use \Nette\SmartObject;
|
||||
}
|
||||
33
app/model/Database/Entity/Attributes/TCreatedAt.php
Executable file
33
app/model/Database/Entity/Attributes/TCreatedAt.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity\Attributes;
|
||||
|
||||
use App\Model\Utils\DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
trait TCreatedAt
|
||||
{
|
||||
|
||||
/**
|
||||
* @var DateTime
|
||||
* @ORM\Column(type="datetime", nullable=FALSE)
|
||||
*/
|
||||
protected $createdAt;
|
||||
|
||||
public function getCreatedAt(): DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctrine annotation
|
||||
*
|
||||
* @ORM\PrePersist
|
||||
* @internal
|
||||
*/
|
||||
public function setCreatedAt(): void
|
||||
{
|
||||
$this->createdAt = new DateTime();
|
||||
}
|
||||
|
||||
}
|
||||
29
app/model/Database/Entity/Attributes/TId.php
Executable file
29
app/model/Database/Entity/Attributes/TId.php
Executable file
@@ -0,0 +1,29 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity\Attributes;
|
||||
|
||||
trait TId
|
||||
{
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @ORM\Column(type="integer", nullable=FALSE)
|
||||
* @ORM\Id
|
||||
* @ORM\GeneratedValue
|
||||
*
|
||||
* @property int $id
|
||||
*/
|
||||
private $id;
|
||||
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
$this->id = null;
|
||||
}
|
||||
|
||||
}
|
||||
33
app/model/Database/Entity/Attributes/TUpdatedAt.php
Executable file
33
app/model/Database/Entity/Attributes/TUpdatedAt.php
Executable file
@@ -0,0 +1,33 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity\Attributes;
|
||||
|
||||
use App\Model\Utils\DateTime;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
trait TUpdatedAt
|
||||
{
|
||||
|
||||
/**
|
||||
* @var DateTime|NULL
|
||||
* @ORM\Column(type="datetime", nullable=TRUE)
|
||||
*/
|
||||
protected $updatedAt;
|
||||
|
||||
public function getUpdatedAt(): ?DateTime
|
||||
{
|
||||
return $this->updatedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Doctrine annotation
|
||||
*
|
||||
* @ORM\PreUpdate
|
||||
* @internal
|
||||
*/
|
||||
public function setUpdatedAt(): void
|
||||
{
|
||||
$this->updatedAt = new DateTime();
|
||||
}
|
||||
|
||||
}
|
||||
50
app/model/Database/Entity/DictType.php
Executable file
50
app/model/Database/Entity/DictType.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\DictTypeRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $shortName
|
||||
* @property String $fullName
|
||||
*/
|
||||
class DictType extends AbstractEntity
|
||||
{
|
||||
use TId;
|
||||
|
||||
public function __construct($short_name,$full_name)
|
||||
{
|
||||
$this->shortName = $short_name;
|
||||
$this->fullName = $full_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $shortName;
|
||||
|
||||
public function getShortName()
|
||||
{
|
||||
return $this->shortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $fullName;
|
||||
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->fullName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
94
app/model/Database/Entity/Dictionary.php
Executable file
94
app/model/Database/Entity/Dictionary.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\DictionaryRepository")
|
||||
* @ORM\Table(name="`dictionary`")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $name
|
||||
* @property String $fullname
|
||||
* @property Term $terms
|
||||
* @property Language $lang1
|
||||
* @property Language $lang2
|
||||
*/
|
||||
class Dictionary extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct($name,$fullname)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->fullName = $fullname;
|
||||
$this->translations = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="\App\Model\Database\Entity\Translation", mappedBy="dictionary", cascade={"persist"})
|
||||
* @var Collection&iterable<Translation>
|
||||
*/
|
||||
protected Collection $translations;
|
||||
|
||||
public function getTranslations()
|
||||
{
|
||||
return $this->translations;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\OnetoMany(targetEntity="\App\Model\Database\Entity\Term", mappedBy="dictionary")
|
||||
* @var Collection&iterable<Term>
|
||||
*/
|
||||
protected Collection $terms;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries1")
|
||||
* @ORM\JoinColumn(name="lang1_id", referencedColumnName="id")
|
||||
*/
|
||||
protected ?Language $lang1;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Language", inversedBy="dictionaries2")
|
||||
* @ORM\JoinColumn(name="lang2_id", referencedColumnName="id")
|
||||
*/
|
||||
protected ?Language $lang2;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $fullName;
|
||||
|
||||
public function setLang1($lang1)
|
||||
{
|
||||
$this->lang1 = $lang1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setLang2($lang2)
|
||||
{
|
||||
$this->lang2 = $lang2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
65
app/model/Database/Entity/Language.php
Executable file
65
app/model/Database/Entity/Language.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\LanguageRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $name
|
||||
* @property String $shortName
|
||||
* @property Dictionary $dictionaries1
|
||||
* @property Dictionary $dictionaries2
|
||||
*
|
||||
*/
|
||||
class Language extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct($shortname,$name)
|
||||
{
|
||||
$this->shortName = $shortname;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string",length=2, unique=true, options={"fixed" = true})
|
||||
*/
|
||||
protected $shortName;
|
||||
|
||||
public function getShortName()
|
||||
{
|
||||
return $this->shortName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string",length=32)
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/*
|
||||
* @var Collection&iterable<Dictionary>
|
||||
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
|
||||
*/
|
||||
protected Collection $dictionaries1;
|
||||
|
||||
/*
|
||||
* @var Collection&iterable<Dictionary>
|
||||
* @ORM\OneToMany(targetEntity="Dictionary", mappedBy="language")
|
||||
*/
|
||||
protected Collection $dictionaries2;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
85
app/model/Database/Entity/Pronunciation.php
Executable file
85
app/model/Database/Entity/Pronunciation.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\PronunciationRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property Term $terms
|
||||
* @property PronunciationType $type
|
||||
* @property String $ipa
|
||||
* @property String $filename
|
||||
*/
|
||||
class Pronunciation extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct($type,$ipa,$filename=null)
|
||||
{
|
||||
$this->type = $type;
|
||||
$this->ipa = $ipa;
|
||||
$this->filename = $filename;
|
||||
$this->terms = new \Doctrine\Common\Collections\ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Term", mappedBy="pronunciations")
|
||||
*/
|
||||
private $terms;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="PronunciationType", inversedBy="pronunciations")
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string",nullable=true)
|
||||
*/
|
||||
protected $ipa;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string", nullable=true)
|
||||
*/
|
||||
protected $filename;
|
||||
|
||||
/**
|
||||
* Get the value of filename
|
||||
*/
|
||||
public function getFilename()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of terms
|
||||
*/
|
||||
public function getTerms()
|
||||
{
|
||||
return $this->terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of ipa
|
||||
*/
|
||||
public function getIpa()
|
||||
{
|
||||
return $this->ipa;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of type
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
37
app/model/Database/Entity/PronunciationType.php
Executable file
37
app/model/Database/Entity/PronunciationType.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\Tid;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\PronunciationTypeRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $name
|
||||
* @property String $fullName
|
||||
*/
|
||||
class PronunciationType extends AbstractEntity
|
||||
{
|
||||
use Tid;
|
||||
|
||||
public function __construct($name,$fullName)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->fullName = $fullName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $fullName;
|
||||
}
|
||||
|
||||
?>
|
||||
36
app/model/Database/Entity/Suffix.php
Executable file
36
app/model/Database/Entity/Suffix.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\SuffixRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $text
|
||||
*/
|
||||
class Suffix extends AbstractEntity
|
||||
{
|
||||
use Tid;
|
||||
|
||||
public function __construct($text)
|
||||
{
|
||||
$this->text = $text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $text;
|
||||
|
||||
|
||||
public function getText()
|
||||
{
|
||||
return $this->text;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
231
app/model/Database/Entity/Term.php
Executable file
231
app/model/Database/Entity/Term.php
Executable file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Proxy\Proxy;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\TermRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
* @ORM\Table(indexes={@ORM\Index(columns={"string1"}, flags={"fulltext"}),@ORM\Index(columns={"string2"}, flags={"fulltext"})})
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $string1
|
||||
* @property String $string2
|
||||
* @property Dictionary $dictionary
|
||||
* @property mixed $pronunciations
|
||||
* @property Suffix $suffix1
|
||||
* @property Suffix $suffix2
|
||||
* @property DictType $type
|
||||
* @property int $order2
|
||||
* @property String $member
|
||||
*/
|
||||
class Term extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct(Dictionary $dictionary, $string)
|
||||
{
|
||||
$this->dictionary = $dictionary;
|
||||
$this->string1 = $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="\App\Model\Database\Entity\Dictionary", inversedBy="terms",cascade={"persist", "remove" })
|
||||
*/
|
||||
protected $dictionary;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $string1;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $string2;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Suffix")
|
||||
*/
|
||||
protected $suffix1;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Suffix")
|
||||
*/
|
||||
protected $suffix2;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="DictType")
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Pronunciation", inversedBy="terms")
|
||||
* @ORM\JoinTable(name="terms_pronunciations")
|
||||
* @var Collection&iterable<Pronunciation>
|
||||
*/
|
||||
protected Collection $pronunciations;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string",nullable=true)
|
||||
*/
|
||||
protected $member;
|
||||
|
||||
public function setMember($member)
|
||||
{
|
||||
$this->member = $member;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMember()
|
||||
{
|
||||
return $this->member;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="smallint",nullable=true)
|
||||
*/
|
||||
protected $order2;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="json_array",nullable=true)
|
||||
*/
|
||||
protected $flags;
|
||||
|
||||
public function getFlags()
|
||||
{
|
||||
return $this->flags;
|
||||
}
|
||||
|
||||
public function setFlags($flags)
|
||||
{
|
||||
$this->flags = $flags;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOrder2()
|
||||
{
|
||||
return $this->order2;
|
||||
}
|
||||
|
||||
public function setOrder2($order2)
|
||||
{
|
||||
$this->order2 = $order2;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of string1
|
||||
*/
|
||||
public function getString1()
|
||||
{
|
||||
return $this->string1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of string1
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setString1($string1)
|
||||
{
|
||||
$this->string1 = $string1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of string2
|
||||
*/
|
||||
public function getString2()
|
||||
{
|
||||
return $this->string2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of string2
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setString2($string2)
|
||||
{
|
||||
$this->string2 = $string2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of suffix1
|
||||
*/
|
||||
public function getSuffix1()
|
||||
{
|
||||
return $this->suffix1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of suffix1
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSuffix1($suffix1)
|
||||
{
|
||||
$this->suffix1 = $suffix1;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of suffix2
|
||||
*/
|
||||
public function getSuffix2()
|
||||
{
|
||||
return $this->suffix2;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of suffix2
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setSuffix2($suffix2)
|
||||
{
|
||||
$this->suffix2 = $suffix2;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of type
|
||||
*/
|
||||
public function getType()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of type
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of pronunciations
|
||||
*
|
||||
* @return Collection&iterable<Pronunciation>
|
||||
*/
|
||||
public function getPronunciations()
|
||||
{
|
||||
return $this->pronunciations;
|
||||
}
|
||||
}
|
||||
97
app/model/Database/Entity/TermFlag.php
Executable file
97
app/model/Database/Entity/TermFlag.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\TermFlagRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property WordClass $class
|
||||
* @property Language $language
|
||||
* @property String $code
|
||||
* @property String $description
|
||||
*/
|
||||
class TermFlag extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct($id,$class,$language,$code,$description)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->class = $class;
|
||||
$this->language = $language;
|
||||
$this->code = $code;
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="WordClass", inversedBy="flags")
|
||||
*/
|
||||
protected $class;
|
||||
|
||||
public function getClass()
|
||||
{
|
||||
return $this->class;
|
||||
}
|
||||
|
||||
public function setClass($class)
|
||||
{
|
||||
$this->class = $class;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Language", inversedBy="flags")
|
||||
*/
|
||||
protected $language;
|
||||
|
||||
public function getLanguage()
|
||||
{
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
public function setLanguage($language)
|
||||
{
|
||||
$this->language = $language;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $code;
|
||||
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
87
app/model/Database/Entity/Translation.php
Executable file
87
app/model/Database/Entity/Translation.php
Executable file
@@ -0,0 +1,87 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\TranslationRepository")
|
||||
* @ORM\Table(name="`translation`")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property Dictionary $dictionary
|
||||
* @property Language $lang1
|
||||
* @property Language $lang2
|
||||
* @property int $direction
|
||||
*/
|
||||
class Translation extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct($dictionary,$lang1,$lang2,$lang_name1,$lang_name2,$direction)
|
||||
{
|
||||
$this->dictionary = $dictionary;
|
||||
$this->lang1 = $lang1;
|
||||
$this->lang2 = $lang2;
|
||||
$this->lang_name1 = $lang_name1;
|
||||
$this->lang_name2 = $lang_name2;
|
||||
$this->direction = $direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Dictionary", inversedBy="translations")
|
||||
*/
|
||||
protected $dictionary;
|
||||
|
||||
public function getDictionary()
|
||||
{
|
||||
return $this->dictionary;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations1")
|
||||
*/
|
||||
protected $lang1;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="App\Model\Database\Entity\Language", inversedBy="translations2")
|
||||
*/
|
||||
protected $lang2;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $lang_name1;
|
||||
|
||||
public function getLangName1(): String
|
||||
{
|
||||
return $this->lang_name1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $lang_name2;
|
||||
|
||||
public function getLangName2(): String
|
||||
{
|
||||
return $this->lang_name2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="smallint")
|
||||
*/
|
||||
protected $direction;
|
||||
|
||||
public function getDirection() : int
|
||||
{
|
||||
return $this->direction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
214
app/model/Database/Entity/User.php
Executable file
214
app/model/Database/Entity/User.php
Executable file
@@ -0,0 +1,214 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use App\Model\Database\Entity\Attributes\TCreatedAt;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
use App\Model\Database\Entity\Attributes\TUpdatedAt;
|
||||
use App\Model\Exception\Logic\InvalidArgumentException;
|
||||
use App\Model\Security\Identity;
|
||||
use App\Model\Utils\DateTime;
|
||||
use App\Model\Utils\Strings;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\UserRepository")
|
||||
* @ORM\Table(name="`user`")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $name
|
||||
* @property String $surname
|
||||
* @property String $email
|
||||
* @property String $password
|
||||
* @property String $role
|
||||
* @property int $state
|
||||
*/
|
||||
class User extends AbstractEntity
|
||||
{
|
||||
|
||||
public const ROLE_ADMIN = 'admin';
|
||||
public const ROLE_USER = 'user';
|
||||
|
||||
public const STATE_FRESH = 1;
|
||||
public const STATE_ACTIVATED = 2;
|
||||
public const STATE_BLOCKED = 3;
|
||||
|
||||
public const STATES = [self::STATE_FRESH, self::STATE_BLOCKED, self::STATE_ACTIVATED];
|
||||
|
||||
use TId;
|
||||
use TCreatedAt;
|
||||
use TUpdatedAt;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255, nullable=FALSE, unique=false)
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255, nullable=FALSE, unique=false)
|
||||
*/
|
||||
private $surname;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255, nullable=FALSE, unique=TRUE)
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255, nullable=FALSE, unique=TRUE)
|
||||
*/
|
||||
private $username;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @ORM\Column(type="integer", length=10, nullable=FALSE)
|
||||
*/
|
||||
private $state;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255, nullable=FALSE)
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @ORM\Column(type="string", length=255, nullable=FALSE)
|
||||
*/
|
||||
private $role;
|
||||
|
||||
/**
|
||||
* @var DateTime|NULL
|
||||
* @ORM\Column(type="datetime", nullable=TRUE)
|
||||
*/
|
||||
private $lastLoggedAt;
|
||||
|
||||
public function __construct(string $name, string $surname, string $email, string $username, string $passwordHash)
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->surname = $surname;
|
||||
$this->email = $email;
|
||||
$this->username = $username;
|
||||
$this->password = $passwordHash;
|
||||
|
||||
$this->role = self::ROLE_USER;
|
||||
$this->state = self::STATE_FRESH;
|
||||
}
|
||||
|
||||
public function changeLoggedAt(): void
|
||||
{
|
||||
$this->lastLoggedAt = new DateTime();
|
||||
}
|
||||
|
||||
public function getEmail(): string
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
public function getUsername(): string
|
||||
{
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
public function changeUsername(string $username): void
|
||||
{
|
||||
$this->username = $username;
|
||||
}
|
||||
|
||||
public function getLastLoggedAt(): ?DateTime
|
||||
{
|
||||
return $this->lastLoggedAt;
|
||||
}
|
||||
|
||||
public function getRole(): string
|
||||
{
|
||||
return $this->role;
|
||||
}
|
||||
|
||||
public function setRole(string $role): void
|
||||
{
|
||||
$this->role = $role;
|
||||
}
|
||||
|
||||
public function getPasswordHash(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function changePasswordHash(string $password): void
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
public function block(): void
|
||||
{
|
||||
$this->state = self::STATE_BLOCKED;
|
||||
}
|
||||
|
||||
public function activate(): void
|
||||
{
|
||||
$this->state = self::STATE_ACTIVATED;
|
||||
}
|
||||
|
||||
public function isActivated(): bool
|
||||
{
|
||||
return $this->state === self::STATE_ACTIVATED;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function getSurname(): string
|
||||
{
|
||||
return $this->surname;
|
||||
}
|
||||
|
||||
public function getFullname(): string
|
||||
{
|
||||
return $this->name . ' ' . $this->surname;
|
||||
}
|
||||
|
||||
public function rename(string $name, string $surname): void
|
||||
{
|
||||
$this->name = $name;
|
||||
$this->surname = $surname;
|
||||
}
|
||||
|
||||
public function getState(): int
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function setState(int $state): void
|
||||
{
|
||||
if (!in_array($state, self::STATES)) {
|
||||
throw new InvalidArgumentException(sprintf('Unsupported state %s', $state));
|
||||
}
|
||||
|
||||
$this->state = $state;
|
||||
}
|
||||
|
||||
public function getGravatar(): string
|
||||
{
|
||||
return 'https://www.gravatar.com/avatar/' . md5($this->email);
|
||||
}
|
||||
|
||||
public function toIdentity(): Identity
|
||||
{
|
||||
return new Identity($this->getId(), [$this->role], [
|
||||
'email' => $this->email,
|
||||
'name' => $this->name,
|
||||
'surname' => $this->surname,
|
||||
'state' => $this->state,
|
||||
'gravatar' => $this->getGravatar(),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
43
app/model/Database/Entity/WordClass.php
Executable file
43
app/model/Database/Entity/WordClass.php
Executable file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model\Database\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Model\Database\Entity\Attributes\TId;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="App\Model\Database\Repository\WordClassRepository")
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*
|
||||
* @property int $id
|
||||
* @property String $name
|
||||
*
|
||||
*/
|
||||
class WordClass extends AbstractEntity
|
||||
{
|
||||
|
||||
use Tid;
|
||||
|
||||
public function __construct($id,$name)
|
||||
{
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="string")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setName($name)
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
28
app/model/Database/EntityManager.php
Executable file
28
app/model/Database/EntityManager.php
Executable file
@@ -0,0 +1,28 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database;
|
||||
|
||||
use App\Model\Database\Repository\AbstractRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
use Nettrine\ORM\EntityManagerDecorator;
|
||||
|
||||
class EntityManager extends EntityManagerDecorator
|
||||
{
|
||||
|
||||
use TRepositories;
|
||||
|
||||
/**
|
||||
* @param string $entityName
|
||||
* @return AbstractRepository<T>|ObjectRepository<T>
|
||||
* @internal
|
||||
* @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint
|
||||
* @phpstan-template T of object
|
||||
* @phpstan-param class-string<T> $entityName
|
||||
* @phpstan-return ObjectRepository<T>
|
||||
*/
|
||||
public function getRepository($entityName): ObjectRepository
|
||||
{
|
||||
return parent::getRepository($entityName);
|
||||
}
|
||||
|
||||
}
|
||||
124
app/model/Database/Facade/TermFacade.php
Executable file
124
app/model/Database/Facade/TermFacade.php
Executable file
@@ -0,0 +1,124 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Facade;
|
||||
|
||||
use App\Model\Database\Entity\Dictionary;
|
||||
use App\Model\Database\Entity\Term;
|
||||
use App\Model\Database\Entity\Translation;
|
||||
use App\Model\Database\EntityManager;
|
||||
|
||||
|
||||
class TermFacade
|
||||
{
|
||||
|
||||
/** @var EntityManager */
|
||||
private $em;
|
||||
private $direction;
|
||||
|
||||
public function __construct(
|
||||
EntityManager $em
|
||||
)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function setDirection(int $direction)
|
||||
{
|
||||
$this->direction = $direction;
|
||||
}
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function findByString(String $term,Dictionary $d,String $clen = null)
|
||||
{
|
||||
$query = $this->em->createQueryBuilder('t')->select('t')
|
||||
->addSelect('s1')
|
||||
->addSelect('s2')
|
||||
->from(Term::class,'t')
|
||||
->leftJoin('t.suffix1','s1')
|
||||
->leftJoin('t.suffix2','s2');
|
||||
if ($this->direction == 1) {
|
||||
$query->where('t.string1 LIKE :str')->setParameter('str', $term."%");
|
||||
$query->orderBy('t.string1,t.id','ASC');
|
||||
} else if ($this->direction == 2) {
|
||||
$query->where('t.string2 LIKE :str')->setParameter('str', $term."%");
|
||||
$query->orderBy('t.string2','ASC');
|
||||
$query->addOrderBy('t.order2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$d->id);
|
||||
if ($clen)
|
||||
$query->andWhere('t.member LIKE :clen')->setParameter('clen','%'.$clen.'%');
|
||||
|
||||
return $query->getQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function findByStringQuick(String $string, Dictionary $d, String $clen = null)
|
||||
{
|
||||
$query = $this->em->createQueryBuilder('t')->select('DISTINCT t.string1 AS str')->from(Term::class,'t');
|
||||
if ($this->direction == 1) {
|
||||
$query->where('t.string1 LIKE :str')->setParameter('str',$string."%");
|
||||
$query->orderBy('t.string1','ASC');
|
||||
} else if ($this->direction == 2) {
|
||||
$query->where('t.string2 LIKE :str')->setParameter('str', $string."%");
|
||||
$query->orderBy('t.string2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$d->id);
|
||||
|
||||
return $query->getQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function findByStringFull(String $string, Dictionary $d, String $clen = null, $like = true)
|
||||
{
|
||||
|
||||
$search = $string;
|
||||
if ($like) $search = $search . "%";
|
||||
|
||||
$query = $this->em->createQueryBuilder('t')->select('t')
|
||||
->addSelect('s1')
|
||||
->addSelect('s2')
|
||||
->addSelect('p')
|
||||
->from(Term::class,'t')
|
||||
->leftJoin('t.suffix1','s1')
|
||||
->leftJoin('t.suffix2','s2')
|
||||
->leftJoin('t.pronunciations','p');
|
||||
if ($this->direction == 1) {
|
||||
$query->where('t.string1 LIKE :str')->setParameter('str',$search);
|
||||
$query->orderBy('t.id','ASC');
|
||||
$query->addOrderBy('p.id','ASC');
|
||||
} else if ($this->direction == 2) {
|
||||
$query->where('t.string2 LIKE :str')->setParameter('str', $search);
|
||||
$query->orderBy('t.string2','ASC');
|
||||
$query->addOrderBy('t.order2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$d->id);
|
||||
if ($clen)
|
||||
$query->andWhere('t.member LIKE :clen')->setParameter('clen','%'.$clen.'%');
|
||||
|
||||
return $query->getQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] $data
|
||||
*/
|
||||
public function findByStringSimple(String $string, Dictionary $d, String $clen = null)
|
||||
{
|
||||
$query = $this->em->createQueryBuilder('t')->select('t')->from(Term::class,'t');
|
||||
if ($this->direction == 1) {
|
||||
$query->where('t.string1 LIKE :str')->setParameter('str',$string."%");
|
||||
$query->orderBy('t.id','ASC');
|
||||
} else if ($this->direction == 2) {
|
||||
$query->where('t.string2 LIKE :str')->setParameter('str', $string."%");
|
||||
$query->orderBy('t.string2','ASC');
|
||||
$query->addOrderBy('t.order2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$d->id);
|
||||
|
||||
return $query->getQuery();
|
||||
}
|
||||
}
|
||||
86
app/model/Database/Repository/AbstractRepository.php
Executable file
86
app/model/Database/Repository/AbstractRepository.php
Executable file
@@ -0,0 +1,86 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
|
||||
/**
|
||||
* @phpstan-template TEntityClass of object
|
||||
* @phpstan-extends EntityRepository<TEntityClass>
|
||||
*/
|
||||
abstract class AbstractRepository extends EntityRepository
|
||||
{
|
||||
|
||||
/**
|
||||
* Fetches all records like $key => $value pairs
|
||||
*
|
||||
* @param mixed[] $criteria
|
||||
* @param mixed[] $orderBy
|
||||
* @return mixed[]
|
||||
*/
|
||||
public function findPairs(?string $key, string $value, array $criteria = [], array $orderBy = []): array
|
||||
{
|
||||
if ($key === null) {
|
||||
$key = $this->getClassMetadata()->getSingleIdentifierFieldName();
|
||||
}
|
||||
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->select(['e.' . $value, 'e.' . $key])
|
||||
->resetDQLPart('from')
|
||||
->from($this->getEntityName(), 'e', 'e.' . $key);
|
||||
|
||||
foreach ($criteria as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$qb->andWhere(sprintf('e.%s IN(:%s)', $k, $k))->setParameter($k, array_values($v));
|
||||
} else {
|
||||
$qb->andWhere(sprintf('e.%s = :%s', $k, $k))->setParameter($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($orderBy as $column => $order) {
|
||||
$qb->addOrderBy($column, $order);
|
||||
}
|
||||
|
||||
return array_map(function ($row) {
|
||||
return reset($row);
|
||||
}, $qb->getQuery()->getArrayResult());
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all records and returns an associative array indexed by key
|
||||
*
|
||||
* @param array $criteria
|
||||
* @param string $key
|
||||
*
|
||||
* @throws \Exception|QueryException
|
||||
* @return array
|
||||
*/
|
||||
public function findAssoc(array $criteria = [],String $key = NULL)
|
||||
{
|
||||
if (!is_array($criteria)) {
|
||||
$key = $criteria;
|
||||
$criteria = [];
|
||||
}
|
||||
|
||||
$qb = $this->createQueryBuilder('e')
|
||||
->resetDQLPart('from')->from($this->getEntityName(), 'e', 'e.' . $key);
|
||||
|
||||
foreach ($criteria as $k => $v) {
|
||||
if (is_array($v)) {
|
||||
$qb->andWhere(sprintf('e.%s IN(:%s)', $k, $k))->setParameter($k, array_values($v));
|
||||
} else {
|
||||
$qb->andWhere(sprintf('e.%s = :%s', $k, $k))->setParameter($k, $v);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return $qb->getQuery()->getResult();
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $this->handleException($e, $qb);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
18
app/model/Database/Repository/DictTypeRepository.php
Executable file
18
app/model/Database/Repository/DictTypeRepository.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\DictType;
|
||||
|
||||
/**
|
||||
* @method DictType|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method DictType|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method DictType[] findAll()
|
||||
* @method DictType[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<DictType>
|
||||
*/
|
||||
class DictTypeRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
18
app/model/Database/Repository/DictionaryRepository.php
Executable file
18
app/model/Database/Repository/DictionaryRepository.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\Dictionary;
|
||||
|
||||
/**
|
||||
* @method Dictionary|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method Dictionary|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method Dictionary[] findAll()
|
||||
* @method Dictionary[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<Dictionary>
|
||||
*/
|
||||
class DictionaryRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
16
app/model/Database/Repository/PronunciationRepository.php
Executable file
16
app/model/Database/Repository/PronunciationRepository.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\Pronunciation;
|
||||
/**
|
||||
* @method Pronunciation|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method Pronunciation|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method Pronunciation[] findAll()
|
||||
* @method Pronunciation[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<Pronunciation>
|
||||
*/
|
||||
class PronunciationRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
}
|
||||
18
app/model/Database/Repository/TermFlagRepository.php
Executable file
18
app/model/Database/Repository/TermFlagRepository.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\TermFlag;
|
||||
|
||||
/**
|
||||
* @method TermFlag|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method TermFlag|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method TermFlag[] findAll()
|
||||
* @method TermFlag[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<TermFlag>
|
||||
*/
|
||||
class TermFlagRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
18
app/model/Database/Repository/TermRepository.php
Executable file
18
app/model/Database/Repository/TermRepository.php
Executable file
@@ -0,0 +1,18 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\Term;
|
||||
|
||||
/**
|
||||
* @method Term|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method Term|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method Term[] findAll()
|
||||
* @method Term[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<Term>
|
||||
*/
|
||||
class TermRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
57
app/model/Database/Repository/TermsQuery.php
Executable file
57
app/model/Database/Repository/TermsQuery.php
Executable file
@@ -0,0 +1,57 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use App\Model\Database\Entity\Dictionary;
|
||||
|
||||
class TermsQuery extends EntityRepository
|
||||
{
|
||||
|
||||
private Dictionary $dictionary;
|
||||
private String $string;
|
||||
private Int $direction;
|
||||
private String $clen;
|
||||
|
||||
public function __construct(Dictionary $dict,String $string,Int $direction = 1)
|
||||
{
|
||||
$this->dictionary = $dict;
|
||||
$this->string = $string;
|
||||
$this->direction = $direction;
|
||||
}
|
||||
|
||||
public function withClen(String $clen)
|
||||
{
|
||||
if ($clen != null && $clen != '')
|
||||
$this->clen = $clen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches all records like $key => $value pairs
|
||||
*
|
||||
* @param mixed[] $criteria
|
||||
* @param mixed[] $orderBy
|
||||
* @return mixed[]
|
||||
*/
|
||||
protected function doCreateQuery()
|
||||
{
|
||||
$query = $this->createQueryBuilder('t')->select('t')
|
||||
->addSelect('s1')
|
||||
->addSelect('s2')
|
||||
->leftJoin('t.suffix1','s1')
|
||||
->leftJoin('t.suffix2','s2');
|
||||
if ($this->direction == 1) {
|
||||
$query->where('t.string1 LIKE :str')->setParameter('str',$this->string."%");
|
||||
$query->orderBy('t.string1,t.id','ASC');
|
||||
} else if ($this->direction == 2) {
|
||||
$query->where('t.string2 LIKE :str')->setParameter('str', $this->string."%");
|
||||
$query->orderBy('t.string2','ASC');
|
||||
$query->addOrderBy('t.order2','ASC');
|
||||
}
|
||||
$query->andWhere('t.dictionary = :dict')->setParameter(':dict',$this->dictionary->id);
|
||||
if ($this->clen)
|
||||
$query->andWhere('t.member LIKE :clen')->setParameter('clen','%'.$this->clen.'%');
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
20
app/model/Database/Repository/TranslationRepository.php
Executable file
20
app/model/Database/Repository/TranslationRepository.php
Executable file
@@ -0,0 +1,20 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\Translation;
|
||||
|
||||
/**
|
||||
* @method Translation|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method Translation|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method Translation[] findAll()
|
||||
* @method Translation[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<Translation>
|
||||
*/
|
||||
class TranslationRepository extends AbstractRepository
|
||||
{
|
||||
public function findOneByEmail(string $email): ?Translation
|
||||
{
|
||||
return $this->findOneBy(['email' => $email]);
|
||||
}
|
||||
}
|
||||
22
app/model/Database/Repository/UserRepository.php
Executable file
22
app/model/Database/Repository/UserRepository.php
Executable file
@@ -0,0 +1,22 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database\Repository;
|
||||
|
||||
use App\Model\Database\Entity\User;
|
||||
|
||||
/**
|
||||
* @method User|NULL find($id, ?int $lockMode = NULL, ?int $lockVersion = NULL)
|
||||
* @method User|NULL findOneBy(array $criteria, array $orderBy = NULL)
|
||||
* @method User[] findAll()
|
||||
* @method User[] findBy(array $criteria, array $orderBy = NULL, ?int $limit = NULL, ?int $offset = NULL)
|
||||
* @extends AbstractRepository<User>
|
||||
*/
|
||||
class UserRepository extends AbstractRepository
|
||||
{
|
||||
|
||||
public function findOneByEmail(string $email): ?User
|
||||
{
|
||||
return $this->findOneBy(['email' => $email]);
|
||||
}
|
||||
|
||||
}
|
||||
61
app/model/Database/TRepositories.php
Executable file
61
app/model/Database/TRepositories.php
Executable file
@@ -0,0 +1,61 @@
|
||||
<?php declare(strict_types = 1);
|
||||
|
||||
namespace App\Model\Database;
|
||||
|
||||
use App\Model\Database\Entity\User;
|
||||
use App\Model\Database\Entity\Translation;
|
||||
use App\Model\Database\Entity\Term;
|
||||
use App\Model\Database\Entity\TermFlag;
|
||||
use App\Model\Database\Entity\Pronunciation;
|
||||
use App\Model\Database\Entity\DictType;
|
||||
use App\Model\Database\Entity\Dictionary;
|
||||
use App\Model\Database\Repository\UserRepository;
|
||||
use App\Model\Database\Repository\TranslationRepository;
|
||||
use App\Model\Database\Repository\TermRepository;
|
||||
use App\Model\Database\Repository\TermFlagRepository;
|
||||
use App\Model\Database\Repository\PronunciationRepository;
|
||||
use App\Model\Database\Repository\DictTypeRepository;
|
||||
use App\Model\Database\Repository\DictionaryRepository;
|
||||
|
||||
/**
|
||||
* @mixin EntityManager
|
||||
*/
|
||||
trait TRepositories
|
||||
{
|
||||
|
||||
public function getUserRepository(): UserRepository
|
||||
{
|
||||
return $this->getRepository(User::class);
|
||||
}
|
||||
|
||||
public function getTranslationRepository(): TranslationRepository
|
||||
{
|
||||
return $this->getRepository(Translation::class);
|
||||
}
|
||||
|
||||
public function getTermRepository(): TermRepository
|
||||
{
|
||||
return $this->getRepository(Term::class);
|
||||
}
|
||||
|
||||
public function getTermFlagRepository(): TermFlagRepository
|
||||
{
|
||||
return $this->getRepository(TermFlag::class);
|
||||
}
|
||||
|
||||
public function getPronunciationRepository(): PronunciationRepository
|
||||
{
|
||||
return $this->getRepository(Pronunciation::class);
|
||||
}
|
||||
|
||||
public function getDictTypeRepository(): DictTypeRepository
|
||||
{
|
||||
return $this->getRepository(DictType::class);
|
||||
}
|
||||
|
||||
public function getDictionaryRepository(): DictionaryRepository
|
||||
{
|
||||
return $this->getRepository(Dictionary::class);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user