Import data from the given data provider

@param NodeTemplate $nodeTemplate
@throws Exception
166312
protected function processBatch(NodeTemplate $nodeTemplate = null)
    {
        $records = $this->dataProvider->fetch();
        if (!\is_iterable($records)) {
            throw new Exception(sprintf('Expected records as an array while calling %s->fetch(), but returned %s instead.', get_class($this->dataProvider), gettype($records)), 1462960769826);
        }
        $records = $this->preProcessing($records);

        foreach ($records as $data) {
            if (!\is_array($data)) {
                $data = $this->propertyMapper->convert($data, 'array');
            }
            $this->processRecord($nodeTemplate, $data);
            ++$this->processedRecords;
        }

        $this->postProcessing($records);
    }
1307958
function fetch( $template = false, $extraParameters = false, $returnResourceData = false )
    {
        $this->resetErrorLog();
        // Reset fetch list when a new fetch is started
        $this->TemplateFetchList = array();

        eZDebug::accumulatorStart( 'template_total' );
        eZDebug::accumulatorStart( 'template_load', 'template_total', 'Template load' );
        $root = null;
        if ( is_string( $template ) )
        {
            $resourceData = $this->loadURIRoot( $template, true, $extraParameters );
            if ( $resourceData and
                 $resourceData['root-node'] !== null )
                $root =& $resourceData['root-node'];
        }
        eZDebug::accumulatorStop( 'template_load' );
        if ( $resourceData['locales'] && !empty( $resourceData['locales'] ) )
        {
            $savedLocale = setlocale( LC_CTYPE, null );
            setlocale( LC_CTYPE, $resourceData['locales'] );
        }

        $text = "";

        if ( $root !== null or
             $resourceData['compiled-template'] )
        {
            if ( $this->ShowDetails )
                eZDebug::addTimingPoint( "Process" );
            eZDebug::accumulatorStart( 'template_processing', 'template_total', 'Template processing' );

            $templateCompilationUsed = false;
            if ( $resourceData['compiled-template'] )
            {
                $textElements = array();
                if ( $this->executeCompiledTemplate( $resourceData, $textElements, "", "", $extraParameters ) )
                {
                    $text = implode( '', $textElements );
                    $templateCompilationUsed = true;
                }
            }
            if ( !$templateCompilationUsed )
            {
                if ( eZTemplate::isDebugEnabled() )
                {
                    $fname = $resourceData['template-filename'];
                    eZDebug::writeDebug( "FETCH START URI: $template, $fname" );
                }
                $this->process( $root, $text, "", "" );
                if ( eZTemplate::isDebugEnabled() )
                    eZDebug::writeDebug( "FETCH END URI: $template, $fname" );
            }

            eZDebug::accumulatorStop( 'template_processing' );
            if ( $this->ShowDetails )
                eZDebug::addTimingPoint( "Process done" );
        }

        eZDebug::accumulatorStop( 'template_total' );

        if ( $resourceData['locales'] && !empty( $resourceData['locales'] ) )
        {
            setlocale( LC_CTYPE, $savedLocale );
        }

        if ( $returnResourceData )
        {
            $resourceData['result_text'] = $text;
            return $resourceData;
        }
        return $text;
    }
322964
public function render(PdfTemplateTransfer $pdfTemplate)
    {
        $loader = new Filesystem($this->config->getTwigTemplatePaths());
        $twig = new Twig_Environment($loader);
        $twig->setExtensions($this->extensions);

        $this->addFilters($twig);
        $this->addFunctions($twig);

        $path = $pdfTemplate->getPath();
        $parameter = $pdfTemplate->getParameter();

        if ($parameter === null) {
            $parameter = [];
        }

        return $twig->render($path, $parameter);
    }
313860
public function iParseAndProcess($template, TableNode $table)
    {
        $data = [];

        foreach ($table->getRows() as $row) {
            $data[$row[0]] = $row[1];
        }

        $this->result = $this->template->parse($template)->process($data);
    }
