protected function _patchEntity($block)
    {
        $this->loadModel('Block.Blocks');
        $data = ['region' => []];

        foreach ($this->request->data() as $column => $value) {
            if ($column == 'region') {
                foreach ($value as $theme => $region) {
                    $tmp = ['theme' => $theme, 'region' => $region];
                    foreach ((array)$block->region as $blockRegion) {
                        if ($blockRegion->theme == $theme) {
                            $tmp['id'] = $blockRegion->id;
                            break;
                        }
                    }
                    $data[$column][] = $tmp;
                }
            } else {
                $data[$column] = $value;
            }
        }

        if ($block->isNew()) {
            $data['handler'] = 'Block\Widget\CustomBlockWidget';
            $block->set('handler', 'Block\Widget\CustomBlockWidget');
        }

        $validator = $block->isCustom() ? 'custom' : 'widget';

        return $this->Blocks->patchEntity($block, $data, ['validate' => $validator, 'entity' => $block]);
    }