writtengames / audit-bundle
Symfony 2 审计包
Requires
- craue/twigextensions-bundle: dev-master
- liuggio/excelbundle: >=1.0.4
- stof/doctrine-extensions-bundle: dev-master
- symfony/symfony: >=2.1
This package is not auto-updated.
Last update: 2024-09-28 13:10:14 UTC
README
Symfony 2 审计包,用于审计流程、员工等。
特性
此包提供用户通过表单(类似于电子表格)审计流程和管理这些表单的功能。每个表单都分为多个部分和字段,并提供了四种可能的答案。每个元素都可以通过管理部分随意修改。(本包不包括用户管理)。
为了帮助您自定义模板,以下Twig扩展可用
twig函数
{{ 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过滤器
{{ 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
当前表单相当静态:每个部分仅与一个表单相关联,每个字段仅与一个部分相关联。
上述内容是包的上一版本的正确做法。当前,架构已更改,允许一个部分分配给多个表单,同样,一个字段也可以分配给多个部分。这意味着表单与部分,以及部分与字段之间的关系是多对多。然而,为了归档部分和字段,这种关系已经在包含属性$archived的类中实现。
请注意:由于gedmo扩展尚未使用,表单中部分的位置和部分中字段的位置目前不起作用,因为架构的改变破坏了这一点。
配置
如果审计要保存为用户已执行审计的引用,则应配置用户实体的类。否则,用户字段将被设置为NULL。
同样,如果使用带有审计引用的文本输入而不是下拉菜单中的实体,则还需要配置被审计实体的类。
此外,如果审计被认为包含致命错误,则可以通知控制用户。
以下是一个完整的示例配置(config.yml)
cisco_audit: control_user: true user: class: Acme\UserBundle\Entity\User property: id audit_reference: class: Acme\ServiceBundle\Entity\ServiceCase property: caseId
必需项
目前需要在项目的composer.json文件中添加以下内容
"repositories": [ { "type": "vcs", "url": "http://github.com/WrittenGames/AuditBundle" } ] ... "require": { "cisco-systems/audit-bundle": "dev-master" }
然后通过composer.phar更新
并在AppKernel中添加包
$bundles = array( new Craue\TwigExtensionsBundle\CraueTwigExtensionsBundle(), new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), new CiscoSystems\AuditBundle\CiscoSystemsAuditBundle(), );
同时将包添加到routing.yml中
CiscoSystemsAuditBundle: resource: "@CiscoSystemsAuditBundle/Resources/config/routing.yml" prefix: /cisco_audit
最后,在config.yml文件中添加stof包的配置
# Doctrine Extensions stof_doctrine_extensions: orm: default: timestampable: true sluggable: true sortable: true
以及用于用户界面的orm包
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
完成以上所有步骤后,生成所需的表格
php app/console doctrine:schema:update --dump-sql
这些是
- audit__audit
- audit__score
- audit__element
- audit__form
- audit__section
- audit__field
- audit__relation
- audit__form_section
- audit__section_field
继承和Doctrine
请注意,类Element是抽象的,Form、Section和Field都是该类的子类。同样,类Relation及其子类FormSection和SectionField也是如此。
请注意,Form和Section、Section和Field之间存在多对多关系。
命令
如果您以某种方式保存了总分(totalscore)为0(零)的某些审计,您可以使用以下命令重新生成
php app/console audit:score:regenerate
- 选项:'id' 作为要处理的审计ID。
- 选项:'--override' 重新生成所有总分,而不仅仅是值为0的分数。
待办事项
- 允许将部分分配给多个表单
- 允许将字段分配给多个部分
- 实现功能测试和单元测试
- 实体完成
- 可能使用 [ICBaseTestBundle] (https://github.com/instaclick/ICBaseTestBundle)
问题
问题应在 [GitHub Issues] (https://github.com/WrittenGames/AuditBundle/issues) 中报告
许可证
此软件包采用 BSD 许可证:许可证内容可在 [LICENSE] (https://github.com/WrittenGames/AuditBundle/blob/master/LICENSE) 中阅读。