public function Gauth::save in Google Auth 8
Return value
int Id for the Gauth being saved.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
Overrides EntityBase::save
File
- src/
Entity/ Gauth.php, line 590
Class
- Gauth
- Defines the Gauth entity.
Namespace
Drupal\gauth\EntityCode
public function save() {
$original = $this->original ? $this->original : NULL;
if (!$original) {
// Usually this should exist in save but still keeping it safe.
$id = $this
->getOriginalId() !== NULL ? $this
->getOriginalId() : $this
->id();
$original = $this
->entityTypeManager()
->getStorage($this
->getEntityTypeId())
->loadUnchanged($id);
}
if ($original && ($original
->getServices() != $this
->getServices() || $original
->getClientId() != $this
->getClientId() || $original
->getClientSecret() != $this
->getClientSecret() || $original
->getDeveloperKey() != $this
->getDeveloperKey())) {
// If the gauth isi modified it needs to be re-authenticated.
$this
->setAccessToken('{}');
$this
->setAuthenticated(FALSE);
}
return parent::save();
}