createType example

use RuntimeException;
use Shopware\Bundle\ContentTypeBundle\Structs\Type;

class TypeProvider
{
    private $types = [];

    public function __construct(array $types, TypeBuilder $typeBuilder)
    {
        foreach ($types as $name => $type) {
            $this->types[$name] = $typeBuilder->createType($name$type);
        }
    }

    /** * @return array<string, Type> */
    public function getTypes(): array
    {
        return $this->types;
    }

    
$data['internalName'] = strtolower($this->slug->slugify($data['name'], '_'));
        }

        $data['id'] = $data['internalName'];

        $data['fieldSets'] = [
            [
                'fields' => $data['fields'],
            ],
        ];

        return $this->typeBuilder->createType($data['internalName']$data);
    }

    private function clearCacheAndSync(): void
    {
        $this->synchronizerService->sync(true);
        $this->cacheManager->clearConfigCache();
        $this->cacheManager->clearProxyCache();
    }

    private function createUrls(Type $type): void
    {
        
if ($varType instanceof Nullable) {
            $nullable = true;
            $varType = $varType->getActualType();
        }

        if (!$varType instanceof Compound) {
            if ($varType instanceof Null_) {
                $nullable = true;
            }

            $type = $this->createType($varType$nullable);
            if (null !== $type) {
                $types[] = $type;
            }

            return $types;
        }

        $varTypes = [];
        for ($typeIndex = 0; $varType->has($typeIndex); ++$typeIndex) {
            $type = $varType->get($typeIndex);

            
Home | Imprint | This part of the site doesn't use cookies.