Sanitize input data.

@param array  $input
@param string $column

@return array
773983
protected function sanitizeInput($input, $column)
    {
        if ($this instanceof Field\MultipleSelect) {
            $value = array_get($input, $column);
            array_set($input, $column, array_filter($value));
        }

        return $input;
    }
898128
protected function resetInputKey(array &$input, array $column)
    {
        /**
         * flip the column name array set.
         *
         * for example, for the DateRange, the column like as below
         *
         * ["start" => "created_at", "end" => "updated_at"]
         *
         * to:
         *
         * [ "created_at" => "start", "updated_at" => "end" ]
         */
        $column = array_flip($column);

        /**
         * $this->column is the inputs array's node name, default is the relation name.
         *
         * So... $input[$this->column] is the data of this column's inputs data
         *
         * in the HasMany relation, has many data/field set, $set is field set in the below
         */
        foreach ($input[$this->column] as $index => $set) {
            /*
             * foreach the field set to find the corresponding $column
             */
            foreach ($set as $name => $value) {
                /*
                 * if doesn't have column name, continue to the next loop
                 */
                if (!array_key_exists($name, $column)) {
                    continue;
                }

                /**
                 * example:  $newKey = created_atstart.
                 *
                 * Σ( ° △ °|||)︴
                 *
                 * I don't know why a form need range input? Only can imagine is for range search....
                 */
                $newKey = $name.$column[$name];

                /*
                 * set new key
                 */
                array_set($input, "{$this->column}.$index.$newKey", $value);
                /*
                 * forget the old key and value
                 */
                array_forget($input, "{$this->column}.$index.$name");
            }
        }
    }
363910
public static function stripslashes(array $input): array
    {
        $result = [];
        
        foreach ($input as $k => $v) {
            $result[$k] = \is_array($v) ? self::stripslashes($v) : \stripslashes($v);
        }
        
        return $result;
    }
960090
protected function handleFileDelete(array $input = [])
    {
        if (array_key_exists(Field::FILE_DELETE_FLAG, $input)) {
            $input[Field::FILE_DELETE_FLAG] = $input['key'];
            unset($input['key']);
        }

        request()->replace($input);

        return $input;
    }
