/**
  * Whether or not the given identity has the given privilege on the given resource.
  *
  * @param IdentityInterface $identity
  * @param mixed $resource
  * @param mixed $privilege
  * @return bool
  */
 public function isAuthorized(IdentityInterface $identity, $resource, $privilege)
 {
     if (strpos($resource, 'ZF\\Apigility\\Admin') === 0 || $identity->getName() == self::ROLE_ADMIN) {
         return true;
     }
     $permission = sprintf('%s.%s', $privilege, $resource);
     return $this->isGranted($identity, $permission);
 }
 protected function ensureRootFolder($filesystemName, IdentityInterface $identity)
 {
     $rootItem = $this->fetchByPath($filesystemName, '');
     if ($rootItem) {
         return $rootItem;
     }
     $data = ['filesystem' => $filesystemName, 'filesystem_path' => '', 'name' => '', 'parent_id' => null, 'create_time' => date(DATE_ATOM), 'type' => 'DIR', 'owner_id' => $identity->getName()];
     return $this->insertAndFetch($data);
 }