You are here

protected function AppForm::saveApp in Apigee Edge 8

Saves the app entity on Apigee Edge.

It should log failures but it should not display messages to users. This is handled in save().

Return value

int SAVED_NEW, SAVED_UPDATED or SAVED_UNKNOWN.

1 call to AppForm::saveApp()
AppForm::save in src/Entity/Form/AppForm.php
Form submission handler for the 'save' action.

File

src/Entity/Form/AppForm.php, line 186

Class

AppForm
Base entity form for developer- and team (company) app create/edit forms.

Namespace

Drupal\apigee_edge\Entity\Form

Code

protected function saveApp() : int {

  /** @var \Drupal\apigee_edge\Entity\AppInterface $app */
  $app = $this->entity;
  $was_new = $app
    ->isNew();
  try {
    $result = $app
      ->save();
  } catch (EntityStorageException $exception) {
    $context = [
      '%app_name' => $app
        ->label(),
      '%owner' => $app
        ->getAppOwner(),
      '@app' => mb_strtolower($this
        ->appEntityDefinition()
        ->getSingularLabel()),
      '@owner' => mb_strtolower($this
        ->appOwnerEntityDefinition()
        ->getSingularLabel()),
      '@operation' => $was_new ? $this
        ->t('create') : $this
        ->t('update'),
    ];
    $context += Error::decodeException($exception);
    $this
      ->logger('apigee_edge')
      ->critical('Could not @operation %app_name @app of %owner @owner. @message %function (line %line of %file). <pre>@backtrace_string</pre>', $context);
    $result = EdgeEntityStorageBase::SAVED_UNKNOWN;
  }
  return $result;
}