本文整理汇总了PHP中Converter::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::toArray方法的具体用法?PHP Converter::toArray怎么用?PHP Converter::toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Converter
的用法示例。
在下文中一共展示了Converter::toArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
/**
* check if we're
* given the needed
* keys. Additionally add
* client checks
*
* token string
* expires integer
*/
public function setup($data)
{
if (is_object($data[0])) {
$data = Converter::toArray($data[0]);
}
foreach ($data as $k => $d) {
if (!in_array($k, array("token", "expires"))) {
throw new CatapultApiException("{$k} is not a valid key for endpoint token");
}
}
$arr = array('token', 'expires');
foreach ($arr as $a) {
if (isset($data[$a])) {
$this->{$a} = $data[$a];
}
}
// important don't serialize
// when sending in a Endpoints object
$this->serialize = FALSE;
}
示例2: setup
/**
* check if we're
* given the needed
* keys. Additionally add
* client checks
*
* password > 6 characters
* realm is four point
* username no check here
*/
public function setup($data)
{
if (is_object($data[0])) {
$data = Converter::toArray($data[0]);
}
foreach ($data as $k => $d) {
if (!in_array($k, array("username", "password", "realm"))) {
throw new CatapultApiException("{$k} is not a valid key for endpoint credentials");
}
}
$arr = array('username', 'password', 'realm');
foreach ($arr as $a) {
if (isset($data[$a])) {
$this->{$a} = $data[$a];
}
}
// important don't serialize
// when sending in a Endpoints object
$this->serialize = FALSE;
}
示例3:
<?php
include_once 'Converter.php';
//Create a json test string
$testString = '{"name":"oreofeolurin","sex":"male","country":"nigeria","origin":"Ilaro"}';
//Call our toArray function on it
$array = Converter::toArray($testString);
//Header for array section
echo "<h4>Array</h4>";
//Lets make sure the right format was used
if ($array == NULL) {
echo "Bad JSON";
} else {
var_dump($array);
}
echo "<br/>";
//Header for json object section
echo "<h4>JSON</h4>";
//lets get our decoded array as test array
$testArray = $array;
//Call our toJson function on it
$json = Converter::toJson($testArray);
//Lets Handle success/failure
if ($json) {
var_dump($json);
} else {
echo "Error ecoding json";
}
示例4: __construct
public function __construct()
{
$data = Ensure::Input(func_get_args(), Converter::toArray(json_decode(file_get_contents("php://input"))));
parent::_init($data, new Call());
}
示例5: toArray
/**
* make all
* properties an array
*
*/
public function toArray()
{
$proto = Converter::toArray($this);
$not = array('primary_method', 'lastUpdate', 'subfunctions', 'client', 'path', 'hasPath');
// we only need key value
foreach ($proto as $k => $p) {
if (in_array($k, $not)) {
unset($proto[$k]);
}
}
return $proto;
}
示例6: unset
if (preg_match('#(^|\\n)(\\t| {1,3})(?:[^ ])#', $request['content'])) {
Notify::error($speak->notify_invalid_indent_character);
Guardian::memorize($request);
}
$k = Text::parse(str_replace(array('Menu::', '()'), "", $request['key']), '->array_key');
if (!$key) {
if (isset($menus[$k])) {
Notify::error(Config::speak('notify_exist', '<code>Menu::' . $k . '()</code>'));
}
} else {
unset($menus[$key]);
}
if ($k === "" || $k === '__') {
Notify::error(Config::speak('notify_error_empty_field', $speak->name));
}
$menus[$k] = Converter::toArray($request['content'], S, ' ');
$P = array('data' => $request);
if (!Notify::errors()) {
ksort($menus);
File::serialize($menus)->saveTo(STATE . DS . 'menu.txt', 0600);
Notify::success(Config::speak('notify_success_' . (!$key ? 'created' : 'updated'), $speak->menu));
Weapon::fire(array('on_menu_update', 'on_menu_' . (!$key ? 'construct' : 'repair')), array($G, $P));
Guardian::kick($key !== $k ? $config->manager->slug . '/menu' : $config->manager->slug . '/menu/repair/key:' . $key);
}
}
Shield::lot(array('segment' => 'menu', 'id' => $key, 'content' => $menu_raw))->attach('manager');
});
/**
* Menu Killer
* -----------
*/
示例7: __fields
private static function __fields(&$results, $FP)
{
// Initialize custom field(s) with the default value(s) so that
// user(s) don't have to write `isset()` function multiple time(s)
// just to prevent error message(s) because of the object key(s)
// that is not available in the old post(s).
$fields = self::state_field(null, array(), true, rtrim($FP, ':'));
foreach ($fields as $k => $v) {
$s = isset($results['fields'][$k]) && trim($results['fields'][$k]) !== "" ? $results['fields'][$k] : "";
if ($s === "") {
// For `option` field type, the first option will be used as the default value
if ($v['type'] === 'option' || $v['type'] === 'o') {
$vv = array_keys(Converter::toArray($v['value']));
if (isset($v['placeholder']) && trim($v['placeholder']) !== "") {
// do nothing ...
} else {
$s = isset($vv[0]) ? $vv[0] : "";
}
// For `boolean` field type, empty value is equal to `false`
} else {
if ($v['type'] === 'boolean' || $v['type'] === 'b') {
$s = false;
}
}
} else {
// For `file` field type, the original custom field value is used to limit the file extension
// So we have to check the existence of the file first. If it does not exist, then it may be
// contained with the file extension(s), not with a file name
if ($v['type'] === 'file' || $v['type'] === 'f') {
$e = File::E($s, false);
$s = $e !== false ? File::exist(SUBSTANCE . DS . $e . DS . $s, "") : "";
}
}
$results['fields'][$k] = $s;
}
unset($fields, $s);
}
示例8: __construct
public function __construct()
{
$data = Ensure::Input(func_get_args, Converter::toArray(json_decode(file_get_contents("php://input"))));
return new ConferenceMember($data);
}
示例9: isset
$html .= '</label>';
} else {
if ($type === 'boolean' || $type === 'b') {
$html .= '<div class="grid-group grid-group-boolean">';
$html .= '<span class="grid span-2"></span>';
$html .= '<span class="grid span-4">';
$html .= Form::checkbox('fields[' . $key . '][value]', !empty($value['value']) ? $value['value'] : 1, isset($field[$key]) && !empty($field[$key]), $value['title']) . $description;
$html .= '</span>';
$html .= '</div>';
} else {
if ($type === 'option' || $type === 'o') {
$html .= '<label class="grid-group grid-group-option">';
$html .= '<span class="grid span-2 form-label">' . $title . '</span>';
$html .= '<span class="grid span-4">';
$select = isset($field[$key]) ? $field[$key] : "";
$options = Converter::toArray($value['value'], S, ' ');
if (isset($value['placeholder']) && trim($value['placeholder']) !== "") {
$options = array("" => $value['placeholder']) + $options;
}
$html .= Form::select('fields[' . $key . '][value]', $options, $select, array('class' => 'select-block'));
$html .= '</span>';
$html .= '</label>';
} else {
if ($type === 'file' || $type === 'f') {
$v = isset($value['value']) && $value['value'] !== "" ? $value['value'] : false;
$vv = isset($field[$key]) && $field[$key] !== "" ? File::E($field[$key]) . DS . File::path($field[$key]) : false;
$has_file = $vv !== false && file_exists(SUBSTANCE . DS . $vv) && is_file(SUBSTANCE . DS . $vv);
$html .= '<div class="grid-group grid-group-file' . ($has_file ? ' grid-group-boolean' : "") . '">';
$html .= !$has_file ? '<span class="grid span-2 form-label">' . $title . '</span>' : '<span class="grid span-2"></span>';
$html .= '<span class="grid span-4">';
if (!$has_file) {
示例10: __construct
public function __construct()
{
$data = Ensure::Input(func_get_args(), Converter::toArray(json_decode("php://input")));
return parent::_init($data, new Conference());
}