【发布时间】:2015-11-18 21:35:24
【问题描述】:
我有一个受保护的对象,我需要将一个数组附加到该对象。对象看起来像这样:我在 print_r($cmb_team_members); 时得到这个;
CMB2 Object (
[cmb_id:protected] => team_member_metabox
[meta_box:protected] => Array
(
[id] => team_member_metabox
[title] => Team Member Metabox
[type] =>
[object_types] => Array
(
[0] => post_type_teammember
)
[context] => normal
[priority] => high
[show_names] => 1
[show_on_cb] =>
[show_on] => Array
(
)
[cmb_styles] => 1
[enqueue_js] => 1
[fields] => Array
(
[_cmb2_division] => Array
(
[name] => Division
[desc] => The division of the company this person works in (These can be edited in the Revolution Group theme options)
[id] => _cmb2_division
[type] => select
[options] => Array
(
)
)
我想在 $cmb_team_members->meta_box['fields']['_cmb2_division']['options'] 中附加一个数组('a' => 'a', 'b' => 'b')
我不能只是 $cmb_team_members->meta_box['fields']['_cmb2_start_year']['options'] = array('a' => 'a', 'b' => 'b');它不像常规数组那样工作。我试图像这样扩展类:
class divisionClass extends CMB2
{
public function __set($name, $value)
{
/*Do something to append the Object with the array*/
}
}
我们将不胜感激任何朝着正确方向的推动。干杯!!!
【问题讨论】: