/** * add * * @param ApiMessage $apiMessage * * @return void */ public function add(ApiMessage $apiMessage) { $index = $this->getIndex($apiMessage->getKey()); if ($index !== null) { unset($this->messages[$index]); } if ($apiMessage->isPrimary()) { array_unshift($this->messages, $apiMessage); return; } $this->messages[] = $apiMessage; }
public function destroy($id) { $input = Input::all(); $sessionId = Common::checkSessionLogin($input); ApiMessage::find($id)->delete(); return Common::returnData(200, DELETE_SUCCESS, $input['user_id'], $sessionId); }
protected function build($properties = [], $ignore = []) { if (!isset($properties['value'])) { $properties['value'] = ''; } parent::populate($properties, $ignore); }
public function run() { ApiMessage::create(['sent_id' => '1', 'receiver_id' => '2', 'message' => 'message test 1', 'status' => '1']); ApiMessage::create(['sent_id' => '1', 'receiver_id' => '2', 'message' => 'message test 2', 'status' => '1']); ApiMessage::create(['sent_id' => '2', 'receiver_id' => '1', 'message' => 'message test 3', 'status' => '1']); ApiMessage::create(['sent_id' => '2', 'receiver_id' => '1', 'message' => 'message test 4', 'status' => '1']); ApiMessage::create(['sent_id' => '2', 'receiver_id' => '1', 'message' => 'message test 5', 'status' => '1']); ApiMessage::create(['sent_id' => '1', 'receiver_id' => '3', 'message' => 'message test 6', 'status' => '1']); }
/** * Actually add the warning or error to the result * @param string $tag 'warning' or 'error' * @param string $moduleName * @param ApiMessage|ApiRawMessage $msg */ protected function addWarningOrError($tag, $moduleName, $msg) { $value = ['code' => $msg->getApiCode()]; switch ($this->format) { case 'wikitext': $value += ['text' => $msg->text(), ApiResult::META_CONTENT => 'text']; break; case 'html': $value += ['html' => $msg->parse(), ApiResult::META_CONTENT => 'html']; break; case 'raw': $value += ['message' => $msg->getKey(), 'params' => $msg->getParams()]; ApiResult::setIndexedTagName($value['params'], 'param'); break; case 'none': break; } $value += $msg->getApiData(); $path = [$tag . 's', $moduleName]; $existing = $this->result->getResultData($path); if ($existing === null || !in_array($value, $existing)) { $flags = ApiResult::NO_SIZE_CHECK; if ($existing === null) { $flags |= ApiResult::ADD_ON_TOP; } $this->result->addValue($path, null, $value, $flags); $this->result->addIndexedTagName($path, $tag); } }
/** * @covers ApiMessage::create */ public function testApiMessageCreate() { $this->assertInstanceOf('ApiMessage', ApiMessage::create(new Message('mainpage'))); $this->assertInstanceOf('ApiRawMessage', ApiMessage::create(new RawMessage('mainpage'))); $this->assertInstanceOf('ApiMessage', ApiMessage::create('mainpage')); $msg = new ApiMessage('mainpage'); $this->assertSame($msg, ApiMessage::create($msg)); $msg = new ApiRawMessage('mainpage'); $this->assertSame($msg, ApiMessage::create($msg)); }
public static function createNewMessage($input, $id, $table = null) { if ($table) { $inputMsg = ['sent_id' => $input['user_id'], 'receiver_id' => $id, 'message' => $input['message'], 'status' => INACTIVE]; } else { $inputMsg = ['sent_id' => $input['user_id'], 'receiver_id' => $id, 'message' => $input['message'], 'status' => INACTIVE]; } $messageId = ApiMessage::create($inputMsg)->id; return $messageId; }