Skip to content

Commit

Permalink
Referencing the global package
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Blanquera committed Feb 12, 2019
1 parent 6783add commit d83f35e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
31 changes: 17 additions & 14 deletions src/bootstrap/errors.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@
//this happens on an error
$this->error(function ($request, $response, $error) {
// if an exception was thrown from the role package
if ($error instanceof \Cradle\Package\Role\Exception) {
$config = $this->package('global')->config('settings');

// set default redirect
$redirect = '/';
if (!($error instanceof \Cradle\Package\Role\Exception)) {
return;
}

// if config home url is set
if (isset($config['home'])) {
// get the home url
$redirect = $config['home'];
}
$global = $this->package('global');
$config = $global->config('settings');

// let them know
$this->package('global')->flash($error->getMessage(), 'error');
// set default redirect
$redirect = '/';

// redirect
return $this->package('global')->redirect($redirect);
// if config home url is set
if (isset($config['home'])) {
// get the home url
$redirect = $config['home'];
}

// let them know
$global->flash($error->getMessage(), 'error');

// redirect
return $global->redirect($redirect);
});
};
8 changes: 4 additions & 4 deletions src/events.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
$this->on('admin-render-page', function ($request, $response) {
$menu = $request->getSession('role', 'role_admin_menu');

$this->package('global')
$global = $this->package('global');

$global
->handlebars()
->registerHelper('nav_match', function (...$args) use ($request) {
//$haystack, $needle, $options
Expand All @@ -41,9 +43,7 @@
});

// get the schema name
$schema = $this
->package('global')
->config('services', 'sql-main')['name'];
$schema = $global->config('services', 'sql-main')['name'];

// get table record count
$records = Service::get('sql')->getSchemaTableRecordCount($schema);
Expand Down

0 comments on commit d83f35e

Please sign in to comment.