Skip to content

Commit

Permalink
Better naming of variables / methods
Browse files Browse the repository at this point in the history
  • Loading branch information
CatoTH committed Dec 25, 2024
1 parent e8ca5cc commit 8bf3d37
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions models/db/ISupporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ public static function createInitiator(Consultation $consultation, SupportBase $
$supporter->name = trim($user->name);
$supporter->organization = $user->organization !== null ? trim($user->organization) : null;
$supporter->contactEmail = $user->email !== null ? trim($user->email) : null;
if ($settings->initiatorCanBePerson && $settings->canSupportAsPerson($consultation)) {
if ($settings->initiatorCanBePerson && $settings->canInitiateAsPerson($consultation)) {
$supporter->personType = static::PERSON_NATURAL;
} elseif ($settings->initiatorCanBeOrganization && $settings->canSupportAsOrganization($consultation)) {
} elseif ($settings->initiatorCanBeOrganization && $settings->canInitiateAsOrganization($consultation)) {
$supporter->personType = static::PERSON_ORGANIZATION;
$supporter->contactName = $user->name;
} else {
Expand Down
4 changes: 2 additions & 2 deletions models/settings/InitiatorForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function setInitiatorPersonPolicyObject(IPolicy $policy): void
$this->initiatorPersonPolicy = $policy->serializeInstanceForDb();
}

public function canSupportAsPerson(\app\models\db\Consultation $consultation): bool
public function canInitiateAsPerson(\app\models\db\Consultation $consultation): bool
{
return $this->initiatorCanBePerson && $this->getInitiatorPersonPolicy($consultation)->checkCurrUser(false);
}
Expand All @@ -88,7 +88,7 @@ public function setInitiatorOrganizationPolicyObject(IPolicy $policy): void
$this->initiatorOrganizationPolicy = $policy->serializeInstanceForDb();
}

public function canSupportAsOrganization(\app\models\db\Consultation $consultation): bool
public function canInitiateAsOrganization(\app\models\db\Consultation $consultation): bool
{
return $this->initiatorCanBeOrganization && $this->getInitiatorOrganizationPolicy($consultation)->checkCurrUser(false);
}
Expand Down
4 changes: 2 additions & 2 deletions models/supportTypes/SupportBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ public function validateMotion(): void
} else {
$personType = intval($initiator['personType']);
}
if ($personType === ISupporter::PERSON_NATURAL && !$settings->canSupportAsPerson($this->motionType->getConsultation())) {
if ($personType === ISupporter::PERSON_NATURAL && !$settings->canInitiateAsPerson($this->motionType->getConsultation())) {
$errors[] = \Yii::t('motion', 'err_invalid_person_type');
}
if ($personType === ISupporter::PERSON_ORGANIZATION && !$settings->canSupportAsOrganization($this->motionType->getConsultation())) {
if ($personType === ISupporter::PERSON_ORGANIZATION && !$settings->canInitiateAsOrganization($this->motionType->getConsultation())) {
$errors[] = \Yii::t('motion', 'err_invalid_person_type');
}
if ($personType === ISupporter::PERSON_ORGANIZATION &&
Expand Down
18 changes: 9 additions & 9 deletions views/shared/create_initiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@

$currentUser = \app\models\db\User::getCurrentUser();

$canSupportAsPerson = $settings->canSupportAsPerson($consultation);
$canSupportAsOrganization = $settings->canSupportAsOrganization($consultation);
$canInitiateAsPerson = $settings->canInitiateAsPerson($consultation);
$canInitiateAsOrganization = $settings->canInitiateAsOrganization($consultation);

echo '<fieldset class="supporterForm supporterFormStd" data-antragsgruen-widget="frontend/InitiatorForm"
data-settings="' . Html::encode(json_encode($settings)) . '"
Expand Down Expand Up @@ -76,7 +76,7 @@
}
}

if ($canSupportAsPerson && $canSupportAsOrganization) {
if ($canInitiateAsPerson && $canInitiateAsOrganization) {
?>
<div class="personTypeSelector stdTwoCols">
<div class="leftColumn"><?= Yii::t('initiator', 'iAmA') ?></div>
Expand Down Expand Up @@ -106,13 +106,13 @@
<?php
}

if (!$canSupportAsPerson && !$canSupportAsOrganization) {
if (!$canInitiateAsPerson && !$canInitiateAsOrganization) {
echo '<div class="alert alert-danger noProposerTypeFoundError"><p>' . Yii::t('motion', 'err_neither_person_orga') . '</p></div>';
}
if ($canSupportAsPerson && !$canSupportAsOrganization) {
if ($canInitiateAsPerson && !$canInitiateAsOrganization) {
echo Html::hiddenInput('Initiator[personType]', ISupporter::PERSON_NATURAL, ['id' => 'personTypeHidden']);
}
if (!$canSupportAsPerson && $canSupportAsOrganization) {
if (!$canInitiateAsPerson && $canInitiateAsOrganization) {
echo Html::hiddenInput('Initiator[personType]', ISupporter::PERSON_ORGANIZATION, ['id' => 'personTypeHidden']);
$policy = $settings->getInitiatorPersonPolicy($consultation);
if ($settings->initiatorCanBePerson && is_a($policy, \app\models\policies\UserGroups::class)) {
Expand Down Expand Up @@ -192,7 +192,7 @@
</div>
<?php

if ($settings->hasOrganizations && $canSupportAsPerson) {
if ($settings->hasOrganizations && $canInitiateAsPerson) {
$preOrga = $initiator->organization;
?>
<div class="stdTwoCols organizationRow">
Expand All @@ -219,7 +219,7 @@
<?php
}

if ($settings->hasResolutionDate !== InitiatorForm::CONTACT_NONE && $canSupportAsOrganization) {
if ($settings->hasResolutionDate !== InitiatorForm::CONTACT_NONE && $canInitiateAsOrganization) {
$preResolution = Tools::dateSql2bootstrapdate($initiator->resolutionDate);
?>
<div class="stdTwoCols resolutionRow">
Expand All @@ -237,7 +237,7 @@
<?php
}

if ($settings->contactGender !== InitiatorForm::CONTACT_NONE && $canSupportAsPerson) {
if ($settings->contactGender !== InitiatorForm::CONTACT_NONE && $canInitiateAsPerson) {
$genderChoices = array_merge(['' => ''], SupportBase::getGenderSelection());
?>
<div class="stdTwoCols genderRow">
Expand Down

0 comments on commit 8bf3d37

Please sign in to comment.