public function createResource($config): ResourceInterface
    {
        if ($config instanceof ResourceInterface) {
            return $config;
        }

        if ($config instanceof ResourceAdapterInterface) {
            return $config->getResource();
        }

        if (!isset($config['class'])) {
            // Default to ElementResourceAdapter
            $config['class'] = ElementResource::class;
        }

        /** @var ResourceInterface|ResourceAdapterInterface $resource */
        $resource = Craft::createObject($config);

        if ($resource instanceof ResourceAdapterInterface) {
            $resource = $resource->getResource();
        }

        return $resource;
    }