factory = $factory; $this->config = $config; $this->acl = $acl; $this->user = $user; $this->metadata = $metadata; } public function process(Params $params): Result { if ($this->config->get('exportDisabled') && !$this->user->isAdmin()) { throw new ForbiddenSilent("Export disabled for non-admin users."); } $entityType = $params->getEntityType(); if ($this->acl->getPermissionLevel('exportPermission') !== Table::LEVEL_YES) { throw new ForbiddenSilent("No 'export' permission."); } if (!$this->acl->check($entityType, Table::ACTION_READ)) { throw new ForbiddenSilent("No 'read' access."); } if ($this->metadata->get(['recordDefs', $entityType, 'exportDisabled'])) { throw new ForbiddenSilent("Export disabled for '{$entityType}'."); } $export = $this->factory->create(); return $export ->setParams($params) ->run(); } }