示例#1
0
 public function testGetValueByKey()
 {
     $inputArray = array('Account' => array('useCache' => true, 'sub' => array('subV' => '125', 'subO' => array('subOV' => '125', 'subOV2' => '125'))), 'Contact' => array('useCache' => true));
     $this->assertEquals($inputArray, Util::getValueByKey($inputArray));
     $this->assertEquals($inputArray, Util::getValueByKey($inputArray, ''));
     $this->assertEquals('125', Util::getValueByKey($inputArray, 'Account.sub.subV'));
     $result = array('useCache' => true);
     $this->assertEquals($result, Util::getValueByKey($inputArray, 'Contact'));
     $this->assertNull(Util::getValueByKey($inputArray, 'Contact.notExists'));
     $this->assertEquals('customReturns', Util::getValueByKey($inputArray, 'Contact.notExists', 'customReturns'));
     $this->assertNotEquals('customReturns', Util::getValueByKey($inputArray, 'Contact.useCache', 'customReturns'));
 }
示例#2
0
 /**
  * Undelete the deleted items
  *
  * @param  string $key1
  * @param  string $key2
  * @param  array $data
  * @return void
  */
 protected function undelete($key1, $key2, $data)
 {
     if (isset($this->deletedData[$key1][$key2])) {
         foreach ($this->deletedData[$key1][$key2] as $unsetIndex => $unsetItem) {
             $value = Util::getValueByKey($data, $unsetItem);
             if (isset($value)) {
                 unset($this->deletedData[$key1][$key2][$unsetIndex]);
             }
         }
     }
 }
示例#3
0
 public function get($key = null, $returns = null)
 {
     $data = $this->getData();
     if (!isset($data) || $data === false) {
         throw new Error('Language: current language [' . $this->getLanguage() . '] does not found');
     }
     return Util::getValueByKey($data, $key, $returns);
 }
示例#4
0
 /**
  * Get Metadata
  *
  * @param string $key
  * @param mixed $return
  *
  * @return array
  */
 public function get($key = null, $returns = null)
 {
     return Util::getValueByKey($this->getData(), $key, $returns);
 }