title: calling controller's action in another controller, making widget
body: <p>I have a problem in Yii framework, I want to call a controller's action in the layout/main.php page which is belong to the siteController, I did this:</p>
  
  <pre><code>$a = UsersController::actionRequestAlert($s);
  </code></pre>
  
  <p>then I got this error:</p>
  
  <pre><code>Non-static method UsersController::actionRequestAlert() should not be called statically, assuming $this from incompatible context
  </code></pre>
  
  <p>so how can I solve this problem?</p>
  
  <hr>
  
  <p>ok,
  now I want to create a widget, here is the steps I made:</p>
  
  <ul>
  <li>created folder 'widgets' in folder 'protected'.</li>
  <li>created folder 'views' in folder 'widgets'.</li>
  <li>added this in config/main.php : <code>'application.widgets.*'</code></li>
  <li><p>this is the code of widgets/Alert.php :</p>
  
  <p>class AlertWidget extends CWidget
  {
      public $alert = null;</p>
  
  <pre><code>private $_data = null;
  
  public function init()
  {
      $s = Yii::app()-&gt;session['userId'];
      $r = Requests::model()-&gt;findAll('idUser='.$s.' and confirm =0 and unconfirm=0 and cancel=0');
      $i=0;
      foreach($r as $x)
          $i++;
          if($i&lt;=0)
              $alert=null;
          else
              $alert="(".$i.")";
      $this-&gt;_data = new CActiveDataProvider($alert);
  }
  
  public function run()
  {
      $this-&gt;render('alert', ['data' =&gt; $this-&gt;_data]);
  }
  </code></pre>
  
  <p>}</p></li>
  <li><p>this is the code of widgets/views/alert.php:</p>
  
  <p>echo $data;</p></li>
  <li><p>this is the code to how I use the widget in a view:</p>
  
  <p>$this->widget('application.widgets.Alert');</p></li>
  </ul>
  
  <p>finally I got these errors:</p>
  
  <pre><code>( ! ) SCREAM: Error suppression ignored for
  ( ! ) Fatal error: Cannot redeclare class AlertWidget in C:\wamp\www\mediastore\protected\widgets\Alert.php on line 27
  </code></pre>