Skip to content

Commit 4e2f0e6

Browse files
committed
Plugin: XApi: Use core entities instead of plugin entities
See chamilo#3943
1 parent 3bc565e commit 4e2f0e6

34 files changed

+82
-1662
lines changed

public/plugin/xapi/admin.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/* For licensing terms, see /license.txt */
66

7-
use Chamilo\PluginBundle\Entity\XApi\LrsAuth;
7+
use Chamilo\CoreBundle\Entity\XApiLrsAuth;
88
use Symfony\Component\HttpFoundation\Request;
99

1010
$cidReset = true;
@@ -26,7 +26,7 @@
2626
*
2727
* @throws Exception
2828
*/
29-
function createForm(?LrsAuth $auth = null)
29+
function createForm(?XApiLrsAuth $auth = null)
3030
{
3131
$pageBaseUrl = api_get_self();
3232

@@ -63,7 +63,7 @@ function createForm(?LrsAuth $auth = null)
6363
if ($form->validate()) {
6464
$values = $form->exportValues();
6565

66-
$auth = new LrsAuth();
66+
$auth = new XApiLrsAuth();
6767
$auth
6868
->setUsername($values['username'])
6969
->setPassword($values['password'])
@@ -94,7 +94,7 @@ function createForm(?LrsAuth $auth = null)
9494
break;
9595

9696
case 'edit':
97-
$auth = $em->find(LrsAuth::class, $request->query->getInt('id'));
97+
$auth = $em->find(XApiLrsAuth::class, $request->query->getInt('id'));
9898

9999
if (null == $auth) {
100100
api_not_allowed(true);
@@ -135,7 +135,7 @@ function createForm(?LrsAuth $auth = null)
135135
break;
136136

137137
case 'delete':
138-
$auth = $em->find(LrsAuth::class, $request->query->getInt('id'));
138+
$auth = $em->find(XApiLrsAuth::class, $request->query->getInt('id'));
139139

140140
if (null == $auth) {
141141
api_not_allowed(true);
@@ -160,7 +160,7 @@ function createForm(?LrsAuth $auth = null)
160160
);
161161
$pageContent = Display::return_message(get_lang('NoData'), 'warning');
162162

163-
$auths = $em->getRepository(LrsAuth::class)->findAll();
163+
$auths = $em->getRepository(XApiLrsAuth::class)->findAll();
164164

165165
if (count($auths) > 0) {
166166
$row = 0;

public/plugin/xapi/cmi5/launch.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/* For licensing terms, see /license.txt */
66

7-
use Chamilo\PluginBundle\Entity\XApi\Cmi5Item;
7+
use Chamilo\CoreBundle\Entity\XApiCmi5Item;
88
use Symfony\Component\HttpFoundation\Request as HttpRequest;
99
use Xabbuh\XApi\Model\Account;
1010
use Xabbuh\XApi\Model\Activity;
@@ -32,7 +32,7 @@
3232

3333
$em = Database::getManager();
3434

35-
$item = $em->find(Cmi5Item::class, $request->query->getInt('id'));
35+
$item = $em->find(XApiCmi5Item::class, $request->query->getInt('id'));
3636
$toolLaunch = $item->getTool();
3737

3838
if ($toolLaunch->getId() !== $request->query->getInt('tool')) {

public/plugin/xapi/cmi5/view.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
/* For licensing terms, see /license.txt */
66

7-
use Chamilo\PluginBundle\Entity\XApi\Cmi5Item;
8-
use Chamilo\PluginBundle\Entity\XApi\ToolLaunch;
7+
use Chamilo\CoreBundle\Entity\XApiCmi5Item;
8+
use Chamilo\CoreBundle\Entity\XApiToolLaunch;
99
use Symfony\Component\HttpFoundation\Request as HttpRequest;
1010
use Xabbuh\XApi\Model\LanguageMap;
1111

@@ -19,7 +19,7 @@
1919
$em = Database::getManager();
2020

2121
$toolLaunch = $em->find(
22-
ToolLaunch::class,
22+
XApiToolLaunch::class,
2323
$request->query->getInt('id')
2424
);
2525

@@ -38,18 +38,16 @@
3838
$user = api_get_user_entity(api_get_user_id());
3939
$interfaceLanguage = api_get_interface_language();
4040

41-
$itemsRepo = $em->getRepository(Cmi5Item::class);
41+
$itemsRepo = $em->getRepository(XApiCmi5Item::class);
4242

43-
$query = $em->createQueryBuilder()
44-
->select('item')
45-
->from(Cmi5Item::class, 'item')
46-
->where('item.tool = :tool')
43+
$query = $itemsRepo->createQueryBuilder('item');
44+
$query
45+
->where($query->expr()->eq('item.tool', ':tool'))
4746
->setParameter('tool', $toolLaunch->getId())
48-
->getQuery()
4947
;
5048

5149
$tocHtml = $itemsRepo->buildTree(
52-
$query->getArrayResult(),
50+
$query->getQuery()->getArrayResult(),
5351
[
5452
'decorate' => true,
5553
'rootOpen' => '<ul>',

public/plugin/xapi/cron/send_statements.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/* For licensing terms, see /license.txt */
66

7-
use Chamilo\PluginBundle\Entity\XApi\SharedStatement;
7+
use Chamilo\CoreBundle\Entity\XApiSharedStatement;
88
use Xabbuh\XApi\Common\Exception\ConflictException;
99
use Xabbuh\XApi\Common\Exception\XApiException;
1010
use Xabbuh\XApi\Model\StatementId;
@@ -25,7 +25,7 @@
2525
$statementSerializer = new StatementSerializer($serializer);
2626

2727
$notSentSharedStatements = $em
28-
->getRepository(SharedStatement::class)
28+
->getRepository(XApiSharedStatement::class)
2929
->findBy(
3030
['uuid' => null, 'sent' => false],
3131
null,
@@ -39,7 +39,6 @@
3939

4040
$client = XApiPlugin::create()->getXapiStatementCronClient();
4141

42-
/** @var SharedStatement $notSentSharedStatement */
4342
foreach ($notSentSharedStatements as $notSentSharedStatement) {
4443
$notSentStatement = $statementSerializer->deserializeStatement(
4544
json_encode($notSentSharedStatement->getStatement())

public/plugin/xapi/install.php

Lines changed: 0 additions & 7 deletions
This file was deleted.

public/plugin/xapi/php-xapi/lrs-bundle/src/Controller/StatementGetController.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,12 @@ class StatementGetController
5757
'cursor' => true,
5858
];
5959

60-
protected $repository;
61-
protected $statementSerializer;
62-
protected $statementResultSerializer;
63-
protected $statementsFilterFactory;
64-
65-
public function __construct(StatementRepositoryInterface $repository, StatementSerializerInterface $statementSerializer, StatementResultSerializerInterface $statementResultSerializer, StatementsFilterFactory $statementsFilterFactory)
66-
{
67-
$this->repository = $repository;
68-
$this->statementSerializer = $statementSerializer;
69-
$this->statementResultSerializer = $statementResultSerializer;
70-
$this->statementsFilterFactory = $statementsFilterFactory;
71-
}
60+
public function __construct(
61+
protected readonly StatementRepositoryInterface $repository,
62+
protected readonly StatementSerializerInterface $statementSerializer,
63+
protected readonly StatementResultSerializerInterface $statementResultSerializer,
64+
protected readonly StatementsFilterFactory $statementsFilterFactory
65+
) {}
7266

7367
/**
7468
* @return Response

public/plugin/xapi/src/Entity/ActivityProfile.php

Lines changed: 0 additions & 99 deletions
This file was deleted.

public/plugin/xapi/src/Entity/ActivityState.php

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)