本文整理汇总了PHP中EEM_Base::valid_cap_contexts方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Base::valid_cap_contexts方法的具体用法?PHP EEM_Base::valid_cap_contexts怎么用?PHP EEM_Base::valid_cap_contexts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EEM_Base
的用法示例。
在下文中一共展示了EEM_Base::valid_cap_contexts方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: verify_is_valid_cap_context
/**
* Verifies $context is one of EEM_Base::valid_cap_contexts(), if not it throws an exception
* @param string $context
* @return bool
* @throws \EE_Error
*/
public static function verify_is_valid_cap_context($context)
{
$valid_cap_contexts = EEM_Base::valid_cap_contexts();
if (in_array($context, $valid_cap_contexts)) {
return true;
} else {
throw new EE_Error(sprintf(__('Context "%1$s" passed into model "%2$s" is not a valid context. They are: %3$s', 'event_espresso'), $context, 'EEM_Base', implode(',', $valid_cap_contexts)));
}
}
示例2: validate_context
/**
* If a context is provided which isn't valid, maybe it was added in a future
* version so just treat it as a default read
*
* @param string $context
* @return string array key of EEM_Base::cap_contexts_to_cap_action_map()
*/
public function validate_context($context)
{
if (!$context) {
$context = \EEM_Base::caps_read;
}
$valid_contexts = \EEM_Base::valid_cap_contexts();
if (in_array($context, $valid_contexts)) {
return $context;
} else {
return \EEM_Base::caps_read;
}
}