GcConfig\Form\Config::initServer PHP Method

initServer() public method

Initialize Server sub form
public initServer ( array $config ) : Config
$config array Configuration
return Config
    public function initServer($config)
    {
        //Local settings
        $localeFieldset = new Fieldset('locale');
        $localeFieldset->setLabel('Locale');
        $locale = new Element\Select('locale');
        $locale->setLabel('Server locale')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'locale')->setAttribute('class', 'form-control')->setValueOptions($config['locales']);
        $localeFieldset->add($locale);
        $this->getInputFilter()->add(array('name' => 'locale', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'locale');
        $this->add($localeFieldset);
        //Mail settings
        $mailFieldset = new Fieldset('mail');
        $mailFieldset->setLabel('Mail');
        $mailFrom = new Element\Text('mail_from');
        $mailFrom->setLabel('From E-mail')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'mail_from')->setAttribute('class', 'form-control');
        $mailFieldset->add($mailFrom);
        $this->getInputFilter()->add(array('name' => 'mail_from_name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'mail_from_name');
        $mailFromName = new Element\Text('mail_from_name');
        $mailFromName->setLabel('From name')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'mail_from_name')->setAttribute('class', 'form-control');
        $mailFieldset->add($mailFromName);
        $this->getInputFilter()->add(array('name' => 'mail_from', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'mail_from');
        $this->add($mailFieldset);
        //Web settings
        $webFieldset = new Fieldset('web');
        $webFieldset->setLabel('Web');
        $forceBackendSsl = new Element\Checkbox('force_backend_ssl');
        $forceBackendSsl->setLabel('Force backend SSL')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'force_backend_ssl')->setAttribute('class', 'input-checkbox')->setAttribute('id', 'force-backend-ssl');
        $webFieldset->add($forceBackendSsl);
        $this->getInputFilter()->add(array('name' => 'force_backend_ssl', 'required' => false), 'force_backend_ssl');
        $forceFrontendSsl = new Element\Checkbox('force_frontend_ssl');
        $forceFrontendSsl->setLabel('Force frontend SSL')->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', 'force_frontend_ssl')->setAttribute('class', 'input-checkbox')->setAttribute('id', 'force-frontend-ssl');
        $webFieldset->add($forceFrontendSsl);
        $this->getInputFilter()->add(array('name' => 'force_frontend_ssl', 'required' => false), 'force_frontend_ssl');
        $pathFields = array('Unsecure backend base path' => 'unsecure_backend_base_path', 'Unsecure frontend base path' => 'unsecure_frontend_base_path', 'Secure backend base path' => 'secure_backend_base_path', 'Secure frontend base path' => 'secure_frontend_base_path', 'Unsecure cdn base path' => 'unsecure_cdn_base_path', 'Secure cdn base path' => 'secure_cdn_base_path');
        foreach ($pathFields as $label => $identifier) {
            $field = new Element\Text($identifier);
            $field->setLabel($label)->setLabelAttributes(array('class' => 'required control-label col-lg-2'))->setAttribute('id', $identifier)->setAttribute('class', 'form-control');
            $webFieldset->add($field);
            $this->getInputFilter()->add(array('name' => $identifier, 'required' => false, 'validators' => array(array('name' => 'uri'))), $identifier);
        }
        $this->add($webFieldset);
        return $this;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Test
  *
  * @return void
  */
 public function testSetValues()
 {
     $this->object->initServer(Registry::get('Application')->getConfig());
     $this->assertNull($this->object->setValues(array(array('identifier' => 'mail_from_name', 'value' => 'Pierre Rambaud'))));
 }
All Usage Examples Of GcConfig\Form\Config::initServer