Jitamin /
jitamin
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 |
||
| 2 | |||
| 3 | /* |
||
| 4 | * This file is part of Jitamin. |
||
| 5 | * |
||
| 6 | * Copyright (C) Jitamin Team |
||
| 7 | * |
||
| 8 | * For the full copyright and license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Jitamin\Foundation\Action; |
||
| 13 | |||
| 14 | use Jitamin\Action\Base as ActionBase; |
||
| 15 | use Jitamin\Foundation\Base; |
||
| 16 | use RuntimeException; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Action Manager. |
||
| 20 | */ |
||
| 21 | class ActionManager extends Base |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * List of automatic actions. |
||
| 25 | * |
||
| 26 | * @var ActionBase[] |
||
| 27 | */ |
||
| 28 | private $actions = []; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Register a new automatic action. |
||
| 32 | * |
||
| 33 | * @param ActionBase $action |
||
| 34 | * |
||
| 35 | * @return ActionManager |
||
| 36 | */ |
||
| 37 | public function register(ActionBase $action) |
||
| 38 | { |
||
| 39 | $this->actions[$action->getName()] = $action; |
||
| 40 | |||
| 41 | return $this; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Get automatic action instance. |
||
| 46 | * |
||
| 47 | * @param string $name Absolute class name with namespace |
||
| 48 | * |
||
| 49 | * @return ActionBase |
||
| 50 | */ |
||
| 51 | public function getAction($name) |
||
| 52 | { |
||
| 53 | if (isset($this->actions[$name])) { |
||
| 54 | return $this->actions[$name]; |
||
| 55 | } |
||
| 56 | |||
| 57 | throw new RuntimeException('Automatic Action Not Found: '.$name); |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Get available automatic actions. |
||
| 62 | * |
||
| 63 | * @return array |
||
| 64 | */ |
||
| 65 | public function getAvailableActions() |
||
| 66 | { |
||
| 67 | $actions = []; |
||
| 68 | |||
| 69 | foreach ($this->actions as $action) { |
||
| 70 | if (count($action->getEvents()) > 0) { |
||
| 71 | $actions[$action->getName()] = $action->getDescription(); |
||
| 72 | } |
||
| 73 | } |
||
| 74 | |||
| 75 | asort($actions); |
||
| 76 | |||
| 77 | return $actions; |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * Get all available action parameters. |
||
| 82 | * |
||
| 83 | * @param array $actions |
||
| 84 | * |
||
| 85 | * @return array |
||
| 86 | */ |
||
| 87 | public function getAvailableParameters(array $actions) |
||
| 88 | { |
||
| 89 | $params = []; |
||
| 90 | |||
| 91 | foreach ($actions as $action) { |
||
| 92 | $currentAction = $this->getAction($action['action_name']); |
||
| 93 | $params[$currentAction->getName()] = $currentAction->getActionRequiredParameters(); |
||
| 94 | } |
||
| 95 | |||
| 96 | return $params; |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * Get list of compatible events for a given action. |
||
| 101 | * |
||
| 102 | * @param string $name |
||
| 103 | * |
||
| 104 | * @return array |
||
| 105 | */ |
||
| 106 | public function getCompatibleEvents($name) |
||
| 107 | { |
||
| 108 | $events = []; |
||
| 109 | $actionEvents = $this->getAction($name)->getEvents(); |
||
| 110 | |||
| 111 | foreach ($this->eventManager->getAll() as $event => $description) { |
||
|
0 ignored issues
–
show
|
|||
| 112 | if (in_array($event, $actionEvents)) { |
||
| 113 | $events[$event] = $description; |
||
| 114 | } |
||
| 115 | } |
||
| 116 | |||
| 117 | return $events; |
||
| 118 | } |
||
| 119 | |||
| 120 | /** |
||
| 121 | * Bind automatic actions to events. |
||
| 122 | * |
||
| 123 | * @return ActionManager |
||
| 124 | */ |
||
| 125 | public function attachEvents() |
||
| 126 | { |
||
| 127 | if ($this->userSession->isLogged()) { |
||
|
0 ignored issues
–
show
The property
userSession does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
|
|||
| 128 | $actions = $this->actionModel->getAllByUser($this->userSession->getId()); |
||
|
0 ignored issues
–
show
The property
actionModel does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
The property
userSession does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
|
|||
| 129 | } else { |
||
| 130 | $actions = $this->actionModel->getAll(); |
||
|
0 ignored issues
–
show
The property
actionModel does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
|
|||
| 131 | } |
||
| 132 | |||
| 133 | foreach ($actions as $action) { |
||
| 134 | $listener = clone $this->getAction($action['action_name']); |
||
| 135 | $listener->setProjectId($action['project_id']); |
||
| 136 | |||
| 137 | foreach ($action['params'] as $param_name => $param_value) { |
||
| 138 | $listener->setParam($param_name, $param_value); |
||
| 139 | } |
||
| 140 | |||
| 141 | $this->dispatcher->addListener($action['event_name'], [$listener, 'execute']); |
||
|
0 ignored issues
–
show
The property
dispatcher does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
|
|||
| 142 | } |
||
| 143 | |||
| 144 | return $this; |
||
| 145 | } |
||
| 146 | |||
| 147 | /** |
||
| 148 | * Remove all listeners for automated actions. |
||
| 149 | */ |
||
| 150 | public function removeEvents() |
||
| 151 | { |
||
| 152 | foreach ($this->dispatcher->getListeners() as $eventName => $listeners) { |
||
|
0 ignored issues
–
show
The property
dispatcher does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
|
|||
| 153 | foreach ($listeners as $listener) { |
||
| 154 | if (is_array($listener) && $listener[0] instanceof ActionBase) { |
||
| 155 | $this->dispatcher->removeListener($eventName, $listener); |
||
|
0 ignored issues
–
show
The property
dispatcher does not exist on object<Jitamin\Foundation\Action\ActionManager>. 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. Loading history...
|
|||
| 156 | } |
||
| 157 | } |
||
| 158 | } |
||
| 159 | } |
||
| 160 | } |
||
| 161 |
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@propertyannotation 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.