CamelCaseToSnakeCaseNameConverter example

$this->createDirectory($appDirectory);

        file_put_contents($appDirectory . '/manifest.xml', $manifestContent);

        if ($createThemeConfig) {
            $manifestContent = $this->replaceTemplateValues(
                $this->getThemeConfigTemplate(),
                [
                    'name' => $details['name'],
                    'author' => $details['author'],
                    'name-snake-case' => (new CamelCaseToSnakeCaseNameConverter())->normalize($details['name']),
                ]
            );

            $this->createDirectory($appDirectory . '/Resources');

            file_put_contents($appDirectory . '/Resources/theme.json', $manifestContent);
        }
    }

    private function createDirectory(string $pathName): void
    {
        
$pluginRepo,
            $this->projectDir
        );
    }

    private function createPlugin(string $path): PluginEntity
    {
        $plugin = new PluginEntity();
        $plugin->setPath($path);
        $plugin->setManagedByComposer(false);
        $plugin->setVersion('1.0.0');
        $plugin->setComposerName('swag/' . (new CamelCaseToSnakeCaseNameConverter())->normalize(basename($path)));

        return $plugin;
    }
}
$translation = DynamicTranslationEntityDefinition::create($entityName$translated$container);
        $container->set($translation->getEntityName()$translation);
        $container->set($translation->getEntityName() . '.repository', self::createRepository($container$translation));

        $registry->register($translation$translation->getEntityName());

        return $collection;
    }

    private static function kebabCaseToCamelCase(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->denormalize(str_replace('-', '_', $string));
    }

    private static function createRepository(ContainerInterface $container, EntityDefinition $definition): EntityRepository
    {
        return new EntityRepository(
            $definition,
            $container->get(EntityReaderInterface::class),
            $container->get(VersionManager::class),
            $container->get(EntitySearcherInterface::class),
            $container->get(EntityAggregatorInterface::class),
            $container->get('event_dispatcher'),
            
$migrationSuffix = str_replace(
            $this->getNamespace(),
            '',
            $this->getMigrationNamespace()
        );

        return $this->getPath() . str_replace('\\', '/', $migrationSuffix);
    }

    final public function getContainerPrefix(): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($this->getName());
    }

    public function configureRoutes(RoutingConfigurator $routes, string $environment): void
    {
        $confDir = $this->getPath() . '/Resources/config';

        if (file_exists($confDir)) {
            $routes->import($confDir . '/{routes}/*' . Kernel::CONFIG_EXTS, 'glob');
            $routes->import($confDir . '/{routes}/' . $environment . '/**/*' . Kernel::CONFIG_EXTS, 'glob');
            $routes->import($confDir . '/{routes}' . Kernel::CONFIG_EXTS, 'glob');
            $routes->import($confDir . '/{routes}_' . $environment . Kernel::CONFIG_EXTS, 'glob');
        }
if ($definition->isVersionAware()) {
            $fields->add(
                (new ReferenceVersionField($definition->getEntityName()))->addFlags(new PrimaryKey()new Required()),
            );
        }

        return $fields;
    }

    protected static function kebabCaseToCamelCase(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->denormalize(str_replace('-', '_', $string));
    }
}
if (mb_strpos($path$this->projectDir) === 0) {
                // make relative                 $path = ltrim(mb_substr($pathmb_strlen($this->projectDir)), '/');
            }

            return $path;
        }$config->getStyleFiles()->getFilepaths());
    }

    private function asSnakeCase(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($string);
    }

    private function getActivePlugins(): array
    {
        $activePlugins = $this->kernel->getPluginLoader()->getPluginInstances()->getActives();

        return array_map(static fn (Plugin $plugin) => $plugin->getName()$activePlugins);
    }
}
$io->error('The name must start with an uppercase character');

            return self::FAILURE;
        }

        if (preg_match('/^[A-Za-z]\w{3,}$/', (string) $themeName) !== 1) {
            $io->error('Theme name is too short (min 4 characters), contains invalid characters');

            return self::FAILURE;
        }

        $snakeCaseName = (new CamelCaseToSnakeCaseNameConverter())->normalize($themeName);
        $snakeCaseName = str_replace('_', '-', $snakeCaseName);

        $pluginName = ucfirst((string) $themeName);

        $directory = $this->projectDir . '/custom/plugins/' . $pluginName;

        if (file_exists($directory)) {
            $io->error(sprintf('Plugin directory %s already exists', $directory));

            return self::FAILURE;
        }

        
