本文整理汇总了PHP中EEM_Base::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP EEM_Base::exists方法的具体用法?PHP EEM_Base::exists怎么用?PHP EEM_Base::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EEM_Base
的用法示例。
在下文中一共展示了EEM_Base::exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filter_out_inaccessible_entity_fields
/**
* Takes a entity that's ready to be returned and removes fields which the user shouldn't be able to access.
* @param array $entity
* @param \EEM_Base $model
* @param string $request_type one of the return values from EEM_Base::valid_cap_contexts()
* @param Model_Version_Info $model_version_info
* @return array ready for converting into json
*/
public static function filter_out_inaccessible_entity_fields($entity, $model, $request_type, $model_version_info)
{
//we only care to do this for frontend reads and when the user can't edit the item
if ($request_type !== \EEM_Base::caps_read || $model->exists(array(array($model->primary_key_name() => $entity[$model->primary_key_name()]), 'default_where_conditions' => 'none', 'caps' => \EEM_Base::caps_edit))) {
return $entity;
}
foreach ($model->field_settings() as $field_name => $field_obj) {
if ($model_version_info->field_has_rendered_format($field_obj) && isset($entity[$field_name]['raw'])) {
unset($entity[$field_name]['raw']);
}
}
//theoretically we may want to filter out specific fields for specific models
return apply_filters('FHEE__Capabilities__filter_out_inaccessible_entity_fields', $entity, $model, $request_type);
}