コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getCallerPermissions(Caller $caller)
 {
     $cacheId = sprintf('callers/%s/%s', $caller->getCallerType(), $caller->getCallerId());
     $permissions = $this->cache->fetch($cacheId);
     if (!$this->cache->contains($cacheId)) {
         $permissions = $this->driver->getCallerPermissions($caller);
         $this->cache->save($cacheId, $permissions);
     }
     return $permissions;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getCallerPermissions(Caller $caller)
 {
     $cacheId = sprintf('callers/%s/%s', $caller->getCallerType(), $caller->getCallerId());
     $item = $this->pool->getItem($cacheId);
     $permissions = $item->get();
     if ($item->isMiss()) {
         $item->lock();
         $permissions = $this->driver->getCallerPermissions($caller);
         $item->set($permissions);
     }
     return $permissions;
 }
コード例 #3
0
 /** @test */
 final function the_caller_can_call_the_caller_trait_methods()
 {
     $this->caller->allow('create');
     $this->assertTrue($this->caller->can('create'));
     $this->caller->deny('create');
     $this->assertFalse($this->caller->can('create'));
     $this->caller->toggle('update');
     $this->assertTrue($this->caller->can('update'));
 }
コード例 #4
0
 /**
  * Creates a key to store the caller's permissions
  *
  * @param \BeatSwitch\Lock\Callers\Caller $caller
  * @return string
  */
 private function getCallerKey(Caller $caller)
 {
     return 'caller_' . $caller->getCallerType() . '_' . $caller->getCallerId();
 }
コード例 #5
0
ファイル: CallerLock.php プロジェクト: jiangyu7408/lock
 /**
  * Get all the lock instances for all the roles of the current caller
  *
  * @return \BeatSwitch\Lock\Roles\RoleLock[]
  */
 protected function getLockInstancesForCallerRoles()
 {
     return array_map(function ($role) {
         return $this->manager->role($role);
     }, $this->caller->getCallerRoles());
 }