Please Disable Your Browser Adblock Extension for our site and Refresh This Page!

our ads are user friendly, we do not serve popup ads. We serve responsible ads!

Refresh Page
Skip to main content
On . By CodimTh
Category:

Classes with annotations serve to define entity types, plugins and so on. Annotations are not executable code as-is, so we need a specific syntax to mark strings to be translated. The @Translation() wrapper serves this purpose. It will run the text through t() when the annotation is evaluated.

Example:

/**
 * Defines the file entity class.
 *
 * @EntityType(
 *   id = "file",
 *   label = @Translation("File"),
 *   ....
 */
class File {
 }

 

Example with context:

/**
 * Defines the file entity class.
 *
 * @EntityType(
 *   id = "file",
 *   label = @Translation("Text in context", context="Name of context"),
 *   ....
 */
class File {
 }

 

Comments

Add new comment

Restricted HTML

Search

Page Facebook

Become a patron

If you need some help or you search a Drupal freelancer don't hesitate to contact us.

 

Contact Us

All the content is FREE but I still need your help

 

Become a patreon