【发布时间】:2017-12-25 18:47:34
【问题描述】:
如何在 Drupal 8 中动态更改注释值?例如,我希望以下注释中的cron = {"time" = 120} 为cron = {"time" = 600}。我想从配置中获得 600 或其他值。
/**
* 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
【问题讨论】:
标签: drupal-8