Skip to content

Adding a custom flex directory type from a plugin #3118

Discussion options

You must be logged in to vote

The solution is to subscribe to the onFlexInit event earlier, under getSubscribedEvents:

class ShopPlugin extends Plugin
{
    public static function getSubscribedEvents(): array
    {
        return [
            'onFlexInit' => ['onFlexInit', 0]
        ];
    }

    public function onFlexInit($event){
        $directory = new FlexDirectory('products', 'plugins://shop/blueprints/flex-objects/products.yaml', ['enabled'=>true]);

        $flex = $event['flex'];
        $flex->addDirectory($directory);
    }
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TheDancingCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Development
Labels
None yet
1 participant