Skip to content

Commit

Permalink
Fixes on the container interface
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvdlinde committed Sep 30, 2024
1 parent 09ca6d9 commit 76ad515
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
11 changes: 6 additions & 5 deletions lib/Cron/ActionTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use OCA\OpenConnector\Db\JobLogMapper;
use OCP\BackgroundJob\TimedJob;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\AppFramework\Utility\IContainer;
use OCP\BackgroundJob\IJobList;
use Psr\Container\ContainerInterface;

/**
* This class is used to run the action tasks for the OpenConnector app. It hooks into the cron job list and runs the classes that are set as the job class in the job.
Expand All @@ -20,19 +20,20 @@ class ActionTask extends TimedJob
private JobMapper $jobMapper;
private JobLogMapper $jobLogMapper;
private IJobList $jobList;
private IContainer $iContainer;
private ContainerInterface $containerInterface;

public function __construct(
ITimeFactory $time,
JobMapper $jobMapper,
JobLogMapper $jobLogMapper,
IJobList $jobList,
IContainer $iContainer
ContainerInterface $containerInterface
) {
parent::__construct($time);
$this->jobMapper = $jobMapper;
$this->jobLogMapper = $jobLogMapper;
$this->jobList = $jobList;
$this->iContainer = $iContainer;
$this->containerInterface = $containerInterface;
// Run every 5 minutes
//$this->setInterval(300);

Expand Down Expand Up @@ -71,7 +72,7 @@ public function run($argument)

$time_start = microtime(true);

$action = $this->iContainer->get($job->getClass());
$action = $this->containerInterface->get($job->getClass());
$action->run($job->getArguments());

$time_end = microtime(true);
Expand Down
35 changes: 19 additions & 16 deletions lib/Service/SynchronizationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use OCA\OpenConnector\Service\CallService;
use OCA\OpenConnector\Service\MappingService;

use OCP\AppFramework\Utility\IContainer;
use Psr\Container\ContainerInterface;
use Twig\Error\LoaderError;
use Twig\Error\SyntaxError;
use Adbar\Dot;
Expand All @@ -20,25 +20,25 @@

class SynchronizationService
{
public $CallService;
public $MappingService;
public $container;
public $synchronization;
public $synchronizationMapper;
public $synchronizationContractMapper;
public $objectService;
private CallService $callService;
private MappingService $mappingService;
private ContainerInterface $containerInterface;
private Synchronization $synchronization;
private SynchronizationMapper $synchronizationMapper;
private SynchronizationContractMapper $synchronizationContractMapper;
private ObjectService $objectService;


public function __construct(
CallService $callService,
MappingService $mappingService,
IContainer $container,
ContainerInterface $containerInterface,
SynchronizationMapper $synchronizationMapper,
SynchronizationContractMapper $synchronizationContractMapper
) {
$this->callService = $callService;
$this->mappingService = $mappingService;
$this->container = $container;
$this->containerInterface = $containerInterface;
$this->synchronizationMapper = $synchronizationMapper;
$this->synchronizationContractMapper = $synchronizationContractMapper;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ public function updateTarget(SynchronizationContract $synchronizationContract, a
switch($type){
case 'register/schema':
// Setup the object service
$this->objectService = $this->iContainer->get('OCA\OpenRegister\Service\ObjectService');
$this->objectService = $this->containerInterface->get('OCA\OpenRegister\Service\ObjectService');
// if we alreadey have an id, we need to get the object and update it
if($synchronizationContract->getTargetId()){
$targetObject['id'] = $synchronizationContract->getTargetId();
Expand All @@ -166,10 +166,11 @@ public function updateTarget(SynchronizationContract $synchronizationContract, a
$synchronizationContract->setTargetId($target->getUuid());
break;
case 'api':
$this->callService->put($targetObject);
//@todo: implement
//$this->callService->put($targetObject);
break;
case 'database':
$this->callService->put($targetObject);
//@todo: implement
break;
}
}
Expand All @@ -185,14 +186,16 @@ public function getAllObjectsFromSource(Synchronization $synchronization)
switch($type){
case 'register/schema':
// Setup the object service
$this->objectService = $this->iContainer->get('OCA\OpenRegister\Service\ObjectService');
$this->objectService = $this->containerInterface->get('OCA\OpenRegister\Service\ObjectService');

break;
case 'api':
$this->callService->put($targetObject);

//@todo: implement
//$this->callService->put($targetObject);
break;
case 'database':
$this->callService->put($targetObject);
//@todo: implement
break;
}
}
Expand Down

0 comments on commit 76ad515

Please sign in to comment.