public function getEventTypes()
    {
        $this->request->allowMethod(['post', 'patch', 'put']);
        $calendarsTable = TableRegistry::Get('Qobo/Calendar.Calendars');

        $eventTypes = [];
        $data = $this->request->getData();

        $calendar = $calendarsTable->get($data['calendar_id']);
        $types = $this->CalendarEvents->getEventTypes(['calendar' => $calendar, 'user' => $this->Auth->user()]);

        foreach ($types as $item) {
            if (isset($item['name'])) {
                $eventTypes[] = $item;
            } else {
                $eventTypes[] = ['name' => $item, 'value' => $item];
            }
        }

        if (!empty($data['exclude'])) {
            foreach ($data['exclude'] as $type) {
                foreach ($eventTypes as $k => $item) {
                    if (preg_match("/^$type/i", $item['value'])) {
                        unset($eventTypes[$k]);
                    }
                }
            }

            $eventTypes = array_values($eventTypes);
        }

        $this->set(compact('eventTypes'));
        $this->set('_serialize', 'eventTypes');
    }