1
|
|
|
<?php namespace Anomaly\AddonsModule\Http\Controller\Admin; |
2
|
|
|
|
3
|
|
|
use Anomaly\AddonsModule\Addon\Table\AddonTableBuilder; |
4
|
|
|
use Anomaly\Streams\Platform\Addon\Addon; |
5
|
|
|
use Anomaly\Streams\Platform\Addon\AddonCollection; |
6
|
|
|
use Anomaly\Streams\Platform\Addon\Extension\Extension; |
7
|
|
|
use Anomaly\Streams\Platform\Addon\Extension\ExtensionManager; |
8
|
|
|
use Anomaly\Streams\Platform\Addon\Module\Module; |
9
|
|
|
use Anomaly\Streams\Platform\Addon\Module\ModuleManager; |
10
|
|
|
use Anomaly\Streams\Platform\Http\Controller\AdminController; |
11
|
|
|
use Illuminate\Filesystem\Filesystem; |
12
|
|
|
use Illuminate\Http\Request; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class AddonsController |
16
|
|
|
* |
17
|
|
|
* @link http://pyrocms.com/ |
18
|
|
|
* @author PyroCMS, Inc. <[email protected]> |
19
|
|
|
* @author Ryan Thompson <[email protected]> |
20
|
|
|
* @package Anomaly\AddonsModule\Http\Controller\Admin |
21
|
|
|
*/ |
22
|
|
|
class AddonsController extends AdminController |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Return an index of existing entries. |
27
|
|
|
* |
28
|
|
|
* @param AddonTableBuilder $builder |
29
|
|
|
* @param string $type |
30
|
|
|
* @return \Symfony\Component\HttpFoundation\Response |
31
|
|
|
*/ |
32
|
|
|
public function index(AddonTableBuilder $builder, $type = 'modules') |
33
|
|
|
{ |
34
|
|
|
$builder->setType($type); |
35
|
|
|
|
36
|
|
|
return $builder->render(); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Return the details for an addon. |
41
|
|
|
* |
42
|
|
|
* @param AddonCollection $addons |
43
|
|
|
* @param $addon |
44
|
|
|
* @return mixed|null|string |
45
|
|
|
*/ |
46
|
|
|
public function details(AddonCollection $addons, $addon) |
47
|
|
|
{ |
48
|
|
|
/* @var Addon $addon */ |
49
|
|
|
$addon = $addons->get($addon); |
50
|
|
|
|
51
|
|
|
$json = $addon->getComposerJson(); |
52
|
|
|
|
53
|
|
|
return view('module::ajax/details', compact('json', 'addon'))->render(); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Return the modal form for the seed |
58
|
|
|
* option when installing modules. |
59
|
|
|
* |
60
|
|
|
* @param AddonCollection $addons |
61
|
|
|
* @param $namespace |
62
|
|
|
* @return |
63
|
|
|
*/ |
64
|
|
|
public function options(AddonCollection $addons, $namespace) |
65
|
|
|
{ |
66
|
|
|
/* @var Addon $addon */ |
67
|
|
|
$addon = $addons->get($namespace); |
68
|
|
|
|
69
|
|
|
return $this->view->make('module::ajax/install', compact('addon', 'namespace')); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Install an addon. |
74
|
|
|
* |
75
|
|
|
* @param Request $request |
76
|
|
|
* @param ModuleManager $modules |
77
|
|
|
* @param AddonCollection $addons |
78
|
|
|
* @param ExtensionManager $extensions |
79
|
|
|
* @param $addon |
80
|
|
|
* @return \Illuminate\Http\RedirectResponse |
81
|
|
|
*/ |
82
|
|
|
public function install( |
83
|
|
|
Request $request, |
84
|
|
|
ModuleManager $modules, |
85
|
|
|
AddonCollection $addons, |
86
|
|
|
ExtensionManager $extensions, |
87
|
|
|
$addon |
88
|
|
|
) { |
89
|
|
|
/* @var Addon|Module|Extension $addon */ |
90
|
|
|
$addon = $addons->get($addon); |
91
|
|
|
|
92
|
|
|
if ($addon instanceof Module) { |
|
|
|
|
93
|
|
|
$modules->install($addon, filter_var($request->input('seed'), FILTER_VALIDATE_BOOLEAN)); |
94
|
|
|
} elseif ($addon instanceof Extension) { |
|
|
|
|
95
|
|
|
$extensions->install($addon, filter_var($request->input('seed'), FILTER_VALIDATE_BOOLEAN)); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
$this->messages->success('module::message.install_addon_success'); |
99
|
|
|
|
100
|
|
|
return $this->redirect->back(); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Uninstall an addon. |
105
|
|
|
* |
106
|
|
|
* @param AddonCollection $addons |
107
|
|
|
* @param ModuleManager $modules |
108
|
|
|
* @param ExtensionManager $extensions |
109
|
|
|
* @param $addon |
110
|
|
|
* @return \Illuminate\Http\RedirectResponse |
111
|
|
|
*/ |
112
|
|
|
public function uninstall(AddonCollection $addons, ModuleManager $modules, ExtensionManager $extensions, $addon) |
113
|
|
|
{ |
114
|
|
|
/* @var Addon|Module|Extension $addon */ |
115
|
|
|
$addon = $addons->get($addon); |
116
|
|
|
|
117
|
|
|
if ($addon instanceof Module) { |
|
|
|
|
118
|
|
|
$modules->uninstall($addon); |
119
|
|
|
} elseif ($addon instanceof Extension) { |
|
|
|
|
120
|
|
|
$extensions->uninstall($addon); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
$this->messages->success('module::message.uninstall_addon_success'); |
124
|
|
|
|
125
|
|
|
return $this->redirect->back(); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.