/home/mmvjnko/www/kirby/src/Http/Response.php
*
* @codeCoverageIgnore
*/
public static function go(string $url = '/', int $code = 302): never
{
die(static::redirect($url, $code));
}
/**
* Ensures that the callback does not produce the first body output
* (used to show when loading a file creates side effects)
*/
public static function guardAgainstOutput(Closure $callback, ...$args): mixed
{
$before = headers_sent();
$result = $callback(...$args);
$after = headers_sent($file, $line);
if ($before === false && $after === true) {
throw new LogicException("Disallowed output from file $file:$line, possible accidental whitespace?");
}
return $result;
}
/**
* Getter for single headers
*
* @param string $key Name of the header
*/
public function header(string $key): string|null
{
return $this->headers[$key] ?? null;
}
/**
* Getter for all headers
*/
public function headers(): array
{
/home/mmvjnko/www/kirby/src/Filesystem/F.php
return include $___file___;
}
/**
* Loads a file using `include_once()` and
* returns whether loading was successful
*/
public static function loadOnce(
string $file,
bool $allowOutput = true
): bool {
if (is_file($file) === false) {
return false;
}
$callback = fn () => include_once $file;
if ($allowOutput === false) {
Response::guardAgainstOutput($callback);
} else {
$callback();
}
return true;
}
/**
* Returns the mime type of a file
*/
public static function mime(string $file): string|null
{
return Mime::type($file);
}
/**
* Converts a mime type to a file extension
*/
public static function mimeToExtension(string|null $mime = null): string|false
{
/home/mmvjnko/www/kirby/src/Cms/AppPlugins.php
$root = $this->root('plugins');
$loaded = [];
foreach (Dir::read($root) as $dirname) {
if (in_array(substr($dirname, 0, 1), ['.', '_']) === true) {
continue;
}
$dir = $root . '/' . $dirname;
if (is_dir($dir) !== true) {
continue;
}
$entry = $dir . '/index.php';
$script = $dir . '/index.js';
$styles = $dir . '/index.css';
if (is_file($entry) === true) {
F::loadOnce($entry, allowOutput: false);
} elseif (is_file($script) === true || is_file($styles) === true) {
// if no PHP file is present but an index.js or index.css,
// register as anonymous plugin (without actual extensions)
// to be picked up by the Panel\Document class when
// rendering the Panel view
static::plugin(
name: 'plugins/' . $dirname,
extends: [],
root: $dir
);
} else {
continue;
}
$loaded[] = $dir;
}
return $loaded;
}
}
/home/mmvjnko/www/kirby/src/Cms/AppPlugins.php
* Loading only happens on the first call.
*
* @internal
* @param array|null $plugins Can be used to overwrite the plugins registry
*/
public function plugins(array $plugins = null): array
{
// overwrite the existing plugins registry
if ($plugins !== null) {
$this->pluginsAreLoaded = true;
return static::$plugins = $plugins;
}
// don't load plugins twice
if ($this->pluginsAreLoaded === true) {
return static::$plugins;
}
// load all plugins from site/plugins
$this->pluginsLoader();
// mark plugins as loaded to stop doing it twice
$this->pluginsAreLoaded = true;
return static::$plugins;
}
/**
* Loads all plugins from site/plugins
*
* @return array Array of loaded directories
*/
protected function pluginsLoader(): array
{
$root = $this->root('plugins');
$loaded = [];
foreach (Dir::read($root) as $dirname) {
if (in_array(substr($dirname, 0, 1), ['.', '_']) === true) {
continue;
}
/home/mmvjnko/www/kirby/src/Cms/AppPlugins.php
* the options array. I.e. hooks and routes can be
* setup from the config.
*/
protected function extensionsFromOptions(): void
{
// register routes and hooks from options
$this->extend([
'api' => $this->options['api'] ?? [],
'routes' => $this->options['routes'] ?? [],
'hooks' => $this->options['hooks'] ?? []
]);
}
/**
* Apply all plugin extensions
*/
protected function extensionsFromPlugins(): void
{
// register all their extensions
foreach ($this->plugins() as $plugin) {
$extends = $plugin->extends();
if (empty($extends) === false) {
$this->extend($extends, $plugin);
}
}
}
/**
* Apply all passed extensions
*/
protected function extensionsFromProps(array $props): void
{
$this->extend($props);
}
/**
* Apply all default extensions
*/
protected function extensionsFromSystem(): void
/home/mmvjnko/www/kirby/src/Cms/App.php
// configurable properties
$this->setLanguages($props['languages'] ?? null);
$this->setRoles($props['roles'] ?? null);
$this->setSite($props['site'] ?? null);
$this->setUser($props['user'] ?? null);
$this->setUsers($props['users'] ?? null);
// set the singleton
if (static::$instance === null || $setInstance === true) {
static::$instance = ModelWithContent::$kirby = Model::$kirby = $this;
}
// setup the I18n class with the translation loader
$this->i18n();
// load all extensions
$this->extensionsFromSystem();
$this->extensionsFromProps($props);
$this->extensionsFromPlugins();
$this->extensionsFromOptions();
$this->extensionsFromFolders();
// trigger hook for use in plugins
$this->trigger('system.loadPlugins:after');
// execute a ready callback from the config
$this->optionsFromReadyCallback();
// bake config
$this->bakeOptions();
}
/**
* Improved `var_dump` output
*
* @codeCoverageIgnore
*/
public function __debugInfo(): array
{
/home/mmvjnko/www/index.php
<?php
require 'kirby/bootstrap.php';
echo (new Kirby)->render();