282671
public function import(Tag $tag, ImportRecordsDataTable $importRecordsDataTable)
    {
        return $importRecordsDataTable->with([
            'resource' => $tag,
            'tabs' => 'adminarea.tags.tabs',
            'url' => route('adminarea.tags.stash'),
            'id' => "adminarea-tags-{$tag->getRouteKey()}-import-table",
        ])->render('cortex/foundation::adminarea.pages.datatable-dropzone');
    }
837253
protected function responseTemplate($template, $data = array()){
        
        if(!isset(hubert()->template)){
            throw new \Exception("no template engine installed");
        }
        $html = hubert()->template->render($template, $data);
        $this->_response->getBody()->write($html);
        
        return $this->_response;
        
    }
643592
public function importData($arElementList, $sSessionKey = null)
    {
        if (empty($arElementList)) {
            return;
        }

        $obImport = new ImportProductModel();
        $obImport->setDeactivateFlag();

        foreach ($arElementList as $iKey => $arImportData) {
            $obImport->import($arImportData);
            $sResultMethod = $obImport->getResultMethod();
            if (in_array($sResultMethod, ['logUpdated', 'logCreated'])) {
                $this->$sResultMethod();
            } else {
                $sErrorMessage = $obImport->getResultError();
                $this->$sResultMethod($iKey, $sErrorMessage);
            }
        }

        $obImport->deactivateElements();
    }
377894
public function import(?DataImporterConfigurationTransfer $dataImporterConfigurationTransfer = null): DataImporterReportTransfer
    {
        return $this->getFactory()
            ->getProductQuantityDataImporter()
            ->import($dataImporterConfigurationTransfer);
    }
