Answers.Body: <p>Assuming <code>PluginCustomClass</code> is a class inside of a Craft plugin, then the issue is probably that you need to reference it in the <code>Craft</code> namespace.  Something like this should work:</p>
  
  <pre><code>-&gt;raw(') = new \Craft\PluginCustomClass(')
  </code></pre>
  
  <p>Depending on what type of class that is (Service, Variable, Helper, standalone, etc.), Craft might not have auto-loaded it, so you might need to manually require it as well.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-01-07T18:49:47.267Z
Answers.LastActivityDate: 2016-01-07T18:49:47.267Z
Answers.UserDisplayName: Brad Bell
Body: <p>In my custom Twig tag I am trying to reference a class in the Twig_Node compile method, however I receive an error every time stating it can't find it.  What would the path be to a custom plugin class for the Twig_Node?</p>
  
  <blockquote>
    <p>Fatal error: Class 'PluginCustomClass' not found in /Volumes/Grid/Devbox/www/event.craft.dev/craft/app/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code on line 431</p>
  </blockquote>
  
  <pre><code>public function compile(\Twig_Compiler $compiler)
      {
          $compiler
              -&gt;addDebugInfo($this)
              -&gt;subcompile($this-&gt;getNode('pluginTarget'))
              -&gt;raw(', ')
              -&gt;subcompile($this-&gt;getNode('elementsTarget'))
              -&gt;raw(') = new \PluginCustomClass(')
              -&gt;subcompile($this-&gt;getNode('criteria'))
              -&gt;raw(");\n");
      }
  </code></pre>
  
Tags: <plugin-development><templating><twigextension>
Title: Path to plugin class from a Twig_Node
ThreadText: # Path to plugin class from a Twig_Node
  
  (Asked by: username_0 on 2016-01-07)
  
  In my custom Twig tag I am trying to reference a class in the Twig\_Node compile method, however I receive an error every time stating it can't find it. What would the path be to a custom plugin class for the Twig\_Node?
  
  > Fatal error: Class 'PluginCustomClass' not found in /Volumes/Grid/Devbox/www/event.craft.dev/craft/app/vendor/twig/twig/lib/Twig/Environment.php(403) : eval()'d code on line 431
  
  ```
  public function compile(\Twig_Compiler $compiler)
      {
          $compiler
              ->addDebugInfo($this)
              ->subcompile($this->getNode('pluginTarget'))
              ->raw(', ')
              ->subcompile($this->getNode('elementsTarget'))
              ->raw(') = new \PluginCustomClass(')
              ->subcompile($this->getNode('criteria'))
              ->raw(");\n");
      }
  
  ```
  
  **Tags:** plugin-development, templating, twigextension
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-01-07. Score: 2 | Accepted answer
  
  Assuming `PluginCustomClass` is a class inside of a Craft plugin, then the issue is probably that you need to reference it in the `Craft` namespace. Something like this should work:
  
  ```
  ->raw(') = new \Craft\PluginCustomClass(')
  
  ```
  
  Depending on what type of class that is (Service, Variable, Helper, standalone, etc.), Craft might not have auto-loaded it, so you might need to manually require it as well.
  
  
  ---
  
  