当前位置: 首页>>代码示例>>PHP>>正文


PHP Message类代码示例

本文整理汇总了PHP中Message的典型用法代码示例。如果您正苦于以下问题:PHP Message类的具体用法?PHP Message怎么用?PHP Message使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Message类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testToString

 /**
  * @covers GitElephant\Objects\Commit\Message::toString
  */
 public function testToString()
 {
     $this->assertEquals($this->shortMsg, $this->msg->toString());
     $this->assertEquals($this->shortMsg, $this->msg->__toString());
     $this->assertEquals($this->shortMsg, (string) $this->msg);
     $this->assertEquals($this->fullMsg, $this->msg->toString(true));
 }
开发者ID:ocubom,项目名称:GitElephant,代码行数:10,代码来源:MessageTest.php

示例2: _render

 /**
  * Render request
  *
  * @param array       $data
  * @param string|null $template
  * @param string|null $blockClass
  * @return $this
  */
 protected function _render(array $data = array(), $template = null, $blockClass = null)
 {
     //create block
     if ($blockClass) {
         $blockClass = '\\App\\Block' . '\\' . $blockClass;
         $block = new $blockClass($data);
     } else {
         $block = new Renderer($data);
     }
     if (!$template) {
         //set template
         $template = $this->getControllerName() . DIRECTORY_SEPARATOR . $this->getActionName() . '.phtml';
     }
     $block->setTemplate($template);
     //get action HTML
     $actionHtml = $block->toHtml();
     if (!$this->isAjax()) {
         $block = new Renderer(array('content' => $actionHtml));
         $block->setTemplate('index.phtml');
         //add system messages block
         $message = new Message();
         $message->setTemplate('index/messages.phtml');
         $block->setChild('message', $message);
         echo $block->toHtml();
     } else {
         echo $actionHtml;
     }
     return $this;
 }
开发者ID:andkirby,项目名称:commithook,代码行数:37,代码来源:TestClassSplit.php

示例3: __construct

 /**
  * Creates a new instance of the SnsNotificationMetadata
  * object, initialized from the Message
  * 
  * @param message              $message                    message for SNS
  * @param NotificationMetadata $parentNotificationMetadata parent message if 
  *                                                         applicable otherwise 
  *                                                         null
  * 
  * @throws OffAmazonPaymentsNotifications_InvalidMessageException invalid message
  * 
  * @return void
  */
 public function __construct(Message $message, NotificationMetadata $parentNotificationMetadata = null)
 {
     $this->_timestamp = $message->getMandatoryField("Timestamp");
     $this->_topicArn = $message->getMandatoryField("TopicArn");
     $this->_messageId = $message->getMandatoryField("MessageId");
     parent::__construct($parentNotificationMetadata);
 }
开发者ID:naka211,项目名称:studiekorrektur,代码行数:20,代码来源:SnsNotificationMetadata.php

