Download the PHP package trinity/settings without Composer
On this page you can find all versions of the php package trinity/settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package settings
Trinity Settings
Bundle for storing Symfony parameters in database using Doctrine2 ORM and easy reach from Symfony Controller and twig.
Installation
1. Add trinity/settings to your composer.json
//composer.json
{
//..
"require": {
//..
"trinity/settings": "~1.0",
//..
}
//..
}
2. Enable trinity/settings in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new \Trinity\Bundle\SettingsBundle\SettingsBundle(),
// ...
);
}
Usages
Set defaults variables:
In some config.yml
trinity_settings:
settings:
null_value: ~
key: "value"
group.key: "value"
Note: The dot is defined for group.
Usage in Controller:
//Global Setting
$this->get('trinity.settings')->set('parameter', $parameter);
$this->get('trinity.settings')->get('parameter');
$this->get('trinity.settings')->has('parameter');
//User Setting
$this->get('trinity.settings')->set('parameter', $parameter, $owner);
$this->get('trinity.settings')->get('parameter', $owner);
$this->get('trinity.settings')->has('parameter', $owner);
$this->get('trinity.settings')->has('parameter', $user->getId());
//Setting for some setting group ($owner can be null)
$this->get('trinity.settings')->set('parameter', $parameter, $owner, $group);
$this->get('trinity.settings')->get('parameter', $owner, $group);
$this->get('trinity.settings')->has('parameter', $owner, $group);
Usage In Twig:
{{ get_setting('some_setting') }}
{{ get_setting('some_user_setting', app.user.id) }}
{{ get_setting('some_group_setting', null, 'MySettingGroup') }}
{{ get_setting('some_user_group_setting', app.user.id, 'MySettingGroup') }}
{{ has_setting('some_setting') }}
{{ has_setting('some_user_setting', app.user.id) }}
{{ has_setting('some_group_setting', null, 'MySettingGroup') }}
{{ has_setting('some_user_group_setting', app.user.id, 'MySettingGroup') }}
Running tests:
php "bin/phpunit.phar"
All versions of settings with dependencies
PHP Build Version
Package Version
Requires
php Version
>=7.1
doctrine/orm Version ~2.5
symfony/http-kernel Version ~2.8|~3.0
symfony/dependency-injection Version ~2.8|~3.0
symfony/config Version ~2.8|~3.0
twig/twig Version ~1.20|~2.0
twig/extensions Version ~1.3
doctrine/orm Version ~2.5
symfony/http-kernel Version ~2.8|~3.0
symfony/dependency-injection Version ~2.8|~3.0
symfony/config Version ~2.8|~3.0
twig/twig Version ~1.20|~2.0
twig/extensions Version ~1.3
The package trinity/settings contains the following files
Loading the files please wait ....