/**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $database = $input->getOption('database');
     $table = $input->getArgument('table');
     $databaseConnection = $this->resolveConnection($io, $database);
     if ($table) {
         $this->redBean = $this->getRedBeanConnection($database);
         $tableInfo = $this->redBean->inspect($table);
         $tableHeader = [$this->trans('commands.database.table.debug.messages.column'), $this->trans('commands.database.table.debug.messages.type')];
         $tableRows = [];
         foreach ($tableInfo as $column => $type) {
             $tableRows[] = ['column' => $column, 'type' => $type];
         }
         $io->table($tableHeader, $tableRows);
         return 0;
     }
     $schema = $this->database->schema();
     $tables = $schema->findTables('%');
     $io->comment(sprintf($this->trans('commands.database.table.debug.messages.table-show'), $databaseConnection['database']));
     $io->table([$this->trans('commands.database.table.debug.messages.table')], $tables);
     return 0;
 }
Esempio n. 2
0
 private function loadFieldsInfoFromDatabase()
 {
     try {
         $this->fieldsInfoFromDatabase = R::inspect($this->tableName);
     } catch (Exception $ex) {
         $this->createTable();
         // Load again
         $this->loadFieldsInfoFromDatabase();
     }
 }
Esempio n. 3
-1
 public function editRota(Request $request, Response $response, array $args)
 {
     $id = $this->authenticator->getIdentity();
     if (strtolower($id['name']) != 'admin') {
         $this->flash->addMessage('flash', 'Access Denied');
         return $response->withRedirect($this->router->pathFor('homepage'));
     }
     $name = $args['name'];
     if (empty($name)) {
         $this->flash->addMessage('flash', 'No rota specified');
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     if ($name != 'new') {
         $rota = R::findOrCreate('rotas', ['name' => $name]);
     } else {
         $rota = R::dispense('rotas');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         //$username = $request->getParam('username');
         $rota->import($data, 'name,fullname,title,comment');
         $rota->sharedUsersList = [];
         foreach ($data['users'] as $checkUserID) {
             $rotaUser = R::load('users', $checkUserID);
             $rota->sharedUsersList[] = $rotaUser;
         }
         $id = R::store($rota);
         try {
             $fieldtest = R::inspect($rota->name);
         } catch (\Exception $e) {
             //thaw for creation
             R::freeze(['users']);
             $rotaUser = R::load('users', 1);
             $rotaDay = R::findOrCreate($rota->name, ['day' => 29, 'month' => 2, 'year' => 2015]);
             $rotaUser = R::load('users', 1);
             $rotaDay->name = $rotaUser;
             $rotaDay->who = $rotaUser;
             $rotaDay->stamp = date("Y-m-d H:i:s");
             R::store($rotaDay);
             R::freeze(true);
         }
         $this->flash->addMessage('flash', "{$rota->name} updated");
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     $userList = R::findAll('users');
     $data = $rota->export();
     $data['userList'] = $userList;
     $users = [];
     $userRota = $rota->sharedUsersList;
     foreach ($userRota as $userCheck) {
         $users[$userCheck->id] = 'checked';
     }
     $data['userCheck'] = $users;
     $this->view->render($response, 'rota.twig', $data);
     return $response;
 }