You are here

private function MainController::saveChildUid in Bakery Single Sign-On System 8.2

Save UID provided by a slave site. Should only be used on the master site.

Parameters

object $account: A local user object.

string $child: The URL of the slave site.

int $child_uid: The corresponding UID on the slave site.

1 call to MainController::saveChildUid()
MainController::eatGingerbreadCookie in src/Controller/MainController.php
Respond with account information.

File

src/Controller/MainController.php, line 129
Router call back functions for bakery SSO functions.

Class

MainController
Route callback functionlities.

Namespace

Drupal\bakery\Controller

Code

private function saveChildUid($account, $child, $child_uid) {

  // This looks like a big overly complicated merge statement?
  $child_site_user_exists = $this->connection
    ->select('bakery_user', 'f')
    ->fields('f', [
    'uid',
  ])
    ->condition('uid', $account
    ->id())
    ->condition('slave', $child)
    ->range(0, 1)
    ->execute()
    ->fetchField();
  if (!empty($child_uid) && !$child_site_user_exists && in_array($child, $this
    ->config('bakery.settings')
    ->get('bakery_slaves') ?: [])) {
    $row = [
      'uid' => $account
        ->id(),
      'slave' => $child,
      'slave_uid' => $child_uid,
    ];
    $this->connection
      ->insert('bakery_user')
      ->fields($row)
      ->execute();
  }
}