Closed unstoppablecarl closed 9 years ago
@unstoppablecarl hopefully this explains it a little.
$this->loadPluginX(
'router',
array_get($config, 'routes', [])
);
//Sets $x equals "router" there $$x creates a variable $router
$this->loadPluginX(
'enqueue',
array_get($config, 'enqueue', [])
);
//Sets $x equals "enqueue" there $$x creates a variable $enqueue
The reason for this to allow files to be loaded like routes.php
have access to $router
:
// $router = Herbert\Framework\Router
$router->get();
I've never used variable variables. This is the first time I've seen a practical use. This is just for convenience, you could get the router by doing $container['router']
right?
Indeed, it is for convenience. Helps remove a lot of repeated code (by having a function for each one that calls loadPluginX
) :smile:
$container['router']
would return the router instance, yeah
Could you explain what this function does, especially the variable variable $$x ?
https://github.com/getherbert/framework/blob/dev/Herbert/Framework/Application.php#L170