public function setActorByName($name, $options) { // Only create an linked Actor if the event or relation type is indicated if (!isset($options['event_type_id']) && !isset($options['relation_type_id'])) { return; } // See if the Actor record already exists, if not create it $criteria = new Criteria(); $criteria->addJoin(QubitActor::ID, QubitActorI18n::ID); $criteria->add(QubitActorI18n::AUTHORIZED_FORM_OF_NAME, $name); if (null === ($actor = QubitActor::getOne($criteria))) { $actor = new QubitActor(); // Make root actor the parent of new actors $actor->parentId = QubitActor::ROOT_ID; $actor->setAuthorizedFormOfName($name); if (isset($options['entity_type_id'])) { // set actor entityTypeId $actor->setEntityTypeId($options['entity_type_id']); } if (isset($options['source'])) { // set actor entityTypeId $actor->setSources($options['source']); } if (isset($options['rules'])) { // set actor entityTypeId $actor->setRules($options['rules']); } if (isset($options['history'])) { $actor->setHistory($options['history']); } $actor->save(); } if (isset($options['event_type_id'])) { // create an event object to link the information object and actor $event = new QubitEvent(); $event->setActorId($actor->id); $event->setTypeId($options['event_type_id']); if (isset($options['dates'])) { $event->setDate($options['dates']); } $this->events[] = $event; } else { if (isset($options['relation_type_id'])) { // only add Actor as name access point if they are not already linked to // an event (i.e. they are not already a "creator", "accumulator", etc.) $existingRelation = false; foreach ($this->events as $existingEvent) { if ($actor->id == $existingEvent->actorId) { $existingRelation = true; break; } } if (!$existingRelation) { $relation = new QubitRelation(); $relation->objectId = $actor->id; $relation->typeId = QubitTerm::NAME_ACCESS_POINT_ID; $this->relationsRelatedBysubjectId[] = $relation; } } } }