Sokil\Mongo\Document::reset PHP Method

reset() public method

Reset all data passed to object in run-time, like events, behaviors, data modifications, etc. to the state just after open or save document
public reset ( ) : Document
return Document
    public function reset()
    {
        // reset structure
        parent::reset();
        // reset errors
        $this->clearErrors();
        // reset behaviors
        $this->clearBehaviors();
        // init delegates
        $this->initDelegates();
        return $this;
    }

Usage Example

Example #1
0
 public function insert(array $document)
 {
     if (!$this->isValidationEnabled) {
         self::$validator->merge($document);
         $isValid = self::$validator->isValid();
         self::$validator->reset();
         if (!$isValid) {
             throw new InvalidDocumentException('Document is invalid on batch insert');
         }
     }
     $this->add($document);
     return $this;
 }