findOneByLocale example

umask($old);
        }
        if (!is_writable($dir)) {
            $output->writeln('<error>Output dir ' . $input->getOption('file') . ' is not writable, aborting</error>');

            return 1;
        }

        /** @var Locale|null $locale */
        $locale = $this->container->get(\Shopware\Components\Model\ModelManager::class)
            ->getRepository(\Shopware\Models\Shop\Locale::class)
            ->findOneByLocale($input->getArgument('locale'));
        if (!$locale) {
            $output->writeln('<error>Provided locale not found</error>');

            return 1;
        }

        $this->exportFormLabels($output$locale$dir);

        $this->exportElementLabels($output$locale$dir);

        return 0;
    }
'If a locale is provided, it will be used to fill in the values for the snippets. Ideal to export missing snippets directly for translation. Defaults to null, which exports empty snippets',
                null
            )
        ;
    }

    /** * {@inheritdoc} */
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $locale = $this->container->get(ModelManager::class)->getRepository(Locale::class)->findOneByLocale($input->getArgument('locale'));
        if (!$locale) {
            $output->writeln('<error>Provided locale not found</error>');

            return 1;
        }

        $filteredQueryBuilder = $this->container->get(ModelManager::class)->getDBALQueryBuilder();
        $localeQueryBuilder = $this->container->get(ModelManager::class)->getDBALQueryBuilder();

        $statement = $localeQueryBuilder
            ->select('DISTINCT CONCAT(s.namespace, s.name) as hash')
            

    public function dumpFromDatabase($snippetsDir$localeName)
    {
        $snippetsDir = $this->kernelRoot . '/' . $snippetsDir . '/';
        if (!file_exists($snippetsDir)) {
            return;
        }

        $snippetRepository = $this->em->getRepository('Shopware\Models\Snippet\Snippet');

        $locale = $this->em->getRepository('Shopware\Models\Shop\Locale')->findOneByLocale($localeName);
        if (!$locale) {
            throw new Exception(sprintf('Locale "%s" not found.', $localeName));
        }

        $outputAdapter = new Enlight_Config_Adapter_File([
            'configDir' => $snippetsDir . '/',
        ]);
        $inputAdapter = new Enlight_Config_Adapter_DbTable([
            'db' => $this->db,
            'table' => 's_core_snippets',
            'namespaceColumn' => 'namespace',
            
Home | Imprint | This part of the site doesn't use cookies.