private function getPermissionsByModel(string $model) : array
    {
        $table = TableRegistry::getTableLocator()->get('RolesCapabilities.Capabilities');
        Assert::isInstanceOf($table, CapabilitiesTable::class);

        $groups = $table->getUserGroups($this->user['id']);

        $query = TableRegistry::getTableLocator()->get('RolesCapabilities.Permissions')
            ->find('all')
            ->select('foreign_key')
            ->where([
                // WARNING: this might conflict with APP table's name matching a plugin's table name
                'model' => $model,
                'type IN ' => ['view'],
                'OR' => [
                    ['owner_foreign_key IN ' => array_keys($groups), 'owner_model' => 'Groups'],
                    ['owner_foreign_key' => $this->user['id'], 'owner_model' => 'Users']
                ]
            ])
            ->applyOptions(['accessCheck' => false]);

        $result = [];
        foreach ($query->all() as $permission) {
            $result[] = $permission->get('foreign_key');
        }

        return $result;
    }