* @method bool getDebug()
* @method $this setChain(array $chain)
* @method array getChain()
+ * @method $this setLanguage(string|null $language)
+ * @method string|null getLanguage()
*/
abstract class AbstractAction implements \ArrayAccess {
*/
protected $version = 4;
+ /**
+ * Preferred language (optional)
+ *
+ * This option will notify major localization subsystems (`ts()`, multilingual, etc)
+ * about which locale should be used for composing/formatting messaging.
+ *
+ * This indicates the preferred language. The effective language is determined
+ * by `Civi\Core\Locale::negotiate($preferredLanguage)`.
+ *
+ * @var string
+ * @optionsCallback getPreferredLanguageOptions
+ */
+ protected $language;
+
/**
* Additional api requests - will be called once per result.
*
}
}
+ /**
+ * Get available preferred languages.
+ *
+ * @return array
+ */
+ protected function getPreferredLanguageOptions(): array {
+ $languages = \CRM_Contact_BAO_Contact::buildOptions('preferred_language');
+ ksort($languages);
+ return array_keys($languages);
+ }
+
}
use Civi\Api4\Utils\ReflectionUtils;
/**
- * @method string getLanguage()
- * @method $this setLanguage(string $language)
+ * Common properties and helper-methods used for DB-oriented actions.
*/
trait DAOActionTrait {
/**
- * Specify the language to use if this is a multi-lingual environment.
- *
- * E.g. "en_US" or "fr_CA"
- *
- * @var string
+ * @var array
*/
- protected $language;
-
private $_maxWeights = [];
/**