瀏覽代碼

Refactoring Container

feature/symfony6.1
Fab 2 年之前
父節點
當前提交
d91a691934
共有 22 個檔案被更改,包括 91 行新增25 行删除
  1. +7
    -0
      Container/Newsletter/NewsletterContainer.php
  2. +6
    -0
      Container/Reminder/ReminderContainer.php
  3. +7
    -0
      Container/Setting/SiteSettingContainer.php
  4. +6
    -0
      Container/Site/NewsContainer.php
  5. +6
    -0
      Container/Site/PageContainer.php
  6. +5
    -0
      Container/Site/SiteContainer.php
  7. +7
    -0
      Container/Ticket/TicketContainer.php
  8. +5
    -0
      Container/Ticket/TicketMessageContainer.php
  9. +5
    -0
      Container/User/GroupUserContainer.php
  10. +5
    -0
      Container/User/UserContainer.php
  11. +1
    -1
      Controller/User/UserAdminController.php
  12. +0
    -1
      Factory/File/FileFactory.php
  13. +3
    -3
      Factory/Newsletter/NewsletterFactory.php
  14. +3
    -3
      Factory/Reminder/ReminderFactory.php
  15. +3
    -2
      Factory/Setting/SiteSettingFactory.php
  16. +3
    -3
      Factory/Site/NewsFactory.php
  17. +3
    -2
      Factory/Site/PageFactory.php
  18. +3
    -2
      Factory/Site/SiteFactory.php
  19. +3
    -2
      Factory/Ticket/TicketFactory.php
  20. +3
    -2
      Factory/Ticket/TicketMessageFactory.php
  21. +3
    -2
      Factory/User/GroupUserFactory.php
  22. +4
    -2
      Factory/User/UserFactory.php

+ 7
- 0
Container/Newsletter/NewsletterContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Newsletter;

use App\Entity\Newsletter\Newsletter;
use Lc\SovBundle\Definition\Field\Newsletter\NewsletterFieldDefinition;
use Lc\SovBundle\Factory\Newsletter\NewsletterFactory;
use Lc\SovBundle\Repository\Newsletter\NewsletterRepositoryQuery;
@@ -26,6 +27,12 @@ class NewsletterContainer
$this->fieldDefinition = $fieldDefinition;
}

public static function getEntityFqcn()
{
return Newsletter::class;
}


public function getFactory(): NewsletterFactory
{
return $this->factory;

+ 6
- 0
Container/Reminder/ReminderContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Reminder;

use App\Entity\Reminder\Reminder;
use Lc\SovBundle\Factory\Reminder\ReminderFactory;
use Lc\SovBundle\Repository\Reminder\ReminderRepositoryQuery;
use Lc\SovBundle\Repository\Reminder\ReminderStore;
@@ -22,6 +23,11 @@ class ReminderContainer
$this->store = $store;
}

public static function getEntityFqcn()
{
return Reminder::class;
}

public function getFactory(): ReminderFactory
{
return $this->factory;

+ 7
- 0
Container/Setting/SiteSettingContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Setting;

use App\Entity\Setting\SiteSetting;
use Lc\SovBundle\Definition\SiteSettingDefinition;
use Lc\SovBundle\Factory\Setting\SiteSettingFactory;
use Lc\SovBundle\Repository\Setting\SiteSettingRepositoryQuery;
@@ -30,6 +31,12 @@ class SiteSettingContainer
$this->settingSolver = $settingSolver;
}


public static function getEntityFqcn()
{
return SiteSetting::class;
}

public function getFactory(): SiteSettingFactory
{
return $this->factory;

+ 6
- 0
Container/Site/NewsContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Site;

use App\Entity\Site\News;
use Lc\SovBundle\Definition\Field\Site\NewsFieldDefinition;
use Lc\SovBundle\Factory\Site\NewsFactory;
use Lc\SovBundle\Repository\Site\NewsRepositoryQuery;
@@ -26,6 +27,11 @@ class NewsContainer
$this->fieldDefinition = $fieldDefinition;
}


public static function getEntityFqcn()
{
return News::class;
}
public function getFactory(): NewsFactory
{
return $this->factory;

+ 6
- 0
Container/Site/PageContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Site;

use App\Entity\Site\Page;
use Lc\SovBundle\Definition\Field\Site\PageFieldDefinition;
use Lc\SovBundle\Factory\Site\PageFactory;
use Lc\SovBundle\Repository\Site\PageRepositoryQuery;
@@ -26,6 +27,11 @@ class PageContainer
$this->fieldDefinition = $fieldDefinition;
}

public static function getEntityFqcn()
{
return Page::class;
}

