create coutry events

This commit is contained in:
Manuel Raynaud
2013-10-07 10:50:44 +02:00
parent f408ad5d1f
commit 51a307527c
9 changed files with 529 additions and 32 deletions

View File

@@ -405,6 +405,21 @@
<default key="_controller">Thelia\Controller\Admin\FolderController::updatePositionAction</default>
</route>
<!-- Countries routes management -->
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
<default key="_controller">Thelia\Controller\Admin\CountryController::defaultAction</default>
</route>
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
</route>
<route id="admin.configuration.countries.update.view" path="/admin/configuration/countries/update/{country_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
<requirement key="country_id">\d+</requirement>
</route>
<!-- content routes management -->
<route id="admin.content.create" path="/admin/content/create">
<default key="_controller">Thelia\Controller\Admin\ContentController::createAction</default>
@@ -668,20 +683,7 @@
<!-- end attribute and feature routes management -->
<!-- Countries routes management -->
<route id="admin.configuration.countries.default" path="/admin/configuration/countries">
<default key="_controller">Thelia\Controller\Admin\CountryController::indexAction</default>
</route>
<route id="admin.configuration.countries.create" path="/admin/configuration/countries/create">
<default key="_controller">Thelia\Controller\Admin\CountryController::createAction</default>
</route>
<route id="admin.configuration.countries.update.view" path="/admin/configuration/countries/update/{country_id}" methods="get">
<default key="_controller">Thelia\Controller\Admin\CountryController::updateAction</default>
<requirement key="country_id">\d+</requirement>
</route>
<!-- end countries routes management -->

View File

