PHP code example of vivait / settings-bundle
1. Go to this page and download the library: Download vivait/settings-bundle library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vivait / settings-bundle example snippets
$this->get('vivait_settings.registry')->get('settingname');
$this->get('vivait_settings.registry')->drivers(['doctrine', 'yaml'])->get('settingname');
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add(
'signature', //setting key
'textarea'
)
->add('Submit', 'submit');
$builder->addEventSubscriber(new SettingsSubscriber($this->driver));
$builder->addModelTransformer(new KeyToArrayTransformer());
}
public function signatureAction(Request $request)
{
$form = $this->createForm('signature');
$form->handleRequest($request);
if($form->isValid()){
$driver = $this->get('vivait_settings.driver.doctrine');
foreach($form->getData() as $key => $value){
$driver->set($key, $value);
}
}
php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Vivait\SettingsBundle\VivaitSettingsBundle()
);
}
$this->get('vivait_settings.registry')->get('settingname', 'default value');