Exemplo n.º 1
0
 public function defineFact($data)
 {
     $ret = array();
     if (is_array($data)) {
         if (!isset($data['__template__'])) {
             // This is a static fact
             $name = array_shift($data);
             $ret[] = '(' . $name;
             foreach ($data as $d) {
                 $ret[] = $this->translate($d);
             }
         } else {
             return $this->defineFact((object) $data);
         }
     } else {
         $obj = $data;
         $name = get_class($obj);
         $reflection = new ReflectionAnnotatedClass($name);
         if (isset($obj->__template__)) {
             $name = $obj->__template__;
         }
         $ret[] = '(' . $name;
         foreach ($obj as $key => $value) {
             if (strpos($key, '_') === 0) {
                 // Skip _ variables
                 continue;
             }
             $ret[] = '(' . $key;
             if ($reflection->hasProperty($key)) {
                 if ($reflection->getProperty($key)->hasAnnotation('ClipsSymbol')) {
                     $value = new ClipsSymbol($value);
                 }
             }
             $ret[] = $this->translate($value) . ')';
         }
     }
     return implode(' ', $ret) . ')';
 }