|
|
|
@ -4,11 +4,13 @@ |
|
|
|
|
|
|
|
|
|
namespace Chamilo\CoreBundle\Migrations\Schema\V200; |
|
|
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
|
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo; |
|
|
|
|
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository; |
|
|
|
|
use Chamilo\CoreBundle\Repository\Node\CourseRepository; |
|
|
|
|
use Chamilo\CoreBundle\Repository\Node\UserRepository; |
|
|
|
|
use Chamilo\CoreBundle\Repository\SessionRepository; |
|
|
|
|
use Chamilo\CourseBundle\Entity\CLink; |
|
|
|
|
use Chamilo\CourseBundle\Entity\CLinkCategory; |
|
|
|
|
use Chamilo\CourseBundle\Repository\CGroupRepository; |
|
|
|
|
use Chamilo\CourseBundle\Repository\CLinkCategoryRepository; |
|
|
|
@ -31,7 +33,6 @@ final class Version20201215141131 extends AbstractMigrationChamilo |
|
|
|
|
/** @var Connection $connection */ |
|
|
|
|
$connection = $em->getConnection(); |
|
|
|
|
|
|
|
|
|
$urlRepo = $container->get(AccessUrlRepository::class); |
|
|
|
|
$linkRepo = $container->get(CLinkRepository::class); |
|
|
|
|
$linkCategoryRepo = $container->get(CLinkCategoryRepository::class); |
|
|
|
|
$courseRepo = $container->get(CourseRepository::class); |
|
|
|
@ -42,6 +43,7 @@ final class Version20201215141131 extends AbstractMigrationChamilo |
|
|
|
|
$admin = $this->getAdmin(); |
|
|
|
|
|
|
|
|
|
$q = $em->createQuery('SELECT c FROM Chamilo\CoreBundle\Entity\Course c'); |
|
|
|
|
/** @var Course $course */ |
|
|
|
|
foreach ($q->toIterable() as $course) { |
|
|
|
|
$counter = 1; |
|
|
|
|
$courseId = $course->getId(); |
|
|
|
@ -73,6 +75,43 @@ final class Version20201215141131 extends AbstractMigrationChamilo |
|
|
|
|
$em->persist($resource); |
|
|
|
|
$em->flush(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sql = "SELECT * FROM c_link WHERE c_id = $courseId |
|
|
|
|
ORDER BY iid"; |
|
|
|
|
$result = $connection->executeQuery($sql); |
|
|
|
|
$items = $result->fetchAllAssociative(); |
|
|
|
|
foreach ($items as $itemData) { |
|
|
|
|
$id = $itemData['iid']; |
|
|
|
|
$categoryId = $itemData['category_id']; |
|
|
|
|
/** @var CLink $event */ |
|
|
|
|
$resource = $linkRepo->find($id); |
|
|
|
|
if ($resource->hasResourceNode()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$parent = $course; |
|
|
|
|
|
|
|
|
|
if (!empty($categoryId)) { |
|
|
|
|
$category = $linkCategoryRepo->find($categoryId); |
|
|
|
|
if (null !== $category) { |
|
|
|
|
$parent = $category; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result = $this->fixItemProperty( |
|
|
|
|
'link', |
|
|
|
|
$linkRepo, |
|
|
|
|
$course, |
|
|
|
|
$admin, |
|
|
|
|
$resource, |
|
|
|
|
$parent |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (false === $result) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
$em->persist($resource); |
|
|
|
|
$em->flush(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|