定制 hostnet/form-handler-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hostnet/form-handler-bundle

最新稳定版本:2.0.1

Composer 安装命令:

composer require hostnet/form-handler-bundle

包简介

Hostnet form handler to provide an easier way of handling forms in actions

README 文档

README

The form handlers are designed to enhance the developer experience (DX) when working with Symfony forms. It makes the controllers simpler by moving the form success and failure flows to a separate class.

class YourController extends Controller
{
    public function formAction(Request $request, MyEntityUser $user)
    {
        $handler = $this->get('hostnet.form_handler.factory')->create(MyFormHandler::class);

        if (($response = $handler->handle($request, new MyFormData())) instanceof RedirectResponse) {
            return $response;
        }

        // regular or in-valid flow
        return $this->render->renderView('/your/form.html.twig', [
            'form' => $handler->getForm()->createView()
        ]);
    }
}

By extracting the success - and if available, the failure - flows, you reduce the amount of code in your controllers, which in turn, achieves slim controllers. The definition of a controller is according to Symfony: "a PHP function you create that reads information from the Symfony's Request object and creates and returns a Response object".

Installation

Documentation

License

The hostnet/form-handler-bundle is licensed under the MIT License, meaning you can reuse the code within proprietary software provided that all copies of the licensed software include a copy of the MIT License terms and the copyright notice.

Get in touch

统计信息

  • 总下载量: 162.05k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 71
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 71
  • Watchers: 15
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-05-23