812547
public function importTables ($xml, $objArchive, $intThemeId, $arrMapper)
	{
		// Store the field names of the theme tables
		$arrDbFields = array
		(
			'tl_elements'	=> $this->Database->getFieldNames('tl_elements'),
			'tl_pattern'	=> $this->Database->getFieldNames('tl_pattern')
		);
			
		// Lock the tables
		$arrLocks = array
		(
			'tl_elements'	=> 'WRITE',
			'tl_pattern'	=> 'WRITE',
			'tl_files'		=> 'READ',
			'tl_theme'		=> 'READ'
		);

		// Load the DCAs of the locked tables (see #7345)
		foreach (array_keys($arrLocks) as $table)
		{
			$this->loadDataContainer($table);
		}

		$this->Database->lockTables($arrLocks);

		// Get the current auto_increment values
		$tl_elements = $this->Database->getNextId('tl_elements');
		$tl_pattern = $this->Database->getNextId('tl_pattern');

		
		$tables = $xml->getElementsByTagName('table');
		
		// Update the mapper data first
		for ($i=0; $i<$tables->length; $i++)
		{
			$rows = $tables->item($i)->childNodes;
			$table = $tables->item($i)->getAttribute('name');

			// Skip all other tables
			if (!in_array($table, array_keys($arrDbFields)))
			{
				continue;
			}

			// Loop through the rows
			for ($j=0; $j<$rows->length; $j++)
			{
				$fields = $rows->item($j)->childNodes;

				// Loop through the fields
				for ($k=0; $k<$fields->length; $k++)
				{
					// Increment the ID
					if ($fields->item($k)->getAttribute('name') == 'id')
					{
						$arrMapper[$table][$fields->item($k)->nodeValue] = ${$table}++;
						break;
					}
				}
			}
		}

		// Loop through the tables
		for ($i=0; $i<$tables->length; $i++)
		{
			$rows = $tables->item($i)->childNodes;
			$table = $tables->item($i)->getAttribute('name');

			// Skip invalid tables
			if (!in_array($table, array_keys($arrDbFields)))
			{
				continue;
			}

			// Get the order fields
			$objDcaExtractor = \DcaExtractor::getInstance($table);
			$arrOrder = $objDcaExtractor->getOrderFields();

			// Loop through the rows
			for ($j=0; $j<$rows->length; $j++)
			{
				$set = array();
				$fields = $rows->item($j)->childNodes;

				// Loop through the fields
				for ($k=0; $k<$fields->length; $k++)
				{
					$value = $fields->item($k)->nodeValue;
					$name = $fields->item($k)->getAttribute('name');

					// Skip NULL values
					if ($value == 'NULL')
					{
						continue;
					}

					// Increment the ID
					elseif ($name == 'id')
					{
						$value = $arrMapper[$table][$value];
					}

					// Increment the parent IDs
					elseif ($name == 'pid')
					{
						if ($table == 'tl_pattern')
						{
							$value = $arrMapper['tl_elements'][$value];
						}
						else
						{
							$value = $arrMapper['tl_theme'][$value];
						}
					}

					// Adjust element alias
					elseif ($table == 'tl_elements' && $name == 'alias')
					{
						$objName = $this->Database->prepare("SELECT name FROM tl_theme WHERE id=?")
												  ->limit(1)
												  ->execute($set['pid']);

						$value = \StringUtil::generateAlias($objName->name . '-' . $set['title']);			  
					}


					// Replace the file paths in singleSRC fields with their tl_files ID
					elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'fileTree' && !$GLOBALS['TL_DCA'][$table]['fields'][$name]['eval']['multiple'])
					{
						if (!$value)
						{
							$value = null; // Contao >= 3.2
						}
						else
						{
							// Do not use the FilesModel here - tables are locked!
							$objFile = $this->Database->prepare("SELECT uuid FROM tl_files WHERE path=?")
													  ->limit(1)
													  ->execute($this->customizeUploadPath($value));

							$value = $objFile->uuid;
						}
					}

					// Replace the file paths in multiSRC fields with their tl_files ID
					elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'fileTree' || in_array($name, $arrOrder))
					{
						$tmp = \StringUtil::deserialize($value);

						if (is_array($tmp))
						{
							foreach ($tmp as $kk=>$vv)
							{
								// Do not use the FilesModel here - tables are locked!
								$objFile = $this->Database->prepare("SELECT uuid FROM tl_files WHERE path=?")
														  ->limit(1)
														  ->execute($this->customizeUploadPath($vv));

								$tmp[$kk] = $objFile->uuid;
							}

							$value = serialize($tmp);
						}
					}

					// Adjust the imageSize widget data
					elseif ($GLOBALS['TL_DCA'][$table]['fields'][$name]['inputType'] == 'imageSize')
					{
						$imageSizes = \StringUtil::deserialize($value, true);

						if (!empty($imageSizes))
						{
							if (is_numeric($imageSizes[2]))
							{
								$imageSizes[2] = $arrMapper['tl_image_size'][$imageSizes[2]];
							}
						}

						$value = serialize($imageSizes);
					}

					// Adjust the sizeList
					elseif ($table == 'tl_pattern' && $name == 'sizeList')
					{
						$imageSizes = \StringUtil::deserialize($value, true);

						if (!empty($imageSizes))
						{
							foreach ($imageSizes as $kk=>$vv)
							{
								$imageSizes[$kk] = $arrMapper['tl_image_size'][$vv];
								if (empty($imageSizes[$kk])) unset($imageSizes[$kk]); // Remove if no new size could be found
							}
						}
						
						$value = serialize($imageSizes);
					}

					$set[$name] = $value;
				}

				// Skip fields that are not in the database (e.g. because of missing extensions)
				foreach ($set as $k=>$v)
				{
					if (!in_array($k, $arrDbFields[$table]))
					{
						unset($set[$k]);
					}
				}
					
				// Insert into database
				$this->Database->prepare("INSERT INTO $table %s")->set($set)->execute();

			}
		}

		// Unlock the tables
		$this->Database->unlockTables();
	
		unset($tl_elements, $tl_pattern);
	}
406074
protected function saveInternal(EmailTemplate $entity, array $data)
    {
        if ($entity->getIsNewRecord() && !$entity->load($data)) {
            throw new \DomainException('Cannot load data to primary model');
        }

        foreach ($data[EmailTemplateTranslation::internalFormName()] as $language => $dataSet) {
            $translationEntity = $entity->getTranslation($language);

            foreach ($dataSet as $attribute => $translation) {
                $translationEntity->$attribute = $translation;
            }
        }

        if (!$entity->save()) {
            throw new \RuntimeException();
        }
    }
