コード例 #1
0
 /**
  * Initializes a new PhabricatorNotification instance
  *
  * @param string $project The project for this notification
  * @param PhabricatorStory $payload The story to convert into a notification
  */
 public function __construct($project, PhabricatorStory $payload)
 {
     // Straightforward properties
     $this->service = "Phabricator";
     $this->project = $project;
     $this->rawContent = $payload;
     $this->text = $payload->text;
     // Analyzes and fills
     $this->type = $payload->getObjectType();
     $this->group = $this->getGroup();
     $this->link = $this->getLink();
 }
コード例 #2
0
 /**
  * Gets the group for a specific story.
  *
  * @return string the group, central part of the routing key
  */
 public function getGroup()
 {
     // If the payload is about some repository matching a table of
     // symbols, we need to sort it to the right group.
     foreach ($this->configuration->map as $mapping) {
         foreach ($this->story->getProjects() as $project) {
             if ($mapping->doesItemBelong($project)) {
                 return $mapping->group;
             }
         }
     }
     // Words
     foreach ($this->configuration->map as $mapping) {
         if ($mapping->doesStoryBelong($this->story)) {
             return $mapping->group;
         }
     }
     // By default, fallback group is the project name or a specified value.
     if (empty($this->configuration->defaultGroup)) {
         return strtolower($this->project);
     }
     return $this->configuration->defaultGroup;
 }
コード例 #3
0
 /**
  * Formats payload to pass to constructor
  *
  * @return PhabricatorStory|stdClass A deserialization of the payload
  */
 private function formatPayload()
 {
     if ($this->service === "Phabricator") {
         $project = $this->constructor['project'];
         return PhabricatorStory::loadFromJson($project, $this->payload);
     }
     return json_decode($this->payload);
 }
コード例 #4
0
 /**
  * Gets story from the request
  *
  * @return PhabricatorStory
  */
 protected function getStory()
 {
     return PhabricatorStory::loadFromArray($this->door, $this->payload);
 }