Nie wiem czemu mój listener nie reaguje na podanie w formularzu 0 (zera).
Wylogowałem sobie jaką wartość dostaję i mam INTEGER 0 (zero) .
Nie wiem czemu kod nie wchodzi w tego elseif-a pierwszego , tylko w tego drugiego.
Będę wdzięczny za podpowiedź.
services.yaml
App\EventListener\ResultListener: tags: - { name: doctrine.event_listener, event: postUpdate }
class ResultListener { ... public function postUpdate(LifecycleEventArgs $args) { $entity = $args->getEntity(); $em = $args->getEntityManager(); if ($entity instanceof Meet) { $meetId = $entity->getId(); $typeRepo = $em->getRepository(Type::class); $types = $typeRepo->findByMeet($meetId); foreach ($types as $type) { ... elseif ( // typ1 == typ2 i wynik1 == wynik2 i typ1 <> wynik1 ($type->getHostType() == $type->getGuestType()) && ($entity->getHostGoals() == $entity->getGuestGoals()) && ($type->getHostType() <> $entity->getHostGoals()) && (!http://www.php.net/empty($entity->getHostGoals()) && !http://www.php.net/empty($entity->getGuestGoals())) ) { $this->logger->info('Update set 2 points (option 3)'); $type->setNumberOfPoints(2); } elseif ( http://www.php.net/empty($entity->getHostGoals()) || http://www.php.net/empty($entity->getGuestGoals()) ) { $this->logger->info('@@@@@@@@@@ $entity->getHostGoals(): ' . $entity->getHostGoals()); $this->logger->info('@@@@@@@@@@ $entity->getGuestGoals(): ' . $entity->getGuestGoals()); $this->logger->info('@@@@@@@@@@ empty($entity->getHostGoals()): ' . http://www.php.net/empty($entity->getHostGoals())); $this->logger->info('@@@@@@@@@@ empty($entity->getGuestGoals()): ' . http://www.php.net/empty($entity->getGuestGoals())); $this->logger->info('@@@@@@@@@@ gettype($entity->getHostGoals()): ' . http://www.php.net/gettype($entity->getHostGoals())); $this->logger->info('@@@@@@@@@@ NO UPDATE!'); } ...
http://www.php.net/empty($entity->getHostGoals())
!http://www.php.net/empty($entity->getHostGoals())
Nie kumam o co chodzi.
Zmieniłem nieco skrypt abyście mogli u siebie sprawdzić co jest nie tak.
Jak mam zmienne tak ustawione (a więc $hostGoals i $guestGoals równe 0):
$hostType = 1;
$guestType = 1;
$hostGoals = 0;
$guestGoals = 0;
to wypisuje mi komunikat "NO UPDATE!"
jak mam tak ustawione (a więc $hostGoals i $guestGoals równe NULL) to również wyświetla mi "NO UPDATE!"
$hostType = 1;
$guestType = 1;
$hostGoals = null;
$guestGoals = null;
if ( ( ($hostType == $guestType) && ($hostGoals == $guestGoals) && ($hostType <> $hostGoals) && ($hostGoals != null || $guestGoals != null) ) || ( ($hostType == $guestType) && ($hostGoals == 0 && $guestGoals == 0) && ($hostType <> $hostGoals) && ($hostGoals != null || $guestGoals != null) ) ) { http://www.php.net/echo 'Update set 2 points'; } elseif ( $hostGoals == null || $guestGoals == null ) { http://www.php.net/echo 'NO UPDATE!'; }
$hostType = 1; $guestType = 1; $hostGoals = (string) 0; $guestGoals = (string) 0; /* $hostType = 1; $guestType = 1; $hostGoals = null; $guestGoals = null; */ if ( ($hostType == $guestType) && ($hostGoals == $guestGoals) && ($hostType <> $hostGoals) && ($hostGoals != null && $guestGoals != null) ) { http://www.php.net/echo 'Update set 2 points'; } elseif ( $hostGoals == null || $guestGoals == null ) { http://www.php.net/echo 'NO UPDATE!'; }
Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)