本文整理汇总了PHP中Attachment::setText方法的典型用法代码示例。如果您正苦于以下问题:PHP Attachment::setText方法的具体用法?PHP Attachment::setText怎么用?PHP Attachment::setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Attachment
的用法示例。
在下文中一共展示了Attachment::setText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Attachment
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
switch ($modx->event->name) {
case 'OnCommentSave':
$slackify = $modx->getService('slackify');
/** @var TicketComment $comment */
$comment =& $object;
/** @var TicketThread $ticket */
$thread = $comment->getOne('Thread');
/** @var Ticket $ticket */
$ticket = $thread->getOne('Ticket');
$a = new Attachment();
$a->setPretext('Somebody left mention to the important theme on site');
$a->setColor(new Color('#00FF00'));
// green
$a->setAuthor(new Author($comment->get('name'), 'mailto:' . $comment->get('email')));
$a->setTitle(new Title("left comment to ticket '{$ticket->get('pagetitle')}'"));
$a->setText($comment->get('text'));
// raw
$a->addField(new Field('When', $comment->get('createdon'), true));
$a->addField(new Field('Published', $comment->get('published') ? 'True' : 'False', true));
$a->addField(new Field('Ticket', new Link($modx->makeUrl($ticket->get('id'), 'web', '', 'full'), $ticket->get('pagetitle'))));
$message = new Message('*New comment*');
$message->attach($a);
$slackify->send($message);
break;
}
示例2: Attachment
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
switch ($modx->event->name) {
case 'OnPageNotFound':
$slackify = $modx->getService('slackify');
$a = new Attachment();
$a->setPretext('This is an automated notification of a 404 error that has occured on the site.');
$a->setColor(new Color('#FF0000'));
$a->setTitle(new Title($_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']));
$a->setText('Requested url not found and returns 404 error');
$a->addField(new Field('When', (new DateTime())->format('d M Y - G:i:s'), true));
$a->addField(new Field('Visitor IP', $_SERVER['REMOTE_ADDR'], true));
$a->addField(new Field('User agent', $_SERVER['HTTP_USER_AGENT']));
$message = new Message('*Error 404*, Page not found');
$message->attach($a);
$slackify->send($message);
break;
}
示例3: Attachment
switch ($modx->event->name) {
case 'msOnChangeOrderStatus':
$slackify = $modx->getService('slackify');
/** @var msOrderStatus $status */
$status = $modx->getObject('msOrderStatus', ['id' => $order->get('status'), 'active' => true]);
$new = $order->get('status') == 1;
$a = new Attachment();
$a->setPretext($new ? 'New order was made on site' : 'Status of order was changed');
$a->setColor(new Color('#' . $status->get('color')));
// from status
/** @var modAction $action */
$action = $modx->getObject('modAction', ['namespace' => 'minishop2', 'controller' => 'controllers/mgr/orders']);
$link = new Link(rtrim(MODX_SITE_URL, '/') . MODX_MANAGER_URL . "index.php?a={$action->get('id')}#&order={$order->get('id')}", $order->get('num'));
$title = $new ? "New order {$link} was placed on the site" : "Order {$link} was updated";
$a->setTitle(new Title($title));
$a->addField(new Field('Status', $status->get('name'), true));
$a->addField(new Field('When', $order->get('createdon'), true));
if ($new) {
$a->addField(new Field('Cost', $order->get('cost'), true));
$a->addField(new Field('Cart cost', $order->get('cost'), true));
$a->addField(new Field('Delivery', $order->getOne('Delivery')->get('name'), true));
$a->addField(new Field('Delivery cost', $order->get('delivery_cost'), true));
$a->addField(new Field('Payment', $order->getOne('Payment')->get('name'), true));
$a->addField(new Field('Weight'), $order->get('weight'));
$a->setText($order->get('comment'));
}
$message = new Message($new ? '*New order*' : '*Order status update*');
$message->attach($a);
$slackify->send($message);
break;
}
示例4: Attachment
* SOFTWARE.
*/
switch ($modx->event->name) {
case 'OnDocFormSave':
if ($resource->get('class_key') !== 'Ticket') {
return;
}
if (!empty($mode) && $mode != 'new') {
return;
}
$slackify = $modx->getService('slackify');
/** @var Ticket $ticket */
$ticket =& $resource;
/** @var modUser $creator */
$creator = $ticket->getOne('CreatedBy');
/** @var modUserProfile $profile */
$creatorProfile = $creator->getOne('Profile');
$a = new Attachment();
$a->setPretext('Somebody add new important theme for discussion to the site');
$a->setColor(new Color('#0000FF'));
// blue
$a->setAuthor(new Author($creatorProfile->get('fullname'), 'mailto:' . $creatorProfile->get('email')));
$ticketTitle = new Link($modx->makeUrl($ticket->get('id'), 'web', '', 'full'), $ticket->get('pagetitle'));
$a->setTitle(new Title("add new ticket '{$ticketTitle}'"));
$a->setText($ticket->get('introtext'));
$a->addField(new Field('When', $ticket->get('createdon'), true));
$message = new Message('*New ticket*');
$message->attach($a);
$slackify->send($message);
break;
}