protected function _actionEdit(AnCommandContext $context)
    {
        $entity = parent::_actionEdit($context);

        if ($entity->isPortraitable() && AnRequest::has('files.portrait')) {
            $file = AnRequest::get('files.portrait', 'raw');

            if ($this->bellowSizeLimit($file) && $file['error'] == 0) {
                $this->getItem()->setPortrait(array(
                    'url' => $file['tmp_name'],
                    'mimetype' => $file['type']
                ));
            } else {
                $this->getItem()->removePortraitImage();
            }
        }

        if ($entity->save($context)) {
            dispatch_plugin('profile.onSave', array(
                'actor' => $entity,
                'data' => $context->data,
                ));
        }

        return $entity;
    }