Sfoglia il codice sorgente

Refactoring services

develop
Guillaume 3 anni fa
parent
commit
9c4aa9731e
9 ha cambiato i file con 126 aggiunte e 71 eliminazioni
  1. +13
    -37
      Doctrine/Extension/BlameableNullableTrait.php
  2. +8
    -12
      Repository/AbstractRepositoryQuery.php
  3. +17
    -0
      Repository/File/FileStore.php
  4. +17
    -0
      Repository/Newsletter/NewsletterStore.php
  5. +14
    -16
      Repository/RepositoryQueryInterface.php
  6. +17
    -0
      Repository/Setting/SiteSettingStore.php
  7. +17
    -0
      Repository/Site/SiteStore.php
  8. +17
    -0
      Repository/Ticket/TicketMessageStore.php
  9. +6
    -6
      Solver/Setting/SettingSolver.php

+ 13
- 37
Doctrine/Extension/BlameableNullableTrait.php Vedi File

@@ -9,43 +9,19 @@ use Lc\SovBundle\Model\User\UserInterface;
trait BlameableNullableTrait
{

/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;
/**
* @Gedmo\Blameable(on="create")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $createdBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;

/**
* @Gedmo\Blameable(on="update")
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $updatedBy;


public function getCreatedBy(): ?UserInterface
{
return $this->createdBy;
}

public function setCreatedBy(?UserInterface $createdBy): self
{
$this->createdBy = $createdBy;

return $this;
}

public function getUpdatedBy(): ?UserInterface
{
return $this->updatedBy;
}

public function setUpdatedBy(?UserInterface $updatedBy): self
{
$this->updatedBy = $updatedBy;

return $this;
}

}

+ 8
- 12
Repository/AbstractRepositoryQuery.php Vedi File

@@ -66,9 +66,10 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
return $this->query->getQuery()->getResult();
}

public function limit(int $maxResults)
public function limit(int $maxResults):self
{
return $this->query->setMaxResults($maxResults);
$this->query->setMaxResults($maxResults);
return $this;
}

public function paginate(int $page = 1, int $limit = 20)
@@ -120,7 +121,7 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
}
}

public function filterById(int $id)
public function filterById(int $id):self
{
return $this
->andWhere('.id = :id')
@@ -140,7 +141,7 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
/*
* SLUG
*/
public function filterBySlug(string $slug)
public function filterBySlug(string $slug):self
{
return $this
->andWhere('.slug = :slug')
@@ -150,17 +151,17 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
/*
* TREE
*/
public function filterIsParent()
public function filterIsParent():self
{
return $this->andWhere('.parent is NULL');
}

public function filterIsChildren()
public function filterIsChildren():self
{
return $this->andWhere('.parent is NOT NULL');
}

public function filterByParent(EntityInterface $parent)
public function filterByParent(EntityInterface $parent):self
{
return $this->andWhere('.parent = :parent')->setParameter('parent', $parent);
}
@@ -168,11 +169,6 @@ abstract class AbstractRepositoryQuery implements RepositoryQueryInterface
/*
* STATUS
*/
public function filterByStatus(int $status):self
{
return $this->andWhereStatus($this->id, $status);
}

public function filterIsOffline():self
{
return $this->andWhereStatus($this->id, 0);

+ 17
- 0
Repository/File/FileStore.php Vedi File

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Repository\File;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class FileStore extends AbstractStore implements FileStoreInterface
{
@@ -12,4 +13,20 @@ class FileStore extends AbstractStore implements FileStoreInterface
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Newsletter/NewsletterStore.php Vedi File

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Repository\Newsletter;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class NewsletterStore extends AbstractStore implements NewsletterStoreInterface
{
@@ -12,4 +13,20 @@ class NewsletterStore extends AbstractStore implements NewsletterStoreInterface
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 14
- 16
Repository/RepositoryQueryInterface.php Vedi File

@@ -9,7 +9,7 @@ interface RepositoryQueryInterface
{
public function create();

public function call(callable $fn): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function call(callable $fn):self;

public function count(): string;

@@ -17,35 +17,33 @@ interface RepositoryQueryInterface

public function find(): array;

public function limit(int $maxResults);
public function limit(int $maxResults):self;

public function paginate(int $page = 1, int $limit = 20);

public function getRepository(): ServiceEntityRepository;

public function groupBy(string $field): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function groupBy(string $field):self;

public function orderBy(string $field, string $sort = 'ASC'): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function orderBy(string $field, string $sort = 'ASC'):self;

public function filterById(int $id);
public function filterById(int $id):self;

public function filterByDevAlias(string $devAlias): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function filterByDevAlias(string $devAlias):self;

public function filterBySlug(string $slug);
public function filterBySlug(string $slug):self;

public function filterIsParent();
public function filterIsParent():self;

public function filterIsChildren();
public function filterIsChildren():self;

public function filterByParent(EntityInterface $parent);
public function filterByParent(EntityInterface $parent):self;

public function filterByStatus($status): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function filterIsOffline():self;

public function filterIsOffline(): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function filterIsOnline():self;

public function filterIsOnline(): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function filterIsDeleted():self;

public function filterIsDeleted(): \Lc\SovBundle\Repository\AbstractRepositoryQuery;

public function filterIsOnlineAndOffline(): \Lc\SovBundle\Repository\AbstractRepositoryQuery;
public function filterIsOnlineAndOffline():self;
}

+ 17
- 0
Repository/Setting/SiteSettingStore.php Vedi File

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Repository\Setting;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class SiteSettingStore extends AbstractStore implements SiteSettingStoreInterface
{
@@ -12,4 +13,20 @@ class SiteSettingStore extends AbstractStore implements SiteSettingStoreInterfac
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Site/SiteStore.php Vedi File

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Repository\Site;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class SiteStore extends AbstractStore implements SiteStoreInterface
{
@@ -12,4 +13,20 @@ class SiteStore extends AbstractStore implements SiteStoreInterface
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 17
- 0
Repository/Ticket/TicketMessageStore.php Vedi File

@@ -3,6 +3,7 @@
namespace Lc\SovBundle\Repository\Ticket;

use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

class TicketMessageStore extends AbstractStore implements TicketMessageStoreInterface
{
@@ -12,4 +13,20 @@ class TicketMessageStore extends AbstractStore implements TicketMessageStoreInte
{
$this->query = $query;
}
public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{

return $query;
}

public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
return $query;
}
}

+ 6
- 6
Solver/Setting/SettingSolver.php Vedi File

@@ -10,12 +10,12 @@ class SettingSolver
{
public function getValue(SettingInterface $setting)
{
if ($this->getText()) {
return $this->getText();
} elseif ($this->getDate()) {
return $this->getDate();
} elseif ($this->getFile()) {
return $this->getFile();
if ($setting->getText()) {
return $setting->getText();
} elseif ($setting->getDate()) {
return $setting->getDate();
} elseif ($setting->getFile()) {
return $setting->getFile();
}
}
}

Loading…
Annulla
Salva