Converts raw data into a content item entity.

@param array       $data
@param ContentItem $contentItem
@param array       $options

@return ContentItem
168495
public function deserialize($data, ContentItem $contentItem = null, array $options = [])
    {
        if (empty($contentItem)) {
            $contentItem = new ContentItem();
        }
        $this->sipe('url', 'setData', $data, $contentItem);
        $this->sipe('data', 'setData', $data, $contentItem);

        return $contentItem;
    }
196517
public function deserialize(array $data, ResourceNode $resourceNode, array $options = [])
    {
        $this->sipe('name', 'setName', $data, $resourceNode);

        if (!in_array(Options::REFRESH_UUID, $options)) {
            $this->sipe('id', 'setUuid', $data, $resourceNode);
        }

        if (isset($data['meta']['workspace'])) {
            /** @var Workspace $workspace */
            $workspace = $this->om->getRepository(Workspace::class)->findOneBy(['uuid' => $data['meta']['workspace']['uuid']]);
            $resourceNode->setWorkspace($workspace);
        }

        if (isset($data['poster']) && isset($data['poster']['url'])) {
            $resourceNode->setPoster($data['poster']['url']);
        }

        if (isset($data['thumbnail']) && isset($data['thumbnail']['url'])) {
            $resourceNode->setThumbnail($data['thumbnail']['url']);
        }

        // meta
        if (empty($resourceNode->getResourceType())) {
            /** @var ResourceType $resourceType */
            $resourceType = $this->om
                ->getRepository('ClarolineCoreBundle:Resource\ResourceType')
                ->findOneBy(['name' => $data['meta']['type']]);

            $resourceNode->setResourceType($resourceType);
        }

        if (empty($resourceNode->getMimeType())) {
            if (isset($data['meta']) && !empty($data['meta']['mimeType'])) {
                $mimeType = $data['meta']['mimeType'];
            } else {
                $mimeType = 'custom/'.$resourceNode->getResourceType()->getName();
            }

            $resourceNode->setMimeType($mimeType);
        }

        if (isset($data['rights'])) {
            $this->deserializeRights($data['rights'], $resourceNode, $options);
        }

        $this->sipe('meta.published', 'setPublished', $data, $resourceNode);
        $this->sipe('meta.description', 'setDescription', $data, $resourceNode);
        $this->sipe('meta.license', 'setLicense', $data, $resourceNode);
        $this->sipe('meta.authors', 'setAuthor', $data, $resourceNode);
        $this->sipe('meta.commentsActivated', 'setCommentsActivated', $data, $resourceNode);

        // display
        $this->sipe('display.fullscreen', 'setFullscreen', $data, $resourceNode);
        $this->sipe('display.showIcon', 'setShowIcon', $data, $resourceNode);
        $this->sipe('display.closable', 'setClosable', $data, $resourceNode);
        $this->sipe('display.closeTarget', 'setCloseTarget', $data, $resourceNode);

        // restrictions
        $this->sipe('restrictions.code', 'setAccessCode', $data, $resourceNode);
        $this->sipe('restrictions.allowedIps', 'setAllowedIps', $data, $resourceNode);
        $this->sipe('restrictions.hidden', 'setHidden', $data, $resourceNode);

        if (isset($data['restrictions']['dates'])) {
            $dateRange = DateRangeNormalizer::denormalize($data['restrictions']['dates']);

            $resourceNode->setAccessibleFrom($dateRange[0]);
            $resourceNode->setAccessibleUntil($dateRange[1]);
        }
    }
311533
public function insert(array $data, array $options = []) {
		return $this->getAdapter()->insert(
			$this->getTableName(),
			$data,
			$options
		);
	}
346500
public function deserializeQuestion(array $questionData, AbstractItem $question = null, array $options = [])
    {
        return $this->getQuestionSerializer()->deserialize($questionData, $question, $options);
    }
468615
protected function _entity(array $data = null, array $options = [])
    {
        if ($this->_entity && empty($data)) {
            return $this->_entity;
        }

        return $this->_table()->newEntity($data, $options);
    }
662722
public function provide($data = null, array $options = [])
    {
        $result = parent::provide($data, $options);
        $errorResponse = sprintf(parent::VALUE_NOT_FOUND_HTML, $data);

        //In case the result is empty or its the same with the errorResponse then return the result
        if (empty($result) || $errorResponse == $result) {
            return $result;
        } else {
            return sprintf(static::ICON_HTML, strtolower($data), $result);
        }
    }
