The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.mozilla.org/MPL/ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is WebORB Presentation Server (R) for PHP. The Initial Developer of the Original Code is Midnight Coders, LLC. All Rights Reserved. ******************************************************************
상속: implements IDispatch
예제 #1
0
 private function invokeFinish(array $namedParams, array $classParams)
 {
     $invoker = new Invoker();
     foreach ($this->finish as $function) {
         $invoker->invoke($function, $namedParams, $classParams);
     }
 }
예제 #2
0
 public function testInvokeWithArguments()
 {
     $invoker = new Invoker();
     $result = $invoker->invoke(function ($a) {
         return 'result';
     }, ['a' => 'value1']);
     $this->assertSame('result', $result);
 }
예제 #3
0
 public function testCommand()
 {
     $expect = "Toggle On" . "Toggle Off";
     $invoker = new Invoker();
     $receiver = new Receiver();
     $invoker->storeCommand(new ToggleOnCommand($receiver));
     $invoker->storeCommand(new ToggleOffCommand($receiver));
     $result = $invoker->execute();
     $this->assertEquals($result, $expect);
 }
예제 #4
0
 public static function main()
 {
     $receiver = new Receiver("John");
     $command = new ConcreteCommand($receiver);
     $invoker = new Invoker($command);
     $invoker->action();
     $receiver = null;
     $command = null;
     $invoker = null;
 }
예제 #5
0
 public static function main()
 {
     $receiver = new Receiver('phpppan');
     $pasteCommand = new PasteCommand($receiver);
     $copyCommand = new CopyCommand($receiver);
     $macroCommand = new DemoMacroCommand();
     $macroCommand->add($copyCommand);
     $macroCommand->add($pasteCommand);
     $invoker = new Invoker($macroCommand);
     $invoker->action();
     $macroCommand->remove($copyCommand);
     $invoker = new Invoker($macroCommand);
     $invoker->action();
 }
예제 #6
0
class Invoker
{
    private $command;
    public function __construct(Command $command)
    {
        $this->command = $command;
    }
    public function action()
    {
        $this->command->execute();
    }
    public function unaction()
    {
        $this->command->undo();
    }
}
//生产接受者
$Reciver2 = new Reciver2();
$Reciver1 = new Reciver1();
//建立接受者和command之间关系
$command1 = new Command1($Reciver1);
$command2 = new Command1($Reciver2);
//生产调度者
$invoker1 = new Invoker($command1);
$invoker2 = new Invoker($command2);
//使用调度者
$invoker1->action();
$invoker1->unaction();
//使用调度者
$invoker2->action();
$invoker2->unaction();
예제 #7
0
    private $_receiver = null;
    public function __construct($receiver)
    {
        $this->_receiver = $receiver;
    }
    public function execute()
    {
        $this->_receiver->action();
        $this->_receiver->action1();
    }
}
$objReceiver = new Receiver("No.1");
$objReceiver1 = new Receiver("No.2");
$objReceiver2 = new Receiver("No.3");
$objCommand = new ConcreteCommand($objReceiver);
$objCommand1 = new ConcreteCommand1($objReceiver);
$objCommand2 = new ConcreteCommand($objReceiver1);
$objCommand3 = new ConcreteCommand1($objReceiver1);
$objCommand4 = new ConcreteCommand2($objReceiver2);
$objInvoker = new Invoker();
$objInvoker->setCommand($objCommand);
$objInvoker->setCommand($objCommand1);
$objInvoker->executeCommand();
echo "\n";
$objInvoker->removeCommand($objCommand1);
$objInvoker->executeCommand();
echo "\n";
$objInvoker->setCommand($objCommand2);
$objInvoker->setCommand($objCommand3);
$objInvoker->setCommand($objCommand4);
$objInvoker->executeCommand();
예제 #8
0
<?php

require_once './Command.php';
require_once './PlayCommand.php';
require_once './PauseCommand.php';
require_once './StopCommand.php';
require_once './Invoker.php';
require_once './Player.php';
$invoker = new Invoker();
$player = new Player();
$playCommand = new PlayCommand($player);
$pauseCommand = new PauseCommand($player);
$invoker->setCommand($playCommand);
$invoker->run();
$invoker->undo();
$invoker->setCommand($pauseCommand);
$invoker->run();
$invoker->undo();
예제 #9
0
 /**
  * @param string $methodName
  * @param array $arguments
  * @return mixed
  */
 public function invoke($methodName, array $arguments)
 {
     $invocation = new Invocation($methodName, $arguments);
     return $this->invoker->invoke($invocation);
 }
예제 #10
0
 public function doSomething(Receiver $receiver)
 {
     $command = new ConcreteCommand($receiver);
     $invoker = new Invoker();
     return $invoker->saveAndExecute($command);
 }
예제 #11
0
파일: Resource.php 프로젝트: mackstar/spout
 /**
  * {@inheritdoc}
  */
 public function setExceptionHandler(ExceptionHandlerInterface $exceptionHandler)
 {
     $this->invoker->setExceptionHandler($exceptionHandler);
 }
