*/ class Configuration extends BaseForm { const PREFIXE_PATTERN = '^[A-Za-z0-9\-_]*$'; protected function buildForm() { $form = $this->formBuilder; $form ->add( 'back_office_path', 'text', array( 'constraints' => array( new NotBlank(), new Regex([ 'pattern' => '#' . self::PREFIXE_PATTERN . '#', 'message' => Translator::getInstance()->trans( 'URL should only use alpha numeric, - and _ characters', [], BackOfficePath::MESSAGE_DOMAIN ) ]) ), 'data' => ConfigQuery::read('back_office_path', ''), 'label' => Translator::getInstance()->trans('The new prefix', [], BackOfficePath::MESSAGE_DOMAIN ), 'label_attr' => array( 'for' => 'back_office_path', 'description' => Translator::getInstance()->trans( 'It will replaced the default %prefix', ['%prefix' => '/' . BackOfficePath::DEFAULT_THELIA_PREFIX], BackOfficePath::MESSAGE_DOMAIN ) ), ) ) ->add( 'back_office_path_default_enabled', 'checkbox', array( 'data' => intval(ConfigQuery::read('back_office_path_default_enabled', '')) === 1, 'label' => Translator::getInstance()->trans('Use also the default prefix', [], BackOfficePath::MESSAGE_DOMAIN), 'label_attr' => array( 'for' => 'back_office_path_default_enabled', 'help' => Translator::getInstance()->trans( 'Activate this to test your new prefix. If it doesn\'t work you could rollback your changes (the link in the HTML content will not be replaced)', [], BackOfficePath::MESSAGE_DOMAIN ) ), ) ); } /** * @return string the name of you form. This name must be unique */ public function getName() { return 'backofficepath'; } }