This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php namespace Modules\Menu\Providers; |
||
2 | |||
3 | use Illuminate\Support\Facades\Config; |
||
4 | use Illuminate\Support\ServiceProvider; |
||
5 | use Modules\Menu\Entities\Menu; |
||
6 | use Modules\Menu\Entities\Menuitem; |
||
7 | use Modules\Menu\Repositories\Cache\CacheMenuDecorator; |
||
8 | use Modules\Menu\Repositories\Cache\CacheMenuItemDecorator; |
||
9 | use Modules\Menu\Repositories\Eloquent\EloquentMenuItemRepository; |
||
10 | use Modules\Menu\Repositories\Eloquent\EloquentMenuRepository; |
||
11 | use Pingpong\Menus\MenuBuilder as Builder; |
||
12 | use Pingpong\Menus\MenuFacade; |
||
13 | use Pingpong\Menus\MenuItem as PingpongMenuItem; |
||
14 | |||
15 | class MenuServiceProvider extends ServiceProvider |
||
16 | { |
||
17 | /** |
||
18 | * Indicates if loading of the provider is deferred. |
||
19 | * |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $defer = false; |
||
23 | |||
24 | /** |
||
25 | * Register the service provider. |
||
26 | * |
||
27 | * @return void |
||
28 | */ |
||
29 | public function register() |
||
30 | { |
||
31 | $this->registerBindings(); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Register all online menus on the Pingpong/Menu package |
||
36 | */ |
||
37 | public function boot() |
||
38 | { |
||
39 | $this->registerMenus(); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Get the services provided by the provider. |
||
44 | * |
||
45 | * @return array |
||
46 | */ |
||
47 | public function provides() |
||
48 | { |
||
49 | return array(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Register class binding |
||
54 | */ |
||
55 | private function registerBindings() |
||
56 | { |
||
57 | $this->app->bind( |
||
58 | 'Modules\Menu\Repositories\MenuRepository', |
||
59 | function () { |
||
60 | $repository = new EloquentMenuRepository(new Menu()); |
||
61 | |||
62 | if (! config('app.cache')) { |
||
63 | return $repository; |
||
64 | } |
||
65 | |||
66 | return new CacheMenuDecorator($repository); |
||
67 | } |
||
68 | ); |
||
69 | |||
70 | $this->app->bind( |
||
71 | 'Modules\Menu\Repositories\MenuItemRepository', |
||
72 | function () { |
||
73 | $repository = new EloquentMenuItemRepository(new Menuitem()); |
||
74 | |||
75 | if (! config('app.cache')) { |
||
76 | return $repository; |
||
77 | } |
||
78 | |||
79 | return new CacheMenuItemDecorator($repository); |
||
80 | } |
||
81 | ); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Add a menu item to the menu |
||
86 | * @param Menuitem $item |
||
87 | * @param Builder $menu |
||
88 | */ |
||
89 | public function addItemToMenu(Menuitem $item, Builder $menu) |
||
90 | { |
||
91 | if ($this->hasChildren($item)) { |
||
92 | $this->addChildrenToMenu($item->title, $item->items, $menu, ['icon' => $item->icon]); |
||
0 ignored issues
–
show
The property
items does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
icon does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
93 | } else { |
||
94 | $target = $item->uri ?: $item->url; |
||
0 ignored issues
–
show
The property
uri does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
url does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
95 | $menu->url( |
||
96 | $target, |
||
97 | $item->title, |
||
0 ignored issues
–
show
The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
98 | ['target' => $item->target, |
||
0 ignored issues
–
show
The property
target does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
99 | 'icon' => $item->icon] |
||
0 ignored issues
–
show
The property
icon does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
100 | ); |
||
101 | } |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * Add children to menu under the give name |
||
106 | * |
||
107 | * @param string $name |
||
108 | * @param object $children |
||
109 | * @param Builder|MenuItem $menu |
||
110 | */ |
||
111 | private function addChildrenToMenu($name, $children, $menu, $attribs = []) |
||
112 | { |
||
113 | $menu->dropdown($name, function (PingpongMenuItem $subMenu) use ($children) { |
||
114 | foreach ($children as $child) { |
||
115 | $this->addSubItemToMenu($child, $subMenu); |
||
116 | } |
||
117 | }, 0, $attribs); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Add children to the given menu recursively |
||
122 | * @param Menuitem $child |
||
123 | * @param PingpongMenuItem $sub |
||
124 | */ |
||
125 | View Code Duplication | private function addSubItemToMenu(Menuitem $child, PingpongMenuItem $sub) |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
126 | { |
||
127 | if ($this->hasChildren($child)) { |
||
128 | $this->addChildrenToMenu($child->title, $child->items, $sub); |
||
0 ignored issues
–
show
The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
items does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
129 | } else { |
||
130 | $target = $child->uri ?: $child->url; |
||
0 ignored issues
–
show
The property
uri does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
url does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
131 | $sub->url($target, $child->title, 0, ['icon' => $child->icon]); |
||
0 ignored issues
–
show
The property
title does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
icon does not exist on object<Modules\Menu\Entities\Menuitem> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
132 | } |
||
133 | } |
||
134 | |||
135 | /** |
||
136 | * Check if the given menu item has children |
||
137 | * |
||
138 | * @param object $item |
||
139 | * @return bool |
||
140 | */ |
||
141 | private function hasChildren($item) |
||
142 | { |
||
143 | return $item->items->count() > 0; |
||
144 | } |
||
145 | |||
146 | /** |
||
147 | * Register the active menus |
||
148 | */ |
||
149 | private function registerMenus() |
||
150 | { |
||
151 | if (! $this->app['asgard.isInstalled']) { |
||
152 | return; |
||
153 | } |
||
154 | $menu = $this->app->make('Modules\Menu\Repositories\MenuRepository'); |
||
155 | $menuItem = $this->app->make('Modules\Menu\Repositories\MenuItemRepository'); |
||
156 | foreach ($menu->allOnline() as $menu) { |
||
157 | $menuTree = $menuItem->getTreeForMenu($menu->id); |
||
158 | MenuFacade::create($menu->name, function (Builder $menu) use ($menuTree) { |
||
159 | foreach ($menuTree as $menuItem) { |
||
160 | $this->addItemToMenu($menuItem, $menu); |
||
161 | } |
||
162 | }); |
||
163 | } |
||
164 | } |
||
165 | } |
||
166 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.