Revert an existing journal voucher (soft delete)

@param int $input Voucher id

@return JSON encoded string
A string as follows:
In case of success: {"success" : form.defaultSuccessDeleteMessage}
167769
public function getJournalVoucher($input, $databaseConnectionName = null, $organizationId = null, $loggedUserId = null)
  {
    if(empty($organizationId))
    {
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId();
    }

    if(empty($loggedUserId))
    {
      $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
    }

    if(isset($input['id']))
    {
      $JournalVoucher = $this->JournalVoucher->byId($input['id'], $databaseConnectionName);
    }

    if(!isset($input['id']) && isset($input['system_reference_id']))
    {
      $JournalVoucher = $this->JournalVoucher->bySystemReferenceAndByOrganizationId($input['system_reference_type'], $input['system_reference_field'], $input['system_reference_id'], $organizationId, $databaseConnectionName)->first();
    }

    return $JournalVoucher;
  }
1363139
public static function unpad(string $input): string
    {
        // Determine the padding size by converting the final byte of the  
        // input to its decimal value
        $padsize = \ord(Str::substr($input, -1));

        // Return string minus the padding amount
        return Str::substr($input, 0, Str::strlen($input) - $padsize);
    }
570082
protected function loc($input){
    $input = urlencode($input);
    $urlindex =  '/authorities/subjects/suggest/?q=' . $input;
    $baseurl = 'https://id.loc.gov';
    $remoteUrl = $baseurl.$urlindex;
    $options['headers']=['Accept' => 'application/json'];
    $body = $this->getRemoteJsonData($remoteUrl, $options);

    $jsondata = [];
    $results = [];
    $jsondata = json_decode($body, TRUE);
    $json_error = json_last_error();
    if ($json_error == JSON_ERROR_NONE) {
      //LoC will always return at least one, the query string
      if (count($jsondata) > 1) {
        foreach ($jsondata[1] as $key => $label) {
          $results[] = [
            'value' => $jsondata[3][$key],
            'label' => $label
          ];
        }
      }
      else {
          $results[] = [
            'value' => NULL,
            'label' => 'Sorry no Match from LoC Subject Headings'
          ];
        }
      return  $results;
    }
    $this->messenger->addError(
      $this->t('Looks like data fetched from @url is not in JSON format.<br> JSON says: @$jsonerror <br>Please check your URL!',
        [
          '@url' => $remoteUrl,
          '@$jsonerror' => $json_error
        ]
      )
    );
    return [];
  }
609079
protected function generateRequestOptions( $input ) {
    $options = [
      'dataType' => 'json',
      'headers' => array_merge(self::$header, (array)$input['header']),
    ];
    $options = array_merge($options, ArrayUtils::array_pick($input, 'json', 'form', 'query'));
    return $options;
  }
867153
protected function process($input)
    {
        if ($this->responseType !== "json") {
            return $input;
        }

        // Unpack JSON Data
        $result = json_decode($input, true);

        // Catch decoding errors -- turn a bad JSON input into an empty result set
        // containing an appropriate error code.
        if (!$result) {
            $result = array(
                'recordCount' => 0,
                'documents' => array(),
                'errors' => array(
                    array(
                        'code' => 'PHP-Internal',
                        'message' => 'Cannot decode JSON response: ' . $input
                    )
                )
            );
        }

        // Detect errors
        if (isset($result['errors']) && is_array($result['errors'])) {
            foreach ($result['errors'] as $current) {
                $errors[] = "{$current['code']}: {$current['message']}";
            }
            $msg = 'Unable to process query<br />Summon returned: ' .
                implode('<br />', $errors);
            throw new SerialsSolutions_Summon_Exception($msg);
        }

        return $result;
    }
359808
protected function _toJson($input)
    {
        $json = json_encode($input);

        if (JSON_ERROR_NONE !== json_last_error())
        {
            throw new InvalidArgumentException(
                'Error encoding JSON data: ' . json_last_error_msg()
            );
        }

        return $json;
    }
