Skip to content

Commit

Permalink
Merge pull request #2565 from najdanovicivan/kint3
Browse files Browse the repository at this point in the history
Updates To Kint Loading
  • Loading branch information
lonnieezell authored Feb 17, 2020
2 parents a0e9741 + c782e9a commit 64d053d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 9 deletions.
11 changes: 11 additions & 0 deletions app/Config/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,15 @@ class App extends BaseConfig
*/
public $CSPEnabled = false;

/*
|--------------------------------------------------------------------------
| Kint
|--------------------------------------------------------------------------
|
| Kint Related configuration
|
*/
public $kintRendererTheme = 'aante-light.css';
public $kintRendererFolder = false;

}
6 changes: 0 additions & 6 deletions system/Autoloader/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,6 @@ protected function discoverComposerNamespaces()
unset($paths['CodeIgniter\\']);
}

// Also get rid of Kint to ensure we use our own copy
if (isset($paths['Kint\\']))
{
unset($paths['Kint\\']);
}

// Composer stores namespaces with trailing slash. We don't.
$newPaths = [];
foreach ($paths as $key => $value)
Expand Down
38 changes: 36 additions & 2 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,45 @@ public function initialize()
$this->detectEnvironment();
$this->bootstrapEnvironment();

if (CI_DEBUG)
$this->initializeKint();

if (! CI_DEBUG)
{
\Kint::$enabled_mode = false;
}
}

//--------------------------------------------------------------------

/**
* Initializes Kint
*/
protected function initializeKint()
{
// If we have KINT_DIR it means it's already loaded via composer
if (! defined('KINT_DIR'))
{
spl_autoload_register(function ($class) {
$class = explode('\\', $class);

if ('Kint' !== array_shift($class))
{
return;
}

$file = SYSTEMPATH . 'ThirdParty/Kint/' . implode('/', $class) . '.php';

file_exists($file) && require_once $file;
});

require_once SYSTEMPATH . 'ThirdParty/Kint/init.php';
\Kint\Renderer\RichRenderer::$theme = 'aante-light.css';
}

//Set the kint theme
\Kint\Renderer\RichRenderer::$theme = $this->config->kintRendererTheme;

//Render kint in place instead of toolbar
\Kint\Renderer\RichRenderer::$folder = $this->config->kintRendererFolder;
}

//--------------------------------------------------------------------
Expand Down
1 change: 0 additions & 1 deletion system/Config/AutoloadConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ public function __construct()
*/
$this->psr4 = [
'CodeIgniter' => realpath(SYSTEMPATH),
'Kint' => SYSTEMPATH . 'ThirdParty/Kint',
];

if (isset($_SERVER['CI_ENVIRONMENT']) && $_SERVER['CI_ENVIRONMENT'] === 'testing')
Expand Down

0 comments on commit 64d053d

Please sign in to comment.