当前位置: 首页>>代码示例>>PHP>>正文


PHP Kernel::setError方法代码示例

本文整理汇总了PHP中Kernel::setError方法的典型用法代码示例。如果您正苦于以下问题:PHP Kernel::setError方法的具体用法?PHP Kernel::setError怎么用?PHP Kernel::setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kernel的用法示例。


在下文中一共展示了Kernel::setError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getModuleProperty

 /**
  * This method is charged to get the value of the property specified as the second argument for the module 
  * specified as the first argument.
  * @param string $module_name
  * @param string $property_name
  * @return the value of the property if everything went fine, false otherwise.
  */
 public function getModuleProperty($module_name, $property_name)
 {
     //Check if the two arguments are set:
     if (is_null($module_name) || empty($module_name)) {
         if (is_null($property_name) || empty($property_name)) {
             Kernel::setError('An error occured while getting an unspecified property of an unspecified module.');
             return false;
         } else {
             Kernel::setError('An error occured while getting an the property ' . $property_name . ' of an unspecified module.');
             return false;
         }
     } else {
         if (is_null($property_name) || empty($property_name)) {
             Kernel::setError('An error occured while getting an unspecified property of the module ' . $module_name . '.');
             return false;
         }
     }
     $applications = simplexml_load_file($this->getFile());
     $dom_applications = dom_import_simplexml($applications);
     //Initialize the return value to false if an error occurs:
     $property_value = false;
     /*------------------------------------------------------------------------------------------------------------------------*/
     //Parse all the applications:
     foreach ($dom_applications->getElementsByTagName('application') as $application) {
         //For each application, parse all of the modules and  check if the module is the one passed as the first argument:
         $module_number = 0;
         foreach ($application->getElementsByTagName('module') as $module) {
             if ($module->getElementsByTagName('name')->item(0)->nodeValue == $module_name) {
                 if (isset($dom_module_node)) {
                     //If the variable $dom_module_node is set, this means we've already found a module whose name
                     //matches the module name passed as the first argument. This means there are several modules
                     //with the same name.
                     exit('Plusieurs module ont le même nom');
                 } else {
                     $dom_module_node = $application->getElementsByTagName('module')->item($module_number);
                 }
             } else {
                 $module_number++;
             }
         }
     }
     //Check if the module we've found is the correct one:
     if ($dom_module_node->getElementsByTagName('name')->item(0)->nodeValue != $module_name) {
         exit('Module not found');
     }
     /*------------------------------------------------------------------------------------------------------------------------*/
     //Check if the property passed as the third argument exists:
     $dom_node_property = $dom_module_node->getElementsByTagName($property_name);
     if (!empty($dom_node_property)) {
         //Check if there is only one property which has the specified name:
         if ($dom_node_property->length > 1) {
             exit('');
         } else {
             //If everything is ok, get the property value:
             $property_value = $dom_node_property->item(0)->nodeValue;
         }
     }
     //Return the property value if the property exists and is unique, false otherwise:
     return $property_value;
 }
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:67,代码来源:ApplicationsCommonInterface.class.php

示例2: getDefault

 /**
  *
  * @param string $param
  */
 public static function getDefault($param_to_search)
 {
     libxml_use_internal_errors(true);
     $param_value = '';
     //Get the xml configuration file as a DOM element:
     if (!($parameters = simplexml_load_file(ProjectConfiguration::guessRootDir() . '/config/' . self::getUserPrefix() . '_' . self::DEFAULT_PARAMS_FILE))) {
         Kernel::setError('Error while reading ' . self::getUserPrefix() . '_' . self::DEFAULT_PARAMS_FILE . ': the file probably doesn\'t exists');
         return false;
     }
     $dom_parameters = dom_import_simplexml($parameters);
     //For each parameter found,
     foreach ($dom_parameters->getElementsByTagName('param') as $param) {
         //Get the name and the value of the parameter:
         $param_name = $param->getElementsByTagName('name')->item(0)->nodeValue;
         //If the param is the one we're looking for:
         if ($param_to_search == $param_name) {
             return $param->getElementsByTagName('value')->item(0)->nodeValue;
         }
     }
     libxml_use_internal_errors(false);
     return $param_value;
 }
开发者ID:xmasclaux,项目名称:OpenGenepi,代码行数:26,代码来源:ParametersConfiguration.class.php


注:本文中的Kernel::setError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。