|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Canvas\Cli\Jobs; |
|
4
|
|
|
|
|
5
|
|
|
use Canvas\Contracts\Queue\QueueableJobInterface; |
|
6
|
|
|
use Canvas\Jobs\Job; |
|
7
|
|
|
use Phalcon\Di; |
|
8
|
|
|
use Canvas\Models\Apps as CanvasApps; |
|
9
|
|
|
use Phalcon\Security\Random; |
|
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class Apps extends Job implements QueueableJobInterface |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* Realtime channel |
|
15
|
|
|
* |
|
16
|
|
|
* @var string |
|
17
|
|
|
*/ |
|
18
|
|
|
protected $appName; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Realtime event |
|
22
|
|
|
* |
|
23
|
|
|
* @var string |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $appDescription; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Realtime params |
|
29
|
|
|
* |
|
30
|
|
|
* @var array |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $params; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Constructor setup info for Pusher |
|
36
|
|
|
* |
|
37
|
|
|
* @param string $channel |
|
38
|
|
|
* @param string $event |
|
39
|
|
|
* @param array $params |
|
40
|
|
|
*/ |
|
41
|
|
|
public function __construct(string $appName, string $appDescription, array $params) |
|
42
|
|
|
{ |
|
43
|
|
|
$this->appName = $appName; |
|
44
|
|
|
$this->appDescription = $appDescription; |
|
45
|
|
|
$this->params = $params; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Handle the pusher request |
|
50
|
|
|
* @todo New Apps can't be created, the system does not take into account the creation of other apps apart from the default. Need to change this |
|
51
|
|
|
* @return void |
|
52
|
|
|
*/ |
|
53
|
|
|
public function handle() |
|
54
|
|
|
{ |
|
55
|
|
|
$random = new Random(); |
|
56
|
|
|
$appDescription = $this->appDescription; |
|
57
|
|
|
|
|
58
|
|
|
$app = new CanvasApps(); |
|
59
|
|
|
$app->name = $this->appName; |
|
60
|
|
|
$app->description = $appDescription; |
|
61
|
|
|
$app->key = $random->uuid(); |
|
62
|
|
|
$app->is_public = 1; |
|
63
|
|
|
$app->default_apps_plan_id = 1; |
|
64
|
|
|
$app->created_at = date('Y-m-d H:i:s'); |
|
65
|
|
|
$app->is_deleted = 0; |
|
66
|
|
|
$app->payments_active = 0; |
|
67
|
|
|
|
|
68
|
|
|
if (!$app->save()) { |
|
69
|
|
|
Di::getDefault()->getLog()->error('App could not be created'); |
|
70
|
|
|
return false; |
|
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @todo Only works for default app |
|
75
|
|
|
*/ |
|
76
|
|
|
Di::getDefault()->getAcl()->setApp($app); |
|
77
|
|
|
|
|
78
|
|
|
Di::getDefault()->getAcl()->addRole($appName .'.Admins'); |
|
|
|
|
|
|
79
|
|
|
Di::getDefault()->getAcl()->addRole($appName .'.Agents'); |
|
80
|
|
|
Di::getDefault()->getAcl()->addRole($appName .'.Users'); |
|
81
|
|
|
|
|
82
|
|
|
Di::getDefault()->getAcl()->addResource($appName .'.Users', ['read', 'list', 'create', 'update', 'delete']); |
|
83
|
|
|
Di::getDefault()->getAcl()->allow('Admins', $appName .'.Users', ['read', 'list', 'create', 'update', 'delete']); |
|
84
|
|
|
|
|
85
|
|
|
return true; |
|
|
|
|
|
|
86
|
|
|
} |
|
87
|
|
|
} |
|
88
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths