/** * Get periods * * @return array * An array of arrays as follows: array( array('label'=>$month0 . $year0, 'value'=>$id0), array('label'=>$month1 . $year1, 'value'=>$id1),…) */ public function getPeriods2() { $periods = array(); $this->Period->byOrganizationWithYear($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function ($Period) use(&$periods) { // array_push($periods, array('value'=> $Period->id, 'label' => $this->Lang->get('decima-accounting::period-management.' . $Period->month) . ' ' . $Period->year->year)); array_push($periods, array('value' => $Period->id, 'label' => $this->Lang->get('decima-accounting::period-management.' . $Period->month) . ' ' . $Period->year)); }); return $periods; }