carpehora/classifiablebehavior
Composer 安装命令:
composer require carpehora/classifiablebehavior
包简介
ClassifiableBehavior is a propel behavior allowing to tag on a list of user defined scopes. kind of Ressource Access Control.
README 文档
README
Quick start
Simply declare the behavior for the classifiable objects to allow filtering by classifications:
<database name="propel"> <table name="repository"> <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" /> <column name="name" type="VARCHAR" size="255" /> <behavior name="classifiable" /> </table> </database>
then just add classificationements to your object:
<?php // create your objects... $MyPhpRepo = new Repository(); $MyPhpRepo->setName('my php repository'); $MyPhpRepo->classify('visibility', 'public'); $MyPhpRepo->classify('language', 'php'); $MyPhpRepo->classify('language', 'js'); $MyPhpRepo->classify('license', 'MIT'); $MyJsRepo = new Repository(); $MyJsRepo->setName('my php repository'); $MyJsRepo->classify('language', 'js'); $MyJsRepo->classify('language', 'php'); // is now classified in js AND php $MyJsRepo->classify('license', 'GPL'); $MyJsRepo->disclose('language', 'js'); // now only classified in php // ...and then retrieve it RepositoryQuery::create() // filter for 'php' AND 'js' language, paranoid ->filterByClassified('language', array('php', 'js'), 'and', $paranoid = true) // filter for 'MIT'OR 'GPL' license, paranoid ->filterByClassified('license', array('MIT', 'BSD'), 'or', $paranoid = true) // filter for public visibility, // default is public, so request match if no visibility defined ->filterByClassified('visibility', 'public', null, $paranoid = false);
Previous example will return a PropelCollection with $MyPhpRepo in it.
OR searches are easily done by giving an array and the operator to use for subqueries:
<?php RepositoryQuery::create() // filter by OR queries ->filterByClassified(array( 'license' => array('MIT', 'BSD'), // licensed under MIT AND BSD as defined $operator argument 'visibility' => 'public', // or with public visibility ), $operator = 'AND', $paranoid = true)
To retrieve classifications an object is attached to, just call the getClassification method:
<?php $myRepo->classify(array( 'license' => array('MIT', 'BSD'), 'visibility' => 'public' ), 'AND', $excludeUnclassified = true); // return $myRepo $myRepo->getClassification(); // array( // 'license' => array('MIT', 'BSD'), // 'visibility' => 'public' // ) $myRepo->isClassified(array( 'license' => array('MIT', 'BSD'), 'visibility' => 'public' ), 'AND', $excludeUnclassified = true); // return true $myRepo->disclose();
To ease classifications management, behavior uses a unique classification table shared
for all classified content. To use separate tables, just override the
classification_table parameter.
Usage
You can use ClassifiableBehavior:
- limit access to classified content
- to organize collections and ease filtering
- to tag objects
- put your idea here
Installation
Under the hood
Behavior creates a cross reference table to access classification dictionnary and filters using EXISTS statements.
Advanced configuration
Following parameters are available :
classification_table: table to use to handle classifications.classification_column: classification column to use.scope_column: scope column to use.auto_create_classification: if no classification found for parameters, should it be created ?scope_default: comma separated default scope list.scope_matching: how to match on scope ?- strict: namespace has to be strictly equal
- nested: namespace has to start the same. separator is defined as
nesting_separator - none: no namespace check
nesting_separator: separator to use on nested scopes
Scopes
A scope can be used to organize classifications. You can use namespaced scope by
providing a nesting_separator. In such case, you can organize your
classifications as files and folders and search can be done on all the scope
descendants.
A scope can either be a foreign key to an object.
TODO
- AR disclose method
- nesting namespaces
- Index classification table fields
carpehora/classifiablebehavior 适用场景与选型建议
carpehora/classifiablebehavior 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 6, 最近一次更新时间为 2012 年 03 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「propel」 「Taggable」 「Classify」 「Classifiable」 「Ressource Access Control」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 carpehora/classifiablebehavior 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 carpehora/classifiablebehavior 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 carpehora/classifiablebehavior 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Doctrine2 taggable behavior extension
The PSR-16 extension to Apix-Cache.
The tag extension for the yii framework
Simple way to tag Eloquent models in Laravel.
Tag management in AsgardCMS
Free as in freedom php component that generates configuration based hard coded locator
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2012-03-16