Separated Entity Managers for magneticod SQLite database and app's PostgreSQL database implemented. Some refactoring has been made.
This commit is contained in:
parent
70f8fef9a2
commit
11d89c8a10
|
@ -7,11 +7,20 @@ parameters:
|
||||||
|
|
||||||
doctrine:
|
doctrine:
|
||||||
dbal:
|
dbal:
|
||||||
# configure these for your database server
|
default_connection: default
|
||||||
|
connections:
|
||||||
|
default:
|
||||||
|
driver: 'pdo_pgsql'
|
||||||
|
url: '%env(resolve:APP_DATABASE_URL)%'
|
||||||
|
magneticod:
|
||||||
driver: 'pdo_sqlite'
|
driver: 'pdo_sqlite'
|
||||||
url: '%env(resolve:DATABASE_URL)%'
|
url: '%env(resolve:MAGNETICOD_DATABASE_URL)%'
|
||||||
orm:
|
orm:
|
||||||
auto_generate_proxy_classes: '%kernel.debug%'
|
auto_generate_proxy_classes: '%kernel.debug%'
|
||||||
|
default_entity_manager: default
|
||||||
|
entity_managers:
|
||||||
|
default:
|
||||||
|
connection: default
|
||||||
naming_strategy: doctrine.orm.naming_strategy.underscore
|
naming_strategy: doctrine.orm.naming_strategy.underscore
|
||||||
auto_mapping: true
|
auto_mapping: true
|
||||||
mappings:
|
mappings:
|
||||||
|
@ -21,3 +30,13 @@ doctrine:
|
||||||
dir: '%kernel.project_dir%/src/Entity'
|
dir: '%kernel.project_dir%/src/Entity'
|
||||||
prefix: 'App\Entity'
|
prefix: 'App\Entity'
|
||||||
alias: App
|
alias: App
|
||||||
|
magneticod:
|
||||||
|
connection: magneticod
|
||||||
|
mappings:
|
||||||
|
Magnetico:
|
||||||
|
is_bundle: false
|
||||||
|
type: annotation
|
||||||
|
dir: '%kernel.project_dir%/src/Magnetico/Entity'
|
||||||
|
prefix: 'App\Magnetico'
|
||||||
|
alias: Magnetico
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,8 @@ namespace App\Api\V1\Controller;
|
||||||
|
|
||||||
use App\Api\V1\DTO\ApiResponse;
|
use App\Api\V1\DTO\ApiResponse;
|
||||||
use App\Api\V1\DTO\ListPage;
|
use App\Api\V1\DTO\ListPage;
|
||||||
use App\Entity\Torrent;
|
use App\Magnetico\Entity\Torrent;
|
||||||
use App\Repository\TorrentRepository;
|
use App\Magnetico\Repository\TorrentRepository;
|
||||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||||
use Pagerfanta\Pagerfanta;
|
use Pagerfanta\Pagerfanta;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Repository\TorrentRepository;
|
use App\Magnetico\Repository\TorrentRepository;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Torrent;
|
use App\Magnetico\Entity\Torrent;
|
||||||
use App\Repository\TorrentRepository;
|
use App\Magnetico\Repository\TorrentRepository;
|
||||||
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
use Pagerfanta\Adapter\DoctrineORMAdapter;
|
||||||
use Pagerfanta\Pagerfanta;
|
use Pagerfanta\Pagerfanta;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Magnetico\Entity;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Serializer\Annotation as Serializer;
|
use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
|
@ -24,7 +24,7 @@ class File
|
||||||
/**
|
/**
|
||||||
* @var Torrent
|
* @var Torrent
|
||||||
*
|
*
|
||||||
* @ORM\ManyToOne(targetEntity="App\Entity\Torrent", inversedBy="files")
|
* @ORM\ManyToOne(targetEntity="App\Magnetico\Entity\Torrent", inversedBy="files")
|
||||||
* @ORM\JoinColumn(name="torrent_id")
|
* @ORM\JoinColumn(name="torrent_id")
|
||||||
*/
|
*/
|
||||||
private $torrent;
|
private $torrent;
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity;
|
namespace App\Magnetico\Entity;
|
||||||
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
@ -11,7 +11,7 @@ use Symfony\Component\Serializer\Annotation as Serializer;
|
||||||
* @ORM\Index(name="discovered_on_index", columns={"discovered_on"}),
|
* @ORM\Index(name="discovered_on_index", columns={"discovered_on"}),
|
||||||
* @ORM\Index(name="info_hash_index", columns={"info_hash"})
|
* @ORM\Index(name="info_hash_index", columns={"info_hash"})
|
||||||
* })
|
* })
|
||||||
* @ORM\Entity(readOnly=true, repositoryClass="App\Repository\TorrentRepository")
|
* @ORM\Entity(readOnly=true, repositoryClass="App\Magnetico\Repository\TorrentRepository")
|
||||||
*/
|
*/
|
||||||
class Torrent
|
class Torrent
|
||||||
{
|
{
|
||||||
|
@ -71,7 +71,7 @@ class Torrent
|
||||||
*
|
*
|
||||||
* @Serializer\Groups({"api_v1_show"})
|
* @Serializer\Groups({"api_v1_show"})
|
||||||
*
|
*
|
||||||
* @ORM\OneToMany(targetEntity="App\Entity\File", fetch="EXTRA_LAZY", mappedBy="torrent")
|
* @ORM\OneToMany(targetEntity="App\Magnetico\Entity\File", fetch="EXTRA_LAZY", mappedBy="torrent")
|
||||||
*/
|
*/
|
||||||
private $files;
|
private $files;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Repository;
|
namespace App\Magnetico\Repository;
|
||||||
|
|
||||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
|
@ -10,7 +10,7 @@ class TorrentRepository extends ServiceEntityRepository
|
||||||
{
|
{
|
||||||
public function __construct(RegistryInterface $registry)
|
public function __construct(RegistryInterface $registry)
|
||||||
{
|
{
|
||||||
parent::__construct($registry, \App\Entity\Torrent::class);
|
parent::__construct($registry, \App\Magnetico\Entity\Torrent::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTorrentsTotalCount(): int
|
public function getTorrentsTotalCount(): int
|
||||||
|
@ -19,7 +19,11 @@ class TorrentRepository extends ServiceEntityRepository
|
||||||
->select('COUNT(t.id)')
|
->select('COUNT(t.id)')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
try {
|
||||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||||
|
} catch (\Exception $ex) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createFindLikeQueryBuilder(string $query): QueryBuilder
|
public function createFindLikeQueryBuilder(string $query): QueryBuilder
|
|
@ -13,7 +13,7 @@
|
||||||
<th scope="col">Discovered</th>
|
<th scope="col">Discovered</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{# @var torrent \App\Entity\Torrent #}
|
{# @var torrent \App\Magnetico\Entity\Torrent #}
|
||||||
{% for torrent in torrents %}
|
{% for torrent in torrents %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ magnet(torrent.name, torrent.infoHash) }}">🔗</a></td>
|
<td><a href="{{ magnet(torrent.name, torrent.infoHash) }}">🔗</a></td>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends 'base.html.twig' %}
|
{% extends 'base.html.twig' %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{# @var torrent \App\Entity\Torrent #}
|
{# @var torrent \App\Magnetico\Entity\Torrent #}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tr>
|
<tr>
|
||||||
<td>Name</td>
|
<td>Name</td>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{# @var file \App\Entity\File #}
|
{# @var file \App\Magnetico\Entity\File #}
|
||||||
{% for file in torrent.files | sort %}
|
{% for file in torrent.files | sort %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ file.path }}</td>
|
<td>{{ file.path }}</td>
|
||||||
|
|
Loading…
Reference in a new issue