<?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(); | |||||
} | |||||
} |
<?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', | |||||
]); | |||||
} | |||||
} |
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class User //extends UserModelFOS | |||||
abstract class User extends UserModelFOS | |||||
{ | { | ||||
/** | /** | ||||
* @ORM\Column(type="string", length=20, nullable=true) | * @ORM\Column(type="string", length=20, nullable=true) |
lc_merchant_list: | |||||
path: /merchant/list | |||||
controller: LcShopBundle:Merchant:list | |||||
{% extends 'base.html.twig' %} | |||||
{% block title %}Hello MerchantController!{% endblock %} | |||||
{% block body %} | |||||
YEAH MEC!!!! | |||||
{% endblock %} |
{% 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 %} |