beck24/elgg_scalarmd 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

beck24/elgg_scalarmd

Composer 安装命令:

composer require beck24/elgg_scalarmd

包简介

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not

README 文档

README

Provide a global function for ensuring metadata output is a string, and potentially fixing it if not.

This is useful for situations where you are expecting a string, and only a string, and an accidental array return would break things. An example might be a webservices response that requires a string.

This is a workaround for Elgg/Elgg#4268 where frequently updated metadata can accidentally duplicate into an array. This function ensures a scalar return for the metadata value and will reset the entity metadata to a scalar value by default.

Caveats

This works for metadata that does not depend on access or ownership, as a simple key/value pair (eg. most metadata usage) If the metadata does depend on access or ownership do not use this function on it or you will surely lose data.

Usage

Scenario:

$entity->country = [
    'canada',
    'canada
];

$entity->country is now:

Array
(
    [0] => canada
    [1] => canada
)

Without fixing: \Beck24\scalarmd($entity, 'country', false)

canada

$entity->country is still:

Array
(
    [0] => canada
    [1] => canada
)

Now with fixing: \Beck24\scalarmd($entity, 'country')

canada

$entity->country is now:

canada

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: JavaScript

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-03-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固