Bristol SU Support Package
AuthenticationResourceIdGenerator.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
12 {
13 
19  private $authentication;
20 
27  {
28  $this->authentication = $authentication;
29  }
30 
41  public function fromString(string $resourceType): int
42  {
43  if ($resourceType === 'user') {
44  $model = $this->authentication->getUser();
45  } elseif ($resourceType === 'group') {
46  $model = $this->authentication->getGroup();
47  } elseif ($resourceType === 'role') {
48  $model = $this->authentication->getRole();
49  }
50  if ($model === null) {
51  throw new \Exception('Not logged into correct model');
52  }
53  return $model->id();
54  }
55 }