Page MenuHomePhabricator
Paste P1944

A not quite right idea
ActivePublic

Authored by yelirekim on Feb 16 2016, 1:38 AM.
Tags
None
Referenced Files
F1113477: A not quite right idea
Feb 16 2016, 1:38 AM
Subscribers
None
<?php
/**
* Exposes a very basic API for reacting to application transactions. Subclasses can override
* @{method:getProcessableTransactionTemplates} or @{method:canProcessTransaction} dending on
* how finely they would like to filter transactions for processing.
*/
abstract class CITransactionProcessor extends Phobject {
abstract public function getProcessableTransactionClasses();
public function canProcessTransaction(PhabricatorApplicationTransaction $transaction) {
return in_array(get_class($transaction), $this->getProcessableTransactionClasses());
}
abstract protected function processTransaction(PhabricatorApplicationTransaction $transaction);
public function processTransactions(array $transactions) {
$results = [];
foreach ($transactions as $transaction) {
$results[$transaction->getPHID()] = $this->processTransaction($transaction);
}
return $results;
}
public function isEnabled() {
return true;
}
final public static function getAllProcessors() {
$processors = (new PhutilClassMapQuery())
->setAncestorClass(__CLASS__)
->setFilterMethod('isEnabled')
->execute();
return $processors;
}
}