Enlight_Config_Adapter_File example

$snippetsDir = $snippetsDir ?: $this->kernelRoot . '/snippets/';
        if (!file_exists($snippetsDir)) {
            if ($snippetsDir == ($this->kernelRoot . '/snippets/')) {
                $this->printWarning('<info>No snippets folder found in Shopware core, skipping</info>');
            }

            return;
        }

        $localeRepository = $this->em->getRepository('Shopware\Models\Shop\Locale');

        $inputAdapter = new Enlight_Config_Adapter_File([
            'configDir' => $snippetsDir,
        ]);

        $databaseWriter = new DatabaseWriter($this->em->getConnection());
        $databaseWriter->setForce($force);

        $finder = new Finder();
        $finder->files()->in($snippetsDir);
        $defaultLocale = $localeRepository->findOneBy(['locale' => 'en_GB']);

        $snippetCount = $this->em->getConnection()->fetchArray('SELECT * FROM s_core_snippets LIMIT 1');
        
public function loadToQuery($snippetsDir = null, $update = true)
    {
        $snippetsDir = $snippetsDir ?: $this->snippetsDir;

        if (!file_exists($snippetsDir)) {
            return [];
        }

        $locales = [];
        $finder = new Finder();

        $inputAdapter = new Enlight_Config_Adapter_File([
            'configDir' => $snippetsDir,
        ]);

        $queryWriter = new QueryWriter();

        $finder->files()->in($snippetsDir);
        foreach ($finder as $file) {
            $filePath = $file->getRelativePathname();
            if (strpos($filePath, '.ini') == \strlen($filePath) - 4) {
                $namespace = substr($filePath, 0, -4);
            } else {
                
$this->modelManager = $modelManager;
        $this->pluginDirectories = $pluginDirectories;

        $fallbackLocale = $this->modelManager->getRepository(Locale::class)->findOneBy(['locale' => 'en_GB']);
        if (!$fallbackLocale instanceof Locale) {
            throw new RuntimeException('Required fallback locale "en_GB" not found');
        }
        $this->fallbackLocale = $fallbackLocale;

        if ($this->snippetConfig['readFromIni']) {
            $configDir = $this->getConfigDirs($themeDir);
            $this->fileAdapter = new Enlight_Config_Adapter_File([
                'configDir' => $configDir,
                'allowWrites' => $snippetConfig['writeToIni'],
            ]);
        }

        // will set $this->adapter = DbAdapter         parent::__construct(new DbAdapter([
            'table' => 's_core_snippets',
            'namespaceColumn' => 'namespace',
            'sectionColumn' => ['shopID', 'localeID'],
            'allowWrites' => $snippetConfig['writeToDb'],
        ]));
'(s.name = fallback_values.name AND s.namespace = fallback_values.namespace AND fallback_values.localeID = :targetLocale)'
                )
                ->setParameter('targetLocale', $targetLocale->getId())
            ;
        }

        $snippets = $statement->execute()->fetchAll();

        $output->writeln('<info></info>');
        $output->writeln('<info>' . \count($snippets) . ' missing snippets detected</info>');

        $outputAdapter = new Enlight_Config_Adapter_File([
            'configDir' => $input->getOption('target') . '/',
        ]);

        $data = [];

        foreach ($snippets as $snippet) {
            if (!\array_key_exists($snippet['namespace']$data)) {
                $data[$snippet['namespace']] = new Enlight_Components_Snippet_Namespace([
                    'name' => $snippet['namespace'],
                    'section' => [
                        $locale->getLocale(),
                    ],
Home | Imprint | This part of the site doesn't use cookies.