Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * 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'));
 }
Пример #3
0
<?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();
Пример #4
0
<?php

class TestPlugin
{
    public static $plugin;
    public static function bootstrap()
    {
    }
}
TestPlugin::$plugin = new Plugin('TestPlugin', 'author', 'desc', '3.3');
TestPlugin::$plugin->bootstrap('TestPlugin::bootstrap');
Пример #5
0
 public function __construct($test)
 {
     $this->load_plugins('test_plugin');
     $test_class = new TestPlugin();
     $test->assertEquals($test_class->foo(), 'foo');
 }
Пример #6
0
 public function run($param)
 {
     echo "test2";
     TestPlugin::setData('b', 'b');
     TestPlugin::showData();
 }