src/wcmf/lib/model/Node.php
protected function loadRelations(array $roles, $buildDepth=BuildDepth::SINGLE) {
    $oldState = $this->getState();
    foreach ($roles as $curRole) {
      if (isset($this->relationStates[$curRole]) &&
              $this->relationStates[$curRole] != self::RELATION_STATE_LOADED) {
        $relatives = [];

        // resolve proxies if the relation is already initialized
        if ($this->relationStates[$curRole] == self::RELATION_STATE_INITIALIZED) {
          $proxies = $this->getValue($curRole);
          if (is_array($proxies)) {
            foreach ($proxies as $curRelative) {
              if ($curRelative instanceof PersistentObjectProxy) {
                // resolve proxies
                $curRelative->resolve($buildDepth);
                $relatives[] = $curRelative->getRealSubject();
              }
              else {
                $relatives[] = $curRelative;
              }
            }
          }
        }
        // otherwise load the objects directly
        else {
          $mapper = $this->getMapper();
          $allRelatives = $mapper->loadRelation([$this], $curRole, $buildDepth);
          $oidStr = $this->getOID()->__toString();
          $relatives = isset($allRelatives[$oidStr]) ? $allRelatives[$oidStr] : null;
          $relDesc = $mapper->getRelation($curRole);
          if (!$relDesc->isMultiValued()) {
            $relatives = $relatives != null ? $relatives[0] : null;
          }
        }
        $this->setValueInternal($curRole, $relatives);
        $this->relationStates[$curRole] = self::RELATION_STATE_LOADED;
      }
    }
    $this->setState($oldState);
  }
protected function loadRelations(array $roles, $buildDepth=BuildDepth::SINGLE) {
    $oldState = $this->getState();
    foreach ($roles as $curRole) {
      if (isset($this->relationStates[$curRole]) &&
              $this->relationStates[$curRole] != self::RELATION_STATE_LOADED) {
        $relatives = [];

        // resolve proxies if the relation is already initialized
        if ($this->relationStates[$curRole] == self::RELATION_STATE_INITIALIZED) {
          $proxies = $this->getValue($curRole);
          if (is_array($proxies)) {
            foreach ($proxies as $curRelative) {
              if ($curRelative instanceof PersistentObjectProxy) {
                // resolve proxies
                $curRelative->resolve($buildDepth);
                $relatives[] = $curRelative->getRealSubject();
              }
              else {
                $relatives[] = $curRelative;
              }
            }
          }
        }
        // otherwise load the objects directly
        else {
          $mapper = $this->getMapper();
          $allRelatives = $mapper->loadRelation([$this], $curRole, $buildDepth);
          $oidStr = $this->getOID()->__toString();
          $relatives = isset($allRelatives[$oidStr]) ? $allRelatives[$oidStr] : null;
          $relDesc = $mapper->getRelation($curRole);
          if (!$relDesc->isMultiValued()) {
            $relatives = $relatives != null ? $relatives[0] : null;
          }
        }
        $this->setValueInternal($curRole, $relatives);
        $this->relationStates[$curRole] = self::RELATION_STATE_LOADED;
      }
    }
    $this->setState($oldState);
  }
protected function loadRelations ( array $ roles , $ buildDepth = BuildDepth :: SINGLE ) { $ oldState = $ this -> getState ( ) ; foreach ( $ roles as $ curRole ) { if ( isset ( $ this -> relationStates [ $ curRole ] ) && $ this -> relationStates [ $ curRole ] != self :: RELATION_STATE_LOADED ) { $ relatives = [ ] ; // resolve proxies if the relation is already initialized if ( $ this -> relationStates [ $ curRole ] == self :: RELATION_STATE_INITIALIZED ) { $ proxies = $ this -> getValue ( $ curRole ) ; if ( is_array ( $ proxies ) ) { foreach ( $ proxies as $ curRelative ) { if ( $ curRelative instanceof PersistentObjectProxy ) { // resolve proxies $ curRelative -> resolve ( $ buildDepth ) ; $ relatives [ ] = $ curRelative -> getRealSubject ( ) ; } else { $ relatives [ ] = $ curRelative ; } } } } // otherwise load the objects directly else { $ mapper = $ this -> getMapper ( ) ; $ allRelatives = $ mapper -> loadRelation ( [ $ this ] , $ curRole , $ buildDepth ) ; $ oidStr = $ this -> getOID ( ) -> __toString ( ) ; $ relatives = isset ( $ allRelatives [ $ oidStr ] ) ? $ allRelatives [ $ oidStr ] : null ; $ relDesc = $ mapper -> getRelation ( $ curRole ) ; if ( ! $ relDesc -> isMultiValued ( ) ) { $ relatives = $ relatives != null ? $ relatives [ 0 ] : null ; } } $ this -> setValueInternal ( $ curRole , $ relatives ) ; $ this -> relationStates [ $ curRole ] = self :: RELATION_STATE_LOADED ; } } $ this -> setState ( $ oldState ) ; }
Load all objects in the given set of relations
@param $roles An array of relation (=role) names
@param $buildDepth One of the BUILDDEPTH constants or a number describing the number of generations to build
(default: _BuildDepth::SINGLE_)
Load all objects in the given set of relations