unite-cms/unite-cms

View on GitHub
src/Bundle/AdminBundle/AdminView/Types/AbstractAdminViewType.php

Summary

Maintainability
A
0 mins
Test Coverage
D
66%
<?php

namespace UniteCMS\AdminBundle\AdminView\Types;

use GraphQL\Language\AST\FragmentDefinitionNode;
use UniteCMS\AdminBundle\AdminView\AdminView;
use UniteCMS\AdminBundle\AdminView\AdminViewTypeInterface;
use UniteCMS\CoreBundle\ContentType\ContentType;
use UniteCMS\CoreBundle\GraphQL\Schema\Provider\SchemaProviderInterface;

abstract class AbstractAdminViewType implements AdminViewTypeInterface, SchemaProviderInterface
{
    const TYPE = null;
    const RETURN_TYPE = null;

    /**
     * {@inheritDoc}
     */
    static function getType() : string {
        return static::TYPE;
    }

    /**
     * {@inheritDoc}
     */
    public function extend(): string
    {
        return file_get_contents(__DIR__ . '/../../Resources/GraphQL/Schema/AdminView/' . static::getType() . '.graphql');
    }

    /**
     * {@inheritDoc}
     */
    public function createView(string $category, ?ContentType $contentType = null, ?FragmentDefinitionNode $definition = null, ?array $directive = null, array $nativeFragments = []) : AdminView {
        return new AdminView(static::RETURN_TYPE, $category, $contentType, $definition, $directive, null, $nativeFragments);
    }
}