-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'textFieldOnResponseOptions-706' into 'main'
Adiciona campo de texto às opções de resposta See merge request softwares-pkp/plugins_ojs/demographicData!13
- Loading branch information
Showing
32 changed files
with
827 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace APP\plugins\generic\demographicData\classes\demographicResponseOption; | ||
|
||
use Illuminate\Database\Query\Builder; | ||
use Illuminate\Support\Facades\DB; | ||
use PKP\core\interfaces\CollectorInterface; | ||
use Illuminate\Support\LazyCollection; | ||
|
||
class Collector implements CollectorInterface | ||
{ | ||
public DAO $dao; | ||
public ?array $questionIds = null; | ||
|
||
public function __construct(DAO $dao) | ||
{ | ||
$this->dao = $dao; | ||
} | ||
|
||
public function filterByQuestionIds(?array $questionIds): Collector | ||
{ | ||
$this->questionIds = $questionIds; | ||
return $this; | ||
} | ||
|
||
public function getQueryBuilder(): Builder | ||
{ | ||
$queryBuilder = DB::table($this->dao->table . ' AS dro') | ||
->select(['dro.*']); | ||
|
||
if (isset($this->questionIds)) { | ||
$queryBuilder->whereIn('dro.demographic_question_id', $this->questionIds); | ||
} | ||
|
||
return $queryBuilder; | ||
} | ||
|
||
public function getCount(): int | ||
{ | ||
return $this->dao->getCount($this); | ||
} | ||
|
||
public function getIds(): Collection | ||
{ | ||
return $this->dao->getIds($this); | ||
} | ||
|
||
public function getMany(): LazyCollection | ||
{ | ||
return $this->dao->getMany($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
namespace APP\plugins\generic\demographicData\classes\demographicResponseOption; | ||
|
||
use PKP\core\EntityDAO; | ||
use Illuminate\Support\LazyCollection; | ||
use PKP\core\traits\EntityWithParent; | ||
|
||
class DAO extends EntityDAO | ||
{ | ||
use EntityWithParent; | ||
|
||
public $schema = 'demographicResponseOption'; | ||
public $table = 'demographic_response_options'; | ||
public $primaryKeyColumn = 'demographic_response_option_id'; | ||
public $settingsTable = 'demographic_response_option_settings'; | ||
public $primaryTableColumns = [ | ||
'id' => 'demographic_response_option_id', | ||
'demographicQuestionId' => 'demographic_question_id', | ||
]; | ||
|
||
public function getParentColumn(): string | ||
{ | ||
return 'demographic_question_id'; | ||
} | ||
|
||
public function newDataObject(): DemographicResponseOption | ||
{ | ||
return app(DemographicResponseOption::class); | ||
} | ||
|
||
public function insert(DemographicResponseOption $demographicResponseOption): int | ||
{ | ||
return parent::_insert($demographicResponseOption); | ||
} | ||
|
||
public function delete(DemographicResponseOption $demographicResponseOption) | ||
{ | ||
return parent::_delete($demographicResponseOption); | ||
} | ||
|
||
public function update(DemographicResponseOption $demographicResponseOption) | ||
{ | ||
return parent::_update($demographicResponseOption); | ||
} | ||
|
||
public function getCount(Collector $query): int | ||
{ | ||
return $query | ||
->getQueryBuilder() | ||
->count(); | ||
} | ||
|
||
public function getMany(Collector $query): LazyCollection | ||
{ | ||
$rows = $query | ||
->getQueryBuilder() | ||
->get(); | ||
|
||
return LazyCollection::make(function () use ($rows) { | ||
foreach ($rows as $row) { | ||
yield $row->demographic_response_option_id => $this->fromRow($row); | ||
} | ||
}); | ||
} | ||
|
||
public function fromRow(object $row): DemographicResponseOption | ||
{ | ||
return parent::fromRow($row); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
classes/demographicResponseOption/DemographicResponseOption.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace APP\plugins\generic\demographicData\classes\demographicResponseOption; | ||
|
||
class DemographicResponseOption extends \PKP\core\DataObject | ||
{ | ||
public function getDemographicQuestionId(): int | ||
{ | ||
return $this->getData('demographicQuestionId'); | ||
} | ||
|
||
public function setDemographicQuestionId($demographicQuestionId) | ||
{ | ||
$this->setData('demographicQuestionId', $demographicQuestionId); | ||
} | ||
|
||
public function getLocalizedOptionText() | ||
{ | ||
return $this->getLocalizedData('optionText'); | ||
} | ||
|
||
public function setOptionText(string $text, string $locale) | ||
{ | ||
$this->setData('optionText', $text, $locale); | ||
} | ||
|
||
public function hasInputField(): bool | ||
{ | ||
return $this->getData('hasInputField'); | ||
} | ||
|
||
public function setHasInputField(bool $hasInputField) | ||
{ | ||
$this->setData('hasInputField', $hasInputField); | ||
} | ||
} |
Oops, something went wrong.