This function is throwing me a "Closure object cannot have properties" error :
public function activitiesSummaryAction()
{
$classes = array();
for($i = 1; $i <=10; $i++)
{
array_push($classes, new Classroom($i, function(){
$activites = array();
for ($i = 1; $i <=10; $i++)
{
array_push($activites, new Activity(rand(1,7), rand(2016,2018)));
}
return $activites;
}
));
}
return $this->render('teacher/activitiesSummary.html.twig', [
'classes' => $classes,
]);
}
Actually I'am not sure if PHP can support this kind of callback functions. Could anyone tell me how to correct this or make it work in another way?
EDITED: Here are the classes Classroom and Activity:
class Activity {
public $_id;
public $_annee;
public $_inProgress;
function __construct($id, $annee) {
$this->_id = $id;
$this->_annee = $annee;
$this->_inProgress = rand(0,1);
}
}
class Classroom {
public $_id;
public $_activities;
function __construct($id, $activities) {
$this->_id = $id;
$this->_activities = array($activities);
}
}