|
|
@ -9,7 +9,6 @@ namespace Chamilo\CoreBundle\Entity\Listener; |
|
|
|
use Chamilo\CoreBundle\Entity\AbstractResource; |
|
|
|
use Chamilo\CoreBundle\Entity\AbstractResource; |
|
|
|
use Chamilo\CoreBundle\Entity\AccessUrl; |
|
|
|
use Chamilo\CoreBundle\Entity\AccessUrl; |
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
use Chamilo\CoreBundle\Entity\EntityAccessUrl; |
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Entity\EntityAccessUrlInterface; |
|
|
|
use Chamilo\CoreBundle\Entity\EntityAccessUrlInterface; |
|
|
|
use Chamilo\CoreBundle\Entity\ResourceFile; |
|
|
|
use Chamilo\CoreBundle\Entity\ResourceFile; |
|
|
|
use Chamilo\CoreBundle\Entity\ResourceLink; |
|
|
|
use Chamilo\CoreBundle\Entity\ResourceLink; |
|
|
@ -58,7 +57,7 @@ class ResourceListener |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Only in creation. |
|
|
|
* Only in creation. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function prePersist(AbstractResource $resource, LifecycleEventArgs $event) |
|
|
|
public function prePersist(AbstractResource $resource, LifecycleEventArgs $event): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
error_log('Resource listener prePersist for obj: '.\get_class($resource)); |
|
|
|
error_log('Resource listener prePersist for obj: '.\get_class($resource)); |
|
|
|
$em = $event->getEntityManager(); |
|
|
|
$em = $event->getEntityManager(); |
|
|
@ -83,6 +82,7 @@ class ResourceListener |
|
|
|
|
|
|
|
|
|
|
|
// Check if creator is set with $resource->setCreator() |
|
|
|
// Check if creator is set with $resource->setCreator() |
|
|
|
$creator = $resource->getResourceNodeCreator(); |
|
|
|
$creator = $resource->getResourceNodeCreator(); |
|
|
|
|
|
|
|
|
|
|
|
if (null === $creator) { |
|
|
|
if (null === $creator) { |
|
|
|
/** @var User|null $creator */ |
|
|
|
/** @var User|null $creator */ |
|
|
|
$defaultCreator = $this->security->getUser(); |
|
|
|
$defaultCreator = $this->security->getUser(); |
|
|
@ -226,7 +226,7 @@ class ResourceListener |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Use by Chamilo. |
|
|
|
// Use by Chamilo. |
|
|
|
$this->setLinks($resourceNode, $resource, $em); |
|
|
|
$this->setLinks($resource, $em); |
|
|
|
|
|
|
|
|
|
|
|
if (null !== $resource->getParent()) { |
|
|
|
if (null !== $resource->getParent()) { |
|
|
|
$resourceNode->setParent($resource->getParent()->getResourceNode()); |
|
|
|
$resourceNode->setParent($resource->getParent()->getResourceNode()); |
|
|
@ -247,7 +247,7 @@ class ResourceListener |
|
|
|
public function preUpdate(AbstractResource $resource, PreUpdateEventArgs $event): void |
|
|
|
public function preUpdate(AbstractResource $resource, PreUpdateEventArgs $event): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
error_log('Resource listener preUpdate'); |
|
|
|
error_log('Resource listener preUpdate'); |
|
|
|
$this->setLinks($resource->getResourceNode(), $resource, $event->getEntityManager()); |
|
|
|
$this->setLinks($resource, $event->getEntityManager()); |
|
|
|
|
|
|
|
|
|
|
|
if ($resource->hasUploadFile()) { |
|
|
|
if ($resource->hasUploadFile()) { |
|
|
|
$uploadedFile = $resource->getUploadFile(); |
|
|
|
$uploadedFile = $resource->getUploadFile(); |
|
|
@ -290,7 +290,7 @@ class ResourceListener |
|
|
|
$resource->getResourceNode()->setTitle($resourceName); |
|
|
|
$resource->getResourceNode()->setTitle($resourceName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function setLinks(ResourceNode $resourceNode, AbstractResource $resource, $em): void |
|
|
|
public function setLinks(AbstractResource $resource, $em): void |
|
|
|
{ |
|
|
|
{ |
|
|
|
error_log('Resource listener setLinks'); |
|
|
|
error_log('Resource listener setLinks'); |
|
|
|
$links = $resource->getResourceLinkEntityList(); |
|
|
|
$links = $resource->getResourceLinkEntityList(); |
|
|
|