Home>

Specify a filtering action,(The following projectcontext () method is being created,List, used when the management page is called)

public function filters ()
{
  return array (
    "accesscontrol", //perform access control for crud operations
    "postonly + delete", //we only allow deletion via post request
    "projectcontext + create index admin",  );
}

Add some filter logic,Define filtering methods,Filter must be added before the filtering method

public function filterprojectcontext ($filterchain)
{
  $prijectid=null;
  if (isset ($_ post ["pid"])) {
    $projectid=$_post ["pid"];
  } elseif (isset ($_ get ["pid"])) {
    $projectid=$_get ["pid"];
  }
  $this->loadproject ($projectid);
  $filterchain->run ();
}
public function loadproject ($projectid)
{
  if ($this->_project === null) {
    $this->_ project=project ::model ()->findbypk ($projectid);
    if ($this->_project === null) {
      throw new chttpexception (404, "Request and item not found!");
    }
  }
  return $this->_project;
}
php
  • Previous Working principle and usage analysis of srbac permission extension module in Yii
  • Next Yii debugging view the method of executing SQL