Skip to content

Latest commit

 

History

History
27 lines (24 loc) · 727 Bytes

chain.md

File metadata and controls

27 lines (24 loc) · 727 Bytes

ChainDecorator

The ChainDecorator hold multiple other decorators and execute one after another. Example:

// MyClass.php
class MyClass
{
    public function doSomething(User $user)
    {
        $activator = new ArrayActivator();
        $decorator = new ChainActivator();
        $decorator->add(new ArrayDecorator([
            'user_id' => $user->getId(),
            'user_role' => $user->GetRole()
        ]));
        $decorator->add(new YourCustomDecorator();

        $manager = new FeatureManager($activator, $decorator);

        // Check the feature with the global defined context
        if ($manager->isActive('feature_def')) {
            // do something
        }
    }
}