public function notify($type, TableInterface $table, RecordInterface $record) { $handler = $this->hm->getHandler('AmunService\\Log', $this->user); $log = $handler->getRecord(); $log->setRefId(isset($record->id) ? $record->id : 0); $log->setType(RecordAbstract::getType($type)); $log->setTable($table->getName()); $handler->create($log); }
public function setType($type) { $type = $this->_validate->apply($type, 'string', array(new Filter\InArray(RecordAbstract::getType())), 'type', 'Type'); if (!$this->_validate->hasError()) { $this->type = $type; } else { throw new Exception($this->_validate->getLastError()); } }
private function handleDefault($type, TableInterface $table, RecordInterface $record) { // get template message $sql = <<<SQL SELECT \t`template`.`verb`, \t`template`.`path`, \t`template`.`summary` FROM \t{$this->registry['table.user_activity_template']} `template` WHERE \t`template`.`table` = ? AND \t`template`.`type` = ? SQL; $row = $this->sql->getRow($sql, array($table->getName(), RecordAbstract::getType($type))); if (!empty($row)) { // get object $className = $this->registry->getClassNameFromTable($table->getName()); $handler = $this->hm->getHandler($className, $this->user); $object = $handler->get($record->id, array(), Sql::FETCH_OBJECT); // build object url if (isset($object->pagePath) && !empty($row['path'])) { $url = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . $object->pagePath . '/' . $row['path']; $url = $this->substituteVars($object, $url); } else { $url = '#'; } // get activity stream object. If the record does not support jas // an exception is thrown $jas = null; try { $jas = $object->export(new WriterResult(WriterInterface::JAS, new Writer\Jas())); } catch (\Exception $e) { } // insert activity $handler = $this->hm->getHandler('AmunService\\User\\Activity', $this->user); $activity = $handler->getRecord(); $activity->verb = $row['verb']; $activity->object = $jas instanceof ActivityStream\Activity ? json_encode($jas->getData()) : null; $activity->summary = $this->substituteVars($object, $row['summary'], $url); $handler->create($activity); } }
/** * This method should be called by each handler if an record was inserted, * updated or deleted. It notifies all listeners of the core.record_change * event * * @param integer $type * @param PSX\Data\RecordInterface $record * @return void */ public function notify($type, RecordInterface $record) { if (RecordAbstract::getType($type) === false) { throw new Exception('Invalid notification type'); } $this->event->notifyListener('core.record_change', array($type, $this->table, $record), $this->user); }