ns/admin-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

ns/admin-bundle

Composer 安装命令:

composer require ns/admin-bundle

包简介

Simple framework for generating SF4/5 admin pages.

README 文档

README

Simple framework for generating SF4/5 admin. Allows you to create simple admin pages for managing entities by creating a basic entity, service, repository, and controller class for each entity.

Requires more coding than using an admin generator like Sonata, but allows for much greater flexibility by ditching complex configurators for simple, easily-overridden and extended classes.

##Installation

Require the AdminBundle

composer require ns/admin-bundle

add it to your project bundles.php

NS\AdminBundle\NSAdminBundle::class => ['all' => true],

and require the routing config in your project routes.yaml file

ns_admin:
    resource: "@NSAdminBundle/Resources/config/routing.yml"
    prefix:  /admin

Create your entity, and extend AdminSoftDeletableEntity. Remember to define a __toString() method:

class FooBar extends NS\AdminBundle\Entity\AdminSoftDeletableEntity
{
    public function __toString()
    {
        return 'somestring';
    }
}

You can extend BaseAdminEntity instead, if you don't need soft delete functionality.

Create the entity repository, extend AbstractAdminManagedRepository, and define the constructor:

class FooBarRepository extends NS\AdminBundle\Repository\AbstractAdminManagedRepository
{
    public function __construct(Doctrine\Persistence\ManagerRegistry $registry)
    {
        parent::__construct($registry, FooBar::class);
    }
}

Create the entity service, extend AdminService, and define the getClass() method:

class FooBarService extends NS\AdminBundle\Service\AdminService
{
    public function getClass(): string
    {
        return FooBar::class;
    }
}

Create the edit form for your entity:

class FooBarEditType extends Symfony\Component\Form\AbstractType
{
    public function buildForm()
    {
        //...
    }
}

Create the admin list template for your entity, extending '@NSAdmin/list.html.twig'. Define the following blocks:

  • model_create_icon
  • list_column_headers
  • list_row blocks

If using a 'view' page instead of proceeding straight from the list to the edit form, override view_button, uncomment the button code, and modify as needed, then create the view template and extend '@NSAdmin/view.html.twig'

Create the admin controller for your entity, extending AbstractAdminController and define the following methods:

class FoobarAdminController extends NS\AdminBundle\Controller\AbstractAdminController
{
    public function __construct(FooBarService $admin_service)
    {
        parent::__construct($admin_service);
    }
    
    protected function getEditFormClass(): string
    {
        return FooBarEditType::class;
    }
    
    protected function getListTemplate(): string
    {
        return 'path/to/list.html.twig';
    }

    //Only needed if using a view template:
    protected function getViewTemplate(): string
    {
        return 'path/to/view.html.twig';
    }

}

The built-in routing will automatically route requests to a controller matching the format %Entityclass%AdminController, where %Entityclass% is an initial-caps variant of your entity class name.

{{ path('admin_model_index', {'_admin_model'=>'foobar'}) }}

For our example of FooBar, and admin controller class of FoobarAdminController will be automatically routed to; FooBarAdminController will require manual routing.

To add an entry to the MenuBuilder in ColorAdminBundle, use the parameters ['route' => 'admin_model_index', 'routeParameters' => ['_admin_model' => 'foobar']]

ns/admin-bundle 适用场景与选型建议

ns/admin-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 165 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 06 月 24 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 ns/admin-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 ns/admin-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 ns/admin-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2020-06-24