示例4: testApiMessage

 /**
  * @covers ApiMessage
  */
 public function testApiMessage()
 {
     $msg = new Message(array('foo', 'bar'), array('baz'));
     $msg->inLanguage('de')->title(Title::newMainPage());
     $msg2 = new ApiMessage($msg, 'code', array('data'));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2 = unserialize(serialize($msg2));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg = new Message(array('foo', 'bar'), array('baz'));
     $msg2 = new ApiMessage(array(array('foo', 'bar'), 'baz'), 'code', array('data'));
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg = new Message('foo');
     $msg2 = new ApiMessage('foo');
     $this->compareMessages($msg, $msg2);
     $this->assertEquals('foo', $msg2->getApiCode());
     $this->assertEquals(array(), $msg2->getApiData());
     $msg2->setApiCode('code', array('data'));
     $this->assertEquals('code', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2->setApiCode(null);
     $this->assertEquals('foo', $msg2->getApiCode());
     $this->assertEquals(array('data'), $msg2->getApiData());
     $msg2->setApiData(array('data2'));
     $this->assertEquals(array('data2'), $msg2->getApiData());
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:34,代码来源:ApiMessageTest.php

示例5: send

 public function send($template, $data, $callback)
 {
     //Nova instanca Mailgun Messagebuildera koji sluzi za pravljenje emailova
     $builder = $this->mailer->MessageBuilder();
     //Kreiramo instancu Message k. da bi mogli poslati body od email,a arg. constuctora $builder,omogucava da se metode
     //iz Message k. izvrse. Message k. ne treba importovati zato sto se nalazi u istom folderu kao i Mailer k.
     $message = new Message($builder);
     //Nastimavamo od koga je poruka sa setFromAddress(),a iz konfiguracije dohvatamo email adresu od koga se salje poruka
     $message->from($this->config->get('mail.from'));
     //Dodajemo $data na view koji smo propustili kao param. u register.php ('email/auth/registered.php'),a to su korinsicki
     //podatci,tako da su ti korisnicki podatci dostupni i šerovani na views-u i da se mogu koristiti unutar Twiga
     $this->view->appendData($data);
     //Dodajemo tijelo email-a tj. poruku sa tekstom body,uz pomoc body() m. iz Message klase,u koji propustamo $template arg.
     //koji ce onda otici na register.php i preuzeti views ('email/auth/registered.php') i uz pomoc render() metoda poslati ga
     //kao tijelo emila
     $message->body($this->view->render($template));
     //Pozivamo callback funkciju sa register.php zajedno sa $message = new Message($this->mailer); da bi mogli koristiti
     //Message metode. callback func. uzima param. $message i onda prilikom svog izvrsavanje koristi to() i subject() m.
     call_user_func($callback, $message);
     //Dohvatamo domenu od Mailguna zato sto cemo slati POST request kroz Milgun API
     $domain = $this->config->get('mail.domain');
     //Slanje email poruke (getMessage() m. je iz Mailguna i sluzi sa dohvatanje email poruke,a post() sluzi sa slanje emaila)
     //"{$domain}/messages" se odnosi na nasu domenu na Mailgun st. i messages view tj. poruke na toj st.
     $this->mailer->post("{$domain}/messages", $builder->getMessage());
 }
开发者ID:retro12,项目名称:Slim-CMS,代码行数:25,代码来源:Mailer.php

示例6: saveNew

 static function saveNew($from, $to, $content, $source)
 {
     $sender = Profile::staticGet('id', $from);
     if (!$sender->hasRight(Right::NEWMESSAGE)) {
         // TRANS: Client exception thrown when a user tries to send a direct message while being banned from sending them.
         throw new ClientException(_('You are banned from sending direct messages.'));
     }
     $msg = new Message();
     $msg->from_profile = $from;
     $msg->to_profile = $to;
     $msg->content = common_shorten_links($content);
     $msg->rendered = common_render_text($content);
     $msg->created = common_sql_now();
     $msg->source = $source;
     $result = $msg->insert();
     if (!$result) {
         common_log_db_error($msg, 'INSERT', __FILE__);
         // TRANS: Message given when a message could not be stored on the server.
         return _('Could not insert message.');
     }
     $orig = clone $msg;
     $msg->uri = common_local_url('showmessage', array('message' => $msg->id));
     $result = $msg->update($orig);
     if (!$result) {
         common_log_db_error($msg, 'UPDATE', __FILE__);
         // TRANS: Message given when a message could not be updated on the server.
         return _('Could not update message with new URI.');
     }
     return $msg;
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:30,代码来源:Message.php

示例7: handleMessage

 /**
  * Handles the message.
  *
  * @param Message $message 
  * @param array $params
  * @param Discord $discord 
  * @param Config $config 
  * @return void 
  */
 public static function handleMessage($message, $params, $discord, $config)
 {
     $prefix = isset($params[0]) ? $params[0] : $config['prefix'];
     $config['prefix'] = $prefix;
     Config::saveConfig($config, $config['filename']);
     $message->reply("Set the prefix to `{$prefix}`");
 }
开发者ID:uniquoooo,项目名称:DiscordPHPBot,代码行数:16,代码来源:SetPrefix.php

示例8: send

 public function send(Message $message)
 {
     $entrypoint = $this->modx->getOption('slackify_entrypoint', null, false);
     if (!$entrypoint) {
         $this->modx->log(modX::LOG_LEVEL_ERROR, 'Entry point for Slackify not defined in system settings');
         return;
     }
     $sender = $this->modx->getOption('slackify_username', null, $this->modx->getOption('site_name', null, ''));
     if (!$sender) {
         $sender = $this->modx->getOption('site_name', null, '');
     }
     $config = ['sender' => $sender, 'channel' => $this->modx->getOption('slackify_channel', null, '#general'), 'icon' => $this->modx->getOption('slackify_icon', null, ''), 'link_names' => $this->modx->getOption('slackify_link_names', null, false), 'unfurl_links' => $this->modx->getOption('slackify_unfurl_links', null, false), 'unfurl_media' => $this->modx->getOption('slackify_unfurl_media', null, true), 'allow_markdown' => $this->modx->getOption('slackify_allow_markdown', null, true), 'markdown_in_attachments' => $this->modx->getOption('slackify_markdown_in_attachments', null, '')];
     $message->setConfig(array_merge($config, $message->getConfig()));
     $fields = ['payload' => json_encode($message)];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $entrypoint);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $output = curl_exec($ch);
     curl_close($ch);
     if ($output != 'ok') {
         $this->modx->log(modX::LOG_LEVEL_ERROR, 'Cannot send message to Slack, reason: "' . $output . '"');
     }
 }
开发者ID:doksec,项目名称:modx-slackify,代码行数:25,代码来源:slackify.class.php

示例9: LoadMessages

 public function LoadMessages()
 {
     global $conversationInfos;
     $myDBConnector = new DBConnector();
     $dbARY = $myDBConnector->infos();
     $connection = new mysqli($dbARY[0], $dbARY[1], $dbARY[2], $dbARY[3]);
     if ($connection->connect_error) {
         echo "Database bağlantı hatası";
     } else {
         mysqli_set_charset($connection, "utf8");
         $query = "SELECT * FROM messages WHERE ((From_msg='" . $conversationInfos["User1"] . "' AND To_msg='" . $conversationInfos["User2"] . "') OR (From_msg='" . $conversationInfos["User2"] . "' AND To_msg='" . $conversationInfos["User1"] . "'))";
         $results = $connection->query($query);
         $num = $results->num_rows;
         echo "<form style=\"display:none;\" id=\"offsetForm_" . $conversationInfos["other"] . "\" method=\"post\" action=\"instantmessage.php?usr1=" . $conversationInfos["User1"] . "&usr2=" . $conversationInfos["User2"] . "&monitor=" . $conversationInfos["WhoIsMonitoring"] . "\">";
         echo "<input name=\"offset\" id=\"offset_" . $conversationInfos["other"] . "\" style=\"display:none;\" type=\"text\" value=\"" . $num . "\"/>";
         echo "</form>";
         while ($curResult = $results->fetch_assoc()) {
             if ($conversationInfos["WhoIsMonitoring"] == $curResult["From_msg"]) {
                 $mode = "EvSahibi";
             } else {
                 $mode = "Deplasman";
             }
             $myMessage = new Message(array($curResult["MessageDate"], $curResult["From_msg"], $curResult["To_msg"], $curResult["Message"], $mode, $curResult["Read_msg"]));
             $myMessage->MessageToHTML();
         }
         $connection->close();
     }
 }
开发者ID:oguzeroglu,项目名称:serinhikaye.com,代码行数:28,代码来源:Conversation.class.php

示例10: main

function main()
{
    $controller = new Controller();
    $response = null;
    switch ($_POST["cmd"]) {
        case "RPC":
            $username = $_POST["user"];
            if ($username == null) {
                $username = $_SESSION['user'];
            }
            $pw = $_POST["pw"];
            $plantname = $_POST["plant"];
            $code = $_POST["code"];
            $plantid = $_POST["id"];
            $response = $controller->HandleRemoteProcedureCall($_POST["func"], $username, $pw, $plantname, $code, $plantid);
            break;
        case "ContentRequest":
            if ($controller->IsLoggedIn() != "false") {
                $response = new ContentMessage($_POST["content"], $_POST["plantid"]);
            } else {
                $func = "function() { this.showLoginDialog(); this.showMessage('Sie sind nicht eingeloggt bitte einloggen', 'error'); }";
                $response = new RemoteProcedureCall($func);
            }
            break;
        default:
            $response = new Message('error', 'unknown Command');
            break;
    }
    if ($response != null) {
        $response->send();
    } else {
        echo "Error! no response was generated";
    }
}
开发者ID:nomeata,项目名称:L-seed,代码行数:34,代码来源:Communication.php

示例11: validate

 /**
  * Validates a message from SNS to ensure that it was delivered by AWS
  *
  * @param Message $message The message to validate
  *
  * @throws CannotGetPublicKeyFromCertificateException If the certificate cannot be retrieved
  * @throws CertificateFromUnrecognizedSourceException If the certificate's source cannot be verified
  * @throws InvalidMessageSignatureException           If the message's signature is invalid
  */
 public function validate($message)
 {
     // Get the cert's URL and ensure it is from AWS
     $certUrl = $message->get('SigningCertURL');
     $host = parse_url($certUrl, PHP_URL_HOST);
     if ('.amazonaws.com' != substr($host, -14)) {
         throw new CertificateFromUnrecognizedSourceException($host . ' did not match .amazonaws.com');
     }
     // Get the cert itself and extract the public key
     $response = wp_remote_get($certUrl);
     if (is_wp_error($response)) {
         throw new CannotGetPublicKeyFromCertificateException('Could not retrieve certificate from ' . $certUrl);
     }
     $certificate = wp_remote_retrieve_body($response);
     $publicKey = openssl_get_publickey($certificate);
     if (!$publicKey) {
         throw new CannotGetPublicKeyFromCertificateException('Could not extract public key from ' . $certUrl);
     }
     // Verify the signature of the message
     $stringToSign = $message->getStringToSign();
     $incomingSignature = base64_decode($message->get('Signature'));
     if (!openssl_verify($stringToSign, $incomingSignature, $publicKey, OPENSSL_ALGO_SHA1)) {
         throw new InvalidMessageSignatureException('The message did not match the signature ' . "\n" . $stringToSign);
     }
 }
开发者ID:easinewe,项目名称:Avec2016,代码行数:34,代码来源:MessageValidator.php

示例12: testWidth

 public function testWidth()
 {
     $message = new Message('message example');
     $this->assertEquals('message example               ', $message->width(30)->getMessage());
     $message = new Message('пример текста');
     $this->assertEquals('пример текста                 ', $message->width(30)->getMessage());
 }
开发者ID:janhenkgerritsen,项目名称:Codeception,代码行数:7,代码来源:MessageTest.php

示例13: round_trip

function round_trip($body)
{
    $msg = new Message();
    $msg->inferred = true;
    $msg->durable = true;
    $msg->id = 10;
    $msg->correlation_id = "asdf";
    $msg->properties = array();
    $msg->properties["null"] = null;
    $msg->properties["boolean"] = true;
    $msg->properties["integer"] = 123;
    $msg->properties["double"] = 3.14159;
    $msg->properties["binary"] = new Binary("binary");
    $msg->properties["symbol"] = new Symbol("symbol");
    $msg->properties["uuid"] = new UUID("1234123412341234");
    $msg->properties["list"] = new PList(1, 2, 3, 4);
    $msg->properties["char"] = new Char(321);
    $msg->body = $body;
    assert($msg->id == 10);
    assert($msg->correlation_id == "asdf");
    $copy = new Message();
    $copy->decode($msg->encode());
    assert($copy->id == $msg->id);
    assert($copy->correlation_id == $msg->correlation_id);
    $diff = array_diff($msg->properties, $copy->properties);
    assert($copy->durable == $msg->durable);
    assert(count($diff) == 0);
    assert($copy->body == $msg->body);
}
开发者ID:SreeramGarlapati,项目名称:qpid-proton,代码行数:29,代码来源:tests.php

示例14: actionIndex

 public function actionIndex()
 {
     //未提示客户端
     $platform = 'android';
     if (isset($_GET['p'])) {
         $platform = $_GET['p'];
     }
     $message = new Message();
     $relation = new Relation();
     if (isset($_POST['Message'])) {
         $message->attributes = $_POST['Message'];
         if (!empty($message->plan)) {
             $message->type = '3';
         }
         if ($message->validate()) {
             $message->file = $this->upload($message);
             if (UserState::model()->findByPk($message->receiver)->type == 0) {
                 $message->chat('android');
             } else {
                 $message->chat('ios');
             }
         }
     }
     $this->render('index', array('message' => $message));
 }
开发者ID:tiger2soft,项目名称:travelman,代码行数:25,代码来源:ChatController.php

示例15: substitmessage

function substitmessage($texte)
{
    preg_match_all("`\\#MESSAGE_([^\\(]+)\\(([^\\)]+)\\)`", $texte, $cut);
    $tab1 = "";
    $tab2 = "";
    for ($i = 0; $i < count($cut[1]); $i++) {
        $message = new Message();
        $message->charger($cut[2][$i]);
        $messagedesc = new Messagedesc();
        $messagedesc->charger($message->id);
        if ($cut[1][$i] == "TITRE") {
            $tab1[$i] = "#MESSAGE_" . $cut[1][$i] . "(" . $cut[2][$i] . ")";
            $tab2[$i] = $messagedesc->titre;
        } else {
            if ($cut[1][$i] == "CHAPO") {
                $tab1[$i] = "#MESSAGE_" . $cut[1][$i] . "(" . $cut[2][$i] . ")";
                $tab2[$i] = $messagedesc->chapo;
            } else {
                if ($cut[1][$i] == "DESCRIPTION") {
                    $tab1[$i] = "#MESSAGE_" . $cut[1][$i] . "(" . $cut[2][$i] . ")";
                    $tab2[$i] = $messagedesc->description;
                }
            }
        }
    }
    $texte = str_replace($tab1, $tab2, $texte);
    return $texte;
}
开发者ID:anti-conformiste,项目名称:thelia1,代码行数:28,代码来源:substitmessage.php


注:本文中的Message类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。