Skip to content

Commit

Permalink
Add audit log for issues entities changeable through admin
Browse files Browse the repository at this point in the history
- `IssuesRepository`
- `MagazinesRepository`
- `SubscriptionTypeMagazinesRepository`

remp/crm#3114
  • Loading branch information
markoph committed Feb 29, 2024
1 parent 6b58af3 commit 560f4c8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
25 changes: 9 additions & 16 deletions src/Repositories/IssuesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Crm\IssuesModule\Repositories;

use Crm\ApplicationModule\Application\Managers\ApplicationMountManager;
use Crm\ApplicationModule\Repositories\AuditLogRepository;
use Crm\ApplicationModule\Repositories\CacheRepository;
use Nette\Database\Explorer;
use Nette\Database\Table\ActiveRow;
Expand All @@ -13,31 +14,23 @@ class IssuesRepository extends IssueBaseRepository
{
protected $tableName = 'issues';

protected $auditLogExcluded = ['updated_at'];

const STATE_NEW = 'new';
const STATE_ERROR = 'error';
const STATE_OK = 'ok';
const STATE_PROCESSING = 'processing';

/** @var IssueSourceFilesRepository */
private $issueSourceFilesRepository;

/** @var IssuePagesRepository */
private $issuePagesRepository;

/** @var CacheRepository */
private $cacheRepository;

public function __construct(
Explorer $database,
ApplicationMountManager $mountManager,
IssueSourceFilesRepository $issueSourceFilesRepository,
IssuePagesRepository $issuePagesRepository,
CacheRepository $cacheRepository
private IssueSourceFilesRepository $issueSourceFilesRepository,
private IssuePagesRepository $issuePagesRepository,
private CacheRepository $cacheRepository,
AuditLogRepository $auditLogRepository,
) {
parent::__construct($database, $mountManager);
$this->issueSourceFilesRepository = $issueSourceFilesRepository;
$this->issuePagesRepository = $issuePagesRepository;
$this->cacheRepository = $cacheRepository;
parent::__construct($database, $mountManager, null);
$this->auditLogRepository = $auditLogRepository;
}

final public function add(
Expand Down
14 changes: 14 additions & 0 deletions src/Repositories/MagazinesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Crm\IssuesModule\Repositories;

use Crm\ApplicationModule\Models\Database\Repository;
use Crm\ApplicationModule\Repositories\AuditLogRepository;
use Nette\Caching\Storage;
use Nette\Database\Explorer;
use Nette\Database\Table\ActiveRow;
use Nette\Database\Table\Selection;
use Nette\Utils\DateTime;
Expand All @@ -11,6 +14,17 @@ class MagazinesRepository extends Repository
{
protected $tableName = 'magazines';

protected $auditLogExcluded = ['updated_at'];

public function __construct(
Explorer $database,
Storage $cacheStorage = null,
AuditLogRepository $auditLogRepository,
) {
parent::__construct($database, $cacheStorage);
$this->auditLogRepository = $auditLogRepository;
}

/**
* @return Selection
*/
Expand Down
12 changes: 12 additions & 0 deletions src/Repositories/SubscriptionTypeMagazinesRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,23 @@
namespace Crm\IssuesModule\Repositories;

use Crm\ApplicationModule\Models\Database\Repository;
use Crm\ApplicationModule\Repositories\AuditLogRepository;
use Nette\Caching\Storage;
use Nette\Database\Explorer;

class SubscriptionTypeMagazinesRepository extends Repository
{
protected $tableName = 'subscription_type_magazines';

public function __construct(
Explorer $database,
Storage $cacheStorage = null,
AuditLogRepository $auditLogRepository,
) {
parent::__construct($database, $cacheStorage);
$this->auditLogRepository = $auditLogRepository;
}

final public function addSubscriptionTypeMagazine($subscriptionTypeID, $magazineID)
{
$record = $this->getTable()->where([
Expand Down

0 comments on commit 560f4c8

Please sign in to comment.