PHP code example of opensoft / rollout-bundle

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

    

opensoft / rollout-bundle example snippets


new Opensoft\RolloutBundle\OpensoftRolloutBundle(),



use Opensoft/Rollout/RolloutUserInterface;

class User implements RolloutUserInterface
{
    /**
     * @return string
     */
    public function getRolloutIdentifier()
    {
        return $this->email;
    }
}




use Doctrine\ORM\EntityRepository;
use Opensoft\RolloutBundle\Rollout\UserProviderInterface;

class UserRepository extends EntityRepository implements UserProviderInterface
{
    /**
     * @param  mixed $id
     * @return RolloutUserInterface|null
     */
    public function findByRolloutIdentifier($id)
    {
        return $this->findOneBy(array('email' => $id));
    }
}



use Opensoft\RolloutBundle\Rollout\GroupDefinitionInterface;

class AcmeEmployeeGroupDefinition implements GroupDefinitionInterface
{
    /**
     * @return string
     */
    public function getName()
    {
        return 'acme_employee';
    }

    /**
     * @return string
     */
    public function getDescription()
    {
        return 'This group contains acme company employees';
    }

    /**
     * @return \Closure
     */
    public function getCallback()
    {
        return function(RolloutUserInterface $user) {
            // Is this user an employee of acme?
            return strpos($user->getEmail(), 'acme.com') !== false;
        };
    }
}



use Opensoft\Rollout\Storage\StorageInterface;

class MyStorage implements StorageInterface
{
    /**
     * @param  string     $key
     * @return mixed|null Null if the value is not found
     */
    public function get($key)
    {
        // implement get
    }

    /**
     * @param string $key
     * @param mixed  $value
     */
    public function set($key, $value)
    {
        // implement set
    }

    /**
     * @param string $key
     * @since 2.0.0
     */
    public function remove($key)
    {
        // implement remove
    }
}

if ($this->get('rollout')->isActive('chat', $this->getUser())) {
    // do some chat related feature work
}