/** * place hook calls into the relevant data array call * @param array $data * @return array $data */ public static function dataLoadandConvert($data) { $hooks = Hooks::get(); $data['afterBody'] = $hooks->run('afterBody', $data['afterBody']); $data['css'] = $hooks->run('css', $data['css']); $data['js'] = $hooks->run('js', $data['js']); return $data; }
/** * Method automatically invoked before the current Action, stopping the flight * when it return false. This Method is supposed to be overriden for using it. */ protected function before() { // Run the Hooks associated to Views. $hooks = Hooks::get(); foreach (array('afterBody', 'css', 'js') as $hook) { $result = $hooks->run($hook); // Share the result into Views. View::share($hook, $result); } // Return true to continue the processing. return true; }
<?php /** * Sample layout */ use Helpers\Assets; use Helpers\Url; use Helpers\Hooks; //initialise hooks $hooks = Hooks::get(); ?> <!DOCTYPE html> <html lang="<?php echo LANGUAGE_CODE; ?> "> <head> <!-- Site meta --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"> <?php //hook for plugging in meta tags $hooks->run('meta'); ?> <title><?php echo $data['title'] . ' - ' . SITETITLE; //SITETITLE defined in app/Core/Config.php ?> </title>
<?php \Helpers\Hooks::get()->run('footer'); ?> </body> </html>