/**
  * @see Stockpile_Passthru::__construct()
  * if we have a transaction object ...
  * set up a callback that will delete the index cache for this user if we rollback the txn.
  * this callback only occur once for each unique combination since the transaction onRollback
  * handler makes sure of this.
  */
 public function __construct(Iface $core, Store\Iface $cacher = NULL)
 {
     parent::__construct($core);
     if (!$cacher) {
         return;
     }
     $app = $this->app();
     $user_id = $this->user();
     $core_type = $this->coreType();
     $cacher = new Store\Prefix($cacher, 'stockpile/sort/' . $app . '/' . $user_id . '/');
     $this->cacher = $cacher;
 }
 /**
  * @see Stockpile_Passthru::__construct()
  * if we have a transaction object ...
  * set up a callback that will delete the index cache for this user if we rollback the txn.
  * this callback only occur once for each unique combination since the transaction onRollback
  * handler makes sure of this.
  */
 public function __construct(Iface $core, Store\Iface $cacher)
 {
     parent::__construct($core);
     $app = $this->app();
     $user_id = $this->user();
     $core_type = $this->coreType();
     $cacher = new Store\Prefix($cacher, 'stockpile/' . $app . '/' . $user_id . '/' . $core_type . '/');
     $this->cacher = $cacher;
     if ($this->inTran()) {
         Transaction::onRollback(array($this->cacher, 'delete'), array(self::INDEX_CACHEKEY));
     }
 }
 /**
  * pass in two accounts, always.
  */
 public function __construct(Iface $core, Iface $other)
 {
     parent::__construct($core);
     if (Transaction::atStart()) {
         throw $this->handle(new Exception('need transaction to transfer'));
     }
     if ($core->app() == $other->app() && $core->user() == $other->user()) {
         throw $this->handle(new Exception('need two different parties to trade'));
     }
     if ($core->coreType() == $this->coreType()) {
         throw $this->handle(new Exception('core must not be a transfer'));
     }
     if ($other->coreType() == $this->coreType()) {
         throw $this->handle(new Exception('other must not be a transfer'));
     }
     if ($core->coreType() != $other->coreType() && $core->coreType() != 'serial-tally' && $other->coreType() != 'serial-tally') {
         throw $this->handle(new Exception('both must be of same coretype in a transfer'));
     }
     $this->other = $other;
 }
 /**
  * @see Stockpile_Core::__construct();
  */
 public function __construct($app, $user_id)
 {
     parent::__construct(new Tally($app, $user_id));
     $this->serial = new Serial($app, $user_id);
 }