Yii Framework Forum: Error on Portlet after Upgrading to 1.0.8 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Error on Portlet after Upgrading to 1.0.8 Rate Topic: -----

#1 User is offline   codezilla 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 14-July 09
  • Location:Thailand

Posted 09 August 2009 - 10:25 PM

Dear All,

Today as Yii 1.0.8 released, I upgraded mine from Yii 1.0.7. And errors show:

FlashMessage does not have a method named "run".


What is weird, it was fine before I upgraded. So I decided to make sure, and degrade it again to Yii 1.0.7, and it runs OK again without errors or exceptions. But when I upgrade to 1.0.8 again, it throws error again.

FlashMessage is a portlet of which displays application messages and determine correct css style to users, for example:

Quote

Data was successfully saved.


FlashMessage extends Portlet which extends CWidget. Here is the code to Portlet.php:
<?php
abstract class Portlet extends CWidget
{
    public $title     = '';
    public $showTitle = true;
    public $published = true;

    public function init() {
        
    }

    public function run()
    {
       if ($this->published)
       {
           $this->renderContent();
           // render the portlet ending frame
       }
    }

    /**
     * Child Classes from Portlet must override this method to render its content
     * @method  renderContent
     * @abstract
     */
    abstract protected function renderContent();

}


And the FlashMessage.php is as simple as below:
<?php
class FlashMessage extends Portlet
{
    public $message = '';
    public $type = 'success'; //success || error || warning || info

    public function init()
    {
        parent::init();
    }

    /**
     *
     * Child Classes from Portlet must override this method to render its content
     * @method  renderContent
     */
    protected function renderContent()
    {
       if(Yii::app()->user->hasFlash('success'))
       {
           $this->message = Yii::app()->user->getFlash('success');
           $this->type = 'success';
       }
       else if (Yii::app()->user->hasFlash('error'))
       {
           $this->message = Yii::app()->user->getFlash('error');
           $this->type = 'error';
       }
       else if (Yii::app()->user->hasFlash('info'))
       {
           $this->message = Yii::app()->user->getFlash('info');
           $this->type = 'info';
       }
       else if (Yii::app()->user->hasFlash('warning'))
       {
           $this->message = Yii::app()->user->getFlash('warning');
           $this->type = 'warning';
       }

       $this->render('_flashMessage');
    }
}


And finaly, the view of the FlashMessage:
<?php if (isset($this->message) && $this->message != "") { ?>
<div class="message <?php echo $this->type; ?>">
   <?php echo $this->message; ?>
</div>
<?php } ?>



I don't know but maybe it has something to do on the way I imported the models and components ? In the config/main.php is all the imports happen in my application:
<?php
// autoloading model and component classes	
	'import'=>array(
		'application.models.*',
		'application.components.*',
        'application.ext.*',
        'application.helpers.*',
        'application.vendors.*'
	)


So, please help on this issue, because I really do not know what has happened ? Why it displays error when I run my application on Yii version 1.0.8 ?

For now, I have degraded again to Yii 1.0.7 as my application runs Stable on the version.

Thank you in advanced!
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 09 August 2009 - 10:47 PM

Do a global search for "FlashMessage". This must be because you have multiple FlashMessage classes. In 1.0.8, the precedence of imported path aliases is reversed (i.e., path imported later has precedence over existing paths).


0

#3 User is offline   codezilla 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 14-July 09
  • Location:Thailand

Posted 09 August 2009 - 11:05 PM

View Postqiang, on 09 August 2009 - 10:47 PM, said:

Do a global search for "FlashMessage". This must be because you have multiple FlashMessage classes. In 1.0.8, the precedence of imported path aliases is reversed (i.e., path imported later has precedence over existing paths).


Hi qiang!

Sorry, but I don't think I have understood on what you said about multiple FlashMessage classes that I have ? I only have 1 class of FlashMessage which is stored in the components folder of my application.

And yes, I also did a global search which I found only 1 FlashMessage.php class, and many on the other views where it is being used, such as:
<?php
   $this->widget('FlashMessage');

0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 09 August 2009 - 11:29 PM

What about 'Portlet' class? Did you find multiple?
0

#5 User is offline   codezilla 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 14-July 09
  • Location:Thailand

Posted 09 August 2009 - 11:37 PM

View Postqiang, on 09 August 2009 - 11:29 PM, said:

What about 'Portlet' class? Did you find multiple?


Oh man, you're right! So, in components folder there is this Portlet.php, and then in my models folder also there is Portlet.php, so I have renamed models/Portlet.php to models/PortletModel.php. And it worked!

Thank you very much, qiang! Problem Solved.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users