Пример #1
0
 function &getEntity($class, $key, $params = array(), $mode = READ_MODE, $package = DEFAULT_PACKAGE)
 {
     // ñìîòðèì ðåæèì ñêà÷èâàíèÿ (ìîæåò èñïîëüçîâàòüñÿ ïîòîì äëÿ ïðàâ)
     $mode = intval($mode);
     if (!$mode) {
         WriteLog('Invalid mode of entity ' . $class . ' in mode ' . $mode, LOGFILE_ENITY);
         return;
     }
     // èùåì ñóùíîñòü â êåøå (äëÿ óáûñòðåíèÿ è îáñåïå÷åíèÿ ïîâòîðíîãî ÷òåíèÿ)
     $hash = md5($package . $class . $mode . serialize($params) . serialize($key));
     if (!empty($this->_entity[$hash])) {
         return $this->_entity[$hash]['entity'];
     } else {
         //Try build new entity
         if (empty($class)) {
             return null;
         }
         if (empty($package)) {
             $package = DEFAULT_PACKAGE;
         }
         $class .= "Entity";
         $full_path = PACKAGES_DIR . '/' . str_replace('.', '/', $package) . '/' . $class . '.class.php';
         if (file_exists($full_path)) {
             if (!in_array($full_path, get_required_files())) {
                 require_once $full_path;
             }
             //Check that needly class exists
             if (!class_exists(str_replace('.', '_', $package) . '_' . $class)) {
                 class_log('XEntityCache', 'Class ' . $class . '  not found ', ENTITYCACHE_LOG);
                 return null;
             } else {
                 $full_class = str_replace('.', '_', $package) . '_' . $class;
                 $methods = array_flip(get_class_methods($full_class));
                 //If called class not derived from entity return null
                 if (!in_array('xentity', $methods)) {
                     return null;
                 }
             }
             return $this->_createEntity($full_class, $key, $params, $mode, $hash);
         } else {
             $sth = null;
             return $sth;
         }
     }
 }
Пример #2
0
 function deleteParam($name)
 {
     if (empty($name)) {
         class_log("XObjectInfo", "Try delete parameter with empty name in object " . $this->Name, CONFIGPARSE_LOG);
         return false;
     } else {
         if (!array_key_exists($name, $this->params)) {
             class_log("XObjectInfo", "Try delete unexisten parameter " . $name . " in object " . $this->Name, CONFIGPARSE_LOG);
             return false;
         } else {
             unset($this->_params);
             return false;
         }
     }
 }