/** * Loads required assets and scripts based on the requested action and page */ static function dispatcher() { // Log caller debug info TestPlugin::log(); // If request does not contain an action if (!isset($_REQUEST['action'])) { // Set as default $_REQUEST['action'] = 'default'; } // Create shorter reference to action $action = $_REQUEST['action']; TestPlugin::log($action); // Get page $page = $_GET['page']; // Recursively stripslahses $params = self::strip_deep($_REQUEST); }
/** * Tests the supportsControllerAndAction methods. */ public function testSupportsControllerAndAction() { $plugin = new TestPlugin(array()); // no lists yet, so plugin supports everything $this->assertTrue($plugin->supportsControllerAndAction('TestController', 'anyAction')); // set a whitelist $plugin->setWhitelist(array('TestController' => AbstractPlugin::ALL_ACTIONS, 'AnotherController' => array('specificAction'))); // all actions enabled for this controller $this->assertTrue($plugin->supportsControllerAndAction('TestController', 'anyAction')); // specific action enabled $this->assertTrue($plugin->supportsControllerAndAction('AnotherController', 'specificAction')); // controller is missing from whitelist $this->assertFalse($plugin->supportsControllerAndAction('MissingController', 'anyAction')); // action is missing from whitelist $this->assertFalse($plugin->supportsControllerAndAction('AnotherController', 'differentAction')); // now the reverse logic for the blacklist $plugin->setBlacklist(array('TestController' => array('bannedAction'), 'BannedController' => AbstractPlugin::ALL_ACTIONS)); // controller is missing from blacklist $this->assertTrue($plugin->supportsControllerAndAction('MissingController', 'anyAction')); // action is blacklisted specifically $this->assertFalse($plugin->supportsControllerAndAction('TestController', 'bannedAction')); // all actions for the controller are banned $this->assertFalse($plugin->supportsControllerAndAction('BannedController', 'anyAction')); }
<?php use Herbie\DI; use Herbie\Hook; use herbie\plugin\test\classes\TestExtension; class TestPlugin { public static function install() { Hook::attach('twigInitialized', ['TestPlugin', 'addTwigExtension']); } public static function addTwigExtension($twig) { $assets = DI::get('Assets'); $testExtension = new TestExtension($assets); $twig->addExtension($testExtension); } } TestPlugin::install();
<?php class TestPlugin { public static $plugin; public static function bootstrap() { } } TestPlugin::$plugin = new Plugin('TestPlugin', 'author', 'desc', '3.3'); TestPlugin::$plugin->bootstrap('TestPlugin::bootstrap');
public function __construct($test) { $this->load_plugins('test_plugin'); $test_class = new TestPlugin(); $test->assertEquals($test_class->foo(), 'foo'); }
public function run($param) { echo "test2"; TestPlugin::setData('b', 'b'); TestPlugin::showData(); }