public function edit($slug)
    {
        $this->loadModel('Content.ContentTypes');
        $this->loadModel('User.Roles');

        $type = $this->ContentTypes
            ->find()
            ->where(['slug' => $slug])
            ->first();

        if (!$type) {
            throw new NotFoundException(__d('content', 'Content type was not found!'));
        }

        if ($this->request->data()) {
            $type->accessible(['id', 'slug'], false);
            $data = $this->request->data();
            $type = $this->ContentTypes->patchEntity($type, $data);

            if ($this->ContentTypes->save($type, ['associated' => ['Roles']])) {
                $this->Flash->success(__d('content', 'Content type updated!'));
                $this->redirect(['plugin' => 'Content', 'controller' => 'types', 'action' => 'edit', $type->slug]);
            } else {
                $this->Flash->danger(__d('content', 'Content type could not be updated, check your information.'));
            }
        } else {
            // fix for auto-fill "defaults.*" by FormHelper
            $this->request->data = $type->toArray();
        }

        $roles = $this->Roles->find('list');
        $this->title(__d('content', 'Configure Content Type'));
        $this->set(compact('type', 'roles'));
        $this->set('languages', LocaleToolbox::languagesList());
        $this->Breadcrumb
            ->push('/admin/content/manage')
            ->push(__d('content', 'Content Types'), '/admin/content/types')
            ->push(__d('content', 'Editing "{0}" Content Type', $type->name), '');
    }