1086939
public function sanitize( $input ) {
		$new_input = [];
		foreach ( array_keys( (array) $input ) as $id ) {
			$new_input[ sanitize_file_name( $id ) ] = sanitize_text_field( $input[ $id ] );
		}

		return $new_input;
	}
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();
	}
855846
public function input($input = null, $default = null)
    {
        // Get all inputs
        $inputs = array_merge($this->getInputs(), $this->additionalInputs);

        // Exclude reserved inputs
        foreach ($inputs as $key => $value) {
            if (in_array($key, $this->reserved)) {
                unset($inputs[$key]);
            }
        }

        // Return one input
        if ($input) {
            return isset($inputs[$input])? $inputs[$input] : $default;
        }

        // Or the complete array of inputs
        return $inputs;
    }
321259
private function cleanVariable($input)
    {
        if (is_string($input)) {
            if ($this->shouldSanitizeInput) {
                return trim(strip_tags($input));
            } else {
                return trim($input);
            }
        } else {
            return $input;
        }
    }
1170221
protected function _fromJson($input)
    {
        $obj = json_decode($input, true);

        if (JSON_ERROR_NONE !== json_last_error())
        {
            throw new InvalidArgumentException(
                'Error decoding JSON data: ' . json_last_error_msg()
            );
        }

        return $obj;
    }
532798
public function trim(array $input)
    {
        $out = [];
        foreach ($input as $line) {
            $chunk = $this->chunk($line);
            $out[] = reset($chunk);
        }
        return $out;
    }
621615
public static function jsonDecode($input)
    {
        $obj = json_decode($input);
        if (function_exists('json_last_error') && $errno = json_last_error()) {
            JWT::_handleJsonError($errno);
        } else if ($obj === null && $input !== 'null') {
            throw new \DomainException('Null result with non-null input');
        }
        return $obj;
    }
1040556
public function convert( $input ) {

        $result = new SearchResult(
            array(
                'time'       => 0,
                'maxScore'   => 0,
                'totalCount' => $input['SearchCount'],
            )
        );

        $contentService = $this->repository->getContentService();

        foreach ( $input['SearchResult'] as $doc )
        {
            $contentObject = $contentService->loadContent( $doc->ContentObjectID );
            $searchHit = new SearchAndFilterHit(
                array(
                    'score'         => 0,
                    'valueObject'   => $contentObject,
                    'objectStates'  => $this->loadContentObjectStates( $contentObject->contentInfo )
                )
            );
            $result->searchHits[] = $searchHit;
        }
        return $result;
    }
538279
private static function processWebhook($input)
    {
        self::$receivedWebhook = $input;
        parse_str($input, $result);
        if ($result && isset($result['type'])) {
            self::dispatchWebhookEvent($result['type'], $result['data']);
            return $result;
        }

        return false;
    }
1260270
public function create(array $input)
	{
    unset($input['_token']);

    $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
    $organizationId = $this->AuthenticationManager->getCurrentUserOrganizationId();

    $input = eloquent_array_filter_for_insert($input);
		$input = array_add($input, 'organization_id', $organizationId);
    // $input['date'] = $this->Carbon->createFromFormat($this->Lang->get('form.phpShortDateFormat'), $input['date'])->format('Y-m-d');

    $this->DB->transaction(function() use ($input, $loggedUserId, $organizationId)
		{
      $VoucherType = $this->VoucherType->create($input);

      $Journal = $this->Journal->create(array('journalized_id' => $VoucherType->id, 'journalized_type' => $this->VoucherType->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
      $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::voucher-type-management.addedJournal', array('VoucherType' => $VoucherType->name)), $Journal));
    });

    return json_encode(array('success' => $this->Lang->get('form.defaultSuccessSaveMessage'), 'voucherTypes' => $this->getVoucherTypes()));
  }
560484
public function serialise($input)
    {
        $writer = Writer::createFromString('');

        if (is_array(reset($input))) {
            $writer->insertOne(array_keys(reset($input)));
        } else {
            $writer->insertOne(array_keys($input));
        }

        if (is_array(reset($input))) {
            $writer->insertAll($input);
        } else {
            $writer->insertOne($input);
        }

        return $writer->__toString();
    }