Doctrine\ODM\OrientDB\Mapper\ClusterMap::identifyClass PHP Метод

identifyClass() публичный Метод

Tries to identify the class of an rid by matching it against the clusters in the database
public identifyClass ( Rid $rid ) : string
$rid Doctrine\ODM\OrientDB\Types\Rid
Результат string
    public function identifyClass(Rid $rid)
    {
        $map = $this->getMap();
        $splitRid = explode(':', ltrim($rid->getValue(), '#'));
        $clusterId = $splitRid[0];
        foreach ($map as $class => $clusters) {
            if (in_array($clusterId, $clusters)) {
                return $class;
            }
        }
        throw MappingException::noClusterForRid($rid);
    }

Usage Example

Пример #1
0
 /**
  * @expectedException \Doctrine\ODM\OrientDB\Mapper\MappingException
  */
 public function testIdentifyClassNotFound()
 {
     $binding = $this->createBinding();
     $cache = $this->createCache(true);
     $clusterMap = new ClusterMap($binding, $cache);
     $clusterMap->identifyClass(new Rid('10:0'));
 }