$ex_object->_event_name = $event_name;
// Layout grid
if ($ex_object->_ref_ex_class->pixel_positionning && !$only_filled) {
    $grid = null;
    $out_of_grid = null;
    $groups = $ex_object->_ref_ex_class->getPixelGrid();
} else {
    list($grid, $out_of_grid, $groups) = $ex_object->_ref_ex_class->getGrid();
}
if ($ex_object_id || $ex_object->_id) {
    $ex_object->load($ex_object_id);
} else {
    $ex_object->group_id = CGroups::loadCurrent()->_id;
}
// Host and reference objects
$ex_object->setObject($object);
if (!$ex_object->_id) {
    if (!$ex_object->reference_id && !$ex_object->reference_class) {
        $reference = $ex_class_event->resolveReferenceObject($object, 1);
        $ex_object->setReferenceObject_1($reference);
    }
    if (!$ex_object->reference2_id && !$ex_object->reference2_class) {
        $reference = $ex_class_event->resolveReferenceObject($object, 2);
        $ex_object->setReferenceObject_2($reference);
    }
} else {
    $ex_object->loadRefsLinks();
}
$ex_object->loadRefGroup();
// loadAllFwdRefs ne marche pas bien (a cause de la clé primaire)
foreach ($ex_object->_specs as $_field => $_spec) {
 /**
  * Check if we can create a new instance of the ExObject
  *
  * @param CMbObject $host Host object
  *
  * @return bool
  */
 function canCreateNew(CMbObject $host)
 {
     switch ($this->unicity) {
         default:
         case "no":
             return true;
         case "host":
             // Host
             $ex_object = new CExObject($this->_id);
             $ex_object->setObject($host);
             if ($ex_object->countMatchingList() > 0) {
                 return false;
             }
             /*
                     // Reférence 1
                     $ex_object = new CExObject($this->_id);
                     $ex_object->setReferenceObject_1($host);
                     
                     if ($ex_object->countMatchingList() > 0) {
                       return false;
                     }
                     
                     // Référence 2
                     $ex_object = new CExObject($this->_id);
                     $ex_object->setReferenceObject_2($host);
                     
                     if ($ex_object->countMatchingList() > 0) {
                       return false;
                     }*/
     }
     return true;
 }
 /**
  * Load CExObjects and inject the CExObject instance into $ex_object
  *
  * @param CMbObject $object     The host object
  * @param null      &$ex_object The variable where the CExObject will be injected
  *
  * @return CExObject[]
  */
 function loadExObjects(CMbObject $object, &$ex_object = null)
 {
     $ex_object = new CExObject($this->_id);
     $ex_object->setObject($object);
     /** @var CExObject[] $list */
     $list = $ex_object->loadMatchingList();
     foreach ($list as $_object) {
         $_object->_ex_class_id = $this->_id;
         $_object->setExClass();
     }
     return $list;
 }