/** * @inheritdoc * * Final submit handler- gather all data together and create new content type. */ public function submitForm(array &$form, FormStateInterface $form_state) { $this->prefix = $this->randomString(4); $this->properties = array(); foreach ($form_state->getValue('fields') as $key => $property) { if ($property['enable'] == 1) { $this->properties[$key] = $property; } } $page_one_values = $form_state->get(['page_values', 1]); $rdf_type = $page_one_values['rdf-type']; $this->createNodeType($rdf_type); $this->rdfMapping = rdf_get_mapping('node', $this->entity->id()); $this->rdfMapping->setBundleMapping(array('types' => array($rdf_type))); $this->createField(); $this->rdfMapping->save(); drupal_set_message($this->t('Content Type %label created', array('%label' => $this->entity->label()))); /*@TODO Revert all saved content type and fields in case of error*/ $form_state->setRedirectUrl(new Url('entity.node.field_ui_fields', array( 'node_type' => $this->entity->id(), ))); }
/** * Builds a standard list of node permissions for a given type. * * @param \Drupal\node\Entity\NodeType $type * The machine name of the node type. * * @return array * An array of permission names and descriptions. */ protected function buildPermissions(NodeType $type) { $type_id = $type->id(); $type_params = array('%type_name' => $type->label()); return array("create {$type_id} content" => array('title' => $this->t('%type_name: Create new content', $type_params)), "edit own {$type_id} content" => array('title' => $this->t('%type_name: Edit own content', $type_params)), "edit any {$type_id} content" => array('title' => $this->t('%type_name: Edit any content', $type_params)), "delete own {$type_id} content" => array('title' => $this->t('%type_name: Delete own content', $type_params)), "delete any {$type_id} content" => array('title' => $this->t('%type_name: Delete any content', $type_params)), "view {$type_id} revisions" => array('title' => $this->t('%type_name: View revisions', $type_params)), "revert {$type_id} revisions" => array('title' => $this->t('%type_name: Revert revisions', $type_params), 'description' => t('Role requires permission <em>view revisions</em> and <em>edit rights</em> for nodes in question, or <em>administer nodes</em>.')), "delete {$type_id} revisions" => array('title' => $this->t('%type_name: Delete revisions', $type_params), 'description' => $this->t('Role requires permission to <em>view revisions</em> and <em>delete rights</em> for nodes in question, or <em>administer nodes</em>.'))); }
/** * Returns a list of view unpublished permissions for a given node type. * * @param \Drupal\node\Entity\NodeType $type * The node type. * * @return array * An associative array of permission names and descriptions. */ protected function buildPermissions(NodeType $type) { $type_id = $type->id(); $type_params = array('%type_name' => $type->label()); return array("view any unpublished {$type_id} content" => array('title' => $this->t('%type_name: View any unpublished content', $type_params))); }