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

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

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

sidus/admin-bundle

Composer 安装命令:

composer require sidus/admin-bundle

包简介

Simple and extendable action-based admin management with built-in routing generation

关键字:

README 文档

README

The missing link between the controllers, the router component, the forms and the entities.

Example in twig:

<a href="{{ admin_path('post', 'list') }}">List</a>
<a href="{{ entity_path(entity, 'edit') }}">Edit</a>

Warning

This bundle requires the security component of Symfony, it will enforce access to any entity using the voter. This bundle is easier to use with Doctrine, it can still be used for non-doctrine entities.

Configuration

Simple example:

sidus_admin:
    configurations:
        post:
            entity: MyBundle\Entity\Post # Class name of your entity
            prefix: /post # Routing prefix
            controller_pattern:
                - 'Sidus\AdminBundle\Action\{{Action}}Action' # Full controller reference
            template_pattern:
                - '@SidusAdmin/Action/{{action}}.{{format}}.twig'
            actions:
                list:
                    path:     /list # Routing path
                edit:
                    path:     /edit/{id}
                    form_type: MyBundle\Form\Type\EditPostType # Form type to use in controller

Configuration reference

All values are the default one except when specified otherwise.

sidus_admin:
    admin_class: Sidus\AdminBundle\Model\Admin
    action_class: Sidus\AdminBundle\Model\Action
    configurations:
        <admin_code>:
            entity: ~ # REQUIRED: The fully qualified class name of the entity (or the Doctrine's shorter reference)
            prefix: ~ # REQUIRED: Routing prefix for all actions
            controller_pattern: [] # The controller reference that will be used to generate routing
            # Available interpolation variables are:
            # {{admin}} lowercase first letter admin code
            # {{Admin}} uppercase first letter admin code
            # {{action}} lowercase first letter action code
            # {{Action}} uppercase first letter action code
            # If you don't set any controller_pattern you will need to set the _controller attribute in the defaults of
            # each action.
            template_pattern: [] # The template pattern
            action_class: # Defaults to main action_class
            options: {} # You can put anything here
            permissions: [ ROLE_USER ] # List of permissions required to access the whole admin
            actions:
                <action_code>: # The action code needs to match the controller's method name without the "Action" suffix
                    form_type: ~ # Useful in combination with AbstractAdminController::getForm($request, $data)
                    form_options: ~ # Static form options
                    template: ~ # Computed by the TemplateResolver using template_pattern if null
                    permissions: [ ROLE_USER ] # List of permissions required to access the action
                    # All the following options are used to generate the route for the routing component
                    # See Symfony doc here: http://symfony.com/doc/current/routing.html
                    path: ~ # REQUIRED
                    defaults: ~
                    requirements: ~
                    options: ~
                    host: ~
                    schemes: ~
                    methods: ~
                    condition: ~

Usage

Generating routes

When routing to an entity, the AdminRouter component will try to fetch missing route parameters from the routing context and then from the entity itself, meaning if you name your route parameters accordingly to your entity properties, you won't need to pass any parameter manually.

PHP

<?php
/** @var $adminRouter AdminRouter */
use Sidus\AdminBundle\Routing\AdminRouter;$adminRouter->generateAdminPath('post', 'list');
$adminRouter->generateEntityPath($entity, 'edit');

When dealing with multiple admins for a single class, you can use this function instead:

<?php
/** @var $adminRouter AdminRouter */
use Sidus\AdminBundle\Routing\AdminRouter;$adminRouter->generateAdminEntityPath('post', $entity, 'edit');

Twig

<a href="{{ admin_path('post', 'list') }}">List</a>
<a href="{{ entity_path(entity, 'edit') }}">Edit</a>

When dealing with multiple admins for a single class, you can use this function instead:

<a href="{{ admin_entity_path('post', entity, 'edit') }}">Edit</a>

Additional optional arguments

For each method, you can pass additional route parameters in the argument just after the action name, you can also set the UrlGeneratorInterface reference type (absolute, relative...).

<?php
/** @var $adminRouter AdminRouter */
use Sidus\AdminBundle\Routing\AdminRouter;use Symfony\Component\Routing\Generator\UrlGeneratorInterface;$adminRouter->generateAdminEntityPath(
    'post',
    $entity,
    'edit',
    ['parametrer' => 'value'],
    UrlGeneratorInterface::ABSOLUTE_PATH
);

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

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

它主要适用于以下技术方向: 「admin」 「action」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-02-23