本文整理匯總了PHP中Manager::dispatch方法的典型用法代碼示例。如果您正苦於以下問題:PHP Manager::dispatch方法的具體用法?PHP Manager::dispatch怎麽用?PHP Manager::dispatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Manager
的用法示例。
在下文中一共展示了Manager::dispatch方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testDispatch
public function testDispatch()
{
$event = new Event('banane', $this);
$manager = new Manager();
$this->assertEquals(array(), $manager->getSubscribers($event));
// nix passiert
$manager->dispatch($event);
$subscriber = $this->getMock('Psc\\Code\\Event\\SubscriberMock', array('trigger'));
// Set up the expectation for the update() method
// to be called only once and with the string 'something'
// as its parameter.
$subscriber->expects($this->once())->method('trigger')->with($this->equalTo($event));
/* bind unseren Subscriber an ddas Event */
$manager->bind($subscriber, 'banane');
$this->assertEquals(1, count($manager->getSubscribers($event)));
/* soll dingsen */
$manager->dispatch($event);
}
示例2: dirname
ob_start("ob_gzhandler");
} else {
ob_start();
}
//les managers ne renvoient QUE du json, on met donc le header de la réponse a jour
//on inclu l'autoloader
include dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoloader.php';
$manager = new Manager();
//on récupère la commande et la parse pour être executée
if (isset($_POST['command'])) {
$commands = explode(':', $_POST['command']);
$managerName = $commands[0];
$managerCommand = $commands[1];
//on supprime la commande de la variable globale, les managers n'ont pas a la connaitre et a l'utiliser
unset($_POST['command']);
//si on trouve la commande on l'execute
if ($manager->match($managerName, $managerCommand)) {
$manager->dispatch($_POST);
} else {
$response = json_encode(['result' => false, 'message' => "commande inexistante"]);
$objectResponse = new Response(404);
$objectResponse->write($response);
$objectResponse->send();
}
} else {
$response = json_encode(['result' => false, 'message' => "Variable POST command inexistante"]);
$objectResponse = new Response(404);
$objectResponse->write($response);
$objectResponse->send();
}
ob_end_clean();
示例3: dirname
//variable globale pour accéder aux dossiers des managers
$GLOBALS['managers_dir'] = dirname(__FILE__);
session_start();
if ($GLOBALS['compression']) {
ob_start("ob_gzhandler");
} else {
ob_start();
}
//les managers ne renvoient QUE du json, on met donc le header de la réponse a jour
//header('Content-Type: application/json');
//on inclu l'autoloader
include dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'autoloader.php';
$manager = new Manager();
//on récupère la commande et la parse pour être executée
$json = json_decode($_POST['json'], true);
$command = $json['command'];
if (isset($command)) {
$commands = explode(':', $command);
$managerName = $commands[0];
$managerCommand = $commands[1];
//si on trouve la commande on l'execute
if ($manager->match($managerName, $managerCommand)) {
$manager->dispatch($json);
} else {
$response = json_encode(['result' => "commande inexistante"]);
$objectResponse = new Response(404);
$objectResponse->write($response);
$objectResponse->send();
}
}
ob_end_clean();