isMultiIndex() public static method

Check if the given relationship type contains multiple values
public static isMultiIndex ( RelationshipType $relationship_type ) : boolean
$relationship_type RelationshipType
return boolean
Exemplo n.º 1
0
 /**
  * Get an array containing an array of foreign entities to remove the local entity from, and an array of foreign
  * entities to add the local entity to and an array of entities which remain the same in the relationship
  *
  * @param string          $key          Local relationship key
  * @param Relationship    $relationship Relationship in question
  * @param object|object[] $new_value    New local value containing foreign entities
  * @return array
  */
 private function getRelationshipDeltas($key, Relationship $relationship, $new_value)
 {
     $this->getDriver()->debugLog('Getting inverse relationship deltas: ' . $key);
     if (RelationshipType::isMultiIndex($relationship->getRelationshipType())) {
         return $this->getRelationshipDeltasMulti($key, $new_value);
     } else {
         return $this->getRelationshipDeltasSingle($key, $new_value);
     }
 }
Exemplo n.º 2
0
 /**
  * Hydrate a relationship
  *
  * @param Relationship $relative
  * @return $this
  */
 public function hydrateRelative(Relationship $relative)
 {
     $this->entity_manager->getDriver()->debugLog("Hydrating relative for " . $this->metadata->getTableName() . "[" . $this->getReader()->getId() . "]::" . $relative->getName());
     $setter = $relative->getSetter();
     $key = $this->entity_manager->getKeyScheme()->getRelationshipKey($relative, $this->entity_manager->getMapper()->getEntityMetadata($relative->getSource())->getTableName(), $this->entity_manager->getMapper()->getEntityMetadata($relative->getTarget())->getTableName(), $this->getReader()->getId());
     if (RelationshipType::isMultiIndex($relative->getRelationshipType())) {
         $items = [];
         $ids = $this->entity_manager->getDriver()->getMultiValueIndex($key);
         foreach ($ids as $id) {
             $items[] = $this->entity_manager->retrieveEntityOrNew($relative->getTarget(), $id);
         }
         $this->proxy->{$setter}($items);
     } else {
         $id = $this->entity_manager->getDriver()->getSingleValueIndex($key);
         if ($id) {
             $this->proxy->{$setter}($this->entity_manager->retrieve($relative->getTarget(), $id));
         }
     }
     return $this;
 }