/** * @description Print SQL code needed to create all the tables corresponding to the models. */ public function showCreateTable() { $objects = ObjectLoader::getObjects(); /** * For each models, generate create table. */ foreach ($objects as $object_name => $object) { $sql_inspector = new SQLModelInspector(); $object->inspectModel($sql_inspector); $query = $sql_inspector->generate(); echo $query, PHP_EOL; } }
/** * @description Create the Administrator role with all the access rights. */ public function createAdminRole() { try { $admin = Role::get(1); $this->output->writeln('The administrator role already exists!'); } catch (\Exception $e) { $admin = new Role(); $admin->role_id = 1; } $rights = \Biome\Biome::getService('rights'); /** * Routes allowing. */ $router = \Biome\Biome::getService('router'); foreach ($router->getRoutes() as $route) { $method = $route['method']; $controller = $route['controller']; $action = $route['action']; $rights->setRoute($method, $controller, $action); } /** * Objects allowing. */ $objects = \Biome\Core\ORM\ObjectLoader::getObjects(); foreach ($objects as $object_name => $object) { $rights->setObject($object_name); foreach ($object->getFieldsName() as $attribute_name) { $rights->setAttribute($object_name, $attribute_name); } } $admin->role_name = 'Administrator'; $admin->role_rights = $rights->exportToJSON(); if (!$admin->save()) { $this->output->writeln('Unable to create the administrator role!'); $this->output->writeln(print_r($admin->getErrors(), TRUE)); return FALSE; } $this->output->writeln('Administrator role created!'); return TRUE; }
<?php $objects = \Biome\Core\ORM\ObjectLoader::getObjects(); $router = \Biome\Biome::getService('router'); $routes = $router->getRoutes(); $rights = \Biome\Core\Rights\AccessRights::loadFromJSON($this->getValue()); ?> <div id="<?php echo $this->getId(); ?> "> <ul class="nav nav-tabs" role="tablist"> <li role="presentation" class="active"><a href="#role_routes" aria-controls="role_routes" role="tab" data-toggle="tab">Routes</a></li> <li role="presentation"><a href="#role_objects" aria-controls="role_objects" role="tab" data-toggle="tab">Objects</a></li> </ul> <div class="tab-content"> <div role="tabpanel" class="tab-pane fade in active" id="role_routes"> <table id="table_routes" class="table table-striped table-hover table-condensed"> <thead> <tr> <th>Method</th> <th>Route</th> <th>Description</th> <th><input type="checkbox" onClick="toggleCheckboxColumn(this, 'table_routes', 'rights-routes');"/> <span> Access</span></th> </tr> </thead> <tbody> <?php foreach ($routes as $r) { $method = $r['method'];