original_string: public function delete($object, $meta=null)
      {
          $query = new Query\Criteria();
  
          if (!is_object($object)) {
              throw new \BadMethodCallException("Please use deleteTable()");
          } 
  
          if ($meta) {
              $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
          } else {
              $meta = $this->mapper->getMeta(get_class($object));
          }
  
          if (!$meta->canDelete) {
              throw new Exception("Meta {$meta->id} prohibits delete");
          }
  
          event_before: {
              if (isset($meta->on['beforeDelete'])) {
                  foreach ($meta->on['beforeDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
              }
              if (isset($this->on['beforeDelete'])) {
                  foreach ($this->on['beforeDelete'] as $cb) { $cb($object, $meta); }
              }
          }
  
          $query->where = $meta->getIndexValue($object);
          $return = $this->executeDelete($meta, $query);
  
          event_after: {
              if (isset($meta->on['afterDelete'])) {
                  foreach ($meta->on['afterDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
              }
              if (isset($this->on['afterDelete'])) {
                  foreach ($this->on['afterDelete'] as $cb) { $cb($object, $meta); }
              }
          }
  
          return $return;
      }
code: public function delete($object, $meta=null)
      {
          $query = new Query\Criteria();
  
          if (!is_object($object)) {
              throw new \BadMethodCallException("Please use deleteTable()");
          } 
  
          if ($meta) {
              $meta = !$meta instanceof Meta ? $this->mapper->getMeta($meta) : $meta;
          } else {
              $meta = $this->mapper->getMeta(get_class($object));
          }
  
          if (!$meta->canDelete) {
              throw new Exception("Meta {$meta->id} prohibits delete");
          }
  
          event_before: {
              if (isset($meta->on['beforeDelete'])) {
                  foreach ($meta->on['beforeDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
              }
              if (isset($this->on['beforeDelete'])) {
                  foreach ($this->on['beforeDelete'] as $cb) { $cb($object, $meta); }
              }
          }
  
          $query->where = $meta->getIndexValue($object);
          $return = $this->executeDelete($meta, $query);
  
          event_after: {
              if (isset($meta->on['afterDelete'])) {
                  foreach ($meta->on['afterDelete'] as $cb) { $cb = [$object, $cb]; $cb(); }
              }
              if (isset($this->on['afterDelete'])) {
                  foreach ($this->on['afterDelete'] as $cb) { $cb($object, $meta); }
              }
          }
  
          return $return;
      }
code_tokens: public function delete ( $ object , $ meta = null ) { $ query = new Query \ Criteria ( ) ; if ( ! is_object ( $ object ) ) { throw new \ BadMethodCallException ( "Please use deleteTable()" ) ; } if ( $ meta ) { $ meta = ! $ meta instanceof Meta ? $ this -> mapper -> getMeta ( $ meta ) : $ meta ; } else { $ meta = $ this -> mapper -> getMeta ( get_class ( $ object ) ) ; } if ( ! $ meta -> canDelete ) { throw new Exception ( "Meta {$meta->id} prohibits delete" ) ; } event_before : { if ( isset ( $ meta -> on [ 'beforeDelete' ] ) ) { foreach ( $ meta -> on [ 'beforeDelete' ] as $ cb ) { $ cb = [ $ object , $ cb ] ; $ cb ( ) ; } } if ( isset ( $ this -> on [ 'beforeDelete' ] ) ) { foreach ( $ this -> on [ 'beforeDelete' ] as $ cb ) { $ cb ( $ object , $ meta ) ; } } } $ query -> where = $ meta -> getIndexValue ( $ object ) ; $ return = $ this -> executeDelete ( $ meta , $ query ) ; event_after : { if ( isset ( $ meta -> on [ 'afterDelete' ] ) ) { foreach ( $ meta -> on [ 'afterDelete' ] as $ cb ) { $ cb = [ $ object , $ cb ] ; $ cb ( ) ; } } if ( isset ( $ this -> on [ 'afterDelete' ] ) ) { foreach ( $ this -> on [ 'afterDelete' ] as $ cb ) { $ cb ( $ object , $ meta ) ; } } } return $ return ; }
docstring: Delete an object from the database
  
  delete ( $object )
  delete ( $object, $meta )
  
  @return void
docstring_tokens: Delete an object from the database