PHP code example of qandidate / toggle-bundle

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

    

qandidate / toggle-bundle example snippets


$bundles = array(
    // ..
    new Symfony\Bundle\SecurityBundle\SecurityBundle(),
    new Symfony\Bundle\TwigBundle\TwigBundle(),
    new Qandidate\Bundle\ToggleBundle\QandidateToggleBundle(),
);

// Acme\Controller

public function __construct(
    /* ArticleRepository, Templating, ..*/ 
    ToggleManager $manager, 
    ContextFactory $contextFactory
) {
    // ..
    $this->manager = $manager;
    $this->context = $contextFactory->createContext();
}

// ..

public function articleAction(Request $request)
{
    $this->article = $this->repository->findBySlug($request->request->get('slug'));

    return $this->templating->render('article.html.twig', array(
        'article'        => $article,
        'enableComments' => $this->manager->active('comments', $this->context),
    ));
}

use Qandidate\Bundle\ToggleBundle\Annotations\Toggle;

/**
 * @Toggle("cool-feature")
 */
class FooController
{

    /**
     * @Toggle("another-cool-feature")
     */
    public function barAction()
    {
    }

    public function bazAction()
    {
    }
}