Get a key string for the permission
public getPermKey ( string $instanceId ) : string | ||
$instanceId | string | instance identifier |
return | string |
/** * Get dynamic option data for the editor * * @return array */ protected function getDynamicOption() { $data = array_except($this->config->all(), 'tools'); $data['fontFamily'] = isset($data['fontFamily']) ? array_map(function ($v) { return trim($v); }, explode(',', $data['fontFamily'])) : []; $data['extensions'] = isset($data['extensions']) ? array_map(function ($v) { return trim($v); }, explode(',', $data['extensions'])) : []; $data['extensions'] = array_search('*', $data['extensions']) !== false ? ['*'] : $data['extensions']; $instance = new Instance($this->editors->getPermKey($this->instanceId)); $data['perms'] = ['html' => $this->gate->allows('html', $instance), 'tool' => $this->gate->allows('tool', $instance), 'upload' => $this->gate->allows('upload', $instance)]; $data['files'] = $this->files; return $data; }
/** * file download * * @param EditorHandler $handler editor handler * @param Storage $storage storage * @param string $instanceId instance id * @param string $id * @return void */ public function fileDownload(EditorHandler $handler, Storage $storage, $instanceId, $id) { if (empty($id) || !($file = File::find($id))) { throw new InvalidArgumentException(); } if (Gate::denies('download', new Instance($handler->getPermKey($instanceId)))) { throw new AccessDeniedHttpException(); } $storage->download($file); }