Import all translation files from app resources

@param ImportCommand $importCommand

@return int total number of files imported
480070
private function importGlobalTranslationFiles(ImportCommand $importCommand)
    {
        $baseDir = Kernel::VERSION_ID >= 40000 ? $this->kernel->getProjectDir() : $this->kernel->getRootDir();
        $translationsDir = Kernel::VERSION_ID >= 40000 ? 'translations' : null;
        $locales = $this->determineLocalesToImport($importCommand);
        $finder = $this->translationFileExplorer->find($baseDir, $locales, $translationsDir);

        return $this->importTranslationFiles($finder, $importCommand->getForce());
    }
153266
public function importAction()
    {
        $controller   = $this->getRequest()->getControllerName();
        $importLoader = $this->loader->getImportLoader();
        $model        = $this->getModel();

        $params = array();
        $params['defaultImportTranslator'] = $importLoader->getDefaultTranslator($controller);
        $params['formatBoxClass']          = 'browser table';
        $params['importer']                = $importLoader->getImporter($controller, $model);
        $params['model']                   = $model;
        $params['tempDirectory']           = $importLoader->getTempDirectory();
        $params['importTranslators']       = $importLoader->getTranslators($controller);

        $this->addSnippets($this->importSnippets, $params);
    }
844329
public function buildDryrunWorkflow(Import $import, ImportRun $importRun = null)
    {
        //build basics
        $workflow = $this->buildBaseWorkflow($import);

        //collect statistics by default
        $statisticsCollector = new ImportRunEventSubscriber($import, true);
        $this->eventDispatcher->addSubscriber($statisticsCollector);

        return $workflow;
    }
1363969
public function importCMDL($path)
    {
        $connection = $this->getDatabase()->getConnection();

        // scan cmdl folder for repositories

        $finder1 = new Finder();
        $finder1->depth(0);
        $directories = $finder1->directories()->in($path);

        /** @var SplFileInfo $directory */
        foreach ($directories as $directory) {

            $repositoryName = $directory->getFilename();

            $sql  = 'DELETE FROM _cmdl_ WHERE repository = ?';
            $stmt = $connection->prepare($sql);
            $stmt->execute([$repositoryName]);

            $path = realpath($directory->getPathname());

            $finder2 = new Finder();
            $finder2->depth(0);

            // transfer content types

            $finder2->files('*.cmdl')->in($path);

            /** @var SplFileInfo $file */
            foreach ($finder2 as $file) {
                $contentTypeName = $file->getBasename('.cmdl');
                $cmdl = $file->getContents();

                $sql  = 'INSERT INTO _cmdl_ (repository,data_type,name,cmdl,lastchange_timestamp) VALUES(?,"content",?,?,?)';
                $stmt = $connection->prepare($sql);
                $stmt->execute([$repositoryName, $contentTypeName, $cmdl, time()]);
            }

            // transfer config types

            if (file_exists($path . '/config')) {
                $finder3 = new Finder();
                $finder3->depth(0);
                $finder3->files('*.cmdl')->in($path . '/config');

                /** @var SplFileInfo $file */
                foreach ($finder3 as $file) {
                    $configTypeName = $file->getBasename('.cmdl');

                    $cmdl = $file->getContents();

                    $sql  = 'INSERT INTO _cmdl_ (repository,data_type,name,cmdl,lastchange_timestamp) VALUES(?,"config",?,?,?)';
                    $stmt = $connection->prepare($sql);
                    $stmt->execute([$repositoryName, $configTypeName, $cmdl, time()]);
                }
            }
        }

    }
