Get prepared view parameters

@param \Wanjee\Shuwee\AdminBundle\Datagrid\Field\DatagridFieldInterface $field
@param mixed $entity Instance of a model entity

@return mixed
968539
public function getBlockVariables($field, $entity)
    {
        $defaults = parent::getBlockVariables($field, $entity);

        return [
            'value' => $defaults['value'],
            'label_link' => $field->getOption('label_link', 'Link'),
            'mailto' => $field->getOption('mailto', false),
        ] + $defaults;
    }
274395
public function decryptEntityField(EntityInterface $entity, string $field)
    {
        if (!$this->canDecryptField($entity, $field)) {
            return null;
        }

        $encryptionKey = $this->getConfig('encryptionKey');
        $base64 = $this->getConfig('base64');
        $encoded = $entity->get($field);
        if (empty($encoded) || $encoded === false) {
            return null;
        }

        if ($base64 === true) {
            $encoded = base64_decode($encoded, true);
            if ($encoded === false) {
                return null;
            }
        }
        $decrypted = Security::decrypt($encoded, $encryptionKey);
        if ($decrypted === false) {
            throw new RuntimeException("Unable to decypher `{$field}`. Check your enryption key.");
        }

        return $decrypted;
    }
973055
protected function getValueFromReferencedEntity(FieldInterface $field)
    {
        $references = $this->model->referredIn($field->name());
        foreach ($references as $foreign => $reference) {
            $entity = $this->accessor->getPropertyValue($this->instance, $reference->container());

            if ($entity === null) {
                continue;
            }

            $value = $this->accessor->getPropertyValue($entity, $foreign);
            $this->accessor->setPropertyValue($this->instance, $field->name(), $value);
            break;
        }
    }
630377
public function getDataTableOptions($field, $data)
    {
        $methodName = 'get'.studly_case($this->fieldName).'DataTableOptions';

        if (!$this->model->methodExists($methodName) && !$this->model->methodExists('getDataTableOptions')) {
            throw new ApplicationException(Lang::get('backend::lang.model.missing_method', ['class' => get_class($this->model), 'method' => 'getDataTableOptions']));
        }

        if ($this->model->methodExists($methodName)) {
            $result = $this->model->$methodName($field, $data);
        }
        else {
            $result = $this->model->getDataTableOptions($this->fieldName, $field, $data);
        }

        if (!is_array($result)) {
            $result = [];
        }

        return $result;
    }
1238559
public function getQueryFrom(DatatableViewInterface $datatableView)
    {
        $twig = $datatableView->getTwig();

        $type = $datatableView->getAjax()->getType();
        $parameterBag = null;

        if ('GET' === strtoupper($type)) {
            $parameterBag = $this->request->query;
        }

        if ('POST' === strtoupper($type)) {
            $parameterBag = $this->request->request;
        }

        $params = $parameterBag->all();
        $query = new DatatableQuery(
            $this->serializer,
            $params,
            $datatableView,
            $this->configs,
            $twig,
            $this->imagineBundle,
            $this->doctrineExtensions,
            $this->locale
        );

        return $query;
    }
1255791
public function load(EntityInterface $entity)
    {
        $adapter = $this->getAdapter();
        $relTable = $this->getParentTableName();
        $pmk = $this->getEntityDescriptor()->getPrimaryKey();
        $fnk = $this->getForeignKey();

        $data = Sql::createSql($adapter)
            ->select($relTable)
            ->where([
                "{$relTable}.{$fnk} = :id" => [
                    ':id' => $entity->{$pmk->name}
                ]
            ])
            ->first();

        $relEntity = $this->getParentEntityMapper()->createFrom($data);

        return null == $relEntity ? null :$this->registerEntity($relEntity);
    }
145104
public function getFormFieldValueOptions(FieldInterface $field)
    {
        $fieldOptions = $this->getFieldOptions($field);

        $formFieldOptions = [];
        if (isset($fieldOptions['minLength'])) {
            $formFieldOptions['constraints'][] = new Length(['min' => $fieldOptions['minLength']]);
        }
        if (isset($fieldOptions['maxLength'])) {
            $formFieldOptions['constraints'][] = new Length(['max' => $fieldOptions['maxLength']]);
        }

        return $formFieldOptions;
    }