continue;
            }

            $values[] = $transformer($field);
        }

        return $values;
    }

    protected static function kebabCaseToCamelCase(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->denormalize(str_replace('-', '_', $string));
    }

    /** * if translations for system default language are not provided it tries to use the english translation as the default, * if english does not exist it uses the first translation * * @param array<string, string> $translations * * @return array<string, string> */
    protected function ensureTranslationForDefaultLanguageExist(array $translations, string $defaultLocale): array
    {
if ($inherited === false) {
            return;
        }

        $name = self::kebabCaseToCamelCase($entity . '_' . $field['name']);

        $reference->addColumn($name, Types::BINARY, ['notnull' => false, 'default' => null, 'length' => 16, 'fixed' => true, 'comment' => self::COMMENT]);
    }

    private static function kebabCaseToCamelCase(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->denormalize(str_replace('-', '_', $string));
    }

    private static function id(string $name): string
    {
        return $name . '_id';
    }

    private function createTable(Schema $schema, string $name): Table
    {
        return $schema->hasTable($name)
            ? $schema->getTable($name)
            :
$loader = new XmlFileLoader(
            $container,
            new FileLocator()
        );

        $loader->load($this->getPath() . '/Resources/services.xml');
    }

    private function camelCaseToUnderscore(string $string): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($string);
    }

    private function registerFilesystems(ContainerBuilder $container): void
    {
        $this->registerFilesystem($container, 'private');
        $this->registerFilesystem($container, 'public');
    }

    private function registerFilesystem(ContainerBuilder $container, string $key): void
    {
        $parameterKey = sprintf('shopware.filesystem.%s', $key);
        
 mb_strtolower($firstHandlerIdentifier)
            . '_'
            . mb_strtolower($lastHandlerIdentifier);
    }

    private function getShortName(Entity $entity): string
    {
        $explodedHandlerIdentifier = explode('\\', (string) $entity->get('handlerIdentifier'));

        $last = $explodedHandlerIdentifier[\count($explodedHandlerIdentifier) - 1];

        return (new CamelCaseToSnakeCaseNameConverter())->normalize($last);
    }

    private function isSynchronous(Entity $entity): bool
    {
        if (($app = $entity->get('appPaymentMethod')) !== null) {
            /** @var Entity $app */
            return !$app->get('finalizeUrl');
        }

        return \is_a($entity->get('handlerIdentifier'), SynchronousPaymentHandlerInterface::class, true);
    }

    

    public static function getResource($name)
    {
        trigger_error('Using Manager::getResource is deprecated since 5.6 and will be removed with 5.8. Inject the resource instead', E_USER_DEPRECATED);

        $container = Shopware()->Container();
        try {
            $serviceId = 'shopware.api.' . (new CamelCaseToSnakeCaseNameConverter())->normalize($name);
            if ($container->has($serviceId)) {
                /** @var Resource\Resource $resource */
                $resource = $container->get($serviceId);
            } else {
                trigger_error(sprintf('The requested service with id %s is deprecated. Please use CamelCased service id instead.', $name), E_USER_DEPRECATED);
                $resource = $container->get('shopware.api.' . strtolower($name));
            }
        } catch (ServiceNotFoundException $e) {
            $name = ucfirst($name);
            $class = __NAMESPACE__ . '\\Resource\\' . $name;

            

        $name = $this->Request()->getActionName();
        if (str_starts_with($name, 'get')) {
            $name = substr($name, 3);
        }

        return $this->camelCaseToUnderscore($name) . '.csv';
    }

    private function camelCaseToUnderscore(string $str): string
    {
        return (new CamelCaseToSnakeCaseNameConverter())->normalize($str);
    }

    /** * helper to get the selected shop ids * if no shop is selected the ids of all shops are returned * * @return array<int> */
    private function getSelectedShopIds(): array
    {
        $selectedShopIds = (string) $this->Request()->getParam('selectedShops');

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