Skip to content

Commit

Permalink
php version, coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-stanek committed Dec 27, 2017
1 parent a178837 commit 4b1d45c
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: php

php: 5.6
php: 7.1

before_install:
- composer self-update
Expand Down
4 changes: 2 additions & 2 deletions app/model/User/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,8 @@ public function removeRole(Role $role)
public function isInRole(Role $role)
{
return $this->roles->filter(function ($item) use ($role) {
return $item == $role;
})->count() != 0;
return $item == $role;
})->count() != 0;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion app/model/User/VariableSymbol.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ public function setVariableSymbol(string $variableSymbol)
{
$this->variableSymbol = $variableSymbol;
}
}
}
37 changes: 23 additions & 14 deletions app/services/ApplicationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use App\Model\Mailing\Template;
use App\Model\Mailing\TemplateVariable;
use App\Model\Settings\Settings;
use App\Model\Settings\SettingsException;
use App\Model\Settings\SettingsRepository;
use App\Model\Structure\DiscountRepository;
use App\Model\Structure\Subevent;
Expand All @@ -26,8 +25,6 @@
use Doctrine\Common\Collections\Collection;
use Kdyby\Translation\Translator;
use Nette;
use Ublaboo\Mailing\Exception\MailingException;
use Ublaboo\Mailing\Exception\MailingMailCreationException;


/**
Expand Down Expand Up @@ -170,8 +167,12 @@ public function updateRoles(User $user, Collection $roles, ?User $createdBy, boo

//pokud se role nezmenily, nic se neprovede
if ($roles->count() == $oldRoles->count()) {
$rolesArray = $roles->map(function (Role $role) {return $role->getId();})->toArray();
$oldRolesArray = $oldRoles->map(function (Role $role) {return $role->getId();})->toArray();
$rolesArray = $roles->map(function (Role $role) {
return $role->getId();
})->toArray();
$oldRolesArray = $oldRoles->map(function (Role $role) {
return $role->getId();
})->toArray();

if (array_diff($rolesArray, $oldRolesArray) === array_diff($oldRolesArray, $rolesArray))
return;
Expand All @@ -190,8 +191,8 @@ public function updateRoles(User $user, Collection $roles, ?User $createdBy, boo
})) {
$user->setApproved(TRUE);
} elseif (!$approve && $roles->exists(function (int $key, Role $role) use ($oldRoles) {
return !$role->isApprovedAfterRegistration() && !$oldRoles->contains($role);
})) {
return !$role->isApprovedAfterRegistration() && !$oldRoles->contains($role);
})) {
$user->setApproved(FALSE);
}

Expand Down Expand Up @@ -236,7 +237,9 @@ public function updateRoles(User $user, Collection $roles, ?User $createdBy, boo

$this->mailService->sendMailFromTemplate($user, '', Template::ROLES_CHANGED, [
TemplateVariable::SEMINAR_NAME => $this->settingsRepository->getValue(Settings::SEMINAR_NAME),
TemplateVariable::USERS_ROLES => implode(', ', $roles->map(function (Role $role) {return $role->getName();})->toArray())
TemplateVariable::USERS_ROLES => implode(', ', $roles->map(function (Role $role) {
return $role->getName();
})->toArray())
]);
}

Expand Down Expand Up @@ -306,8 +309,12 @@ public function updateSubeventsApplication(SubeventsApplication $application, Co

//pokud se podakce nezmenily, nic se neprovede
if ($subevents->count() == $oldSubevents->count()) {
$subeventsArray = $subevents->map(function (Subevent $subevent) {return $subevent->getId();})->toArray();
$oldSubeventsArray = $oldSubevents->map(function (Subevent $subevent) {return $subevent->getId();})->toArray();
$subeventsArray = $subevents->map(function (Subevent $subevent) {
return $subevent->getId();
})->toArray();
$oldSubeventsArray = $oldSubevents->map(function (Subevent $subevent) {
return $subevent->getId();
})->toArray();

if (array_diff($subeventsArray, $oldSubeventsArray) === array_diff($oldSubeventsArray, $subeventsArray))
return;
Expand Down Expand Up @@ -396,8 +403,10 @@ public function updatePayment(Application $application, string $variableSymbol,
&& $maturityDate == $oldMaturityDate)
return;

$this->applicationRepository->getEntityManager()->transactional(function ($em) use ($application,
$variableSymbol, $paymentMethod, $paymentDate, $incomeProofPrintedDate, $maturityDate, $createdBy) {
$this->applicationRepository->getEntityManager()->transactional(function ($em) use (
$application,
$variableSymbol, $paymentMethod, $paymentDate, $incomeProofPrintedDate, $maturityDate, $createdBy
) {
$user = $application->getUser();

$newApplication = clone $application;
Expand Down Expand Up @@ -449,8 +458,8 @@ private function createRolesApplication(User $user, Collection $roles, User $cre
{
$user->setApproved(TRUE);
if (!$approve && $roles->exists(function (int $key, Role $role) {
return !$role->isApprovedAfterRegistration();
}))
return !$role->isApprovedAfterRegistration();
}))
$user->setApproved(FALSE);

$user->setRoles($roles);
Expand Down
2 changes: 1 addition & 1 deletion app/utils/Validators.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,4 @@ public function validateSubeventsRegistered(Collection $selectedSubevents, User
}
return TRUE;
}
}
}

0 comments on commit 4b1d45c

Please sign in to comment.