Webiny\Component\Entity\AbstractEntity::exists PHP Method

exists() public method

Is this entity already saved?
public exists ( ) : boolean
return boolean
    public function exists()
    {
        return $this->id !== null;
    }

Usage Example

コード例 #1
0
 private function cleanUpRecords($newValues)
 {
     if (!$this->parent->exists()) {
         return;
     }
     $newIds = [];
     foreach ($newValues as $nv) {
         if (isset($nv['id']) && $nv['id'] != '') {
             $newIds[] = Entity::getInstance()->getDatabase()->id($nv['id']);
         }
     }
     $attrValues = $this->getValue();
     foreach ($attrValues as $r) {
         if (!in_array($r->id, $newIds)) {
             $r->delete();
         }
     }
 }
All Usage Examples Of Webiny\Component\Entity\AbstractEntity::exists