本文整理汇总了PHP中Drupal\node\Entity\NodeType::label方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeType::label方法的具体用法?PHP NodeType::label怎么用?PHP NodeType::label使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\node\Entity\NodeType
的用法示例。
在下文中一共展示了NodeType::label方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitForm
/**
* @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(),
)));
}
示例2: buildPermissions
/**
* 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>.')));
}
示例3: buildPermissions
/**
* 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)));
}