add() 공개 메소드

The benefit of using the add function over using the queue as an array is that you are given back an index of the new item in the queue. This index allows you to remove it at a later stage if you choose.
또한 보기: rcrowe\Hippy\Message\Queue::offsetSet()
public add ( rcrowe\Hippy\Message\MessageInterface $message ) : integer
$message rcrowe\Hippy\Message\MessageInterface
리턴 integer Index of the new item in the queue.
예제 #1
0
파일: SendTest.php 프로젝트: rcrowe/hippy
 public function testQueuedMessages()
 {
     $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest');
     $entity->shouldReceive('send')->twice();
     $http = m::mock('Guzzle\\Http\\Client');
     $http->shouldReceive('post')->andReturn($entity)->twice();
     $transport = new Guzzle('123', 'cog', 'vivalacrowe');
     $transport->setHttp($http);
     $hippy = new Hippy($transport);
     $queue = new Queue();
     $queue->add(new Message(true, 'red'));
     $queue->add(new Message(false, 'random'));
     $hippy->send($queue);
 }
예제 #2
0
파일: Facade.php 프로젝트: rcrowe/hippy
 /**
  * Add a html message to the queue.
  *
  * @param string $msg
  * @param bool   $notify
  * @param string $background
  * @throws RuntimeException When Facade::init() has not been called.
  * @return void
  */
 public static function addHtml($msg, $notify = false, $background = Message::BACKGROUND_YELLOW)
 {
     if (static::$client === null) {
         throw new RuntimeException('Must call init first');
     }
     $message = new Message($notify, $background);
     $message->setHtml($msg);
     static::$queue->add($message);
 }