Back to MetadataManager class

Method createOrUpdateRecord

public void
createOrUpdateRecord
(\Joomla\Session\SessionInterface $session, \Joomla\CMS\User\User $user)
Create the metadata record if it does not exist.
Parameters
  • \Joomla\Session\SessionInterface $session The session to create or update the metadata record for.
  • \Joomla\CMS\User\User $user The user to associate with the record.
Returns
  • void
Since
  • 4.0.0
-
  • \RuntimeException

Method createOrUpdateRecord - Source code

/**
 * Create the metadata record if it does not exist.
 *
 * @param   SessionInterface  $session  The session to create or update the metadata record for.
 * @param   User              $user     The user to associate with the record.
 *
 * @return  void
 *
 * @since   4.0.0
 * @throws  \RuntimeException
 */
public function createOrUpdateRecord(SessionInterface $session, User $user)
{
    $exists = $this->checkSessionRecordExists($session->getId());
    // Do not try to touch the database if we can't determine the record state
    if ($exists === self::$sessionRecordUnknown) {
        return;
    }
    if ($exists === self::$sessionRecordDoesNotExist) {
        $this->createSessionRecord($session, $user);
        return;
    }
    $this->updateSessionRecord($session, $user);
}