create form for language url
This commit is contained in:
@@ -155,6 +155,7 @@
|
||||
<form name="thelia.lang.update" class="Thelia\Form\Lang\LangUpdateForm"/>
|
||||
<form name="thelia.lang.create" class="Thelia\Form\Lang\LangCreateForm"/>
|
||||
<form name="thelia.lang.defaultBehavior" class="Thelia\Form\Lang\LangDefaultBehaviorForm"/>
|
||||
<form name="thelia.lang.url" class="Thelia\Form\Lang\LangUrlForm"/>
|
||||
</forms>
|
||||
|
||||
|
||||
|
||||
@@ -953,6 +953,17 @@
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::defaultBehaviorAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.domain" path="/admin/configuration/languages/domain">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::domainAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.domain.activation" path="/admin/configuration/languages/domain/activate">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::activateDomainAction</default>
|
||||
</route>
|
||||
|
||||
<route id="admin.configuration.languages.domain.deactivation" path="/admin/configuration/languages/domain/deactivate">
|
||||
<default key="_controller">Thelia\Controller\Admin\LangController::deactivateDomainAction</default>
|
||||
</route>
|
||||
|
||||
<!-- The default route, to display a template -->
|
||||
|
||||
|
||||
@@ -231,7 +231,6 @@ class LangController extends BaseAdminController
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
$exception = false;
|
||||
|
||||
$behaviorForm = new LangDefaultBehaviorForm($this->getRequest());
|
||||
|
||||
@@ -258,4 +257,34 @@ class LangController extends BaseAdminController
|
||||
// At this point, the form has error, and should be redisplayed.
|
||||
return $this->renderDefault();
|
||||
}
|
||||
|
||||
public function domainAction()
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
}
|
||||
|
||||
public function activateDomainAction()
|
||||
{
|
||||
$this->domainActivation(1);
|
||||
}
|
||||
|
||||
public function deactivateDomainAction()
|
||||
{
|
||||
$this->domainActivation(0);
|
||||
}
|
||||
|
||||
private function domainActivation($activate)
|
||||
{
|
||||
if (null !== $response = $this->checkAuth(AdminResources::LANGUAGE, AccessManager::UPDATE)) return $response;
|
||||
|
||||
$error_msg = false;
|
||||
|
||||
ConfigQuery::create()
|
||||
->filterByName('one_domain_foreach_lang')
|
||||
->update(array('Value' => $activate));
|
||||
|
||||
$this->redirectToRoute('admin.configuration.languages');
|
||||
}
|
||||
}
|
||||
86
core/lib/Thelia/Form/Lang/LangUrlForm.php
Normal file
86
core/lib/Thelia/Form/Lang/LangUrlForm.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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\Form\Lang;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Model\LangQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangUrlForm
|
||||
* @package Thelia\Form\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangUrlForm extends BaseForm
|
||||
{
|
||||
const LANG_PREFIX = 'url';
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
* Form this you have to call add method on $this->formBuilder attribute :
|
||||
*
|
||||
* $this->formBuilder->add("name", "text")
|
||||
* ->add("email", "email", array(
|
||||
* "attr" => array(
|
||||
* "class" => "field"
|
||||
* ),
|
||||
* "label" => "email",
|
||||
* "constraints" => array(
|
||||
* new \Symfony\Component\Validator\Constraints\NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
foreach (LangQuery::create()->find() as $lang) {
|
||||
$this->formBuilder->add(
|
||||
self::LANG_PREFIX . $lang->getId(),
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"attr" => array(
|
||||
"tag" => "url",
|
||||
"url_id" => $lang->getId(),
|
||||
),
|
||||
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string the name of you form. This name must be unique
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_language_url';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user