-
Notifications
You must be signed in to change notification settings - Fork 486
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Internal: Add entity listener to track deleted resource link
- Loading branch information
Showing
5 changed files
with
75 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
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,29 @@ | ||
<?php | ||
|
||
/* For licensing terms, see /license.txt */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chamilo\CoreBundle\Entity\Listener; | ||
|
||
use Chamilo\CoreBundle\Entity\ResourceLink; | ||
use Doctrine\ORM\Event\PostRemoveEventArgs; | ||
use Doctrine\ORM\Exception\ORMException; | ||
use Event; | ||
|
||
class ResourceLinkListener | ||
{ | ||
/** | ||
* @throws ORMException | ||
*/ | ||
public function postRemove(ResourceLink $resourceLink, PostRemoveEventArgs $args): void | ||
{ | ||
$resourceNode = $resourceLink->getResourceNode(); | ||
|
||
Event::addEvent( | ||
LOG_RESOURCE_LINK_DELETE, | ||
LOG_RESOURCE_NODE, | ||
$resourceNode->getId(), | ||
); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
/* For licensing terms, see /license.txt */ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Chamilo\CoreBundle\EventListener; | ||
|
||
use Chamilo\CoreBundle\Entity\ResourceLink; | ||
use Doctrine\Bundle\DoctrineBundle\Attribute\AsDoctrineListener; | ||
use Doctrine\ORM\Exception\ORMException; | ||
use Event; | ||
use Gedmo\SoftDeleteable\Event\PostSoftDeleteEventArgs; | ||
use Gedmo\SoftDeleteable\SoftDeleteableListener; | ||
|
||
#[AsDoctrineListener(event: SoftDeleteableListener::POST_SOFT_DELETE, connection: 'default')] | ||
class ResourceLinkListener | ||
{ | ||
/** | ||
* @throws ORMException | ||
*/ | ||
public function postSoftDelete(PostSoftDeleteEventArgs $args): void | ||
{ | ||
$object = $args->getObject(); | ||
|
||
if (!$object instanceof ResourceLink) { | ||
return; | ||
} | ||
|
||
Event::addEvent( | ||
LOG_RESOURCE_LINK_SOFT_DELETE, | ||
LOG_RESOURCE_LINK, | ||
$object->getId(), | ||
); | ||
} | ||
} |
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