Creates a FieldDefinition from the data in $row.

@param array $row

@param array $multilingualData

@return \eZ\Publish\SPI\Persistence\Content\Type\FieldDefinition
439956
public function extractFieldFromRow(array $row, array $multilingualData = [])
    {
        $storageFieldDef = $this->extractStorageFieldFromRow($row, $multilingualData);

        $field = new FieldDefinition();

        $field->id = (int)$row['ezcontentclass_attribute_id'];
        $field->name = $this->unserialize($row['ezcontentclass_attribute_serialized_name_list']);
        $field->description = $this->unserialize($row['ezcontentclass_attribute_serialized_description_list']);
        // Unset redundant data
        unset(
            $field->name['always-available'],
            $field->name[0],
            $field->description['always-available'],
            $field->description[0]
        );
        $field->identifier = $row['ezcontentclass_attribute_identifier'];
        $field->fieldGroup = $row['ezcontentclass_attribute_category'];
        $field->fieldType = $row['ezcontentclass_attribute_data_type_string'];
        $field->isTranslatable = ($row['ezcontentclass_attribute_can_translate'] == 1);
        $field->isRequired = $row['ezcontentclass_attribute_is_required'] == 1;
        $field->isInfoCollector = $row['ezcontentclass_attribute_is_information_collector'] == 1;

        $field->isSearchable = (bool)$row['ezcontentclass_attribute_is_searchable'];
        $field->position = (int)$row['ezcontentclass_attribute_placement'];

        $mainLanguageCode = $this->maskGenerator->extractLanguageCodesFromMask((int)$row['ezcontentclass_initial_language_id']);
        $field->mainLanguageCode = array_shift($mainLanguageCode);

        $this->toFieldDefinition($storageFieldDef, $field);

        return $field;
    }
764711
protected function getTerm($name, Row $row, $vocabulary) {
    // Attempt to fetch an existing term.
    $properties = [];
    if (!empty($name)) {
      $properties['name'] = $name;
    }
    $vocabularies = taxonomy_vocabulary_get_names();
    if (isset($vocabularies[$vocabulary])) {
      $properties['vid'] = $vocabulary;
    }
    else {
      // Return NULL when filtering by a non-existing vocabulary.
      return NULL;
    }

    $terms = \Drupal::getContainer()->get('entity.manager')->getStorage('taxonomy_term')->loadByProperties($properties);
    $term = reset($terms);
    if (!empty($term)) {
      if ($row->getDestinationProperty('langcode') && $row->getDestinationProperty('langcode') != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
        if (!$term->hasTranslation($row->getDestinationProperty('langcode'))) {
          $term->addTranslation($row->getDestinationProperty('langcode'));
        }
        $term = $term->getTranslation($row->getDestinationProperty('langcode'));
      }
      return $term;
    }
    // Fallback, create a new term.
    $term = Term::create($properties);
    if ($row->getDestinationProperty('langcode')) {
      $term->langcode = $row->getDestinationProperty('langcode');
    }
    return $term;
  }
217035
protected static function generateRow(array $row, $delimiter, $enclose)
    {
        array_walk($row, function (&$item) use ($enclose) {
            if (is_bool($item)) {
                $item = (int) $item;
            } elseif (is_null($item)) {
                $item = '';
            } elseif (!is_scalar($item)) {
                $item = "[array]";
            }
            $item = $enclose.Html::encode($item).$enclose;
        });

        return implode($delimiter, $row) . PHP_EOL;
    }
683388
public function toFieldDefinition(StorageFieldDefinition $storageDef, FieldDefinition $fieldDef)
    {
        $options = [];
        $multiLingualOptions = [$fieldDef->mainLanguageCode => []];

        if (isset($storageDef->dataText5)) {
            $optionsXml = simplexml_load_string($storageDef->dataText5);
            if ($optionsXml !== false) {
                foreach ($optionsXml->options->option as $option) {
                    $options[(int)$option['id']] = (string)$option['name'];
                }
            }
        }

        if (isset($fieldDef->mainLanguageCode) && !empty($options)) {
            $multiLingualOptions[$fieldDef->mainLanguageCode] = $options;
        }

        foreach ($storageDef->multilingualData as $languageCode => $mlData) {
            $xml = simplexml_load_string($mlData->dataText);
            if ($xml !== false) {
                foreach ($xml->options->option as $option) {
                    $multiLingualOptions[$languageCode][(int)$option['id']] = (string)$option['name'];
                }
            }
        }

        $fieldDef->fieldTypeConstraints->fieldSettings = new FieldSettings([
                'isMultiple' => !empty($storageDef->dataInt1) ? (bool)$storageDef->dataInt1 : false,
                'options' => $options,
                'multilingualOptions' => $multiLingualOptions,
            ]
        );

        // @todo: Can Selection store a default value in the DB?
        $fieldDef->defaultValue = new FieldValue();
        $fieldDef->defaultValue->data = array();
        $fieldDef->defaultValue->sortKey = '';
    }