public function getFactory(): PageFactory
{
return $this->factory;

+ 5
- 0
Container/Site/SiteContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Site;

use App\Entity\Site\Site;
use Lc\SovBundle\Factory\Site\SiteFactory;
use Lc\SovBundle\Repository\Site\SiteRepositoryQuery;
use Lc\SovBundle\Repository\Site\SiteStore;
@@ -22,6 +23,10 @@ class SiteContainer
$this->store = $store;
}

public static function getEntityFqcn()
{
return Site::class;
}
public function getFactory(): SiteFactory
{
return $this->factory;

+ 7
- 0
Container/Ticket/TicketContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Ticket;

use App\Entity\Ticket\Ticket;
use Lc\SovBundle\Builder\Ticket\TicketBuilder;
use Lc\SovBundle\Definition\Field\Ticket\TicketFieldDefinition;
use Lc\SovBundle\Factory\Ticket\TicketFactory;
@@ -34,6 +35,12 @@ class TicketContainer
$this->fieldDefinition = $fieldDefinition;
}


public static function getEntityFqcn()
{
return Ticket::class;
}

public function getFactory(): TicketFactory
{
return $this->factory;

+ 5
- 0
Container/Ticket/TicketMessageContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\Ticket;

use App\Entity\Ticket\TicketMessage;
use Lc\SovBundle\Builder\Ticket\TicketMessageBuilder;
use Lc\SovBundle\Factory\Ticket\TicketMessageFactory;
use Lc\SovBundle\Repository\Ticket\TicketMessageRepositoryQuery;
@@ -26,6 +27,10 @@ class TicketMessageContainer
$this->builder = $builder;
}

public static function getEntityFqcn()
{
return TicketMessage::class;
}
public function getFactory(): TicketMessageFactory
{
return $this->factory;

+ 5
- 0
Container/User/GroupUserContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\User;

use App\Entity\User\GroupUser;
use Lc\SovBundle\Factory\User\GroupUserFactory;
use Lc\SovBundle\Repository\User\GroupUserRepositoryQuery;
use Lc\SovBundle\Repository\User\GroupUserStore;
@@ -22,6 +23,10 @@ class GroupUserContainer
$this->store = $store;
}

public static function getEntityFqcn()
{
return GroupUser::class;
}
public function getFactory(): GroupUserFactory
{
return $this->factory;

+ 5
- 0
Container/User/UserContainer.php 查看文件

@@ -2,6 +2,7 @@

namespace Lc\SovBundle\Container\User;

use App\Entity\User\User;
use Lc\SovBundle\Builder\User\UserBuilder;
use Lc\SovBundle\Definition\Field\User\UserFieldDefinition;
use Lc\SovBundle\Definition\RolesDefinitionInterface;
@@ -37,6 +38,10 @@ class UserContainer
$this->fieldDefinition = $fieldDefinition;
$this->rolesDefinition = $rolesDefinition;
}
public static function getEntityFqcn()
{
return User::class;
}

