Browse Source

travail sur strucuture

reduction
Fab 4 years ago
parent
commit
e5fc06cc37
6 changed files with 106 additions and 1 deletions
  1. +29
    -0
      ShopBundle/Controller/AbstractController.php
  2. +43
    -0
      ShopBundle/Controller/MerchantController.php
  3. +1
    -1
      ShopBundle/Model/User.php
  4. +6
    -0
      ShopBundle/Resources/config/shop_routes.yaml
  5. +7
    -0
      ShopBundle/Resources/views/merchant/edit.html.twig
  6. +20
    -0
      ShopBundle/Resources/views/merchant/list.html.twig

+ 29
- 0
ShopBundle/Controller/AbstractController.php View File

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

namespace Lc\ShopBundle\Controller;

use Symfony\Bundle\FrameworkBundle\Controller\AbstractController as SfAbstractController;

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

/**
* @var object|string
* User currently connected
*/
protected $user;

public function __construct()
{

$this->em = $this->getDoctrine()->getManager();
$this->user = $this->get('security.token_storage')->getToken()->getUser();
}


}

+ 43
- 0
ShopBundle/Controller/MerchantController.php View File

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

namespace Lc\ShopBundle\Controller;

use App\Entity\Merchant;
use Lc\ShopBundle\Context\MerchantInterface;

class MerchantController extends AbstractController
{
protected $repo;
public function __construct()
{
$this->repo = $this->em->getRepository(MerchantInterface::class);

}


public function edit(){
$merchant = new Merchant();
$merchant->setCreatedBy($this->user);
$merchant->setUpdatedBy($this->user);

$this->em->persist($merchant);
$this->em->flush();
die();

$merchant = $this->repo->find($id);
dump($merchant);

return $this->render('@LcShop/merchant/edit.html.twig', [

]);
}


public function list(){
return $this->render('merchant/index.html.twig', [
'controller_name' => 'MerchantController',
]);
}


}

+ 1
- 1
ShopBundle/Model/User.php View File

@@ -9,7 +9,7 @@ use Lc\ShopBundle\Context\MerchantInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class User //extends UserModelFOS
abstract class User extends UserModelFOS
{

/**

+ 6
- 0
ShopBundle/Resources/config/shop_routes.yaml View File

@@ -0,0 +1,6 @@

lc_merchant_list:
path: /merchant/list
controller: LcShopBundle:Merchant:list



+ 7
- 0
ShopBundle/Resources/views/merchant/edit.html.twig View File

@@ -0,0 +1,7 @@
{% extends 'base.html.twig' %}

{% block title %}Hello MerchantController!{% endblock %}

{% block body %}
YEAH MEC!!!!
{% endblock %}

+ 20
- 0
ShopBundle/Resources/views/merchant/list.html.twig View File

@@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}

{% block title %}Hello MerchantController!{% endblock %}

{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>

<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>

This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/home/fab/Documents/Pro/www/pdl/sandbox/src/Controller/MerchantController.php'|file_link(0) }}">src/Controller/MerchantController.php</a></code></li>
<li>Your template at <code><a href="{{ '/home/fab/Documents/Pro/www/pdl/sandbox/templates/merchant/index.html.twig'|file_link(0) }}">templates/merchant/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}

Loading…
Cancel
Save