1166387
private function mapDocument(array $row)
    {
        $message = Message::create(
            $row['subject'],
            $row['body'],
            $row['priority'],
            $row['type'],
            $row['channel'],
            $row['role'],
            $row['user'],
            \DateTime::createFromFormat('U', $row['createdAt'])
        );

        return $message;
    }
255230
protected function loadObjects(array $row)
    {

        $objectsInfo = [];
        foreach ($row as $alias => $value) {
            $pos = strrpos($alias, ISelector::ALIAS_SEPARATOR);
            if (!$pos) {
                throw new LoadEntityException($this->translate(
                    'Cannot load objects from data row. Field alias "{alias}" is not correct.',
                    ['alias' => $alias]
                ));
            }
            $collectionPath = substr($alias, 0, $pos);
            $fieldName = substr($alias, $pos + 1);

            if (!isset($objectsInfo[$collectionPath])) {
                $objectsInfo[$collectionPath] = [];
            }
            $objectsInfo[$collectionPath][$fieldName] = $value;
        }

        $mainObject = null;
        foreach ($objectsInfo as $collectionPath => $objectInfo) {

            if (!array_key_exists(IObject::FIELD_TYPE, $objectInfo)) {
                throw new LoadEntityException($this->translate(
                    'Cannot load object from data row. Information about object type is not found.'
                ));
            }

            if (!is_null($objectInfo[IObject::FIELD_TYPE])) {
                $object = $this->loadObject($objectInfo[IObject::FIELD_TYPE], $objectInfo);
                if (!$mainObject && !substr_count($collectionPath, ISelector::FIELD_SEPARATOR)) {
                    $mainObject = $object;
                }
            }

        }
        if (!$mainObject) {
            throw new LoadEntityException($this->translate(
                'Cannot detect main object from data row.'
            ));
        }

        return $mainObject;
    }
335072
protected function getRowId(array $row, $idField)
    {
        if (!array_key_exists($idField, $row)) {
            throw new ReaderException(
                sprintf(
                    'Row: "%s" has no field named "%s"',
                    $this->key(),
                    $idField
                )
            );
        }

        return $row[$idField];
    }
1202328
public function renderDataCellContent($row, $data)
    {
        $isModel = $data instanceOf CModel;
        
        if($isModel) {
            $widgetClass = 'TbEditableField';
            $options = array(
                'model'        => $data,
                'attribute'    => empty($this->editable['attribute']) ? $this->name : $this->editable['attribute'],
            );
            
            //if value defined in column config --> we should evaluate it 
            //and pass to widget via `text` option: set flag `passText` = true 
            $passText = !empty($this->value);     
        } else {
            $widgetClass = 'TbEditable';
            $options = array(
                'pk'           => $data[$this->grid->dataProvider->keyField],
                'name'         => empty($this->editable['name']) ? $this->name : $this->editable['name'],
            );
            
            $passText = true;
            //if autotext will be applied, do not pass `text` option (pass `value` instead)
            if(empty($this->value) && TbEditable::isAutotext($this->editable, isset($this->editable['type']) ? $this->editable['type'] : '')) {
               $options['value'] = $data[$this->name]; 
               $passText = false;
            } 
        }
        
        //for live update
        $options['liveTarget'] = $this->grid->id;
        
        $options = CMap::mergeArray($this->editable, $options);

        //if value defined for column --> use it as element text
        if($passText) {
            ob_start();
            parent::renderDataCellContent($row, $data);
            $text = ob_get_clean();
            $options['text'] = $text;
            $options['encode'] = false;
        }
        
        //apply may be a string expression, see https://github.com/vitalets/x-editable-yii/issues/33
        if (isset($options['apply']) && is_string($options['apply'])) {
            $options['apply'] = $this->evaluateExpression($options['apply'], array('data'=>$data, 'row'=>$row));
        }

        //evaluate htmlOptions inside editable config as they can depend on $data
        //see https://github.com/vitalets/x-editable-yii/issues/40
        if (isset($options['htmlOptions']) && is_array($options['htmlOptions'])) {
            foreach($options['htmlOptions'] as $k => $v) {
                if(is_string($v) && (strpos($v, '$data') !== false || strpos($v, '$row') !== false)) {
                    $options['htmlOptions'][$k] = $this->evaluateExpression($v, array('data'=>$data, 'row'=>$row));
                }
            }
        }           
        
        $this->grid->controller->widget($widgetClass, $options);
    }
454598
public function translateRowValues($row, $key)
    {
        $row = parent::translateRowValues($row, $key);

        if (! $row) {
            return false;
        }

        // Get the real organization from the provider_id or code if it exists
        if (isset($row[$this->orgIdField], $this->orgTranslations[$row[$this->orgIdField]])) {
            $row[$this->orgIdField] = $this->orgTranslations[$row[$this->orgIdField]];
        }

        return $row;
    }
754388
public function getDataStructureIdentifierPreProcess(array $fieldTca, string $tableName, string $fieldName, array $row): array
    {
        if ($tableName != 'tt_content' || $fieldName != 'tx_column_layout_column_config') {
            return [];
        }

        return [
            'type' => 'tca',
            'tableName' => $tableName,
            'fieldName' => $fieldName,
            'dataStructureKey' => ColumnLayoutUtility::getColumnLayoutSettings($row['_tx_column_layout_orig_pid'] ?? $row['pid'])['flexFormKey']
        ];
    }