320152
protected function getView(Entity $entity, array $params = [])
    {
        switch (true) {
            case $entity instanceof ContentItem:
                $template = $entity->isIndex() ? 'index.twig' : 'entry.twig';
                $params['entry'] = $entity;
                break;
            case $entity instanceof Taxonomy:
                $template = 'taxonomy.twig';
                $params['taxonomy'] = $entity;
                break;
            case $entity instanceof Term:
                $template = 'term.twig';
                $params['term'] = $entity;
                break;
            default:
                throw new \LogicException('Cannot render entity of type '.get_class($entity));
        }

        return new View($template, $params);
    }
284013
protected function generateSetterMethod(Entity $entity, FieldDescriptorProto $field)
    {
        $body       = [];
        $fieldName  = $field->getName();
        $fieldType  = $field->getType();
        $fieldLabel = $field->getLabel();
        $typeHint   = $this->getTypeHint($field);

        if ($fieldType === Type::TYPE_BYTES() && $fieldLabel !== Label::LABEL_REPEATED()) {
            $body[] = 'if ($value !== null && ! $value instanceof \Protobuf\Stream) {';
            $body[] = '    $value = \Protobuf\Stream::wrap($value);';
            $body[] = '}';
            $body[] = null;

            $typeHint = null;
        }

        $body[] = '$this->' . $fieldName . ' = $value;';

        $methodName = $this->getAccessorName('set', $field);
        $method     = MethodGenerator::fromArray([
            'name'       => $methodName,
            'body'       => implode(PHP_EOL, $body),
            'parameters' => [
                [
                    'name'   => 'value',
                    'type'   => $typeHint
                ]
            ],
            'docblock'   => [
                'shortDescription' => "Set '$fieldName' value",
                'tags'             => [
                    [
                        'name'        => 'param',
                        'description' => $this->getDocBlockType($field) . ' $value'
                    ]
                ]
            ]
        ]);

        $method->getDocblock()->setWordWrap(false);

        if ($fieldLabel !== Label::LABEL_REQUIRED()) {
            $method->getParameters()['value']->setDefaultValue(null);
        }

        return $method;
    }
427174
private function getFieldValue($entity, \ReflectionProperty $reflectionProperty)
    {
        $value = null;
        if ($reflectionProperty) {
            $reflectionProperty->setAccessible(true);
            $value = $reflectionProperty->getValue($entity);
        }

        return $value;
    }
325838
private function getScalarField($field)
	{
		$dataField = array_merge($this->defaultField, [
			'property' => $field->getName(),
			'title' => $field->getTitle(),
			'type' => get_class($field),
			'validators' => $field->getValidators(),
			'modifiers' => [
				'save' => $field->getSaveDataModifiers(),
				'fetch' => $field->getFetchDataModifiers(),
			],
		]);

		if($field instanceof Main\Entity\ScalarField){
			$dataField['primary'] = $field->isPrimary();
			$dataField['unique'] = $field->isUnique();
			$dataField['autocomplete'] = $field->isAutocomplete();
			$dataField['require'] = $field->isRequired();
			$dataField['serialized'] = $field->isSerialized();
			if(method_exists($field, 'getValues')){
				$dataField['values'] = $field->getValues();
			}
		} elseif ($field instanceof Main\Entity\ReferenceField){
			$ref = $field->getReference();
			$ref = array_shift($ref);

			preg_match('/^ref\.([a-zA-Z]+)$/i', $ref, $matchRef);

			$refEntity = $field->getRefEntity();
			$refNameShow = $matchRef[1];
			if($refEntity->hasField('NAME')){
				$refNameShow = $refEntity->getField('NAME')->getName();
			} elseif ($refEntity->hasField('TITLE')){
				$refNameShow = $refEntity->getField('TITLE')->getName();
			}
			$dataField['property'] = $field->getName().'_REF_'.$refNameShow;
			$dataField['virtual'] = true;
			$dataField['reference'] = [
				'FROM' => $field->getName(),
				'TO' => $refNameShow,
			];
		}

		return $dataField;
	}
915892
protected function getFormFieldStoreStrategyParametersForField(ModelFormFieldDataInterface $field)
    {
        $strategy = $field->store_strategy ?: '';

        $pos = strpos($strategy, ':');

        if (false === $pos) {
            return [];
        }

        return array_map('trim', explode(',', substr($strategy, $pos + 1)));
    }
1121849
public function toggleField(EntityInterface $entity) {
		$field = $this->getConfig('field');
		$id = $entity->get('id');
		$conditions = $this->buildConditions($entity);

		$primary = $this->_table->updateAll([$field => true], ['id' => $id] + $conditions);
		$others = $this->_table->updateAll([$field => false], ['id !=' => $id] + $conditions);

		return $primary + $others > 0;
	}
