protected function execute($listener, $type, Fluent $extension, Closure $callback)
    {
        $name = $extension->get('name');

        try {
            // Check if folder is writable via the web instance, this would
            // avoid issue running Orchestra Platform with debug as true where
            // creating/copying the directory would throw an ErrorException.
            if (! $this->factory->permission($name)) {
                throw new FilePermissionException("[{$name}] is not writable.");
            }

            $callback($this->factory, $name);
        } catch (FilePermissionException $e) {
            return $listener->{"{$type}HasFailed"}($extension, ['error' => $e->getMessage()]);
        }

        return $listener->{"{$type}HasSucceed"}($extension);
    }