/** * Register a new custom interaction * * @param string $qtiClass * @param string $phpClass * @throws common_exception_Error */ public function set($qtiClass, $phpClass) { if (!class_exists($phpClass)) { throw new common_exception_Error('Custom interaction class ' . $phpClass . ' not found'); } if (!is_subclass_of($phpClass, $this->getInteractionClass())) { throw new common_exception_Error('Class ' . $phpClass . ' not a subclass of ' . $this->getInteractionClass()); } parent::set($qtiClass, $phpClass); }
/** * @param PortableElementObject $object * @throws PortableElementNotFoundException * @throws PortableElementVersionIncompatibilityException * @throws PortableElementInconsistencyModelException */ public function delete(PortableElementObject $object) { $portableElements = $this->getAllVersions($object->getTypeIdentifier()); if (!isset($portableElements[$object->getVersion()])) { throw new PortableElementVersionIncompatibilityException($this->getModel()->getId() . ' with identifier ' . $object->getTypeIdentifier() . ' found, ' . 'but version ' . $object->getVersion() . 'does not exist. Deletion impossible.'); } unset($portableElements[$object->getVersion()]); if (empty($portableElements)) { parent::remove($object->getTypeIdentifier()); } else { parent::set($object->getTypeIdentifier(), $portableElements); } }