Issues (496)

lib/Controller/WizardController.php (6 issues)

1
<?php
2
/**
3
 * Analytics
4
 *
5
 * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
6
 * SPDX-License-Identifier: AGPL-3.0-or-later
7
 */
8
9
namespace OCA\Analytics\Controller;
10
11
use OCP\AppFramework\Controller;
0 ignored issues
show
The type OCP\AppFramework\Controller was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use OCP\AppFramework\Http\DataResponse;
0 ignored issues
show
The type OCP\AppFramework\Http\DataResponse was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use OCP\IConfig;
0 ignored issues
show
The type OCP\IConfig was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
use OCP\IRequest;
0 ignored issues
show
The type OCP\IRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
use OCP\IUserSession;
0 ignored issues
show
The type OCP\IUserSession was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
16
17
class WizardController extends Controller
18
{
19
20
    /** @var IConfig */
21
    protected $config;
22
    /** @var IUserSession */
23
    private $userSession;
24
25
    public function __construct(
26
        string $appName,
27
        IRequest $request,
28
        IUserSession $userSession,
29
        IConfig $config
30
    )
31
    {
32
        parent::__construct($appName, $request);
33
        $this->appName = $appName;
0 ignored issues
show
Bug Best Practice introduced by
The property appName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
34
        $this->config = $config;
35
        $this->userSession = $userSession;
36
    }
37
38
39
    /**
40
     * @NoAdminRequired
41
     *
42
     * @return DataResponse
43
     * @throws \OCP\PreConditionNotMetException
44
     */
45
    public function dismiss(): DataResponse
46
    {
47
        $user = $this->userSession->getUser();
48
        if ($user === null) {
49
            throw new \RuntimeException("Acting user cannot be resolved");
50
        }
51
        $this->config->setUserValue($user->getUID(), $this->appName, 'wizzard', 1);
52
        return new DataResponse();
53
    }
54
}