Skip to content

Commit

Permalink
Merge pull request #193 from Techbot/192-sql-error-when-flagging-and-…
Browse files Browse the repository at this point in the history
…unflagging-content-entities

fixes #192
  • Loading branch information
Techbot authored May 20, 2024
2 parents 9648425 + 5201df2 commit ef5a7c5
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/EventSubscriber/FlagSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,30 @@ public function onFlag(FlaggingEvent $event)
{
$flagging = $event->getFlagging();
$entity_nid = $flagging->getFlaggable()->id();
$parentMission = $this->getParentMission($entity_nid);
$AllMissionSwitches = $this->getAllMissionSwitches($parentMission);
$FlickedSwitches = $this->player->getFlickedSwitches('switch');
$loopcheck = $this->getLoopCheck($AllMissionSwitches, $FlickedSwitches);
if ($loopcheck){
$this->completeMission($parentMission);

$query = $this->database->query("SELECT flagging.flag_id
FROM flagging WHERE flagging.entity_id = " . $entity_nid);
$result = $query->fetchAll()[0]->flag_id;

///////////////////////////Switch ////////////////////////////////////////
if ($result == 'switch') {
$parentMission = $this->getParentMission($entity_nid);
$AllMissionSwitches = $this->getAllMissionSwitches($parentMission);
$FlickedSwitches = $this->player->getFlickedSwitches('switch');
$loopcheck = $this->getLoopCheck($AllMissionSwitches, $FlickedSwitches);
if ($loopcheck) {
$this->completeMission($parentMission);
}
///////////////////////////Mission Completed ///////////////////////////


}
}

public function getLoopCheck($AllMissionSwitches, $FlickedSwitches)
{
foreach ($AllMissionSwitches as $missionSwitch) {
if (!in_array($missionSwitch, $FlickedSwitches )) {
if (!in_array($missionSwitch, $FlickedSwitches)) {
return false;
}
}
Expand Down

0 comments on commit ef5a7c5

Please sign in to comment.