2017-12-25 1 views
0

Drupal 8에서 주석 값을 동적으로 어떻게 변경합니까? 예를 들어 다음 주석의 cron = {"time" = 120}cron = {"time" = 600}으로 지정합니다. 구성에서 600이나 다른 값을 얻고 싶습니다.Drupal 8의 주석 값을 동적으로 변경하십시오.

/** 
* Updates the google analytics counters. 
* 
* @QueueWorker(
* id = "google_analytics_counter_worker", 
* title = @Translation("Import Data from Google Analytics"), 
* cron = {"time" = 120} 
*) 
*/ 

나는 주석 전에 일정을 추가하는 시도했다 :

const DURATION = 600; 

/** 
* Updates the google analytics counters. 
* 
* @QueueWorker(
* id = "google_analytics_counter_worker", 
* title = @Translation("Import Data from Google Analytics"), 
* cron = {"time" = DURATION} 
*) 
*/ 

그러나 오류 던지고 : 이것에 대한

Doctrine\Common\Annotations\AnnotationException: [Semantical Error] Couldn't find constant DURATION, class                [error] 
Drupal\google_analytics_counter\Plugin\QueueWorker\GoogleAnalyticsCounterQueue. in 
/private/var/www/sites/mskcc_deploy/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:54 

답변

1

사용 hook_queue_info_alter을 :

function mymodule_queue_info_alter(&$queues) { 
    $queues['google_analytics_counter_worker']['cron']['time'] = DURATION; 
} 
+0

완벽한 . 감사. – esod

관련 문제