mirror of
https://github.com/wiosna-dev/limesurvey-api-client.git
synced 2026-03-12 18:11:50 +01:00
Participants collection - store instances of ParticipantShort instead of Participant
Required to fix bug "Call to undefined method Meritoo\LimeSurvey\ApiClient\Result\Item\ParticipantShort::isCompleted() in /src/Service/ParticipantService.php on line 206"
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Meritoo\LimeSurvey\ApiClient\Result\Collection;
|
||||
|
||||
use Meritoo\Common\Collection\Collection;
|
||||
use Meritoo\Common\Exception\Method\DisabledMethodException;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Item\Participant;
|
||||
use Meritoo\LimeSurvey\ApiClient\Result\Item\ParticipantShort;
|
||||
|
||||
/**
|
||||
* Collection of participants (of surveys).
|
||||
@@ -75,11 +75,11 @@ class Participants extends Collection
|
||||
/**
|
||||
* Adds participant of given survey
|
||||
*
|
||||
* @param Participant $participant Participant to add
|
||||
* @param int $surveyId ID of survey
|
||||
* @param ParticipantShort $participant Participant to add
|
||||
* @param int $surveyId ID of survey
|
||||
* @return $this
|
||||
*/
|
||||
public function addParticipant(Participant $participant, $surveyId)
|
||||
public function addParticipant(ParticipantShort $participant, $surveyId)
|
||||
{
|
||||
$this
|
||||
->getBySurvey($surveyId)
|
||||
@@ -128,7 +128,7 @@ class Participants extends Collection
|
||||
*
|
||||
* @param int $surveyId ID of survey
|
||||
* @param string $participantEmail E-mail of searched participant
|
||||
* @return Participant|null
|
||||
* @return ParticipantShort|null
|
||||
*/
|
||||
public function getParticipantOfSurvey($surveyId, $participantEmail)
|
||||
{
|
||||
@@ -139,7 +139,7 @@ class Participants extends Collection
|
||||
return null;
|
||||
}
|
||||
|
||||
/* @var Participant $participant */
|
||||
/* @var ParticipantShort $participant */
|
||||
foreach ($participants as $participant) {
|
||||
if ($participant->getEmail() == $participantEmail) {
|
||||
return $participant;
|
||||
|
||||
@@ -128,7 +128,11 @@ class Result
|
||||
->getResultProcessor()
|
||||
->process($this->method, $rawData);
|
||||
|
||||
if (null === $processed || is_array($processed)) {
|
||||
/*
|
||||
* Result is unknown and it should be iterable the result is an array?
|
||||
* Let's prepare and return collection
|
||||
*/
|
||||
if ((null === $processed && MethodType::isResultIterable($this->method)) || is_array($processed)) {
|
||||
$collection = new Collection();
|
||||
|
||||
if (is_array($processed)) {
|
||||
|
||||
Reference in New Issue
Block a user