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

Updated loader and composer script to use Kint 3.3 for #2373 #2564

Merged
merged 7 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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;

}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ext-curl": "*",
"ext-intl": "*",
"ext-json": "*",
"kint-php/kint": "^2.1",
"kint-php/kint": "^3.3",
"psr/log": "^1.1",
"laminas/laminas-escaper": "^2.6"
},
Expand Down
39 changes: 37 additions & 2 deletions system/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +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'))
{
require_once SYSTEMPATH . 'ThirdParty/Kint/kint.php';
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';
}

//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
35 changes: 29 additions & 6 deletions system/ComposerScripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,29 @@ protected static function removeDir($dir)
}
}

protected static function copyDir($source, $dest)
{
$dir = opendir($source);
@mkdir($dest);

while (false !== ( $file = readdir($dir)))
{
if (( $file !== '.' ) && ( $file !== '..' ))
{
if (is_dir($source . '/' . $file))
{
static::copyDir($source . '/' . $file, $dest . '/' . $file);
}
else
{
copy($source . '/' . $file, $dest . '/' . $file);
}
}
}

closedir($dir);
}

/**
* Moves the Laminas Escaper files into our base repo so that it's
* available for packaged releases where the users don't user Composer.
Expand Down Expand Up @@ -194,9 +217,9 @@ public static function moveEscaper()
*/
public static function moveKint()
{
$filename = 'vendor/kint-php/kint/build/kint-aante-light.php';
$dir = 'vendor/kint-php/kint/src';

if (is_file($filename))
if (is_dir($dir))
{
$base = basename(__DIR__) . '/' . static::$basePath . 'Kint';

Expand All @@ -212,10 +235,10 @@ public static function moveKint()
mkdir($base, 0755);
}

if (! static::moveFile($filename, $base . '/kint.php'))
{
die('Error moving: ' . $filename);
}
static::copyDir($dir, $base);
static::copyDir($dir . '/../resources', $base . '/resources');
copy($dir . '/../init.php', $base . '/init.php');
copy($dir . '/../init_helpers.php', $base . '/init_helpers.php');
}
}
}
Loading