Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Commit

Permalink
Changed method signatures for all hooks to include app container
Browse files Browse the repository at this point in the history
  • Loading branch information
hassankhan committed Feb 13, 2014
1 parent f45e8cf commit 0d62620
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
12 changes: 6 additions & 6 deletions library/Zepto/PluginInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
*/
interface PluginInterface {

public function after_plugins_load();
public function after_plugins_load(\Pimple $app);

public function before_config_load(&$settings);
public function before_config_load(\Pimple $app, &$settings);

public function before_router_setup();
public function before_router_setup(\Pimple $app);

public function after_router_setup();
public function after_router_setup(\Pimple $app);

public function before_response_send();
public function before_response_send(\Pimple $app);

public function after_response_send();
public function after_response_send(\Pimple $app);

}
2 changes: 1 addition & 1 deletion library/Zepto/Zepto.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public function run_hooks($hook_id, $args = array())
}

// Send app reference to hooks
$args = array_merge($args, array($this->app));
$args = array_merge(array($this->app), $args);

// Run hooks associated with that event
foreach ($app['plugins'] as $plugin_id => $plugin) {
Expand Down
12 changes: 6 additions & 6 deletions plugins/ExamplePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@
*/
class ExamplePlugin implements \Zepto\PluginInterface {

public function after_plugins_load()
public function after_plugins_load(\Pimple $app)
{
// echo __CLASS__ . '::after_plugins_load';
}

public function before_config_load(&$settings)
public function before_config_load(\Pimple $app, &$settings)
{
// echo __CLASS__ . '::before_config_load';
}

public function before_router_setup()
public function before_router_setup(\Pimple $app)
{
}

public function after_router_setup()
public function after_router_setup(\Pimple $app)
{
}

public function before_response_send()
public function before_response_send(\Pimple $app)
{
}

public function after_response_send()
public function after_response_send(\Pimple $app)
{
}

Expand Down
12 changes: 6 additions & 6 deletions plugins/NavGenPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@
*/
class NavGenPlugin implements \Zepto\PluginInterface {

public function after_plugins_load()
public function after_plugins_load(\Pimple $app)
{
}

public function before_config_load(&$settings)
public function before_config_load(\Pimple $app, &$settings)
{
}

public function before_router_setup()
public function before_router_setup(\Pimple $app)
{
}

public function after_router_setup()
public function after_router_setup(\Pimple $app)
{
// Use this one
$app = func_get_arg(0);
$html = $this->generate_html($app);
$app['nav'] = array('nav' => $html);
}

public function before_response_send()
public function before_response_send(\Pimple $app)
{
}

public function after_response_send()
public function after_response_send(\Pimple $app)
{
}

Expand Down
12 changes: 6 additions & 6 deletions plugins/OtherExamplePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@
*/
class OtherExamplePlugin implements \Zepto\PluginInterface {

public function after_plugins_load()
public function after_plugins_load(\Pimple $app)
{
}

public function before_config_load(&$settings)
public function before_config_load(\Pimple $app, &$settings)
{
}

public function before_router_setup()
public function before_router_setup(\Pimple $app)
{
}

public function after_router_setup()
public function after_router_setup(\Pimple $app)
{
}

public function before_response_send()
public function before_response_send(\Pimple $app)
{
}

public function after_response_send()
public function after_response_send(\Pimple $app)
{
}

Expand Down
12 changes: 5 additions & 7 deletions plugins/WhoopsPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
*/
class WhoopsPlugin implements \Zepto\PluginInterface {

public function after_plugins_load()
public function after_plugins_load(\Pimple $app)
{
$app = func_get_arg(0);

// Add Whoops handlers
$app['whoopsPrettyPageHandler'] = $app->share(
function() {
Expand Down Expand Up @@ -109,19 +107,19 @@ public function before_config_load(\Pimple $app, &$settings)
}
}

public function before_router_setup()
public function before_router_setup(\Pimple $app)
{
}

public function after_router_setup()
public function after_router_setup(\Pimple $app)
{
}

public function before_response_send()
public function before_response_send(\Pimple $app)
{
}

public function after_response_send()
public function after_response_send(\Pimple $app)
{
}

Expand Down

0 comments on commit 0d62620

Please sign in to comment.