Exemplo n.º 1
0
 protected function _mapToModel(array $data, $usePreset = true)
 {
     $this->_map($data, $this->_mapModelToSdp, true);
     if ($usePreset) {
         foreach ($this->_presetModelValues as $modelField => $value) {
             if (!App_Util_Array::issetItem($data, $modelField)) {
                 App_Util_Array::setItem($data, $modelField, $value);
             }
         }
     }
     return $data;
 }
 public function getConfig($key, $default = null)
 {
     if (is_array($key)) {
         if (isset($key['default'])) {
             $default = $key['default'];
         }
         if (!isset($key['key'])) {
             throw new InvalidArgumentException("Parameter key must be a string or an array with a 'key' element");
         }
         $key = $key['key'];
     }
     $data = $this->exportData();
     if (!\App_Util_Array::issetItem($data, $key)) {
         return $default;
     }
     return \App_Util_Array::getItem($data, $key);
 }
 protected function _checkProtectedField($resource, $newResource, $privilege, $prefix)
 {
     try {
         $field = substr($privilege, strlen($prefix) + 1, strlen($privilege));
         $field = str_replace(':', '.', $field);
         if ($field !== "default" && \App_Util_Array::issetItem($newResource, $field)) {
             $this->_allowed($privilege, $resource);
         }
     } catch (Exception $e) {
         \App::log()->debug("User has no permission to {$prefix} {$field} in {$resource}");
         if ($this->getThrowExOnNotAllowed()) {
             throw $e;
         } else {
             // Clean privilege
             \App_Util_Array::unsetItem($newResource, $field);
             return false;
         }
     }
     return true;
 }
Exemplo n.º 4
0
 public function testWildcardIssetItemFail()
 {
     $this->assertFalse(\App_Util_Array::issetItem($this->_data, 'a.*.sss'));
 }