423748
public function renderRow($row, array $data = [])
    {
        if (is_string($row)) {
            if (null === $element = $this->editor->getRepository()->findRowByName($row)) {
                $this->persist($element = $this->editor->getRowManager()->create($row, $data));
            }
            $row = $element;
        }

        if ($row instanceof EM\RowInterface) {
            $this->tagManager->addTags($row->getEntityTag());

            $row = $this->editor->getViewBuilder()->buildRow($row);
        }

        if (!$row instanceof View\RowView) {
            throw new Exception\InvalidArgumentException(
                'Expected string or instance of ' .
                EM\RowInterface::class . ' or ' .
                View\RowView::class
            );
        }

        /** @noinspection PhpInternalEntityUsedInspection */
        return $this->getTemplate()->renderBlock('cms_row', [
            'row' => $row,
        ]);
    }
551181
public function getField($row, array $templates = []): string
    {
        $value = $this->attributes['field']($row, $this, $templates);

        if ($value instanceof Renderable) {
            return $value->render();
        }

        return $value;
    }
855179
public function create($rowOrName, $type = null, array $data = [])
    {
        // Check if row or name is defined
        if (!(
            $rowOrName instanceof Model\RowInterface ||
            (is_string($rowOrName) && 0 < strlen($rowOrName))
        )
        ) {
            throw new InvalidOperationException("Excepted instance of RowInterface or string.");
        }

        // Default type if null
        if (null === $type) {
            $type = $this->defaultType;
        }

        // New instance
        $block = $this->editor->getRepository()->createBlock();
        $block->setType($type);

        // Layout creation
//        $this->editor->getLayoutAdapter()->createBlock($block, $data);

        // Plugin creation
        $this->editor->getBlockPlugin($type)->create($block, $data);

        // Add to row if available
        if ($rowOrName instanceof Model\RowInterface) {
            $count = $rowOrName->getBlocks()->count();
            $block
                ->setPosition($count);

            $rowOrName->addBlock($block);
        } else {
            $block->setName($rowOrName);
        }

        return $block;
    }
92286
public function createTagInfoFromRow(array $row)
    {
        $tagInfo = new TagInfo();

        $tagInfo->id = (int) $row['id'];
        $tagInfo->parentTagId = (int) $row['parent_id'];
        $tagInfo->mainTagId = (int) $row['main_tag_id'];
        $tagInfo->depth = (int) $row['depth'];
        $tagInfo->pathString = $row['path_string'];
        $tagInfo->modificationDate = (int) $row['modified'];
        $tagInfo->remoteId = $row['remote_id'];
        $tagInfo->alwaysAvailable = ((int) $row['language_mask'] & 1) ? true : false;
        $tagInfo->mainLanguageCode = $this->languageHandler->load($row['main_language_id'])->languageCode;
        $tagInfo->languageIds = $this->languageMaskGenerator->extractLanguageIdsFromMask((int) $row['language_mask']);

        return $tagInfo;
    }
793287
public function _prepareArrayRow(\Magento\Framework\DataObject $row)
    {
        $options = [];

        $options['option_' . $this->_getAttributeRenderer()->calcOptionHash(
            $row->getData('attribute')
        )]
            = 'selected="selected"';
        $options['option_' . $this->_getDatafieldRenderer()->calcOptionHash(
            $row->getData('datafield')
        )]
            = 'selected="selected"';

        $row->setData('option_extra_attrs', $options);
    }
1328786
private function getVisitFieldsToUpdate(array $row, $location)
    {
        if (isset($location[LocationProvider::COUNTRY_CODE_KEY])) {
            $location[LocationProvider::COUNTRY_CODE_KEY] = strtolower($location[LocationProvider::COUNTRY_CODE_KEY]);
        }

        $valuesToUpdate = array();
        foreach (self::$logVisitFieldsToUpdate as $column => $locationKey) {
            if (empty($location[$locationKey])) {
                continue;
            }

            $locationPropertyValue = $location[$locationKey];
            $existingPropertyValue = $row[$column];

            if (!$this->areLocationPropertiesEqual($locationKey, $locationPropertyValue, $existingPropertyValue)) {
                $valuesToUpdate[$column] = $locationPropertyValue;
            }
        }
        return $valuesToUpdate;
    }
715865
private function resolveProperty(Row $row, $name, $locale, $shadowLocale = null)
    {
        if (array_key_exists(sprintf('node.%s', $name), $row->getValues())) {
            return $row->getValue($name);
        }

        if (null !== $shadowLocale && !in_array($name, self::$nonFallbackProperties)) {
            $locale = $shadowLocale;
        }

        $name = sprintf('%s%s', $locale, str_replace('-', '_', ucfirst($name)));

        try {
            return $row->getValue($name);
        } catch (ItemNotFoundException $e) {
            // the default value of a non existing property in jackalope is an empty string
            return '';
        }
    }