363526
public function delete(array $input)
  {
    $info = false;

    $this->DB->transaction(function() use ($input, &$info)
    {
      $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');
      $ids = $this->getAccountChildrenIds($input['id']);

      array_push($ids, $input['id']);

      if($this->JournalEntry->byAccountIds($ids)->count() > 0)
      {
        $info = $this->Lang->get('decima-accounting::account-management.accountValidationMessage');
        return;
      }

      $this->Account->byIds($ids)->each(function($Account) use ($loggedUserId, $organizationId)
      {
        $Journal = $this->Journal->create(array('journalized_id' => $Account->id, 'journalized_type' => $this->Account->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
        $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::account-management.accountDeletedAccount', array('account' => $Account->key . ' ' . $Account->name)), $Journal));
      });

      $this->Account->delete($ids);
    });

    if(!$info)
    {
      return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage')));
    }
    else
    {
      return json_encode(array('info' => $info));
    }
  }
71500
public function save(array $input) : array {
		$input[\Object\Form\Parent2::BUTTON_SUBMIT_SAVE] = true;
		// we must set entry method
		if (isset($this->form->form_object->collection_object->primary_model->column_prefix)) {
			$input[$this->form->form_object->collection_object->primary_model->column_prefix . 'entry_method'] = 'G';
		}
		$this->form->form_object->addInput($input);
		$this->form->form_object->process();
		return $this->form->form_object->apiResult();
	}
128740
public function unserialize($input)
    {
        $htmlCleaner = unserialize($input);

        $this->htmlCleaner = $htmlCleaner;

        $this->loadDefaultHandlers();
    }
665834
public function process($model, $input)
    {
        $column = $this->getColumn();

        if(isset($input[$column])) {
            $model->{$column} = $input[$column];
        }

        return $model;
    }
1246939
protected function touchedTranslatableFilter(Queryable $input, $columns)
    {
        return ($this->model instanceof Translatable)
            && $this->isTranslatable($input, $this->translatableColumns($columns));
    }
482617
public function resetInputKey(array &$input, array $column)
    {
        $column = array_flip($column);

        foreach ($input[$this->column] as $key => $value) {
            if (!array_key_exists($key, $column)) {
                continue;
            }

            $newKey = $key.$column[$key];

            /*
             * set new key
             */
            array_set($input, "{$this->column}.$newKey", $value);
            /*
             * forget the old key and value
             */
            array_forget($input, "{$this->column}.$key");
        }
    }
835327
private function filterEmptyInput($input)
    {
        foreach ($input as $key => $value)
        {
            if (empty($value))
            {
                unset($input[$key]);
            }
        }

        return $input;
    }
1198092
public function create( $inputs = [] )
	{
		$columns = [];
		$placeholders = [];
		$values = [];

		foreach( $inputs as $column => $value )
		{
			$columns []= "`$column`";
			$placeholders []= ":$column";
			$values[":$column"] = $value;
		}

		$keys = implode(',', $columns);
		$placeholders = implode(',', $placeholders);

		$this->_exec_( "INSERT INTO `{$this->table}` ( $keys ) VALUES ( $placeholders )", $values );

		return $this->insert_id();
	}
564396
private function fromFlattenedSerializationRecipientToSerialization($input)
    {
        $recipient = [];
        foreach (['header', 'encrypted_key'] as $key) {
            if (array_key_exists($key, $input)) {
                $recipient[$key] = $input[$key];
            }
        }
        $recipients = [
            'ciphertext' => $input['ciphertext'],
            'recipients' => [$recipient],
        ];
        foreach (['protected', 'unprotected', 'iv', 'aad', 'tag'] as $key) {
            if (array_key_exists($key, $input)) {
                $recipients[$key] = $input[$key];
            }
        }

        return $recipients;
    }
63527
public function delete(array $input) : array {
		$input[\Object\Form\Parent2::BUTTON_SUBMIT_SAVE] = true;
		$input[\Object\Form\Parent2::BUTTON_SUBMIT_DELETE] = true;
		$this->form->form_object->addInput($input);
		$this->form->form_object->process();
		return $this->form->form_object->apiResult();
	}
872169
protected function doUnprocess($input)
    {
        $columns = [];
        $rows    = [];
        $cells   = [];

        $columnObjects = $input->getColumns();
        $rowObjects    = $input->getRows();

        $columnKey = 0;
        foreach ($columnObjects as $column) {
            $columns[$columnKey] = $column->getKey();
            $columnKey++;
        }

        $rowKey = 0;
        foreach ($rowObjects as $row) {
            $rows[$rowKey] = $row->getKey();

            $columnKey = 0;
            foreach ($columnObjects as $column) {
                $cells[$rowKey][$columnKey] = $row[$column];
                $columnKey++;
            }

            $rowKey++;
        }

        $data                           = [];
        $data[TableType::COLUMNS_FIELD] = $columns;

        if ($this->includeRows) {
            $data[TableType::ROWS_FIELD] = $rows;
        }

        $data[TableType::CELLS_FIELD] = $cells;


        return $data;
    }
716416
public function getValidator(array $input)
    {
        if (!array_key_exists($this->column, $input)) {
            return false;
        }

        $input = array_only($input, $this->column);

        $form = $this->buildNestedForm($this->column, $this->builder);

        $rules = $attributes = [];

        /* @var Field $field */
        foreach ($form->fields() as $field) {
            if (!$fieldRules = $field->getRules()) {
                continue;
            }

            $column = $field->column();

            if (is_array($column)) {
                foreach ($column as $key => $name) {
                    $rules[$name.$key] = $fieldRules;
                }

                $this->resetInputKey($input, $column);
            } else {
                $rules[$column] = $fieldRules;
            }

            $attributes = array_merge(
                $attributes,
                $this->formatValidationAttribute($input, $field->label(), $column)
            );
        }

        array_forget($rules, NestedForm::REMOVE_FLAG_NAME);

        if (empty($rules)) {
            return false;
        }

        $newRules = [];

        foreach ($rules as $column => $rule) {
            foreach (array_keys($input[$this->column]) as $key) {
                $newRules["{$this->column}.$key.$column"] = $rule;
            }
        }

        return Validator::make($input, $newRules, $this->validationMessages, $attributes);
    }
1141631
function sanitize( $input ) {
		$options = [];

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

		if ( property_exists( $this, 'booleans' ) ) {
			foreach ( $this->booleans as $key ) {
				if ( empty( $input[ $key ] ) ) {
					$options[ $key ] = 0;
				} else {
					$options[ $key ] = 1;
				}
			}
		}

		if ( property_exists( $this, 'strings' ) ) {
			foreach ( $this->strings as $key ) {
				if ( empty( $input[ $key ] ) ) {
					unset( $options[ $key ] );
				} else {
					$options[ $key ] = sanitize_text_field( $input[ $key ] );
				}
			}
		}

		if ( property_exists( $this, 'urls' ) ) {
			foreach ( $this->urls as $key ) {
				if ( empty( $input[ $key ] ) ) {
					unset( $options[ $key ] );
				} else {
					$value = trim( strip_tags( stripslashes( $input[ $key ] ) ) );
					if ( $value ) {
						$options[ $key ] = \Pressbooks\Sanitize\canonicalize_url( $value );
					} else {
						unset( $options[ $key ] );
					}
				}
			}
		}

		if ( property_exists( $this, 'integers' ) ) {
			foreach ( $this->integers as $key ) {
				if ( empty( $input[ $key ] ) ) {
					unset( $options[ $key ] );
				} else {
					$options[ $key ] = absint( $input[ $key ] );
				}
			}
		}

		if ( property_exists( $this, 'floats' ) ) {
			foreach ( $this->floats as $key ) {
				if ( empty( $input[ $key ] ) ) {
					unset( $options[ $key ] );
				} else {
					$options[ $key ] = filter_var( $input[ $key ], FILTER_VALIDATE_FLOAT );
				}
			}
		}

		if ( property_exists( $this, 'predefined' ) ) {
			foreach ( $this->predefined as $key ) {
				if ( empty( $input[ $key ] ) ) {
					unset( $options[ $key ] );
				} else {
					$options[ $key ] = $input[ $key ];
				}
			}
		}

		return $options;
	}