<?php

final class ExtensionStorePublisherTransactionEditor
  extends ExtensionStoreTransactionEditor {

  public function getEditorObjectsDescription() {
    return pht('Publishers');
  }

  public function getTransactionTypes() {
    $types = parent::getTransactionTypes();

    $types[] = PhabricatorTransactions::TYPE_VIEW_POLICY;
    $types[] = PhabricatorTransactions::TYPE_EDIT_POLICY;
    $types[] = PhabricatorTransactions::TYPE_EDGE;

    return $types;
  }

  protected function buildMailTemplate(PhabricatorLiskDAO $object) {
    $name = $object->getName();
    $id = $object->getID();
    $subject = pht('Publisher %d: %s', $id, $name);

    return id(new PhabricatorMetaMTAMail())
      ->setSubject($subject);
  }

  protected function buildReplyHandler(PhabricatorLiskDAO $object) {
    return id(new ExtensionStorePublisherReplyHandler())
      ->setMailReceiver($object);
  }

  protected function getMailTo(PhabricatorLiskDAO $object) {
    return array(
      $this->requireActor()->getPHID(),
    );
  }

  protected function buildMailBody(
    PhabricatorLiskDAO $object,
    array $xactions) {

    $body = parent::buildMailBody($object, $xactions);

    $body->addLinkSection(pht('PUBLISHER DETAIL'), $object->getURI());
    return $body;
  }
}
