Browse Source

remove manual torrent/page relations

main
ghost 1 year ago
parent
commit
f56f07ac29
  1. 8
      src/Controller/TorrentController.php
  2. 103
      src/Entity/ArticleTorrents.php
  3. 23
      src/Repository/ArticleTorrentsRepository.php
  4. 31
      templates/default/torrent/info.html.twig

8
src/Controller/TorrentController.php

@ -325,7 +325,7 @@ class TorrentController extends AbstractController
$torrent->getId() $torrent->getId()
); );
// Redirect to info article created // Redirect to info page
return $this->redirectToRoute( return $this->redirectToRoute(
'torrent_info', 'torrent_info',
[ [
@ -519,7 +519,7 @@ class TorrentController extends AbstractController
$torrentLocales->getId() $torrentLocales->getId()
); );
// Redirect to info article created // Redirect to info page
return $this->redirectToRoute( return $this->redirectToRoute(
'torrent_info', 'torrent_info',
[ [
@ -622,7 +622,7 @@ class TorrentController extends AbstractController
$torrentLocales->getId() $torrentLocales->getId()
); );
// Redirect to info article created // Redirect back to form
return $this->redirectToRoute( return $this->redirectToRoute(
'torrent_locales_edit', 'torrent_locales_edit',
[ [
@ -695,7 +695,7 @@ class TorrentController extends AbstractController
$torrentLocales->getId() $torrentLocales->getId()
); );
// Redirect to info article created // Redirect back to form
return $this->redirectToRoute( return $this->redirectToRoute(
'torrent_locales_edit', 'torrent_locales_edit',
[ [

103
src/Entity/ArticleTorrents.php

@ -1,103 +0,0 @@
<?php
namespace App\Entity;
use App\Repository\ArticleTorrentsRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: ArticleTorrentsRepository::class)]
class ArticleTorrents
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column]
private ?int $articleId = null;
#[ORM\Column]
private ?int $userId = null;
#[ORM\Column(type: Types::ARRAY)]
private array $torrentsId = [];
#[ORM\Column]
private ?int $added = null;
#[ORM\Column]
private ?bool $approved = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(string $id): static
{
$this->id = $id;
return $this;
}
public function getArticleId(): ?int
{
return $this->articleId;
}
public function setArticleId(int $articleId): static
{
$this->articleId = $articleId;
return $this;
}
public function getUserId(): ?int
{
return $this->userId;
}
public function setUserId(int $userId): static
{
$this->userId = $userId;
return $this;
}
public function getTorrentsId(): array
{
return $this->torrentsId;
}
public function setTorrentsId(array $torrentsId): static
{
$this->torrentsId = $torrentsId;
return $this;
}
public function getAdded(): ?int
{
return $this->added;
}
public function setAdded(int $added): static
{
$this->added = $added;
return $this;
}
public function isApproved(): ?bool
{
return $this->approved;
}
public function setApproved(bool $approved): static
{
$this->approved = $approved;
return $this;
}
}

23
src/Repository/ArticleTorrentsRepository.php

@ -1,23 +0,0 @@
<?php
namespace App\Repository;
use App\Entity\ArticleTorrents;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
/**
* @extends ServiceEntityRepository<ArticleTorrents>
*
* @method ArticleTorrents|null find($id, $lockMode = null, $lockVersion = null)
* @method ArticleTorrents|null findOneBy(array $criteria, array $orderBy = null)
* @method ArticleTorrents[] findAll()
* @method ArticleTorrents[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ArticleTorrentsRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, ArticleTorrents::class);
}
}

31
templates/default/torrent/info.html.twig

@ -264,7 +264,7 @@
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
</div> </div>
<div class="padding-y-8-px text-right"> <div class="text-right">
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_locales_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}"> <a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_locales_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/> <path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
@ -280,7 +280,7 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="padding-y-8-px text-right"> <div class="text-right">
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}"> <a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_sensitive_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/> <path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
@ -288,7 +288,7 @@
</a> </a>
{{ 'Sensitive'|trans }} {{ 'Sensitive'|trans }}
<div class="padding-b-8-px border-bottom-default"></div> <div class="padding-b-8-px border-bottom-default"></div>
<div class="padding-y-16-px text-left"> <div class="padding-t-16-px text-left">
{% if torrent.sensitive %} {% if torrent.sensitive %}
{{ 'Yes' | trans }} {{ 'Yes' | trans }}
{% else %} {% else %}
@ -296,31 +296,6 @@
{% endif %} {% endif %}
</div> </div>
</div> </div>
<div class="padding-y-8-px text-right">
<a class="margin-r-4-px{#opacity-0 parent-hover-opacity-09#}" href="{{ path('torrent_locales_edit', { torrentId : torrent.id }) }}" title="{{'Edit'|trans }}">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M12.854.146a.5.5 0 0 0-.707 0L10.5 1.793 14.207 5.5l1.647-1.646a.5.5 0 0 0 0-.708l-3-3zm.646 6.061L9.793 2.5 3.293 9H3.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.5h.5a.5.5 0 0 1 .5.5v.207l6.5-6.5zm-7.468 7.468A.5.5 0 0 1 6 13.5V13h-.5a.5.5 0 0 1-.5-.5V12h-.5a.5.5 0 0 1-.5-.5V11h-.5a.5.5 0 0 1-.5-.5V10h-.5a.499.499 0 0 1-.175-.032l-.179.178a.5.5 0 0 0-.11.168l-2 5a.5.5 0 0 0 .65.65l5-2a.5.5 0 0 0 .168-.11l.178-.178z"/>
</svg>
</a>
{{ 'Articles' | trans }}
<div class="padding-b-8-px border-bottom-default"></div>
<div class="padding-y-16-px text-left">
{% for article in torrent.articles %}
<div>
{{ article }}
</div>
{% endfor %}
<form name="articles" method="post" action="{{ path('article_submit') }}">
<input type="hidden" name="torrentId" value="{{ torrent.id }}" />
<button type="submit" class="button-green">
<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" fill="currentColor" viewBox="0 0 16 16">
<path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/>
</svg>
{{'Add'|trans }}
</button>
</form>
</div>
</div>
</div> </div>
{% if activities %} {% if activities %}
<a name="activity"></a> <a name="activity"></a>

Loading…
Cancel
Save