@@ -22,31 +22,185 @@
/*************************************************************************************/
namespace Thelia\Controller\Admin;
use Thelia\Core\Event\TheliaEvents;
/**
* Class CustomerController
* @package Thelia\Controller\Admin
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryController extends BaseAdminController
class CountryController extends AbstractCrudController
{
public function indexAction()
/**
* @param string $objectName the lower case object name. Example. "message"
*
* @param string $defaultListOrder the default object list order, or null if list is not sortable. Example: manual
* @param string $orderRequestParameterName Name of the request parameter that set the list order (null if list is not sortable)
*
* @param string $viewPermissionIdentifier the 'view' permission identifier. Example: "admin.configuration.message.view"
* @param string $createPermissionIdentifier the 'create' permission identifier. Example: "admin.configuration.message.create"
* @param string $updatePermissionIdentifier the 'update' permission identifier. Example: "admin.configuration.message.update"
* @param string $deletePermissionIdentifier the 'delete' permission identifier. Example: "admin.configuration.message.delete"
*
* @param string $createEventIdentifier the dispatched create TheliaEvent identifier. Example: TheliaEvents::MESSAGE_CREATE
* @param string $updateEventIdentifier the dispatched update TheliaEvent identifier. Example: TheliaEvents::MESSAGE_UPDATE
* @param string $deleteEventIdentifier the dispatched delete TheliaEvent identifier. Example: TheliaEvents::MESSAGE_DELETE
*
* @param string $visibilityToggleEventIdentifier the dispatched visibility toggle TheliaEvent identifier, or null if the object has no visible options. Example: TheliaEvents::MESSAGE_TOGGLE_VISIBILITY
* @param string $changePositionEventIdentifier the dispatched position change TheliaEvent identifier, or null if the object has no position. Example: TheliaEvents::MESSAGE_UPDATE_POSITION
*/
public function __construct()
{
parent::__construct(
'country',
'manual',
'country_order',
'admin.country.default',
'admin.country.create',
'admin.country.update',
'admin.country.delete',
TheliaEvents::COUNTRY_CREATE,
TheliaEvents::COUNTRY_UPDATE,
TheliaEvents::COUNTRY_DELETE
);
}
/**
* Return the creation form for this object
*/
protected function getCreationForm()
{
// TODO: Implement getCreationForm() method.
}
/**
* Return the update form for this object
*/
protected function getUpdateForm()
{
// TODO: Implement getUpdateForm() method.
}
/**
* Hydrate the update form for this object, before passing it to the update template
*
* @param unknown $object
*/
protected function hydrateObjectForm($object)
{
// TODO: Implement hydrateObjectForm() method.
}
/**
* Creates the creation event with the provided form data
*
* @param unknown $formData
*/
protected function getCreationEvent($formData)
{
// TODO: Implement getCreationEvent() method.
}
/**
* Creates the update event with the provided form data
*
* @param unknown $formData
*/
protected function getUpdateEvent($formData)
{
// TODO: Implement getUpdateEvent() method.
}
/**
* Creates the delete event with the provided form data
*/
protected function getDeleteEvent()
{
// TODO: Implement getDeleteEvent() method.
}
/**
* Return true if the event contains the object, e.g. the action has updated the object in the event.
*
* @param unknown $event
*/
protected function eventContainsObject($event)
{
// TODO: Implement eventContainsObject() method.
}
/**
* Get the created object from an event.
*
* @param unknown $createEvent
*/
protected function getObjectFromEvent($event)
{
// TODO: Implement getObjectFromEvent() method.
}
/**
* Load an existing object from the database
*/
protected function getExistingObject()
{
// TODO: Implement getExistingObject() method.
}
/**
* Returns the object label form the object event (name, title, etc.)
*
* @param unknown $object
*/
protected function getObjectLabel($object)
{
// TODO: Implement getObjectLabel() method.
}
/**
* Returns the object ID from the object
*
* @param unknown $object
*/
protected function getObjectId($object)
{
// TODO: Implement getObjectId() method.
}
/**
* Render the main list template
*
* @param unknown $currentOrder, if any, null otherwise.
*/
protected function renderListTemplate($currentOrder)
{
if (null !== $response = $this->checkAuth("admin.country.view")) return $response;
return $this->render("countries", array("display_country" => 20));
}
/**
* update country action
*
* @param $country_id
* @return mixed|\Symfony\Component\HttpFoundation\Response
* Render the edition template
*/
public function updateAction($country_id)
protected function renderEditionTemplate()
{
return $this->render("country-edit", array(
"country_id" => $country_id
));
// TODO: Implement renderEditionTemplate() method.
}
/**
* Redirect to the edition template
*/
protected function redirectToEditionTemplate()
{
// TODO: Implement redirectToEditionTemplate() method.
}
/**
* Redirect to the list template
*/
protected function redirectToListTemplate()
{
// TODO: Implement redirectToListTemplate() method.
}
}

View File

@@ -0,0 +1,154 @@
<?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\Core\Event\Country;
/**
* Class CountryCreateEvent
* @package Thelia\Core\Event\Country
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryCreateEvent extends CountryEvent
{
protected $locale;
protected $title;
protected $isocode;
protected $isoAlpha2;
protected $isoAlpha3;
/**
* @var int area zone
*/
protected $area;
/**
* @param mixed $isoAlpha2
*/
public function setIsoAlpha2($isoAlpha2)
{
$this->isoAlpha2 = $isoAlpha2;
return $this;
}
/**
* @return mixed
*/
public function getIsoAlpha2()
{
return $this->isoAlpha2;
}
/**
* @param mixed $isoAlpha3
*/
public function setIsoAlpha3($isoAlpha3)
{
$this->isoAlpha3 = $isoAlpha3;
return $this;
}
/**
* @return mixed
*/
public function getIsoAlpha3()
{
return $this->isoAlpha3;
}
/**
* @param mixed $isocode
*/
public function setIsocode($isocode)
{
$this->isocode = $isocode;
return $this;
}
/**
* @return mixed
*/
public function getIsocode()
{
return $this->isocode;
}
/**
* @param mixed $locale
*/
public function setLocale($locale)
{
$this->locale = $locale;
return $this;
}
/**
* @return mixed
*/
public function getLocale()
{
return $this->locale;
}
/**
* @param mixed $title
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param int $area
*/
public function setArea($area)
{
$this->area = $area;
return $this;
}
/**
* @return int
*/
public function getArea()
{
return $this->area;
}
}

