Issues (447)

src/controllers/RoutesController.php (73 issues)

1
<?php
2
/**
3
 * Route Map plugin for Craft CMS
4
 *
5
 * Returns a list of public routes for elements with URLs
6
 *
7
 * @link      https://nystudio107.com/
0 ignored issues
show
The tag in position 1 should be the @copyright tag
Loading history...
8
 * @copyright Copyright (c) 2017 nystudio107
0 ignored issues
show
@copyright tag must contain a year and the name of the copyright holder
Loading history...
9
 */
0 ignored issues
show
PHP version not specified
Loading history...
Missing @category tag in file comment
Loading history...
Missing @package tag in file comment
Loading history...
Missing @author tag in file comment
Loading history...
Missing @license tag in file comment
Loading history...
10
11
namespace nystudio107\routemap\controllers;
12
13
use craft\base\ElementInterface;
0 ignored issues
show
The type craft\base\ElementInterface 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 craft\web\Controller;
15
use nystudio107\routemap\RouteMap;
16
use yii\web\Response;
17
18
/**
0 ignored issues
show
Missing short description in doc comment
Loading history...
19
 * @author    nystudio107
0 ignored issues
show
The tag in position 1 should be the @package tag
Loading history...
Content of the @author tag must be in the form "Display Name <[email protected]>"
Loading history...
Tag value for @author tag indented incorrectly; expected 2 spaces but found 4
Loading history...
20
 * @package   RouteMap
0 ignored issues
show
Tag value for @package tag indented incorrectly; expected 1 spaces but found 3
Loading history...
21
 * @since     1.0.0
0 ignored issues
show
The tag in position 3 should be the @author tag
Loading history...
Tag value for @since tag indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 */
0 ignored issues
show
Missing @category tag in class comment
Loading history...
Missing @license tag in class comment
Loading history...
Missing @link tag in class comment
Loading history...
23
class RoutesController extends Controller
24
{
25
    // Protected Properties
26
    // =========================================================================
27
28
    protected array|bool|int $allowAnonymous = [
29
        'get-all-urls',
30
        'get-section-urls',
31
        'get-all-route-rules',
32
        'get-section-route-rules',
33
        'get-url-asset-urls',
34
        'get-element-urls',
35
    ];
36
37
    // Public Methods
38
    // =========================================================================
39
    /**
0 ignored issues
show
Parameter $criteria should have a doc-comment as per coding-style.
Loading history...
Parameter $siteId should have a doc-comment as per coding-style.
Loading history...
40
     * Return the public URLs for all elements that have URLs
41
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
42
    public function actionGetAllUrls(array $criteria = [], ?int $siteId = null): Response
43
    {
44
        return $this->asJson(RouteMap::$plugin->routes->getAllUrls($criteria, $siteId));
45
    }
46
47
    /**
0 ignored issues
show
Parameter $section should have a doc-comment as per coding-style.
Loading history...
Parameter $criteria should have a doc-comment as per coding-style.
Loading history...
Parameter $siteId should have a doc-comment as per coding-style.
Loading history...
48
     * Return the public URLs for a section
49
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
50
    public function actionGetSectionUrls(string $section, array $criteria = [], ?int $siteId = null): Response
51
    {
52
        return $this->asJson(RouteMap::$plugin->routes->getSectionUrls($section, $criteria, $siteId));
53
    }
54
55
    /**
0 ignored issues
show
Parameter $category should have a doc-comment as per coding-style.
Loading history...
Parameter $criteria should have a doc-comment as per coding-style.
Loading history...
Parameter $siteId should have a doc-comment as per coding-style.
Loading history...
56
     * Return the public URLs for a category
57
     */
0 ignored issues
show
Missing @return tag in function comment
Loading history...
58
    public function actionGetCategoryUrls(string $category, array $criteria = [], ?int $siteId = null): Response
59
    {
60
        return $this->asJson(RouteMap::$plugin->routes->getCategoryUrls($category, $criteria, $siteId));
61
    }
62
63
    /**
64
     * Return all the section route rules
65
     *
66
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
67
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
68
     * @return Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
69
     */
70
    public function actionGetAllRouteRules(string $format = 'Craft', ?int $siteId = null): Response
71
    {
72
        return $this->asJson(RouteMap::$plugin->routes->getAllRouteRules($format, $siteId));
73
    }
74
75
    /**
76
     * Return the route rules for a specific section
77
     *
78
     * @param string $section
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
79
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Expected 2 spaces after parameter name; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
80
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
81
     * @return Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
82
     */
83
    public function actionGetSectionRouteRules(string $section, string $format = 'Craft', ?int $siteId = null): Response
84
    {
85
        return $this->asJson(RouteMap::$plugin->routes->getSectionRouteRules($section, $format, $siteId));
86
    }
87
88
    /**
89
     * Return the route rules for a specific category
90
     *
91
     * @param string $category
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
92
     * @param string $format 'Craft'|'React'|'Vue'
0 ignored issues
show
Expected 3 spaces after parameter name; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
93
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
94
     * @return Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
95
     */
96
    public function actionGetCategoryRouteRules(string $category, string $format = 'Craft', ?int $siteId = null): Response
97
    {
98
        return $this->asJson(RouteMap::$plugin->routes->getCategoryRouteRules($category, $format, $siteId));
99
    }
100
101
    /**
102
     * Return the Craft Control Panel and `routes.php` rules
103
     *
104
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
105
     * @param bool $includeGlobal
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
106
     * @return Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
107
     */
108
    public function actionGetRouteRules(?int $siteId = null, bool $includeGlobal = true): Response
109
    {
110
        return $this->asJson(RouteMap::$plugin->routes->getRouteRules($siteId, $includeGlobal));
111
    }
112
113
    /**
114
     * Get all the assets of the type $assetTypes that are used in the Entry
115
     * that matches the $url
116
     *
117
     * @param string $url
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
118
     * @param array $assetTypes
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 2 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
119
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 3 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
120
     * @return Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
121
     */
122
    public function actionGetUrlAssetUrls(string $url, array $assetTypes = ['image'], ?int $siteId = null): Response
123
    {
124
        return $this->asJson(RouteMap::$plugin->routes->getUrlAssetUrls($url, $assetTypes, $siteId));
125
    }
126
127
    /**
128
     * Returns all of the URLs for the given $elementType based on the passed in
129
     * $criteria and $siteId
130
     *
131
     * @param string|ElementInterface $elementType
0 ignored issues
show
Missing parameter comment
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
132
     * @param array $criteria
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 19 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
133
     * @param ?int $siteId
0 ignored issues
show
Missing parameter comment
Loading history...
Expected 20 spaces after parameter type; 1 found
Loading history...
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
134
     * @return Response
0 ignored issues
show
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
135
     */
136
    public function actionGetElementUrls(string|ElementInterface $elementType, array $criteria = [], ?int $siteId = null): Response
137
    {
138
        return $this->asJson(RouteMap::$plugin->routes->getElementUrls($elementType, $criteria, $siteId));
139
    }
140
}
141