0

I have following code in my php class called Plaint:

class Plaint extends CAction
{
    public function run()
    {
        $model = new PlaintForm();
        $this->runTests($model);
        ...........

I need to run this class without($this->runTests($model)), if enter from this url /plaint. If I enter this page from other url, I need to run $this->runTests($model);.(e.g /filled). How can I do it?

phpdev
  • 511
  • 4
  • 22

1 Answers1

0

You can look for specific phrase in current url:

if(strpos(Yii::app()->request->requestUri, '/filled') !== false) {
    $this->runTests($model);
}

I advise against putting test code into production code.

xReprisal
  • 810
  • 8
  • 23