2012-01-27 4 views
1

설치 프로필을 작성 중이며 "max_execution_time"및 "memory_limit"값이 낮 으면 사용자에게 알리고 싶습니다. 드루팔 간단한 위의 코드를 무시 -설치 프로파일에 사용자 정의 요구 사항을 추가하십시오. Drupal 7

 function myprofile_requirements($phase) { 
      $requirements = array(); 
      // Min required PHP execution time 
      $min_time = 60; 
      // Min required memory limit, Mb 
      $min_memory = 128; 
      // Get current value of "max_execution_time" 
      $time = ini_get('max_execution_time'); 
      // Get current value of "max_execution_time" 
      $memory = ini_get('memory_limit'); 
      // Get "raw" numeric value 
      preg_match("|\d+|", $memory, $value); 
      $severity_time = ($time < $min_time) ? REQUIREMENT_WARNING : REQUIREMENT_OK; 
      $severity_memory = ($value[0] < $min_memory) ? REQUIREMENT_WARNING : REQUIREMENT_OK; 
      $t = get_t(); 
      if ($phase == 'install') { 
      $requirements['max_execution_time'] = array(
       'title' => $t('PHP max execution time'), 
       'value' => $t('Please increase the parameter "max_execution_time" in your PHP settings . Recommended value is at least @min sec. and more (now you have @current sec.', 
     array('@min' => $min_time, '@current' => $time)), 
       'severity' => $severity_time, 
    ); 
      $requirements['memory_limit'] = array(
       'title' => $t('PHP memory limit'), 
       'value' => $t('Please increase the parameter "memory_limit" in your PHP settings . Recommended value is at least @minM and more (now you have @current', 
     array('@min' => $min_memory, '@current' => $memory)), 
       'severity' => $severity_memory, 
    ); 
    } 
    return $requirements; 
} 

그것은 작동하지 않습니다 : 내가 드루팔 가능한 요구 사항 myprofile.install 파일을 확인해야 이해 그래서 나는이 다음에 위치. 뭐가 문제 야? 그것은 hook_requirements()처럼 보이는

답변

1

가 설치 프로필에서 호출되지 않습니다, 그것은 다음 단계에서 호출 것 :

  • 설치 : 모듈이 설치되고있다.
  • 업데이트 : 모듈이 사용 가능하며 update.php가 실행됩니다.
  • 런타임 : 런타임 요구 사항을 확인하고 상태 보고서 페이지에 표시합니다.

위의 install은 전체적으로 설치 프로필이 아닌 모듈이 설치되어 있음을 나타냅니다.

+0

"위의 설치는 전체적으로 설치 프로필이 아닌 모듈이 설치되는 것을 의미합니다." 그러나 설치 프로파일은 모듈입니다. – ymakux

관련 문제