public function delete($conditions)
    {
        if ($conditions instanceof \Traversable) {
            $conditions = iterator_to_array($conditions);
        } elseif (is_object($conditions)) {
            $conditions = get_object_vars($conditions);
        }

        if (!is_array($conditions)) {
            // Load by primary key.
            $keyCount = count($this->getKeyName(true));

            if ($keyCount) {
                if ($keyCount > 1) {
                    throw new \InvalidArgumentException(
                        'Table has multiple primary keys specified, only one primary key value provided.'
                    );
                }

                $conditions = [$this->getKeyName() => $conditions];
            } else {
                throw new \RuntimeException('No primary keys defined.');
            }
        }

        // Event
        $this->triggerEvent(
            'onBefore' . ucfirst(__FUNCTION__),
            [
                'conditions' => &$conditions,
            ]
        );

        $result = $this->doDelete($conditions);

        // Event
        $this->triggerEvent(
            'onAfter' . ucfirst(__FUNCTION__),
            [
                'result' => &$result,
            ]
        );

        return $result;
    }