public function getFactory(): UserFactory
{

+ 1
- 1
Controller/User/UserAdminController.php 查看文件

@@ -100,7 +100,7 @@ abstract class UserAdminController extends AbstractAdminController

$entityInstance = $event->getEntityInstance();

ApplicationDefinition::getSubscribedContainerServices();
ApplicationDefinition::getSubscribedContainerServices();


$metas = $this->getEntityManager()->getMetadataFactory()->getAllMetadata();

+ 0
- 1
Factory/File/FileFactory.php 查看文件

@@ -2,7 +2,6 @@

namespace Lc\SovBundle\Factory\File;

use App\Entity\File\File;
use Lc\SovBundle\Container\File\FileContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\File\FileInterface;

+ 3
- 3
Factory/Newsletter/NewsletterFactory.php 查看文件

@@ -2,8 +2,7 @@

namespace Lc\SovBundle\Factory\Newsletter;

use App\Entity\Newsletter\Newsletter;
use Lc\SovBundle\Definition\ApplicationDefinition;
use Lc\SovBundle\Container\Newsletter\NewsletterContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;

@@ -11,7 +10,8 @@ class NewsletterFactory extends AbstractFactory
{
public function create(): NewsletterInterface
{
$newsletter = new Newsletter();
$class = NewsletterContainer::getEntityFqcn();
$newsletter = new $class;

return $newsletter;
}

+ 3
- 3
Factory/Reminder/ReminderFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Reminder;

use App\Entity\Reminder\Reminder;
use Lc\SovBundle\Container\Reminder\ReminderContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Reminder\ReminderInterface;

@@ -13,8 +13,8 @@ class ReminderFactory extends AbstractFactory implements ReminderFactoryInterfac
string $crudControllerFqcn = null,
int $entityId = null
): ReminderInterface {
$reminder = new Reminder();
$class = ReminderContainer::getEntityFqcn();
$reminder = new $class;
$reminder->setCrudAction($crudAction);
$reminder->setCrudControllerFqcn($crudControllerFqcn);
$reminder->setEntityId($entityId);

+ 3
- 2
Factory/Setting/SiteSettingFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Setting;

use App\Entity\Setting\SiteSetting;
use Lc\SovBundle\Container\Setting\SiteSettingContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\File\FileInterface;
use Lc\SovBundle\Model\Setting\SiteSettingInterface;
@@ -12,7 +12,8 @@ class SiteSettingFactory extends AbstractFactory implements SiteSettingFactoryIn
{
public function create(SiteInterface $site, string $name, string $text = null, \DateTime $date = null, FileInterface $file = null): SiteSettingInterface
{
$siteSetting = new SiteSetting();
$class = SiteSettingContainer::getEntityFqcn();
$siteSetting = new $class;

$siteSetting->setSite($site);
$siteSetting->setName($name);

+ 3
- 3
Factory/Site/NewsFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Site;

use App\Entity\Site\News;
use Lc\SovBundle\Container\Site\NewsContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Site\NewsInterface;

@@ -10,8 +10,8 @@ class NewsFactory extends AbstractFactory implements NewsFactoryInterface
{
public function create(): NewsInterface
{
$news = new News();
$class = NewsContainer::getEntityFqcn();
$news = new $class;
$news->setStatus(1);

return $news;

+ 3
- 2
Factory/Site/PageFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Site;

use App\Entity\Site\Page;
use Lc\SovBundle\Container\Site\PageContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Site\PageInterface;

@@ -10,7 +10,8 @@ class PageFactory extends AbstractFactory implements PageFactoryInterface
{
public function create(): PageInterface
{
$page = new Page();
$class = PageContainer::getEntityFqcn();
$page = new $class;

$page->setStatus(1);


+ 3
- 2
Factory/Site/SiteFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Site;

use App\Entity\Site\Site;
use Lc\SovBundle\Container\Site\SiteContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Site\SiteInterface;

@@ -10,7 +10,8 @@ class SiteFactory extends AbstractFactory implements SiteFactoryInterface
{
public function create(string $devAlias = null): SiteInterface
{
$site = new Site();
$class = SiteContainer::getEntityFqcn();
$site = new $class;

$site->setDevAlias($devAlias);


+ 3
- 2
Factory/Ticket/TicketFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Ticket;

use App\Entity\Ticket\Ticket;
use Lc\SovBundle\Container\Ticket\TicketContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketModel;
@@ -11,7 +11,8 @@ class TicketFactory extends AbstractFactory implements TicketFactoryInterface
{
public function create(): TicketInterface
{
$ticket = new Ticket();
$class = TicketContainer::getEntityFqcn();
$ticket = new $class;

$ticketMessageFactory = new TicketMessageFactory();
$ticketMessage = $ticketMessageFactory->create($ticket) ;

+ 3
- 2
Factory/Ticket/TicketMessageFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\Ticket;

use App\Entity\Ticket\TicketMessage;
use Lc\SovBundle\Container\Ticket\TicketMessageContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\Ticket\TicketMessageInterface;
@@ -11,7 +11,8 @@ class TicketMessageFactory extends AbstractFactory implements TicketMessageFacto
{
public function create(TicketInterface $ticket): TicketMessageInterface
{
$ticketMessage = new TicketMessage();
$class = TicketMessageContainer::getEntityFqcn();
$ticketMessage = new $class;

$ticketMessage->setTicket($ticket);
$ticketMessage->setStatus(1);

+ 3
- 2
Factory/User/GroupUserFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\User;

use App\Entity\User\GroupUser;
use Lc\SovBundle\Container\User\GroupUserContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\User\GroupUserInterface;

@@ -10,7 +10,8 @@ class GroupUserFactory extends AbstractFactory implements GroupUserFactoryInterf
{
public function create(): GroupUserInterface
{
$groupUser = new GroupUser();
$class = GroupUserContainer::getEntityFqcn();
$groupUser = new $class;

$groupUser->setStatus(1);


+ 4
- 2
Factory/User/UserFactory.php 查看文件

@@ -2,7 +2,7 @@

namespace Lc\SovBundle\Factory\User;

use App\Entity\User\User;
use Lc\SovBundle\Container\User\UserContainer;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\User\UserInterface;

@@ -10,7 +10,9 @@ class UserFactory extends AbstractFactory
{
public function create(): UserInterface
{
$user = new User();

$class = UserContainer::getEntityFqcn();
$user = new $class;

return $user;
}

Loading…
取消
儲存