PHP code example of tsslabs / toggle-bundle

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

    

tsslabs / toggle-bundle example snippets


$bundles = array(
    // ..
    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),
    ));
}