Doctrine\ODM\MongoDB\MongoDBException::cannotPersistMappedSuperclass PHP Method

cannotPersistMappedSuperclass() public static method

public static cannotPersistMappedSuperclass ( string $className ) : MongoDBException
$className string
return MongoDBException
    public static function cannotPersistMappedSuperclass($className)
    {
        return new self('Cannot persist an embedded document, aggregation result document or mapped superclass ' . $className);
    }

Usage Example

Example #1
0
 /**
  * Persists a document as part of the current unit of work.
  *
  * @param object $document The document to persist.
  * @throws MongoDBException If trying to persist MappedSuperclass.
  * @throws \InvalidArgumentException If there is something wrong with document's identifier.
  */
 public function persist($document)
 {
     $class = $this->dm->getClassMetadata(get_class($document));
     if ($class->isMappedSuperclass) {
         throw MongoDBException::cannotPersistMappedSuperclass($class->name);
     }
     $visited = array();
     $this->doPersist($document, $visited);
 }