comanage-dev - [comanage-dev] Code Diff
Subject: COmanage Developers List
List archive
- From: Benn Oshrin <>
- To: comanage-dev <>
- Subject: [comanage-dev] Code Diff
- Date: Fri, 20 Feb 2015 21:49:52 -0500
As mentioned on today's dev call, here's an example from CoPersonRole::afterSave()
// Since the Provisioner Behavior will only provision group memberships
// for CO People with an Active status we do not need to manage
// membership in the members group based on status here. So we only
// add a CO Person to the COU members group whenever we detect
// the CO Person Record has a COU.
- $couid = $this->data[$this->alias]['cou_id'];
- if (empty($couid)) {
- return;
+ if(empty($this->data[$this->alias]['cou_id'])) {
+ return;
}
+ $couid = $this->data[$this->alias]['cou_id'];
PHP will evaluate $this->data[$this->alias]['cou_id'] before assigning it to $couid, and if any component is invalid (data is empty, there is no cou_id element, etc) will output a warning. So you can't assign and then test for empty, you have to check for empty before you assign. That's what the above diff does (as well as fixing some spacing issues).
(empty() and isset() will suppress warnings during evaluation.)
Thanks,
-Benn-
- [comanage-dev] Code Diff, Benn Oshrin, 02/21/2015
- Re: [comanage-dev] Code Diff, Benn Oshrin, 02/21/2015
Archive powered by MHonArc 2.6.16.