Open an existing period

@param array $input
An array as follows: array(id => $id);

@return JSON encoded string
A string as follows:
In case of success: {"success" : form.defaultSuccessOperationMessage}
170272
public function openPeriod(array $input)
  {
    $this->DB->transaction(function() use ($input)
    {
      $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');

      $Period = $this->Period->byId($input['id']);
      $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->Period->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
      // $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.status'), 'field_lang_key' => 'decima-accounting::journal-management.status', 'old_value' => $this->Lang->get('decima-accounting::period-management.closed'), 'new_value' => $this->Lang->get('decima-accounting::period-management.opened')), $Journal);
      $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::period-management.periodOpenedJournal', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))), $Journal));
      $this->Period->update(array('is_closed' => false), $Period);
    });

    return json_encode(array('success' => $this->Lang->get('form.defaultSuccessOperationMessage'), 'periods' => $this->getPeriods(), 'periodsFilter' => $this->getPeriods2()));
  }
471502
public static function fromArray(array $input) {
        $input = array_map(function($value) {
            return is_array($value) ? ArrayObject::fromArray($value) : $value;
        }, $input);

        return new ArrayObject($input);
    }
984039
private function _initialise(array $input = array())
	{
		foreach ($input as $key => $object)
		{
			if (!is_null($object))
			{
				$this->offsetSet($key, $object);
			}
		}

		$this->rewind();
	}
1006208
public static function clearInput($input)
    {
        if (is_array($input)) {
            foreach ($input as $key => $value) {
                if (!isset($value) || $value === '') {
                    unset($input[$key]);
                }
            }

            return $input;
        }

        return $input;
    }
993326
public function create(array $input, array $queryParams = [])
    {
        $response = $this->client->post($this->uri(), [
            RequestOptions::JSON => ['application' => $input],
            'query' => $queryParams,
        ]);

        return $this->handleResponse($response);
    }
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));
    }
  }
1284450
protected function cleanInputData(array $input)
    {
        $columns = $this->getColumns();
        foreach ($columns as $column) {
            if (!isset($input[$column])) {
                $input[$column] = '';
            }
        }
        return $input;
    }
124034
public function delete(array $input)
   {
     $count = 0;

     $this->DB->transaction(function() use ($input, &$count)
     {
       $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
       $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');

       foreach ($input['id'] as $key => $id)
       {
         $count++;

         $VoucherType = $this->VoucherType->byId($id);

         $Journal = $this->Journal->create(array('journalized_id' => $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.deletedJournal', array('name' => $VoucherType->name))), $Journal);

         $this->VoucherType->delete(array($id));
       }
     });

     if($count == 1)
     {
       return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage')));
     }
     else
     {
       return json_encode(array('success' => $this->Lang->get('form.defaultSuccessDeleteMessage1')));
     }
   }
1035784
public function sanitizeInput(array $input)
    {
        return $input = collect($input)->reject(function ($value) {
            return is_null($value) || empty($value);
        })->toArray();
    }
796964
public function validate(array $input = []): ValidationResult
    {
        $results = [];

        foreach ($this->rules as $key => $definition) {

            $rules = $this->parser->parseRulesDefinition($definition);

            $results[$key] = $rules->validate($key, $input);

        }

        return new ValidationResult($results, $this->translator);
    }
468002
public function closePeriod(array $input)
  {
    $canBeClosed = true;

    $this->DB->transaction(function() use ($input, &$canBeClosed)
    {
      $loggedUserId = $this->AuthenticationManager->getLoggedUserId();
      $organizationId = $this->AuthenticationManager->getCurrentUserOrganization('id');

      if($this->JournalVoucher->getByOrganizationByPeriodAndByStatus($organizationId, array($input['id']), 'A')->count() > 0)
      {
        $canBeClosed = false;
        return;
      }

      $Period = $this->Period->byId($input['id']);
      $Journal = $this->Journal->create(array('journalized_id' => $input['id'], 'journalized_type' => $this->Period->getTable(), 'user_id' => $loggedUserId, 'organization_id' => $organizationId));
      // $this->Journal->attachDetail($Journal->id, array('field' => $this->Lang->get('decima-accounting::journal-management.status'), 'field_lang_key' => 'decima-accounting::journal-management.status', 'old_value' => $this->Lang->get('decima-accounting::period-management.opened'), 'new_value' => $this->Lang->get('decima-accounting::period-management.closed')), $Journal);
      $this->Journal->attachDetail($Journal->id, array('note' => $this->Lang->get('decima-accounting::period-management.periodClosedJournal', array('period' => $this->Lang->get('decima-accounting::period-management.' . $Period->month))), $Journal));
      $this->Period->update(array('is_closed' => true), $Period);
    });

    if(!$canBeClosed)
    {
      return json_encode(array('success' => false, 'info' => $this->Lang->get('decima-accounting::period-management.voucherException')));
    }

    return json_encode(array('success' => $this->Lang->get('form.defaultSuccessOperationMessage'), 'periods' => $this->getPeriods(), 'periodsFilter' => $this->getPeriods2()));
  }
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;
    }
402783
public function create(array $input) {
    $data = array (
            "email"          => isset($input["email"]) ? $input["email"] : $input["copyEmail"],
            "password"       => $input["password"],
            "activated"      => $input["activated"],
            "preferred_lang" => isset($input["preferred_lang"]) ? $input["preferred_lang"] : Config::get('authentication::default_preferred_lang')
    );
    try {
      $user = $this->sentry->createUser($data);
    } catch (CartaUserExists $e) {
      throw new UserExistsException;
    }

    return $user;
  }
100292
protected function parse($input): string
    {
        if (!is_array($input)) {
            return json_encode($input);
        }

        $parsed = "";
        foreach ($input as $key => $value) {
            $key = (!is_numeric($key) ? ($key . ": " ) : '');
            if (!is_array($value)) {
                $parsed .= $key . $this->parse($value) . ', ';
            } elseif (is_null(key($value)) || is_numeric(key($value))) {
                $parsed .= $key . "[" . $this->parse($value) . "], ";
            } else {
                $parsed .= $key . "{" . $this->parse($value) . "}, ";
            }
        }

        return rtrim($parsed, ', ');
    }
1226771
protected function arrayToConditionDataModel(array $input)
    {
        /** @var \Smile\ElasticsuiteCatalogRule\Model\Data\Condition $conditionDataModel */
        $conditionDataModel = $this->conditionDataFactory->create();
        foreach ($input as $key => $value) {
            switch ($key) {
                case 'type':
                    $conditionDataModel->setConditionType($value);
                    break;
                case 'attribute':
                    $conditionDataModel->setAttributeName($value);
                    break;
                case 'operator':
                    $conditionDataModel->setOperator($value);
                    break;
                case 'value':
                    $conditionDataModel->setValue($value);
                    break;
                case 'aggregator':
                    $conditionDataModel->setAggregatorType($value);
                    break;
                case 'conditions':
                    $conditions = [];
                    foreach ($value as $condition) {
                        $conditions[] = $this->arrayToConditionDataModel($condition);
                    }
                    $conditionDataModel->setConditions($conditions);
                    break;
                default:
            }
        }

        return $conditionDataModel;
    }
438795
public function firstOrCreate(array $input)
    {
        $this->cache->tags($this->getModel())->flush();
        return $this->repository->firstOrCreate($input);
    }
535183
public function get(array $input) : array {
		$this->form->form_object->addInput($input);
		$this->form->form_object->process();
		return $this->form->form_object->apiResult();
	}