Answers.Body: <p>The shortest answer is "that's not possible," and the slightly longer answer is "that's not possible because Controllers and Variables have no reason to ever interact." If your Controller relies on a Variable (or vice versa), something is architecturally incorrect. There's no reason for the two to cross paths.</p>
  
  <p>The purpose of a <strong>Controller</strong> is to receive input from a form, AJAX call, or to be used as an API endpoint. It can also be used via routing to show a particular template under particular conditions.</p>
  
  <p>The purpose of a <strong>Variable</strong> is simply to render a value in your Twig template.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-11-24T06:10:23.683Z
Answers.LastActivityDate: 2018-11-24T06:10:23.683Z
Answers.UserDisplayName: Lindsey D
Body: <p>In my Craft 3 plugin I would like to pass a variable defined in my Controller to my PluginVariable.php file. Is this possible?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-11-23T14:57:19.797Z
Comments.Text: Maybe you should improve your question with at least one example of what you'd like to achieve. When building a plugin, I couldn't think of a use case where passing a variable from a controller to the plugin variable would be a good idea.
Comments.UserDisplayName: Paul
Tags: <plugin-development><craft3><variable><controller>
Title: How can I pass a variable defined in a Controller to my variables?
ThreadText: # How can I pass a variable defined in a Controller to my variables?
  
  (Asked by: username_0 on 2018-11-23)
  
  In my Craft 3 plugin I would like to pass a variable defined in my Controller to my PluginVariable.php file. Is this possible?
  
  **Tags:** plugin-development, craft3, variable, controller
  
  > **Comments:**
  > **username_1**: Maybe you should improve your question with at least one example of what you'd like to achieve. When building a plugin, I couldn't think of a use case where passing a variable from a controller to the plugin variable would be a good idea.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2018-11-24. Score: 3
  
  The shortest answer is "that's not possible," and the slightly longer answer is "that's not possible because Controllers and Variables have no reason to ever interact." If your Controller relies on a Variable (or vice versa), something is architecturally incorrect. There's no reason for the two to cross paths.
  
  The purpose of a **Controller** is to receive input from a form, AJAX call, or to be used as an API endpoint. It can also be used via routing to show a particular template under particular conditions.
  
  The purpose of a **Variable** is simply to render a value in your Twig template.
  
  
  ---
  
  