public function testGetSetPathParts() { $arr = array('one' => '1', 'two' => array('half' => 2)); $this->assertEquals('1', CRM_Utils_Array::pathGet($arr, array('one'))); $this->assertEquals('2', CRM_Utils_Array::pathGet($arr, array('two', 'half'))); $this->assertEquals(NULL, CRM_Utils_Array::pathGet($arr, array('zoo', 'half'))); CRM_Utils_Array::pathSet($arr, array('zoo', 'half'), '3'); $this->assertEquals(3, CRM_Utils_Array::pathGet($arr, array('zoo', 'half'))); $this->assertEquals(3, $arr['zoo']['half']); }
/** * Invoke function. * * @return mixed */ public function __invoke($arg1 = NULL) { if ($this->mode === 'getter') { return \CRM_Utils_Array::pathGet($GLOBALS, explode('/', $this->path)); } elseif ($this->mode === 'setter') { \CRM_Utils_Array::pathSet($GLOBALS, explode('/', $this->path), $arg1); } else { throw new \RuntimeException("Resolver failed: global:// must specify getter or setter mode."); } }