public function render()
 {
     $handler = $this->component->getActivityLogHandler();
     $currentPage = $this->request->getQuery('listing-page', 1);
     $criteria = ['handlers' => $handler, 'limit' => $this->pageSize, 'offset' => ($currentPage - 1) * $this->pageSize];
     if ($this->request->getQuery('id')) {
         $entity = $handler->createEntity($this->request->getQuery('id'));
         $criteria['entities'] = $entity;
         $this->view->assign('entity', $entity);
     }
     $entries = $this->getActivityLog()->getEntries($criteria);
     $this->view->assign('entries', $entries)->assign('title', $this->component->getTitle())->assign('entryCount', $entries->getTotalCount())->assign('pageSize', $this->pageSize)->assign('currentPage', $currentPage);
 }
Exemple #2
0
 protected function logActivity(RowEditor $rowEditor)
 {
     $model = $this->component->getPrimaryModel();
     $rows = $rowEditor->getRows();
     $id = null;
     /* @var $row \Dewdrop\Db\Row */
     foreach ($rows as $row) {
         if ($row->getTable() === $model) {
             $id = $row->get(current($model->getPrimaryKey()));
         }
     }
     if ($id) {
         /* @var $handler \Dewdrop\ActivityLog\Handler\CrudHandlerAbstract */
         $handler = $this->component->getActivityLogHandler();
         $handler->restore($id);
     }
 }
 /**
  * @return \Dewdrop\ActivityLog\Handler\TableHandler
  */
 public function getActivityLogHandler()
 {
     if (parent::getActivityLogHandler() instanceof ActivityLogNullHandler) {
         return $this->getPrimaryModel()->getActivityLogHandler();
     } else {
         return parent::getActivityLogHandler();
     }
 }