Sen https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!Plugin!DataType!EntityReference.php/8
yardım alabilirsiniz Yoksa örnek varlık örnekler de https://www.drupal.org/project/examples
indirebilirsiniz Yoksa benim yöntemi kullanabilirsiniz çok aşağıda olduğu:
modülünü content_entity_example ayarlayın. info.yml
name: Content Entity Example
type: module
description: 'Provides ContentEntityExampleContact entity.'
package: Example modules
core: 8.x
# These modules are required by the tests, must be available at bootstrap time
dependencies:
- options
- entity_reference
- examples
Biz İnsanlar (İletişim) eklemek, düzenlemek ve silmek için bir 'İletişim' varlık yaratacak Drupal 8'de
bir içerik varlık türü oluşturuluyor. Tamamen fieldable ve 8.
content_entity_example.routing.yml
# This file brings everything together. Very nifty!
# Route name can be used in sevaral place (links, redirects, local actions etc.)
entity.content_entity_example_contact.canonical:
path: '/content_entity_example_contact/{content_entity_example_contact}'
defaults:
# Calls the view controller, defined in the annotation of the contact entity
_entity_view: 'content_entity_example_contact'
_title: 'Contact Content'
requirements:
# Calls the access controller of the entity, $operation 'view'
_entity_access: 'content_entity_example_contact.view'
entity.content_entity_example_contact.collection:
path: '/content_entity_example_contact/list'
defaults:
# Calls the list controller, defined in the annotation of the contact entity.
_entity_list: 'content_entity_example_contact'
_title: 'Contact List'
requirements:
# Checks for permission directly.
_permission: 'view contact entity'
content_entity_example.contact_add:
path: '/content_entity_example_contact/add'
defaults:
# Calls the form.add controller, defined in the contact entity.
_entity_form: content_entity_example_contact.add
_title: 'Add Contact'
requirements:
_entity_create_access: 'content_entity_example_contact'
entity.content_entity_example_contact.edit_form:
path: '/content_entity_example_contact/{content_entity_example_contact}/edit'
defaults:
# Calls the form.edit controller, defined in the contact entity.
_entity_form: content_entity_example_contact.edit
_title: 'Edit Contact'
requirements:
_entity_access: 'content_entity_example_contact.edit'
entity.content_entity_example_contact.delete_form:
path: '/contact/{content_entity_example_contact}/delete'
defaults:
# Calls the form.delete controller, defined in the contact entity.
_entity_form: content_entity_example_contact.delete
_title: 'Delete Contact'
requirements:
_entity_access: 'content_entity_example_contact.delete'
content_entity_example.contact_settings:
path: 'admin/structure/content_entity_example_contact_settings'
defaults:
_form: '\Drupal\content_entity_example\Form\ContactSettingsForm'
_title: 'Contact Settings'
requirements:
_permission: 'administer contact entity'
arasında 'bağlantı' bölümünde tanımlanan eylemler için rota isimleri yönlendirme Drupal yeni varlık kavramların çoğu mevcut kullanır varlık açıklamaları doğru kalıbı takip etmelidir. Ayrıntılar için lütfen aşağıdaki İçerik Varlığı Sınıfına bakınız. Yönlendirme dosyası ile kombinasyon halinde
content_entity_example.links.menu.yml
, bu modül için hook_menu değiştirir.
# Define the menu links for this module
entity.content_entity_example_contact.collection:
title: 'Content Entity Example: Contacts Listing'
route_name: entity.content_entity_example_contact.collection
description: 'List Contacts'
weight: 10
content_entity_example_contact.admin.structure.settings:
title: Contact Settings
description: 'Configure Contact entity'
route_name: content_entity_example.contact_settings
parent: system.admin_structure
Bu article
demeti ile node
içerik türleri için bir işletme başvuru alanı yaratacak
# All action links for this module
content_entity_example.contact_add:
# Which route will be called by the link
route_name: content_entity_example.contact_add
title: 'Add Contact'
# Where will the link appear, defined by route name.
appears_on:
- entity.content_entity_example_contact.collection
- entity.content_entity_example_contact.canonical
Bu yaratmak için kod gibi görünüyor özel varlık türü Ancak, soru bir varlık referans alanı oluşturmayla ilgilidir. – Christian