public static function load($yaml, $class, $dir) { try { $em = DoctrineBootstrap::getEntityManager(); $userId = $userId = wp_get_current_user()->ID; $ward = WardCRUD::getWardForUser($userId); $user = $em->find("\\Hospitalplugin\\Entities\\User", $userId); if (!empty($_POST)) { $args = $_POST; $i = new $class($args); $i->setWard($ward); $i->setUser($user); $em->persist($i); $em->flush(); } else { $object = \Hospitalplugin\utils\YAML2Object::getObject($yaml); echo PLTwig::load($dir)->render('form.twig', array('infections' => $object)); } } catch (Exception $e) { echo "ERR: " . $e; } }
/** */ public static function getWardIdForUser($userId) { return WardCRUD::getWardForUser($userId)->getId(); }