예제 #12
0
}
class Receiver
{
    // 接收者角色
    private $_name;
    public function __construct($name)
    {
        $this->_name = $name;
    }
    public function action()
    {
        echo 'receive some cmd:' . $this->_name;
    }
}
class Invoker
{
    // 请求者角色
    private $_command;
    public function __construct(Command $command)
    {
        $this->_command = $command;
    }
    public function action()
    {
        $this->_command->execute();
    }
}
$receiver = new Receiver('hello world');
$command = new ConcreteCommand($receiver);
$invoker = new Invoker($command);
$invoker->action();
예제 #13
0
 public function execute(Request $request)
 {
     if ("5" == $this->operation || "2" == $this->operation || "0" == $this->operation || "1" == $this->operation) {
         //        	$bodyData = $request->getRequestBodyData();
         //          	$namedObject = $bodyData[0];
         //            /*CommandMessage*/ $commandMessage = new CommandMessage($this->operation, $namedObject);
         //          	return $commandMessage->execute($request);
     } else {
         if ("9" == $this->operation) {
             ThreadContext::setCallerCredentials(null);
             return new AckMessage($this->messageId, $this->clientId, null);
         } else {
             if ("8" == $this->operation) {
                 $arr = $this->body->getBody();
                 $adaptingType = $arr[0];
                 $authData = split(":", base64_decode($adaptingType->defaultAdapt()));
                 $credentials = new Credentials($authData[0], $authData[1]);
                 $authHandler = ORBSecurity::getAuthenticationHandler(ThreadContext::getORBConfig());
                 if (LOGGING) {
                     Log::log(LoggingConstants::DEBUG, "got auth handler " . get_class($authHandler));
                 }
                 if (LOGGING) {
                     Log::log(LoggingConstants::MYDEBUG, "file: 'ReqMessage.php' got auth handler " . get_class($authHandler));
                 }
                 if ($authHandler == null) {
                     $errorMessage = new ErrMessage($this->messageId, new ServiceException("Missing authentication handler"));
                     $errorMessage->faultCode = "Client.Authentication";
                     return $errorMessage;
                 }
                 try {
                     $authHandler->checkCredentials($credentials->getUserId(), $credentials->getPassword(), $request);
                     if (LOGGING) {
                         Log::log(LoggingConstants::DEBUG, "credentials are valid ");
                     }
                     ThreadContext::setCallerCredentials($credentials);
                 } catch (Exception $e) {
                     if (LOGGING) {
                         Log::log(LoggingConstants::EXCEPTION, "authentication exception", $e);
                     }
                     $errorMessage = new ErrMessage($this->messageId, $e);
                     $errorMessage->faultCode = "Client.Authentication";
                     return $errorMessage;
                 }
                 return new AckMessage($this->messageId, $this->clientId, null);
             } else {
                 if (is_null($this->body->getBody())) {
                     $arr = array(0);
                     $this->body->setBody($arr);
                 } else {
                     if (!is_array($this->body->getBody())) {
                         $arr = array($this->body->getBody());
                         $this->body->setBody($arr);
                     }
                 }
                 try {
                     //          	Log::log(LoggingConstants::MYDEBUG, $_SESSION["credentials"]);
                     $resolvedName = ServiceRegistry::getMapping($this->destination);
                     if ($resolvedName == "*") {
                         $this->destination = $this->source;
                     }
                     $body = $this->body->getBody();
                     $returnValue = Invoker::handleInvoke($request, $this->destination, $this->operation, $body);
                     return new AckMessage($this->messageId, $this->clientId, $returnValue);
                 } catch (Exception $e) {
                     if (LOGGING) {
                         Log::log(LoggingConstants::EXCEPTION, "method invocation exception" . $e);
                     }
                     return new ErrMessage($this->messageId, $e);
                 }
             }
         }
     }
 }
예제 #14
0
 public function testInvoker()
 {
     $command = new AddRequirementCommand();
     $invoker = new Invoker($command);
     $invoker->action();
 }
예제 #15
0
파일: API.php 프로젝트: m6w6/seekat
 /**
  * Run the send loop through a generator
  *
  * @param callable|Generator $cbg A \Generator or a factory of a \Generator yielding promises
  * @return ExtendedPromiseInterface The promise of the generator's return value
  * @throws InvalidArgumentException
  */
 function __invoke($cbg) : ExtendedPromiseInterface
 {
     $this->__log->debug(__FUNCTION__);
     $invoker = new Invoker($this->__client);
     if ($cbg instanceof Generator) {
         return $invoker->iterate($cbg)->promise();
     }
     if (is_callable($cbg)) {
         return $invoker->invoke(function () use($cbg) {
             return $cbg($this);
         })->promise();
     }
     throw InvalidArgumentException("Expected callable or Generator, got " . (is_object($cbg) ? "instance of " . get_class($cbg) : gettype($cbg) . ": " . var_export($cbg, true)));
 }