我希望我的扩展程序注意到您有权限,在记录关于$ app ['user'] - > isAllowed(),有没有如何使用它的例子?
答案 0 :(得分:1)
方法 isAllowed()的使用可能会因目的而异。
其中一个可能是扩展程序可编辑:http://bit.ly/1teHdS9
更详细的说明可以在Doccode中找到:
/**
* Runs a permission check. Permissions are encoded as strings, where
* the ':' character acts as a separator for dynamic parts and
* sub-permissions.
* Apart from the route-based rules defined in permissions.yml, the
* following special cases are available:
*
* "overview:$contenttype" - view the overview for the content type. Alias
* for "contenttype:$contenttype:view".
* "contenttype:$contenttype",
* "contenttype:$contenttype:view",
* "contenttype:$contenttype:view:$id" - View any item or a particular item
* of the specified content type.
* "contenttype:$contenttype:edit",
* "contenttype:$contenttype:edit:$id" - Edit any item or a particular item
* of the specified content type.
* "contenttype:$contenttype:create" - Create a new item of the specified
* content type. (It doesn't make sense
* to provide this permission on a
* per-item basis, for obvious reasons)
* "contenttype:$contenttype:change-ownership",
* "contenttype:$contenttype:change-ownership:$id" - Change the ownership
* of the specified content type or item.
*
* @param string $what The desired permission, as elaborated upon above.
* @return bool TRUE if the permission is granted, FALSE if denied.
*/
由于扩展的架构师在即将发布的v2中会略有变化 isAllowed()与以前保持一致。