-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add moderator updates to the modlog (#799)
Co-authored-by: debounced <[email protected]>
- Loading branch information
1 parent
d38d2da
commit 9389aa2
Showing
7 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20240528172429 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add a field to the magazine log table for adding and removing a moderator'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE magazine_log ADD acting_user_id INT DEFAULT NULL'); | ||
$this->addSql('ALTER TABLE magazine_log ADD CONSTRAINT FK_87D3D4C53EAD8611 FOREIGN KEY (acting_user_id) REFERENCES "user" (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); | ||
$this->addSql('CREATE INDEX IDX_87D3D4C53EAD8611 ON magazine_log (acting_user_id)'); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE magazine_log DROP CONSTRAINT FK_87D3D4C53EAD8611'); | ||
$this->addSql('DROP INDEX IDX_87D3D4C53EAD8611'); | ||
$this->addSql('ALTER TABLE magazine_log DROP acting_user_id'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity; | ||
|
||
use App\Entity\Contracts\ContentInterface; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\JoinColumn; | ||
use Doctrine\ORM\Mapping\ManyToOne; | ||
|
||
#[Entity] | ||
class MagazineLogModeratorAdd extends MagazineLog | ||
{ | ||
#[ManyToOne(targetEntity: User::class)] | ||
#[JoinColumn(nullable: true, onDelete: 'CASCADE')] | ||
public ?User $actingUser; | ||
|
||
public function __construct(Magazine $magazine, User $addedMod, ?User $actingUser) | ||
{ | ||
parent::__construct($magazine, $addedMod); | ||
$this->actingUser = $actingUser; | ||
} | ||
|
||
public function getSubject(): ContentInterface|null | ||
{ | ||
return null; | ||
} | ||
|
||
public function clearSubject(): MagazineLog | ||
{ | ||
return $this; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'log_moderator_add'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Entity; | ||
|
||
use App\Entity\Contracts\ContentInterface; | ||
use Doctrine\ORM\Mapping\Entity; | ||
use Doctrine\ORM\Mapping\JoinColumn; | ||
use Doctrine\ORM\Mapping\ManyToOne; | ||
|
||
#[Entity] | ||
class MagazineLogModeratorRemove extends MagazineLog | ||
{ | ||
#[ManyToOne(targetEntity: User::class)] | ||
#[JoinColumn(nullable: true, onDelete: 'CASCADE')] | ||
public ?User $actingUser; | ||
|
||
public function __construct(Magazine $magazine, User $addedMod, ?User $actingUser) | ||
{ | ||
parent::__construct($magazine, $addedMod); | ||
$this->actingUser = $actingUser; | ||
} | ||
|
||
public function getSubject(): ContentInterface|null | ||
{ | ||
return null; | ||
} | ||
|
||
public function clearSubject(): MagazineLog | ||
{ | ||
return $this; | ||
} | ||
|
||
public function getType(): string | ||
{ | ||
return 'log_moderator_remove'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters