<?php /** * Perforce Swarm * * @copyright 2015 Perforce Software. All rights reserved. * @license Please see LICENSE.txt in top-level folder of this distribution. * @version <release>/<patch> */ namespace Slack; use P4\Spec\Change; use Zend\View\Helper\AbstractHelper; use Zend\Stdlib\StringUtils; /** * Provides Slack message formatting for Perforce changes. */ class Message extends AbstractHelper { protected $msg = ''; public function __construct($host, Change $change, $max) { $this->msg = $this->formatChange($host, $change, $max); } public function toString() { return $this->msg; } private function formatChange($host, $change, $max) { $id = $change->getId(); $id_url = $host('change', array('change' => $id)); $description = $change->getDescription(); $user = $change->getUser(); $user_url = $host('user', array('user' => $user)); $client = $change->getClient(); $date = $change->getDate(); $summary = "Change " . "<" . $id_url . "|" . $id . ">" . " by " . "<" . $user_url . "|" . $user . "@" . $client . ">" . " on " . $date . "\n"; $utility = StringUtils::getWrapper(); $length = strlen($description); if($length > $max) { $description = $utility->substr($description, 0, $max) . "..."; } $msg = $summary . $description . "\n"; return $msg; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#5 | 20871 | Paul Allen | Update my old dev branch 'paul_allen' with changes from 'perforce_software'. | ||
#4 | 16611 | Paul Allen |
Updates changes from Internal Swarm review. Use JS injection for dynamic Project Configuration. |
||
#3 | 16472 | Paul Allen | Minor fix for cropping change description and testing if the Slack Webhook is defined in the project. | ||
#2 | 16469 | Paul Allen |
Trim Change description. Config option (default 80) |
||
#1 | 16466 | Paul Allen | Simple Change Activity Slack integration. |