setUrl($_POST['emote_url']) ->setHierarchy($_POST['emote_hierarchy']) ->setOrder($_POST['emote_order']) ->save(); if($isNew && !$emoteInfo->hasId()) throw new \Exception("SOMETHING HAPPENED"); $setStrings = array_column($emoteInfo->getStrings(), 'emote_string'); $applyStrings = explode(' ', mb_strtolower($_POST['emote_strings'])); $removeStrings = []; foreach($setStrings as $string) { if(!in_array($string, $applyStrings)) { $removeStrings[] = $string; } } $setStrings = array_diff($setStrings, $removeStrings); foreach($applyStrings as $string) { if(!in_array($string, $setStrings)) { $setStrings[] = $string; } } foreach($removeStrings as $string) $emoteInfo->removeString($string); foreach($setStrings as $string) $emoteInfo->addString($string); } Template::render('manage.general.emoticon', [ 'emote_info' => $emoteInfo, ]);