writtengames/audit-bundle 问题修复 & 功能扩展

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

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

writtengames/audit-bundle

Composer 安装命令:

composer require writtengames/audit-bundle

包简介

Symfony 2 bundle for auditing

README 文档

README

Build Status

Symfony 2 bundle for auditing processes, employees, etc.

Features

This bundle offers the use of form (as in spreadsheet) for a user to audit a process and the management of these forms. Each form is divided in sections and fields and offers four choices of answer possible. Each of the elements can be modified at will through the administration part. (No user management is included in this bundle).

In order to help you customize your template, the following twig extensions are available:

twig functions:

    {{ get_resultforsection() }}        // return the score for the section
    {{ get_weightforsection() }}        // return the weight for the section
    {{ get_resultforaudit() }}          // return the result for the audit
    {{ get_weightforaudit() }}          // return the weight for the audit

twig filters:

    {{ element | archived ( parent ) }} // return the value of archived for the element and its parent element (section/form and field/section)
    {{ element | position ( parent ) }} // return the value of position for the element and its parent element (section/form and field/section)
    {{ form | sections( false|true ) }} // return the sections for the form archived === false | true
    {{ section | fields( false|true ) }}// return the fields for the section archived === false | true

Currently the forms are fairly static: Each Section is attached to one and only one Form and each Field is attached to one and only one Section.

The above was correct in the previous iteration of the bundle. Currently, the schema has been changed to allow a Section to be assigned to more than one Form and similarily a Field can be assigned to more than one Section. Which means that the relationship between Form and Section, and between Section and Field are of Many to Many. However, in order to archive Sections, and Fields, the relationship itself has been materialized in a class that holds the property $archived.

PLEASE NOTE: the position of Sections on Form and Fields on Section is currently not working as the gedmo extension was to be used, but a change in the schema broke this.

Configuration

If audits are to be saved with a reference to the user having done the auditing the class of the User entity should be configured. Otherwise the user field will be set to NULL.

Likewise, if instead of a text input with the audit reference a dropdown menu with entities should be rendered, the class of the audited entity needs to be configured as well.

Also, a control user can be notified if an audit is considered as containing fatal errors.

Below is a complete example configuration (config.yml):

cisco_audit:
    control_user: true
    user:
        class: Acme\UserBundle\Entity\User
        property: id
    audit_reference:
        class: Acme\ServiceBundle\Entity\ServiceCase
        property: caseId

Required

For now the following need to be added to the composer.json file of the project:

    "repositories": [
        { "type": "vcs", "url": "http://github.com/WrittenGames/AuditBundle" }
    ]

    ...

    "require": {
        "cisco-systems/audit-bundle": "dev-master"
    }

Then update through composer.phar

And add the bundle in the AppKernel:

    $bundles = array(
        new Craue\TwigExtensionsBundle\CraueTwigExtensionsBundle(),
        new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
        new CiscoSystems\AuditBundle\CiscoSystemsAuditBundle(),
    );

Add as well the Bundle to the routing.yml:

    CiscoSystemsAuditBundle:
        resource: "@CiscoSystemsAuditBundle/Resources/config/routing.yml"
        prefix:   /cisco_audit

Finally add the configuration for the stof bundle in the config.yml file:

    # Doctrine Extensions
    stof_doctrine_extensions:
        orm:
            default:
                timestampable: true
                sluggable: true
                sortable: true

And the orm bundle for the user interface:

    doctrine:
        orm:
            resolve_target_entities:
                CiscoSystems\AuditBundle\Model\UserInterface: Acme\UserBundle\Entity\User
                CiscoSystems\AuditBundle\Model\ReferenceInterface: Acme\UserBundle\Entity\Reference
                CiscoSystems\AuditBundle\Model\MetadataInterface: Acme\AuditBundle\Entity\Metadata

Once this all done, generate the tables needed:

    php app/console doctrine:schema:update --dump-sql

Those are:

  • audit__audit
  • audit__score
  • audit__element
  • audit__form
  • audit__section
  • audit__field
  • audit__relation
  • audit__form_section
  • audit__section_field

inheritance and doctrine

Please note that the class Element is abstract and Form, Section and Field are all children of that class. The same apply to the class Relation and its children: FormSection and SectionField.

Please note as well, that ManyToMany relationship exist between Form and Section, and Section and Field.

command

if you have saved (somehow) some audit with a totalscore of 0 (zero), you can regenerate those with the following command:

    php app/console audit:score:regenerate
  • Option: 'id' as the audit id to process.
  • Option: '--override' to regenerate all the total score and not just the one with value of 0.

TODO

  • Allow a section to be assigned to more than one Form
  • Allow a Field to be assigned to more than one Section
  • Implement functional and unit testing

Issues

Issues should be reported in [GitHub Issues] (https://github.com/WrittenGames/AuditBundle/issues)

License

This bundle is under the BSD license: The license can be read in [LICENSE] (https://github.com/WrittenGames/AuditBundle/blob/master/LICENSE).

writtengames/audit-bundle 适用场景与选型建议

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

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 4
  • Watchers: 3
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: BSD
  • 更新时间: 2012-11-06