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,17 +7,36 @@ parameters:
|
||||||
|
|
||||||
doctrine:
|
doctrine:
|
||||||
dbal:
|
dbal:
|
||||||
# configure these for your database server
|
default_connection: default
|
||||||
driver: 'pdo_sqlite'
|
connections:
|
||||||
url: '%env(resolve:DATABASE_URL)%'
|
default:
|
||||||
|
driver: 'pdo_pgsql'
|
||||||
|
url: '%env(resolve:APP_DATABASE_URL)%'
|
||||||
|
magneticod:
|
||||||
|
driver: 'pdo_sqlite'
|
||||||
|
url: '%env(resolve:MAGNETICOD_DATABASE_URL)%'
|
||||||
orm:
|
orm:
|
||||||
auto_generate_proxy_classes: '%kernel.debug%'
|
auto_generate_proxy_classes: '%kernel.debug%'
|
||||||
naming_strategy: doctrine.orm.naming_strategy.underscore
|
default_entity_manager: default
|
||||||
auto_mapping: true
|
entity_managers:
|
||||||
mappings:
|
default:
|
||||||
App:
|
connection: default
|
||||||
is_bundle: false
|
naming_strategy: doctrine.orm.naming_strategy.underscore
|
||||||
type: annotation
|
auto_mapping: true
|
||||||
dir: '%kernel.project_dir%/src/Entity'
|
mappings:
|
||||||
prefix: 'App\Entity'
|
App:
|
||||||
alias: App
|
is_bundle: false
|
||||||
|
type: annotation
|
||||||
|
dir: '%kernel.project_dir%/src/Entity'
|
||||||
|
prefix: 'App\Entity'
|
||||||
|
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)')
|
||||||
;
|
;
|
||||||
|
|
||||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
try {
|
||||||
|
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