Provide field value


@param mixed $data Field value (Request, Entity, etc)
@param array $options Options to use for provision
@return mixed Field value
979131
public function provide($data = null, array $options = [])
    {
        if (empty($options['entity'])) {
            return null;
        }

        $table = $this->config->getTable();

        // return null in cases where no table or a dummy table was provided by the config class
        try {
            $primaryKey = $table->getPrimaryKey();
        } catch (Exception $e) {
            return null;
        }

        if (! is_string($primaryKey)) {
            throw new UnsupportedPrimaryKeyException();
        }

        if ($options['entity'] instanceof EntityInterface) {
            return $options['entity']->get($primaryKey);
        }

        if ($options['entity'] instanceof ServerRequest) {
            return $options['entity']->getData($primaryKey);
        }

        return null;
    }
436319
public function insert($data, $options = [])
    {
        return $this->database->createCommand()->insert($this->name, $data, $options);
    }
1268853
public function createFromArrayWithContext($data, $options)
    {
        $_edgeClass = $this->_edgeClass;

        return $_edgeClass::createFromArray($data, $options);
    }
249733
public function deserialize(array $data, Options $options = null)
    {
        if (empty($options)) {
            $options = $this->optionsRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($options)) {
            $options = new Options();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $options->setUser($user);
        }
        if (isset($data['data'])) {
            $options->setOptions($data['data']);
        }

        return $options;
    }
1333845
public function provide($data = null, array $options = [])
    {
        if (!$data instanceof CsvField) {
            throw new InvalidArgumentException("Given data is not an instance of CsvField");
        }

        $data->setType($this->dbFieldType);
        // Set the limit to Phinx\Db\Adapter\MysqlAdapter::BLOB_LONG
        $data->setLimit(MysqlAdapter::BLOB_LONG);

        $dbField = DbField::fromCsvField($data);
        $result = [
            $data->getName() => $dbField,
        ];

        return $result;
    }
1068383
public function save(array &$data, array $options = array())
    {
        $document = new Document($data, $this);
        $save = $document->save($options);
        $data = $document->data;

        return $save;
    }
311533
public function insert(array $data, array $options = []) {
		return $this->getAdapter()->insert(
			$this->getTableName(),
			$data,
			$options
		);
	}
124130
public function val($field, $options = [])
    {
        $val = parent::val($field, $options);
        if ($val === null) {
            $parts  = explode('.', $field);
            $entity = $this->entity($parts);

            if ($entity instanceof Data) {
                $key = array_pop($parts);
                $val = $entity->get($key);
            }
        }

        return $val;
    }
450399
protected function getRequestBody($params, $data, $options)
    {
        $params['scope'] = 'crmapi';
        $params['authtoken'] = $this->authtoken;
        $params += ['newFormat' => 1]; //'version' => 2,
        if (!empty($data)) {
            $params['xmlData'] = (isset($options['map']) && $options['map']) ? $this->toXML($data) : $data;
        }

        if (!isset($params['content'])) {
            return http_build_query($params, '', '&');
        }

        return $params;
    }
147216
public function read($data, array $options = []) {
		$class = $options['class'];

		$encrypted = $class::read(null, ['strategies' => false]);
		$key = isset($options['key']) ? $options['key'] : null;

		if (!isset($encrypted['__encrypted']) || !$encrypted['__encrypted']) {
			return isset($encrypted[$key]) ? $encrypted[$key] : null;
		}

		$current = $this->_decrypt($encrypted['__encrypted']);

		if ($key) {
			return isset($current[$key]) ? $current[$key] : null;
		} else {
			return $current;
		}
	}
