瀏覽代碼

Ecriture des controller

feature/ticket
Fab 3 年之前
父節點
當前提交
c63878a3df
共有 3 個檔案被更改,包括 86 行新增6 行删除
  1. +1
    -6
      Controller/Common/TaxRateCrudController.php
  2. +64
    -0
      Controller/User/GroupUserCrudController.php
  3. +21
    -0
      Repository/File/DocumentRepository.php

+ 1
- 6
Controller/Common/TaxRateCrudController.php 查看文件

@@ -6,15 +6,10 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\SovBundle\Controller\Admin\AbstractCrudController;

class TaxRateCrudController extends AbstractCrudController
abstract class TaxRateCrudController extends AbstractCrudController
{
public static function getEntityFqcn(): string
{
return TaxRateInterface::class;
}

public function configureCrud(Crud $crud): Crud
{

+ 64
- 0
Controller/User/GroupUserCrudController.php 查看文件

@@ -0,0 +1,64 @@
<?php

namespace Lc\CaracoleBundle\Controller\User;

use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AbstractCrudController;
use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;

abstract class GroupUserCrudController extends AbstractCrudController
{


public function configureCrud(Crud $crud): Crud
{
return $crud
->setSearchFields(['id', 'title', 'description', 'devAlias', 'position', 'status', 'slug', 'image', 'metaTitle', 'metaDescription', 'oldUrls'])
->setPaginatorPageSize(50)
->setEntityPermission('ROLE_ADMIN')
->overrideTemplate('layout', '@LcShop/backend/default/layout/layout.html.twig')
->overrideTemplate('menu', '@LcShop/backend/default/menu.html.twig')
->overrideTemplate('crud/edit', '@LcShop/backend/default/edit.html.twig')
->overrideTemplate('crud/index', '@LcShop/backend/default/list.html.twig')
->overrideTemplate('crud/new', '@LcShop/backend/default/new.html.twig')
->overrideTemplate('crud/paginator', '@LcShop/backend/default/block/paginator.html.twig');
}

public function configureFields(string $pageName): iterable
{
$title = TextField::new('title');
$devAlias = TextField::new('devAlias');
$id = IntegerField::new('id', 'ID');
$description = TextareaField::new('description');
$createdAt = DateTimeField::new('createdAt');
$updatedAt = DateTimeField::new('updatedAt');
$position = NumberField::new('position');
$status = Field::new('status')->setTemplatePath('@LcShop/backend/default/field/toggle.html.twig');
$slug = TextField::new('slug');
$image = TextField::new('image');
$metaTitle = TextField::new('metaTitle');
$metaDescription = TextareaField::new('metaDescription');
$oldUrls = ArrayField::new('oldUrls');
$merchant = AssociationField::new('merchant');
$users = AssociationField::new('users');
$createdBy = AssociationField::new('createdBy');
$updatedBy = AssociationField::new('updatedBy');

if (Crud::PAGE_INDEX === $pageName) {
return [$title, $status];
} elseif (Crud::PAGE_DETAIL === $pageName) {
return [$id, $title, $description, $devAlias, $createdAt, $updatedAt, $position, $status, $slug, $image, $metaTitle, $metaDescription, $oldUrls, $merchant, $users, $createdBy, $updatedBy];
} elseif (Crud::PAGE_NEW === $pageName) {
return [$title, $devAlias];
} elseif (Crud::PAGE_EDIT === $pageName) {
return [$title, $devAlias];
}
}
}

+ 21
- 0
Repository/File/DocumentRepository.php 查看文件

@@ -0,0 +1,21 @@
<?php

namespace Lc\CaracoleBundle\Repository\File;

use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Lc\CaracoleBundle\Model\File\DocumentInterface;

/**
* @method DocumentInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method DocumentInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method DocumentInterface[] findAll()
* @method DocumentInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class DocumentRepository extends ServiceEntityRepository
{
public function __construct(ManagerRegistry $registry)
{
parent::__construct($registry, DocumentInterface::class);
}
}

Loading…
取消
儲存