Kernel (class)

Everything goes through the kernel.

Methods

getInstance() static

Get kernel singleton by calling kernel::getInstance(). Use this when there is no other way of accessing kernel: from static methods and classes that are not subclasses of \Core\Controller or \Core\Module.

In controllers and subclasses of \Core\Module you can use $this->kernel.

debug() static

emit($parent, $name) static

Emit a signal. Usually you should use \Core\Module::emit() for this.

expand($content, $vars = null) static

Expand variables in content.

Variables are detected from {variable_name} notation.

Built-in variables:

Example

$custom_config_file = kernel::expand('{path:config}/custom_config.yml');

tr($text_id, …) static

Translate identifier to text. Optional parameters after text are printed as if using sprintf().

Example

Contents of config/translations.yml:

en:
  title:
    site: My Site

Code:

/* will echo "My Site" when language is set to english */
echo kernel::tr('title:site');

log($level, $message, …) static

Write to log. Works like php syslog() function except additional tags can be given.

Levels:

Any (string) arguments given after the first two are taken as tags for this message. Tags can be used to sort and filter messages afterwards.

msg($type, $message) static

Add a message to be shown to user on next page load. This is a convenient way to queue messages through session data to be shown on the next page load for current browser session.

These messages are usually rendered in views/messages.html.

Following types, though not restricted to, can be used:

getConfigValue(…) static

Get value from configuration or null if value with given key-chain is not found. Give chain of keys as parameters.

Example:

/* returns true or false */
kernel::getConfigValue('setup', 'debug');
/* returns whole setup array */
kernel::getConfigValue('setup');

historyPop($count = 0) static

Pop $count items from history and return last one popped.

historyDisable() static

Disable current request from being saved into history (session data).

createTempFile($postfix = null) static

Create a temporary file that will be removed when request is finished (in kernel destructor).

url($path = false) static

Create manual URL that is prepended with site assets path.

getCacheInstance() static

Get current cache instance. This is most probably an instance of phpfastcache.

yamlRead($file, $ttl = 600) static

Read data from YAML-file.

yamlWrite($file, $data) static

Write data to YAML-file.

Signals

kernel:log