Guillaume 4 anos atrás
pai
commit
38a39ce90a
6 arquivos alterados com 106 adições e 1 exclusões
  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 Ver arquivo

@@ -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 Ver arquivo

@@ -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 Ver arquivo

@@ -11,7 +11,7 @@ use Lc\ShopBundle\Context\MerchantInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class User //extends UserModelFOS
abstract class User extends UserModelFOS
{
/**
* @ORM\Column(type="string", length=20, nullable=true)

+ 6
- 0
ShopBundle/Resources/config/shop_routes.yaml Ver arquivo

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

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



+ 7
- 0
ShopBundle/Resources/views/merchant/edit.html.twig Ver arquivo

@@ -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 Ver arquivo

@@ -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 %}

Carregando…
Cancelar
Salvar