Hi,
I am getting "clone method called on non-object" error on line:
$to = clone $calendar->from_time;
Does anyone know, how ti fix this? I need to solve this ASAP, thanks for any help.
Code of my function is:
public function renderDetail($id)
{
$db = $this->getService('database');
$event = $db->table('events')->find($id)->fetch();
$place = $db->table('places')->find($event->id_place)->fetch();
if ($event->permanent)
{
$today = new NetteDateTime();
$calendar = $db->table('calendar')->where(array(
'event_id' => $event->id,
'day_id' => $today->format('N'),
))->fetch();
}
else
{
$calendar = $db->table('calendar')->where(array(
'event_id' => $event->id,
))->fetch();
}
$to = clone $calendar->from_time;
$interval = new DateInterval('PT'.$calendar->duration->format('H').'H'.$calendar->duration->format('i').'M');
$to->add($interval);
$response = array(
'place_name' => $place->name,
'message' => $event->message,
'from' => $calendar->from_time->format('H:i'),
'to' => $to->format('H:i'),
'latitude' => $place->latitude,
'longitude' => $place->longitude,
'address' => $place->address,
);
$this->sendResponse(new NetteApplicationResponsesJsonResponse(array(
'success' => true,
'event' => $response,
)));
}
Thank you!