748407
public function import(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer
    {
        return $this->getFactory()->createCategoryImporter()->import($dataImporterConfigurationTransfer);
    }
378014
private function buildSheetImports($import): array
    {
        $sheetImports = [];
        if ($import instanceof WithMultipleSheets) {
            $sheetImports = $import->sheets();

            // When only sheet names are given and the reader has
            // an option to load only the selected sheets.
            if (
                method_exists($this->reader, 'setLoadSheetsOnly')
                && count(array_filter(array_keys($sheetImports), 'is_numeric')) === 0
            ) {
                $this->reader->setLoadSheetsOnly(array_keys($sheetImports));
            }
        }

        return $sheetImports;
    }
1153950
public function addImport(string $importFilePath)
    {
        $normalizedImportPath = $this->normalizePath($importFilePath);

        $this->addSectionIfMissing($this::IMPORTS_SECTION);
        foreach ($this->getImports() as $import) {
            if ($import[$this::RESOURCE_KEY] === $normalizedImportPath) {
                return;
            }
        }
        $this->configArray[$this::IMPORTS_SECTION][] = [$this::RESOURCE_KEY => $normalizedImportPath];
    }
377894
public function import(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer
    {
        return $this->getFactory()
            ->getProductQuantityDataImporter()
            ->import($dataImporterConfigurationTransfer);
    }
803811
private function getImportResources($themeName, $importId)
    {
        $theme = $this->themeManager->getTheme($themeName);

        $path = implode(
            DIRECTORY_SEPARATOR,
            [$theme->getName(), self::IMPORT_FOLDER, $importId]
        );

        $files = $this->resourceProvider->findApplicableResources([$path]);
        if ($theme->getParentTheme()) {
            $files = array_merge($this->getImportResources($theme->getParentTheme(), $importId), $files);
        }

        return $files;
    }
1152084
public function importData(array $importData)
    {
        //@TODO przeniesienie do setDefaultImportParams
        \App\Registry::$db->query('SET FOREIGN_KEY_CHECKS = 0;');
        \App\Registry::$db->setDefaultImportParams()
            ->beginTransaction();
        //iteracja po danych z tabel
        foreach ($importData as $tableName => $data) {
            \App\Registry::$db;
            //puste dane
            if (empty($data)) {
                continue;
            }
            //czyszczenie tabeli
            \App\Registry::$db->delete($tableName);
            //wstawienie danych
            \App\Registry::$db->insertAll($tableName, $data);
        }
        //commit transakcji
        return \App\Registry::$db->commit();
    }
166772
public function import(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer
    {
        return $this->getFactory()->createProductDiscontinuedDataImport()->import($dataImporterConfigurationTransfer);
    }
268572
public function importAction()
    {
        if (!$this->getRequest() instanceof ConsoleRequest) {
            throw new \RuntimeException('You can only use this action from a console!');
        }

        $filter = $this->inputFilterSearch;

        $filter->setData(
            $this->params()
                 ->fromRoute()
        );

        if ($filter->isValid() && $filter->getValue('help') == null) {
            if ($filter->getValue('confirm') == 'yes') {
                $confirm = new Confirm(
                    'Are you sure you want to Import Search Results? [y/n]',
                    'y',
                    'n'
                );

                $result = $confirm->show();
            } else {
                $result = true;
            }

            if ($result) {
                $this->serviceSearch->import();
            }
        } else {
            if ($filter->getValue('help') != null) {
                $this->getEventManager()
                     ->trigger(
                         'Mp3Help',
                         null,
                         ['help' => 'import']
                     );

                exit;
            }
        }
    }
34041
private function import(&$data)
    {
        $imports = array();
        preg_match_all('/#@([-a-z0-9\/_]+)\\n/is', $data, $imports, PREG_SET_ORDER);
        foreach ($imports as $import) {
            $importPath = FS2LANG . '/' . $this->local . '/' . $import[1] . '.txt';
            $importData = @file_get_contents($importPath);

            // getting file content ok
            if ($importData != false) {
                $importData = str_replace(array("\r\n", "\r"), "\n", $importData); // unify linebreaks
                $this->import($importData);
                $replace = '/#@' . preg_quote($import[1], '/') . '/i';
                $data = preg_replace($replace, $importData, $data);
                // replace all imports recursive
            }
        }
        unset($imports);
    }
412432
public function count(Import $import)
	{
		// create iterator
		$iterator = new Reader($import->getDatapath(), $this->delimiter);

		// iterate over each row
		foreach ($iterator as $row => $data)
		{
			// if we got back null for a row dont count
			if ($data !== null)
			{
				$data = array_map('trim', (array)$data);

				if (array_filter($data))
				{
					$this->data_count++;
				}
			}
		}

		// return count
		return $this->data_count;
	}
238222
private function importAllBundlesTranslationFiles(ImportCommand $importCommand)
    {
        $bundles = array_map('strtolower', array_keys($this->kernel->getBundles()));
        $imported = 0;

        foreach ($bundles as $bundle) {
            $importCommand->setDefaultBundle($bundle);

            try {
                $imported += $this->importSingleBundleTranslationFiles($importCommand);
            } catch (TranslationsNotFoundException $e) {
                continue;
            }
        }

        return $imported;
    }
1286916
public function getContactsTransactionalDataImportByImportId($importId)
    {
        $url = $this->getApiEndpoint() . self::REST_TRANSACTIONAL_DATA_IMPORT
            . $importId;

        $this->setUrl($url)
            ->setVerb('GET');

        $response = $this->execute();

        if (isset($response->message)) {
            $message = 'GET CONTACTS TRANSACTIONAL DATA IMPORT BY IMPORT ID '
                . $response->message;
            $this->helper->debug('getContactsTransactionalDataImportByImportId', [$message]);
        }

        return $response;
    }
151324
public function importAction()
    {
        $success = null;
        $request = $this->getRequest();
        $data    = $request->getPost();
        $form    = $this->getServiceLocator()
                        ->get( 'Form' )
                        ->get( 'Grid\Paragraph\ImportContent\Import' );

        $form->setAttribute(
            'action',
            $this->url()
                 ->fromRoute( 'Grid\Paragraph\ImportContent\Import', array(
                     'locale'       => (string) $this->locale(),
                     'redirectUri'  => $request->getQuery( 'returnUri' ),
                 ) )
        );

        if ( $request->isPost() )
        {
            $form->setData( $data );

            if ( $form->isValid() )
            {
                $data   = $form->getData();
                $model  = $this->getServiceLocator()
                               ->get( 'Grid\Paragraph\Model\Paragraph\Model' );
                $id     = $model->cloneFrom( $data['importId'], '_central' );
                $menuId = (int) $data['menuId'];
                unset( $data['menuId'] );
                unset( $data['importId'] );

                if ( empty( $id ) )
                {
                    $success = false;
                }
                else
                {
                    $content = $model->find( $id );

                    if ( empty( $content ) )
                    {
                        $success = false;
                    }
                    else
                    {
                        $userId = $this->getAuthenticationService()
                                       ->getIdentity()
                                       ->id;

                        $data['created']    = null;
                        $data['userId']     = $userId;
                        $data['editUsers']  = array( $userId );

                        $success = (bool) $content->setOptions( $data )
                                                  ->save();

                        if ( $success )
                        {
                            if ( isset( $data['title'] ) )
                            {
                                $data['title'] = trim( $data['title'] );
                            }

                            if ( ! empty( $data['title'] ) )
                            {
                                $subdomain = $this->getServiceLocator()
                                                  ->get( 'SiteInfo' )
                                                  ->getSubdomainId();

                                $postfix = '';
                                $uri = preg_replace(
                                    '/\\s+/', '-',
                                    mb_strtolower( $data['title'], 'UTF-8' )
                                );

                                $model = $this->getServiceLocator()
                                              ->get( 'Grid\Core\Model\Uri\Model' );

                                while ( $model->isSubdomainUriExists(
                                            $subdomain,
                                            $uri . $postfix
                                        ) )
                                {
                                    --$postfix;
                                }

                                $uri = $model->create( array(
                                    'subdomainId'   => $subdomain,
                                    'contentId'     => $content->id,
                                    'locale'        => $this->getAdminLocale(),
                                    'uri'           => $uri . $postfix,
                                ) );

                                if ( $uri->save() )
                                {
                                    $redirect = '/' . $uri->safeUri;
                                }

                                if ( $menuId )
                                {
                                    $menuModel = $this->getServiceLocator()
                                                      ->get( 'Grid\Menu\Model\Menu\Model' );

                                    $menu = $menuModel->create( array(
                                        'type'      => 'content',
                                        'label'     => $data['title'],
                                        'contentId' => $content->id,
                                    ) );

                                    if ( $menu->save() )
                                    {
                                        $menuModel->appendTo( $menu->id, $menuId );
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                $success = false;
            }
        }

        if ( true === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.importContent.success',
                        'paragraph', Message::LEVEL_INFO );
        }

        if ( false === $success )
        {
            $this->messenger()
                 ->add( 'paragraph.action.importContent.failed',
                        'paragraph', Message::LEVEL_ERROR );
        }

        if ( null !== $success )
        {
            if ( empty( $redirect ) )
            {
                if ( empty( $id ) )
                {
                    $redirect = $request->getQuery( 'returnUri', '/' );
                }
                else
                {
                    $redirect = $this->url()
                                     ->fromRoute( 'Grid\Paragraph\Render\Paragraph', array(
                                         'locale'       => $this->getAdminLocale(),
                                         'paragraphId'  => $id,
                                     ) );
                }
            }

            return $this->redirect()
                        ->toUrl( $redirect );
        }

        $view = new ViewModel( array(
            'form' => $form,
        ) );
        return $view->setTerminal( true );
    }