Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates To Kint Loading #2565

Merged
merged 1 commit into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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