54876
private function getFieldOptions(ParameterModel $parameterModel, ConfigurationInterface $configuration)
    {
        $fieldOptions = [
            'required' => false,
        ];

        $parameterOptions = $parameterModel->getOptions();

        if (isset($parameterOptions['form']['options'])) {
            $fieldOptions = array_merge($fieldOptions, $parameterOptions['form']['options']);
        }
        if (!array_key_exists('label', $fieldOptions)) {
            $fieldOptions['label'] = sprintf(
                'configuration.%s.parameter.%s',
                $configuration->getName(),
                $parameterModel->getName()
            );
        }
        if (ParameterModel::TYPE_ENTITY === $parameterModel->getType() && !isset($fieldOptions['class'])) {
            $fieldOptions['class'] = $parameterOptions['class'];
        }
        if (ParameterModel::TYPE_OBJECT === $parameterModel->getType()) {
            if (!isset($fieldOptions['constraints'])) {
                $fieldOptions['constraints'] = [];
            }
            if (!is_array($fieldOptions['constraints'])) {
                $fieldOptions['constraints'] = [$fieldOptions['constraints']];
            }

            $fieldOptions['constraints'][] = new Valid();
        }

        return $fieldOptions;
    }
1043335
public function getEntityAccessFields($entity, $bundle) {
    $fields = [];
    $field_definitions = $this->entityManager->getFieldDefinitions($entity, $bundle->id());
    foreach ($field_definitions as $field_name => $field_definition) {
      if (!empty($field_definition->getTargetBundle())) {
        if ($field_definition->getType() === 'entity_access_field') {
          $fields[$field_name] = $field_definition;
        }
      }
    }
    return $fields;
  }
899535
public function get($field)
    {
        if (!is_null($this->filtered) && ! is_null($this->filtered[0])) {
            return isset($this->filtered[0][0][$field]) ? $this->filtered[0][0][$field] : null;
        }

        // Todo: Get values of entities
    }
1136649
public function getFields(GridField $grid, DataObjectInterface $record)
    {
        $cols   = $this->getDisplayFields($grid);
        $fields = new FieldList();

        /** @var DataList $list */
        $list   = $grid->getList();
        $class  = $list ? $list->dataClass() : null;

        foreach ($cols as $col => $info) {
            $field = null;

            if ($info instanceof Closure) {
                $field = call_user_func($info, $record, $col, $grid);
            } elseif (is_array($info)) {
                if (isset($info['callback'])) {
                    $field = call_user_func($info['callback'], $record, $col, $grid);
                } elseif (isset($info['field'])) {
                    if ($info['field'] == LiteralField::class) {
                        $field = new $info['field']($col, null);
                    } else {
                        $field = new $info['field']($col);
                    }
                }

                if (!$field instanceof FormField) {
                    throw new Exception(sprintf(
                        'The field for column "%s" is not a valid form field',
                        $col
                    ));
                }
            }

            if (!$field && $list instanceof ManyManyList) {
                $extra = $list->getExtraFields();

                if ($extra && array_key_exists($col, $extra)) {
                    $field = Injector::inst()->create($extra[$col], $col)->scaffoldFormField();
                }
            }

            if (!$field) {
                if (!$this->displayFields) {
                    // If setDisplayFields() not used, utilize $summary_fields
                    // in a way similar to base class
                    //
                    // Allows use of 'MyBool.Nice' and 'MyHTML.NoHTML' so that
                    // GridFields not using inline editing still look good or
                    // revert to looking good in cases where the field isn't
                    // available or is readonly
                    //
                    $colRelation = explode('.', $col);
                    if ($class && $obj = DataObject::singleton($class)->dbObject($colRelation[0])) {
                        $field = $obj->scaffoldFormField();
                    } else {
                        $field = new ReadonlyField($colRelation[0]);
                    }
                } elseif ($class && $obj = DataObject::singleton($class)->dbObject($col)) {
                    $field = $obj->scaffoldFormField();
                } else {
                    $field = new ReadonlyField($col);
                }
            }

            if (!$field instanceof FormField) {
                throw new Exception(sprintf(
                    'Invalid form field instance for column "%s"',
                    $col
                ));
            }

            // Add CSS class for interactive fields
            if (!($field->isReadOnly() || $field instanceof LiteralField)) {
                $field->addExtraClass('editable-column-field');
            }

            $fields->push($field);
        }

        return $fields;
    }