/** * Factory that creates a PutRequest from a PutItem command * * @param AbstractCommand $command The command to create the request from * * @return PutRequest * * @throws InvalidArgumentException if the command is not a PutItem command */ public static function fromCommand(AbstractCommand $command) { if ($command->getName() !== 'PutItem') { throw new InvalidArgumentException(); } // Get relevant data for a PutRequest $table = $command->get('TableName'); $item = $command->get('Item'); // Return an instantiated PutRequest object return new PutRequest($item, $table); }
/** * Factory that creates a DeleteRequest from a DeleteItem command * * @param AbstractCommand $command The command to create the request from * * @return PutRequest * * @throws InvalidArgumentException if the command is not a DeleteItem command */ public static function fromCommand(AbstractCommand $command) { if ($command->getName() !== 'DeleteItem') { throw new InvalidArgumentException(); } // Get relevant data for a DeleteRequest $table = $command->get('TableName'); $key = $command->get('Key'); // Return an instantiated DeleteRequest object return new DeleteRequest($key, $table); }
/** * Determines whether a command's response type is a model * * @param Guzzle\Service\Command\AbstractCommand $command * * @return boolean */ public function responseTypeIsModel(AbstractCommand $command) { $operation = $command->getOperation(); $processing = $command->get(AbstractCommand::RESPONSE_PROCESSING); $description = $operation->getServiceDescription(); return $operation->getResponseType() == OperationInterface::TYPE_MODEL && $description->hasModel($operation->getResponseClass()) && $processing == AbstractCommand::TYPE_MODEL; }