PHP code example of harmony / settings-manager-bundle

1. Go to this page and download the library: Download harmony/settings-manager-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/ */

    

harmony / settings-manager-bundle example snippets




class AppKernel extends Kernel
{
    public function registerBundles()
    {
        return [
            new Harmony\Bundle\SettingsManagerBundle\HarmonySettingsManagerBundle(),
        ];
    }
}

use Harmony\Bundle\SettingsManagerBundle\Settings\Traits\SettingsRouterAwareTrait;

class MuchAmazingService
{
    use SettingsRouterAwareTrait;

    public function doSmth()
    {
        if ($this->settingsRouter->getBool('foo')) {
            // do it
        }

        // just do it
    }
}


declare(strict_types=1);

namespace App\Entity;

use Doctrine\ORM\Mapping as ORM;
use Harmony\Bundle\SettingsManagerBundle\Model\SettingModel;

/**
 * @ORM\Entity()
 * @ORM\Table(name="setting")
 */
class Setting extends SettingModel
{
    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\GeneratedValue
     * @ORM\Column(type="integer")
     */
    protected $id;
}

public function indexAction(): Response
{
    $this->denyUnlessEnabled('index_page');
    ...
}