View File

@@ -0,0 +1,60 @@
<?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\Core\Event\Country;
/**
* Class CountryDeleteEvent
* @package Thelia\Core\Event\Country
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryDeleteEvent extends CountryEvent
{
/**
* @var int country id
*/
protected $country_id;
function __construct($country_id)
{
$this->country_id = $country_id;
}
/**
* @param int $country_id
*/
public function setCountryId($country_id)
{
$this->country_id = $country_id;
}
/**
* @return int
*/
public function getCountryId()
{
return $this->country_id;
}
}

View File

@@ -0,0 +1,73 @@
<?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\Core\Event\Country;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Country;
/**
* Class CountryEvent
* @package Thelia\Core\Event\Country
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryEvent extends ActionEvent
{
/*
* @var \Thelia\Model\Country
*/
protected $country;
function __construct(Country $country)
{
$this->country = $country;
}
/**
* @param mixed $country
*/
public function setCountry(Country $country)
{
$this->country = $country;
return $this;
}
/**
* @return null|\Thelia\Model\Country
*/
public function getCountry()
{
return $this->country;
}
/**
* @return bool
*/
public function hasCountry()
{
return null !== $this->country;
}
}

View File

@@ -0,0 +1,35 @@
<?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\Core\Event\Country;
/**
* Class CountryUpdateEvent
* @package Thelia\Core\Event\Country
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class CountryUpdateEvent extends CountryCreateEvent
{
}

View File

@@ -183,8 +183,6 @@ final class TheliaEvents
const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility";
const FOLDER_UPDATE_POSITION = "action.updateFolderPosition";
// const FOLDER_ADD_CONTENT = "action.categoryAddContent";
// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent";
const BEFORE_CREATEFOLDER = "action.before_createFolder";
const AFTER_CREATEFOLDER = "action.after_createFolder";
@@ -216,6 +214,24 @@ final class TheliaEvents
const BEFORE_UPDATECONTENT = "action.before_updateContent";
const AFTER_UPDATECONTENT = "action.after_updateContent";
// -- country management -----------------------------------------------
const COUNTRY_CREATE = "action.createCountry";
const COUNTRY_UPDATE = "action.updateCountry";
const COUNTRY_DELETE = "action.deleteCountry";
const COUNTRY_TOGGLE_VISIBILITY = "action.toggleCountryVisibility";
//const COUNTRY_UPDATE_POSITION = "action.updateFolderPosition";
const BEFORE_CREATECOUNTRY = "action.before_createCountry";
const AFTER_CREATECOUNTRY = "action.after_createCountry";
const BEFORE_DELETECOUNTRY = "action.before_deleteCountry";
const AFTER_DELETECOUNTRY = "action.after_deleteCountry";
const BEFORE_UPDATECOUNTRY = "action.before_updateCountry";
const AFTER_UPDATECOUNTRY = "action.after_updateCountry";
// -- Categories Associated Content ----------------------------------------
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";

View File

@@ -6,4 +6,7 @@ use Thelia\Model\Base\Country as BaseCountry;
class Country extends BaseCountry {
}

View File

@@ -35,12 +35,12 @@
</caption>
<thead>
<tr>
<th>ID</th>
<th>Name</th>
<th>Default</th>
<th>Shop</th>
<th>N° ISO</th>
<th>ISO Code</th>
<th>{intl l="ID"}</th>
<th>{intl l="Name"}</th>
<th>{intl l="Default"}</th>
<th>{intl l="Shop"}</th>
<th>{intl l="N° ISO"}</th>
<th>{intl l="ISO Code"}</th>
{module_include location='countries_table_header'}