<?php

final class ExtensionStoreReleaseTransactionEditor
  extends ExtensionStoreTransactionEditor {

  public function getEditorObjectsDescription() {
    return pht('Extension Releases');
  }

  public function getCreateObjectTitle($author, $object) {
    return pht('%s created this version.', $author);
  }

  public function getCreateObjectTitleForFeed($author, $object) {
    return pht('%s created %s.', $author, $object);
  }

  protected function getMailTo(PhabricatorLiskDAO $object) {
    return array();
  }

  /**
   * @task mail
   */
  protected function getMailCC(PhabricatorLiskDAO $object) {
    return array();
  }


  protected function didCatchDuplicateKeyException(
    PhabricatorLiskDAO $object,
    array $xactions,
    Exception $ex) {

    $errors = array();
    $errors[] = new PhabricatorApplicationTransactionValidationError(
      ExtensionStoreReleaseNameTransaction::TRANSACTIONTYPE,
      pht('Duplicate'),
      pht(
        'The version "%s" already exists for this extension. Each version '.
        'must have a unique name.',
        $object->getName()),
      null);

    throw new PhabricatorApplicationTransactionValidationException($errors);
  }

}
