コード例 #1
0
 /**
  * getId
  * @param  DocumentInterface|array $document
  * @return \MongoId
  */
 public static function getId($document)
 {
     if ($document instanceof DocumentInterface) {
         $mongoId = $document->get_id();
     } elseif (is_array($document) && array_key_exists('_id', $document)) {
         $mongoId = $document['_id'];
     } else {
         throw new \Exception("Document must implement Symflo\\MongoDBODM\\Document\\DocumentInterface or key _id");
     }
     return $mongoId;
 }
コード例 #2
0
 /**
  * isNew
  * @param  DocumentInterface $document
  * @return boolean 
  */
 private function isNew(DocumentInterface $document)
 {
     return (bool) (null === $document->get_id());
 }