This repository has been archived by the owner on Jun 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontroller.php
executable file
·136 lines (110 loc) · 3.68 KB
/
controller.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* @project: Entity Designer
*
* @author Fabian Bitter (fabian@bitter.de)
* @copyright (C) 2020 Fabian Bitter (www.bitter.de)
* @version X.X.X
*/
namespace Concrete\Package\EntityDesigner;
use Bitter\EntityDesigner\Console\Command\GenerateEntities;
use Bitter\EntityDesigner\Provider\ServiceProvider;
use Concrete\Core\Error\ErrorList\ErrorList;
use Concrete\Core\Package\Package;
use Concrete\Core\Page\Single;
use Concrete\Core\Permission\Access\Access;
use Concrete\Core\Permission\Access\Entity\GroupEntity;
use Concrete\Core\Permission\Key\Key;
use Concrete\Core\User\Group\Group;
class Controller extends Package
{
protected $pkgHandle = 'entity_designer';
protected $pkgVersion = '2.5.1';
protected $appVersionRequired = '9.0.0';
protected $pkgAutoloaderRegistries = [
'src/Bitter/EntityDesigner' => 'Bitter\EntityDesigner',
];
public function getPackageDescription()
{
return t('Create Doctrine-Entities easily in your concrete5 Dashboard. The code for entity, controller, detail view and list view is generated automatically.');
}
public function getPackageName()
{
return t('Entity Designer');
}
public function on_start()
{
require_once("vendor/autoload.php");
if ($this->app->isRunThroughCommandLineInterface()) {
$console = $this->app->make('console');
$console->add(new GenerateEntities());
}
/** @var ServiceProvider $serviceProvider */
$serviceProvider = $this->app->make(ServiceProvider::class);
$serviceProvider->register();
}
/**
* @param bool $testForAlreadyInstalled
* @return ErrorList|true|void
*/
public function testForInstall($testForAlreadyInstalled = false)
{
/** @var ErrorList $errors */
$errors = $this->app->make(ErrorList::class);
$directories = [
"application/controllers",
"application/single_pages",
"application/src",
"application/elements",
"application/blocks",
"packages"
];
foreach ($directories as $directory) {
if (!is_writable(DIR_BASE . DIRECTORY_SEPARATOR . $directory)) {
$errors->add(t('The directory "%s" needs to be writable.', $directory));
}
}
return $errors->has() ? $errors : true;
}
public function upgrade()
{
require_once("vendor/autoload.php");
parent::upgrade();
}
public function install()
{
require_once("vendor/autoload.php");
/*
* Install single pages
*/
$pkg = parent::install();
Single::add("/dashboard/entity_designer", $pkg);
/*
* Install task permissions
*/
$taskPermissions = [
[
"handle" => "access_entity_designer",
"name" => t("Access Entity Designer")
],
[
"handle" => "edit_fields",
"name" => t("Insert Rows")
],
[
"handle" => "add_packages",
"name" => t("Add Packages")
]
];
$group = Group::getByID(ADMIN_GROUP_ID);
$adminGroupEntity = GroupEntity::getOrCreate($group);
foreach ($taskPermissions as $taskPermission) {
/** @var Key $pk */
$pk = Key::add('admin', $taskPermission["handle"], $taskPermission["name"], "", false, false, $pkg);
$pa = Access::create($pk);
$pa->addListItem($adminGroupEntity);
$pt = $pk->getPermissionAssignmentObject();
$pt->assignPermissionAccess($pa);
}
}
}