create controller for front office

This commit is contained in:
Manuel Raynaud
2013-08-12 15:27:19 +02:00
parent 13e380a498
commit 7c6763ea59
10 changed files with 82 additions and 22 deletions

View File

@@ -55,12 +55,6 @@
<argument type="service" id="service_container" /> <argument type="service" id="service_container" />
</service> </service>
<service id="thelia.controller_listener" class="Thelia\Core\EventListener\ControllerListener" scope="request">
<tag name="kernel.event_subscriber"/>
<argument type="service" id="thelia.parser.context"/>
</service>
<!-- <!--
A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations, A ControllerResolver that supports "a:b:c", "service:method" and class::method" notations,
thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html) thus allowing the definition of controllers as service (see http://symfony.com/fr/doc/current/cookbook/controller/service.html)

View File

@@ -42,12 +42,12 @@
<argument>%thelia.core_dir%/Config/Resources/routing</argument> <argument>%thelia.core_dir%/Config/Resources/routing</argument>
</service> </service>
<service id="router.admin.xmlLoader" class="Symfony\Component\Routing\Loader\XmlFileLoader"> <service id="router.xmlLoader" class="Symfony\Component\Routing\Loader\XmlFileLoader">
<argument type="service" id="router.admin.fileLocator"/> <argument type="service" id="router.admin.fileLocator"/>
</service> </service>
<service id="router.admin" class="%router.class%"> <service id="router.admin" class="%router.class%">
<argument type="service" id="router.admin.xmlLoader"/> <argument type="service" id="router.xmlLoader"/>
<argument>admin.xml</argument> <argument>admin.xml</argument>
<argument type="collection"> <argument type="collection">
<argument key="cache_dir">%kernel.cache_dir%</argument> <argument key="cache_dir">%kernel.cache_dir%</argument>
@@ -56,6 +56,16 @@
<argument type="service" id="request.context"/> <argument type="service" id="request.context"/>
</service> </service>
<service id="router.front" class="%router.class%">
<argument type="service" id="router.xmlLoader"/>
<argument>front.xml</argument>
<argument type="collection">
<argument key="cache_dir">%kernel.cache_dir%</argument>
<argument key="debug">%kernel.debug%</argument>
</argument>
<argument type="service" id="request.context"/>
</service>
<service id="router.chainRequest" class="%router.chainRouter.class%"> <service id="router.chainRequest" class="%router.chainRouter.class%">
<call method="setContext"> <call method="setContext">
<argument type="service" id="request.context"/> <argument type="service" id="request.context"/>
@@ -64,10 +74,15 @@
<argument type="service" id="router.default_route"/> <argument type="service" id="router.default_route"/>
<argument>-255</argument> <argument>-255</argument>
</call> </call>
<call method="add"> <call method="add">
<argument type="service" id="router.admin"/> <argument type="service" id="router.admin"/>
<argument>0</argument> <argument>0</argument>
</call> </call>
<call method="add">
<argument type="service" id="router.front"/>
<argument>255</argument>
</call>
</service> </service>
<service id="listener.router" class="Symfony\Component\HttpKernel\EventListener\RouterListener"> <service id="listener.router" class="Symfony\Component\HttpKernel\EventListener\RouterListener">

View File

@@ -6,39 +6,39 @@
<!-- Route to administration base --> <!-- Route to administration base -->
<route id="admin" path="/admin"> <route id="admin" path="/admin">
<default key="_controller">Thelia\Admin\Controller\AdminController::indexAction</default> <default key="_controller">Thelia\Controller\Admin\AdminController::indexAction</default>
</route> </route>
<!-- Route to the administration login page --> <!-- Route to the administration login page -->
<route id="admin.login" path="/admin/login"> <route id="admin.login" path="/admin/login">
<default key="_controller">Thelia\Admin\Controller\SessionController::showLoginAction</default> <default key="_controller">Thelia\Controller\Admin\SessionController::showLoginAction</default>
</route> </route>
<!-- Route to the administration logout page --> <!-- Route to the administration logout page -->
<route id="admin.logout" path="/admin/logout"> <route id="admin.logout" path="/admin/logout">
<default key="_controller">Thelia\Admin\Controller\SessionController::checkLogoutAction</default> <default key="_controller">Thelia\Controller\Admin\SessionController::checkLogoutAction</default>
</route> </route>
<!-- Route to the login check controller --> <!-- Route to the login check controller -->
<route id="admin.checklogin" path="/admin/checklogin"> <route id="admin.checklogin" path="/admin/checklogin">
<default key="_controller">Thelia\Admin\Controller\SessionController::checkLoginAction</default> <default key="_controller">Thelia\Controller\Admin\SessionController::checkLoginAction</default>
</route> </route>
<!-- Route to the catalog controller (process category browsing) --> <!-- Route to the catalog controller (process category browsing) -->
<route id="admin.catalog" path="/admin/catalog"> <route id="admin.catalog" path="/admin/catalog">
<default key="_controller">Thelia\Admin\Controller\CategoryController::indexAction</default> <default key="_controller">Thelia\Controller\Admin\CategoryController::indexAction</default>
</route> </route>
<route id="admin.category" path="/admin/catalog/category"> <route id="admin.category" path="/admin/catalog/category">
<default key="_controller">Thelia\Admin\Controller\CategoryController::processAction</default> <default key="_controller">Thelia\Controller\Admin\CategoryController::processAction</default>
</route> </route>
<!-- The default route, to display a template --> <!-- The default route, to display a template -->
<route id="admin.processTemplate" path="/admin/{template}"> <route id="admin.processTemplate" path="/admin/{template}">
<default key="_controller">Thelia\Admin\Controller\AdminController::processTemplateAction</default> <default key="_controller">Thelia\Controller\Admin\AdminController::processTemplateAction</default>
<requirement key="template">.*</requirement> <requirement key="template">.*</requirement>
</route> </route>
</routes> </routes>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8" ?>
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing http://symfony.com/schema/routing/routing-1.0.xsd">
<route id="customer.create" path="customer/create">
<default key="_controller">Thelia\Controller\Front\CustomerController::createAction</default>
</route>
</routes>

View File

@@ -23,7 +23,9 @@
namespace Thelia\Admin\Controller; namespace Thelia\Admin\Controller;
class AdminController extends BaseAdminController { use Thelia\Controller\BaseController;
class AdminController extends BaseController {
public function indexAction() public function indexAction()
{ {

View File

@@ -26,8 +26,9 @@ namespace Thelia\Admin\Controller;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\AuthorizationException; use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Controller\BaseController;
class CategoryController extends BaseAdminController { class CategoryController extends BaseController {
protected function createNewCategory($args) { protected function createNewCategory($args) {
$this->dispatchEvent("createCategory"); $this->dispatchEvent("createCategory");

View File

@@ -32,8 +32,9 @@ use Symfony\Component\Validator\Exception\ValidatorException;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Tools\Redirect; use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Controller\BaseController;
class SessionController extends BaseAdminController { class SessionController extends BaseController {
public function showLoginAction() public function showLoginAction()
{ {

View File

@@ -20,12 +20,12 @@
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */ /* */
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Admin\Controller; namespace Thelia\Controller;
use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RequestContext;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerAware;
use Thelia\Core\DependencyInjection\ContainerAwareAdmin;
use Thelia\Form\BaseForm; use Thelia\Form\BaseForm;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\HttpKernelInterface; use Symfony\Component\HttpKernel\HttpKernelInterface;
@@ -51,7 +51,7 @@ use Thelia\Core\Security\Exception\AuthorizationException;
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class BaseAdminController extends ContainerAwareAdmin class BaseController extends ContainerAware
{ {
const TEMPLATE_404 = "404"; const TEMPLATE_404 = "404";

View File

@@ -0,0 +1,36 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
/* web : http://www.thelia.net */
/* */
/* This program is free software; you can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 3 of the License */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* */
/* You should have received a copy of the GNU General Public License */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Controller\Front;
use Thelia\Controller\BaseController;
use Symfony\Component\DependencyInjection\ContainerAware;
use Thelia\Core\Security\SecurityContext;
class CustomerController extends BaseController {
public function createAction()
{
}
}

View File

@@ -33,7 +33,7 @@ class CustomerCreation extends BaseForm
protected function buildForm() protected function buildForm()
{ {
$this->formBuilder $this->formBuilder
->add("auto_login", "boolean") ->add("auto_login", "integer")
->add("firstname", "text", array( ->add("firstname", "text", array(
"constraints" => array( "constraints" => array(
new Constraints\NotBlank() new Constraints\NotBlank()