Przeglądaj źródła

Installation EasyAdminBundle

reduction
Guillaume 4 lat temu
rodzic
commit
1ee947b3a5
4 zmienionych plików z 0 dodań i 166 usunięć
  1. +0
    -99
      ShopBundle/Controller/AbstractController.php
  2. +0
    -10
      ShopBundle/Controller/Admin/TaxRateAdminController.php
  3. +0
    -27
      ShopBundle/Controller/CreditConfigController.php
  4. +0
    -30
      ShopBundle/Controller/TaxRateController.php

+ 0
- 99
ShopBundle/Controller/AbstractController.php Wyświetl plik

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

namespace Lc\ShopBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditHistoryInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as SfAbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

abstract class AbstractController extends SfAbstractController
{
/**
* @var \Doctrine\Persistence\ObjectManager
* Entity manager
*/
protected $em;

public $class;

public $type;

public $template;

public $routePrefix;

public $repos;


public function __construct(EntityManagerInterface $entityManager)
{
$this->em = $entityManager;
$metadata = $this->em->getClassMetadata($this->class);
$this->class = $metadata->getName();
$this->repo = $this->em->getRepository($this->class);

}

public function indexAction(): Response
{
$repo = $this->em->getRepository($this->class);
return $this->render('LcShopBundle:' . $this->template . ':index.html.twig', [
'entities' => $repo->findAll(),
'routePrefix'=> $this->routePrefix
]);
}

public function showAction($id): Response
{
$enity = $this->repo->find($id);

return $this->render('LcShopBundle:'.$this->template.':show.html.twig', [
'entity' => $enity,
'routePrefix'=> $this->routePrefix

]);
}
public function editAction(Request $request, $id): Response
{

if ($id == 'new') {
$entity = new $this->class;
} else {
$repo = $this->em->getRepository($this->class);
$entity = $repo->find($id);
}
$form = $this->createForm($this->type, $entity);
$form->handleRequest($request);

if ($form->isSubmitted() && $form->isValid()) {
$this->em->persist($entity);
$this->getDoctrine()->getManager()->flush();

return $this->redirectToRoute($this->routePrefix . '_index');
}


return $this->render('LcShopBundle:' . $this->template . ':edit.html.twig', [
'entity' => $entity,
'form' => $form->createView(),
'routePrefix'=> $this->routePrefix
]);
}


public function deleteAction(Request $request, $id): Response
{
$enity = $this->repo->find($id);

if ($this->isCsrfTokenValid('delete'.$enity->getId(), $request->request->get('_token'))) {
$entityManager = $this->getDoctrine()->getManager();
$entityManager->remove($enity);
$entityManager->flush();
}

return $this->redirectToRoute($this->routePrefix.'_index');
}

}

+ 0
- 10
ShopBundle/Controller/Admin/TaxRateAdminController.php Wyświetl plik

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

namespace Lc\ShopBundle\Controller\Admin;

use Lc\ShopBundle\Controller\Admin\AdminController;

class TaxRateAdminController extends AdminController
{

}

+ 0
- 27
ShopBundle/Controller/CreditConfigController.php Wyświetl plik

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

namespace Lc\ShopBundle\Controller;


use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\CreditConfigInterface;
use Lc\ShopBundle\Form\CreditConfigType;

class CreditConfigController extends AbstractController
{

protected $repo;

public function __construct(EntityManagerInterface $entityManager)
{
//Cette valeur sera récrite dans le AbstractController pour qu'elle pointe vers l'entité et non plus l'interface
$this->class = CreditConfigInterface::class;
$this->type = CreditConfigType::class;
$this->template = "default";
$this->routePrefix = "lc_shop_credit_config";

parent::__construct($entityManager);

}

}

+ 0
- 30
ShopBundle/Controller/TaxRateController.php Wyświetl plik

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

namespace Lc\ShopBundle\Controller;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Form\TaxRateType;

class TaxRateController extends AbstractController
{

protected $repo;

public function __construct(EntityManagerInterface $entityManager)
{
//Cette valeur sera récrite dans le AbstractController pour qu'elle pointe vers l'entité et non plus l'interface
$this->class = TaxRateInterface::class;
$this->type = TaxRateType::class;
$this->template = "default";
$this->routePrefix = "lc_shop_tax_rate";

parent::__construct($entityManager);

}

public function newBeforeFlush(){

}

}

Ładowanie…
Anuluj
Zapisz