1 | <?php |
||||
2 | |||||
3 | namespace PhpTek\Exodus\Model; |
||||
4 | |||||
5 | use SilverStripe\CMS\Model\SiteTree; |
||||
6 | use SilverStripe\Core\Injector\Injectable; |
||||
7 | use SilverStripe\ORM\DataObject; |
||||
8 | use SilverStripe\ORM\ArrayList; |
||||
9 | use SilverStripe\ORM\FieldType\DBVarchar; |
||||
10 | |||||
11 | /** |
||||
12 | * A model object that represents a single failed link-rewrite during the |
||||
13 | * running of the StaticSiteRewriteLinksTask. This data is then used to power the |
||||
14 | * {@link FailedURLRewriteReport}. |
||||
15 | * |
||||
16 | * @author Russell Michell <[email protected]> |
||||
17 | * @package phptek/silverstripe-exodus |
||||
18 | * @see {@link StaticSiteLinkRewriteTask} |
||||
19 | */ |
||||
20 | class FailedURLRewriteObject extends DataObject |
||||
21 | { |
||||
22 | use Injectable; |
||||
23 | |||||
24 | /** |
||||
25 | * @var string |
||||
26 | */ |
||||
27 | private static $table_name = 'FailedURLRewriteObject'; |
||||
0 ignored issues
–
show
introduced
by
![]() |
|||||
28 | |||||
29 | /** |
||||
30 | * |
||||
31 | * @var array |
||||
32 | */ |
||||
33 | private static $db = [ |
||||
0 ignored issues
–
show
|
|||||
34 | "BadLinkType" => "Enum('ThirdParty, BadScheme, NotImported, Junk, Unknown', 'Unknown')", |
||||
35 | "OrigUrl" => DBVarchar::class, |
||||
36 | ]; |
||||
37 | |||||
38 | /** |
||||
39 | * |
||||
40 | * @var array |
||||
41 | */ |
||||
42 | private static $has_one = [ |
||||
0 ignored issues
–
show
|
|||||
43 | 'Import' => StaticSiteImportDataObject::class, |
||||
44 | 'ContainedIn' => SiteTree::class, |
||||
45 | ]; |
||||
46 | |||||
47 | /** |
||||
48 | * Customise the output of the FailedURLRewriteReport CSV export. |
||||
49 | * |
||||
50 | * @return array |
||||
51 | */ |
||||
52 | public function summaryFields() |
||||
53 | { |
||||
54 | return [ |
||||
55 | 'ContainedIn.Title' => 'Imported page', |
||||
56 | 'Import.Created' => 'Import date', |
||||
57 | 'ThirdPartyTotal' => 'No. 3rd Party Urls', |
||||
58 | 'BadSchemeTotal' => 'No. Urls with bad-scheme', |
||||
59 | 'NotImportedTotal' => 'No. Unimported Urls', |
||||
60 | 'JunkTotal' => 'No. Junk Urls', |
||||
61 | ]; |
||||
62 | } |
||||
63 | |||||
64 | /** |
||||
65 | * Fetch the related SiteTree object's Title property. |
||||
66 | * |
||||
67 | * @return string |
||||
68 | */ |
||||
69 | public function Title() |
||||
70 | { |
||||
71 | return $this->ContainedIn()->Title; |
||||
0 ignored issues
–
show
The method
ContainedIn() does not exist on PhpTek\Exodus\Model\FailedURLRewriteObject . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
72 | } |
||||
73 | |||||
74 | /** |
||||
75 | * Get totals for each type of failed URL. |
||||
76 | * |
||||
77 | * @param number $importID |
||||
78 | * @param string $badLinkType e.g. 'NotImported' |
||||
79 | * @return SS_List |
||||
0 ignored issues
–
show
The type
PhpTek\Exodus\Model\SS_List 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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
80 | */ |
||||
81 | public function getBadImportData($importID, $badLinkType = null) |
||||
82 | { |
||||
83 | $default = ArrayList::create(); |
||||
84 | |||||
85 | $badLinks = DataObject::get(__CLASS__) |
||||
86 | ->filter('ImportID', $importID) |
||||
87 | ->sort('Created'); |
||||
88 | |||||
89 | if ($badLinks) { |
||||
0 ignored issues
–
show
|
|||||
90 | if ($badLinkType) { |
||||
91 | return $badLinks->filter('BadLinkType', $badLinkType); |
||||
0 ignored issues
–
show
|
|||||
92 | } |
||||
93 | return $badLinks; |
||||
0 ignored issues
–
show
|
|||||
94 | } |
||||
95 | |||||
96 | return $default; |
||||
97 | } |
||||
98 | } |
||||
99 |