162154
public function denormalise(array $data, array $options = [])
    {
        if (empty($data)) {
            return $data;
        }

        if (!isset($options["entityClass"])) {
            throw new NormalisationException("Cannot denormalise data without knowing the main entity class");
        }
        if (!isset($options["metadataProvider"])) {
            throw new NormalisationException("Cannot denormalise data without a metadata provider");
        }

        /** @var EntityMetadataProviderInterface $metadataProvider */
        $this->metadataProvider = $options["metadataProvider"];
        $metadata = $this->metadataProvider->getEntityMetadata($options["entityClass"]);

        // split fields based on prefix
        $prefixedFields = [];
        foreach ($data[0] as $field => $value) {
            $fieldParts = explode("__", $field);
            // if this field has no prefix, set it to an empty string
            if (count($fieldParts) == 1) {
                array_unshift($fieldParts, "");
            }
            // add the field to the prefix's array
            $prefix = $fieldParts[0];
            if (empty($prefixedFields[$prefix])) {
                $prefixedFields[$prefix] = [];
            }
            $prefixedFields[$prefix][$fieldParts[1]] = $field;
        }

        // handle case where only 1 prefix is present
        if (count($prefixedFields) == 1) {
            $fields = array_pop($prefixedFields);
            $primaryKey = $metadata->getPrimaryKey();
            if (isset($fields[$primaryKey])) {
                $this->primaryKeyFields = [$fields[$primaryKey] => true];
            }
            return $this->denormaliseData($data, $fields);
        }

        // complex result set
        if (!isset($options["entityMap"])) {
            throw new NormalisationException("Cannot denormalise data without an entity map");
        }

        $entityMap = $options["entityMap"];

        $collection = $metadata->getCollection();

        if (empty($prefixedFields[$collection])) {
            throw new NormalisationException("The collection '$collection' was not found in the fields array for this record set: '" . implode("', '", array_keys($prefixedFields)) . "'");
        }

        // reset primary key fields
        $this->primaryKeyFields = [];
        $this->treedEntities = [];
        $this->childRowAliases = [];

        $this->createFieldTree($prefixedFields, $entityMap, $collection, $options["entityClass"]);

        reset($data);
        $result = $this->denormaliseData($data, $prefixedFields[$collection], $collection);

        return  $result;
    }
482339
protected function createFromArrayWithContext($data, $options)
    {
        $_documentClass = $this->_documentClass;

        return $_documentClass::createFromArray($data, $options);
    }
788664
protected function parseData($data, array $options, $key = null)
    {
        $architect = new Architect();

        return $architect->parseData($data, $options['modes'], $key);
    }
1089753
public function save($data = null, array $options = []) {
        if ($data) {
            $this->data($data);
        }

        return $this->getRepository()->save($this, $options);
    }
249125
public static final function jsonEncode($data, array $options = null): array
    {
        $encoder = new JsonEncoder($options);

        return [$encoder->encode($data), $encoder->hasError()
            ? new EncoderException('JSON Error: '. $encoder->getError()) : null];
    }
351699
public function provide($data = null, array $options = [])
    {
        $template = $this->getBasicTemplate('number');
        $defaultOptions = $this->getDefaultOptions($data, $options);
        $defaultOptions['input'] = ['content' => $template];

        $view = $this->config->getView();
        $content = $view->Form->control('', [
            'name' => '{{name}}',
            'value' => '{{value}}',
            'type' => 'number',
            'step' => $options['step'] ?? Setting::DEFAULT_STEP_FOR_NUMBER,
            'max' => $options['max'] ?? Setting::MAX_VALUE_FOR_NUMBER,
            'min' => $options['min'] ?? Setting::MIN_VALUE_FOR_NUMBER,
            'label' => false
        ]);

        $defaultOptions['input'] = [
            'content' => $content
        ];

        $result[$this->config->getField()] = $defaultOptions;

        return $result;
    }
1190041
public function provide($data = null, array $options = [])
    {
        $result = parent::provide($data, $options);

        if (empty($result)) {
            return $result;
        }

        $config = [
            'html_input' => 'escape',
            'allow_unsafe_links' => false
        ];

        $converter = new CommonMarkConverter($config);

        return $converter->convertToHtml($result);
    }