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;
    }
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;
    }
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 ; }
Creates a Fractal resource based on the given config.

@param array|ResourceInterface|ResourceAdapterInterface
@return ResourceInterface
Creates a Fractal resource based on the given config .