Exemplo n.º 1
0
 public static function getObject($yamlFile)
 {
     if (YAML2Object::$object == null) {
         $wardsFileContents = file_get_contents($yamlFile);
         YAML2Object::$object = Yaml::parse($wardsFileContents);
     }
     return YAML2Object::$object;
 }
Exemplo n.º 2
0
 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;
     }
 }