1169267
protected function encode($data, $options = 0)
    {
        // Check is already json string.
        if (is_string($data) && strlen($data) >= 1) {
            $firstChar = $data[0];

            if (in_array($firstChar, ['[', '{', '"'])) {
                return $data;
            }
        }

        // Clear json_last_error()
        json_encode(null);

        $json = json_encode($data, $options);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new \UnexpectedValueException(sprintf('JSON encode failure: %s', json_last_error_msg()));
        }

        return $json;
    }
465232
public static function dump(string $filename, $data, array $options = []): bool
    {
        return file_put_contents($filename, self::encode($data, $options)) !== false;
    }
676700
private static function _arr2xml($data, $content = '')
    {
        foreach ($data as $key => $val) {
            is_numeric($key) && $key = 'item';
            $content .= "<{$key}>";
            if (is_array($val) || is_object($val)) {
                $content .= self::_arr2xml($val);
            } elseif (is_string($val)) {
                $content .= '<![CDATA[' . preg_replace("/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/", '', $val) . ']]>';
            } else {
                $content .= $val;
            }
            $content .= "</{$key}>";
        }
        return $content;
    }
1089753
public function save($data = null, array $options = []) {
        if ($data) {
            $this->data($data);
        }

        return $this->getRepository()->save($this, $options);
    }
215802
public static function create(array $data, array $options = []) {
        /** @type \Titon\Model\Model $model */
        $model = new static();
        $model->fill($data);

        if ($model->save($options)) {
            return $model;
        }

        return null;
    }
362864
protected function prepareEntityItem(array &$item, array $options)
    {
        $this->setItemEntityUrl($item, $options);
        $this->setItemThumb($item, $this->image, $options);

        if ($options['entity'] === 'product') {
            $this->prepareProductItem($item, $options);
        } else {
            $this->setItemIndentation($item);
            $this->setItemUrlActive($item);
            $this->setItemRendered($item, array('item' => $item), $options);
        }
    }
1002788
public function deserialize($data, Keyword $keyword = null, array $options = [])
    {
        if (empty($keyword)) {
            $keyword = new Keyword();
        }
        $cleanedText = trim(strip_tags(html_entity_decode($data['text'])));
        $keyword->setText($cleanedText);

        $this->sipe('caseSensitive', 'setCaseSensitive', $data, $keyword);
        $this->sipe('score', 'setScore', $data, $keyword);
        $this->sipe('feedback', 'setFeedback', $data, $keyword);

        return $keyword;
    }
772173
public function createForm($data = null, array $options = [])
    {
        return $this->formFactory->create(NodeFormType::class, $data, $options);
    }
1224708
public function deserialize($data, ItemObject $itemObject = null, array $options = [])
    {
        $itemObject = $itemObject ?: new ItemObject();

        $this->sipe('id', 'setUuid', $data, $itemObject);

        if (in_array(Transfer::REFRESH_UUID, $options)) {
            $itemObject->refreshUuid();
        }
        $this->sipe('type', 'setMimeType', $data, $itemObject);
        $this->sipe('url', 'setData', $data, $itemObject);
        $this->sipe('data', 'setData', $data, $itemObject);

        return $itemObject;
    }
899384
public function provide($data = null, array $options = [])
    {
        $selectListItems = $this->config->getProvider('selectOptions');
        $selectListItems = new $selectListItems($this->config);
        $listName = $options['fieldDefinitions']->getLimit();

        $selectOptions = $selectListItems->provide($listName, []);
        foreach ($selectOptions as $k => $v) {
            $selectOptions[$k] = sprintf(CountryValueRenderer::ICON_HTML, strtolower($k), $v);
        }

        $options['selectOptions'] = $selectOptions;
        $options['element'] = 'CsvMigrations.FieldHandlers/CountryFieldHandler/input';

        return parent::provide($data, $options);
    }
1197967
static private function _data_to_xml($data, $item = 'item', $id = 'id', $content = '')
    {
        foreach ($data as $key => $val) {
            is_numeric($key) && $key = "{$item} {$id}=\"{$key}\"";
            $content .= "<{$key}>";
            if (is_array($val) || is_object($val)) {
                $content .= self::_data_to_xml($val);
            } elseif (is_numeric($val)) {
                $content .= $val;
            } else {
                $content .= '<![CDATA[' . preg_replace("/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/", '', $val) . ']]>';
            }
            list($_key, ) = explode(' ', $key . ' ');
            $content .= "</$_key>";
        }
        return $content;
    }