873641
protected function prepareTemplate(Template $objTemplate, $arrRowData, $objSettings)
    {
        parent::prepareTemplate($objTemplate, $arrRowData, $objSettings);

        $toolbox = clone $this->toolboxFile;
        $toolbox
            ->setBaseLanguage($this->getMetaModel()->getActiveLanguage())
            ->setFallbackLanguage($this->getMetaModel()->getFallbackLanguage())
            ->setLightboxId(
                \sprintf(
                    '%s.%s.%s',
                    $this->getMetaModel()->getTableName(),
                    $objSettings->get('id'),
                    $arrRowData['id']
                )
            )
            ->setShowImages($objSettings->get('file_showImage'));

        if (($types = \trim($this->get('file_validFileTypes')))) {
            $toolbox->setAcceptedExtensions($types);
        }

        if ($objSettings->get('file_imageSize')) {
            $toolbox->setResizeImages($objSettings->get('file_imageSize'));
        }

        if ($arrRowData[$this->getColName()]) {
            if (!isset($arrRowData[$this->getColName()]['value']['bin'])) {
                throw new \InvalidArgumentException('No binary in value.');
            }

            foreach ($arrRowData[$this->getColName()]['value']['bin'] as $strFile) {
                $toolbox->addPathById($strFile);
            }
        }

        $arrData = [];
        $toolbox->resolveFiles();
        if ('manual' !== $objSettings->get('file_sortBy')) {
            $arrData = $toolbox->sortFiles($objSettings->get('file_sortBy'));
        }
        if ('manual' === $objSettings->get('file_sortBy')) {
            $arrData = $toolbox->sortFiles(
                $objSettings->get('file_sortBy'),
                ($arrRowData[$this->getColName()]['value_sorting']['bin'] ?? [])
            );
        }

        $objTemplate->files = $arrData['files'];
        $objTemplate->src   = $arrData['source'];
    }
338697
private function _getCreateTaskTemplateContext(TaskTemplate $taskTemplate)
    {
        $result = new HttpCallContext();
        $result->setMethod(Resources::HTTP_POST);
        $result->setHeaders($this->_batchHeaders);
        $result->setUri($this->getUri());
        $result->setPath('/$1/TaskTemplates');
        $result->setBody($this->wrapAtomEntry($taskTemplate));
        $result->addStatusCode(Resources::STATUS_CREATED);

        return $result;
    }
998736
public function addDeliveryTemplate(array $deliveryTemplate)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_DELIVERY_TEMPLATE_ADD_URL . 'access_token=' . $this->getAccessToken(), [
            'delivery_template' => $deliveryTemplate
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['template_id'] : false;
    }
1273527
public static void loadTemplate(SheetTemplate template, int sheetIndex) {

        if (sheetIndex < 0) sheetIndex = 0;
        template.sheetIndex = sheetIndex;
        template.sheet = template.workbook.getSheetAt(sheetIndex);
        initModuleConfig(template);
        template.currentRowIndex = template.initRowIndex;
        template.currentColumnIndex = template.initColumnIndex;
        template.lastRowIndex = template.sheet.getLastRowNum();
    }
830559
public function getTemplateFile($template)
    {
        $paths  = $this->config["path"];
        $suffix = $this->config["suffix"];

        foreach ($paths as $path) {
            $file = $path . "/" . $template . $suffix;
            if (is_file($file)) {
                return $file;
            }
        }

        throw new Exception("Could not find template file '$template'.");
    }
1112845
private function extractAttributes(\DOMElement $node, array $data, $nodeName)
    {
        foreach ($data['@attributes'] as $key => $value) {

            if (! $this->isValidTagName($key)) {

                throw new \Exception(__CLASS__.' Illegal character in attribute name. attribute: '.$key.' in node: '.$nodeName);

            }

            $node->setAttribute($key, $this->boolToString($value));
        }
    }
909385
private function importTable(string $tableName, array $columns, array $items)
    {
        if (empty($tableName) || empty($columns) || empty($items)) {
            throw new \RuntimeException(
                'Invalid import data',
                1535487373
            );
        }

        $this->connection->truncate($tableName);

        $columnNames = array_keys($columns);
        $columnTypes = array_values($columns);
        foreach ($items as $item) {
            $this->connection->insert(
                $tableName,
                array_combine($columnNames, $item),
                $columns
            );
        }
    }