Entites in Drupal 8. Sascha Grossenbacher Christophe Galli



Similar documents
How To Fix A Bug In Drupal 8.Dev

Eclipse 4 RCP application Development COURSE OUTLINE

Everything you ever wanted to know about Drupal 8*

Data Management Applications with Drupal as Your Framework

Drupal 8 The site builder's release

Migrating into Drupal 8 Migrando a Drupal 8

Migrating into Drupal 8

Drupal Module Development

DRUPAL CONTINUOUS INTEGRATION. Part I - Introduction

Drupal 8. Core and API Changes Shabir Ahmad MS Software Engg. NUST Principal Software Engineser PHP/Drupal

AVOIDING THE GIT OF DESPAIR

MASTER DRUPAL 7 MODULE DEVELOPMENT

Auditing Drupal sites for performance, content and optimal configuration

Multilingual content in Drupal 8: a highly evolved permutated API. DrupalCamp Vienna 2013 Francesco Placella

CERTIFIED MULESOFT DEVELOPER EXAM. Preparation Guide

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

Drupal CMS for marketing sites

Introduction to Module Development

Beginning Oracle. Application Express 4. Doug Gault. Timothy St. Hilaire. Karen Cannell. Martin D'Souza. Patrick Cimolini

IBM Business Monitor Version IBM Business Monitor Installation Guide

Visual Basic. murach's TRAINING & REFERENCE

Configuration Management in Drupal 8. Andrea Pescetti Nuvole

WEBAPP PATTERN FOR APACHE TOMCAT - USER GUIDE

Commerce Services Documentation

Things Made Easy: One Click CMS Integration with Solr & Drupal

Faichi Solutions. The Changing Face of Drupal with Drupal 8

The Search API in Drupal 8. Thomas Seidl (drunken monkey)

Secure Messaging Server Console... 2

GlassFish v3. Building an ex tensible modular Java EE application server. Jerome Dochez and Ludovic Champenois Sun Microsystems, Inc.

False Positives & Managing G11n in Sync with Development

NS DISCOVER 4.0 ADMINISTRATOR S GUIDE. July, Version 4.0

D83167 Oracle Data Integrator 12c: Integration and Administration

Symfony2 and Drupal. Why to talk about Symfony2 framework?

metaengine DataConnect For SharePoint 2007 Configuration Guide

1 Basic Configuration of Cisco 2600 Router. Basic Configuration Cisco 2600 Router

Chef Integration. Chef Integration. with IDERA s Uptime Cloud Monitor. Simple, Smart, Seamless May 10, 2013 IDERA

Using LDAP Authentication in a PowerCenter Domain

Enhanced Connector Applications SupportPac VP01 for IBM WebSphere Business Events 3.0.0

IBM WebSphere Message Broker Message Monitoring, Auditing, Record and Replay. Tim Kimber WebSphere Message Broker Development IBM Hursley Park, UK

Services, Dependency Injection, and Containers, Oh my!

IP Phone Presence Setup

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Engine: Using MSBuild and Team Foundation

BUILDING MULTILINGUAL WEBSITES WITH DRUPAL 7

Magento Search Extension TECHNICAL DOCUMENTATION

Authoring for System Center 2012 Operations Manager

How does Drupal 7 Work? Tess Flynn, KDØPQK

Application. 1.1 About This Tutorial Tutorial Requirements Provided Files


Easy configuration of NETCONF devices

How To Load balance traffic of Mail server hosted in the Internal network and redirect traffic over preferred Interface

Dollar Universe SNMP Monitoring User Guide

Drupal and ArcGIS Yes, it can be done. Frank McLean Developer

Oracle Data Integrator 12c: Integration and Administration

Product Guide Addendum. SafeWord Check Point User Management Console Version 2.1

ESB Features Comparison

HP A-IMC Firewall Manager

E4 development: examples, methods and tools. Eclipse Con France 2014

Enable SSL for Apollo 2015

SDK Code Examples Version 2.4.2

Cisco - Configure the 1721 Router for VLANs Using a Switch Module (WIC-4ESW)

Table of Contents. Chapter 1: Installing Endpoint Application Control. Chapter 2: Getting Support. Index

enetworks TM Using the Syslog Feature C.1 Configuring the Syslog Feature

Installation Instruction STATISTICA Enterprise Server

#d8rules - Support the Rules module for Drupal 8

SECURE MOBILE ACCESS MODULE USER GUIDE EFT 2013

c360 to Case Installation and Configuration Guide

TIBCO Hawk SNMP Adapter Installation

Implementation notes on Integration of Avaya Aura Application Enablement Services with Microsoft Lync 2010 Server.

Configuring Load Balancing

Define and Configure an Application Request Routing Server Farm

isolar Integrated Solution for AUTOSAR

Headless Drupal 8. #HeadlessDrupal

KonyOne Server Installer - Linux Release Notes

VRC 7900/8900 Avalanche Enabler User s Manual

Basic Exchange Setup Guide

Web Services for Management Perl Library VMware ESX Server 3.5, VMware ESX Server 3i version 3.5, and VMware VirtualCenter 2.5

Chapter 1 - Web Server Management and Cluster Topology

Exam : Administrating Windows Server 2012 R2. Course Overview

Portal Factory CMIS Connector Module documentation

Working With Virtual Hosts on Pramati Server

Installation Manual for Catalog Infinite Scroll extension

Load Balancing BEA WebLogic Servers with F5 Networks BIG-IP

Integrating CoroSoft Datacenter Automation Suite with F5 Networks BIG-IP

Module 12. Configuring and Managing Storage Technologies. Contents:

J j enterpririse. Oracle Application Express 3. Develop Native Oracle database-centric web applications quickly and easily with Oracle APEX

To Configure Network Connect, We need to follow the steps below:

This class is intended for experienced software developers who understand object-oriented programming (OOP) and C# or VB.NET.

Pcounter Web Administrator User Guide - v Pcounter Web Administrator User Guide Version 1.0

Spectrum Technology Platform. Version 9.0. Administration Guide

2012 Nolio Ltd. All rights reserved

Transcription:

Entites in Drupal 8 Sascha Grossenbacher Christophe Galli

Who are we? Sascha (berdir) Christophe (cgalli) Active core contributor Entity system maintainer Porting and maintaining lots of D8 contrib projects Part-Time Developer Site builder Author of Content Entity Example Module

What are we going to talk about Content vs Config Entities Minimalistic approach Installing and using Making them useful in Drupal Views integration Overview and tools

Before we start: The most important command! drush cr

Content vs. Config Entities in Drupal 8 Config Entity Content Entity Configuration Management Defaults Deployable Dependencies Config translation Not scalable Stored in Tables (by Default) Configurable fields Views integration Content translation Scalable Examples Node Type Vocabulary View Filter format Examples Node Term User Comment

Minimalistic Approach: Use content entity solely for data storage! Define Entity Define fields (Content entity only) /** * Defines the Contact entity. * * @ContentEntityType( * id = "content_entity_example_contact", * label = @Translation("Contact entity"), * base_table = "contact", * entity_keys = { * "id" = "id", * "label" = "name", * "uuid" = "uuid" * }, * ) */ class Contact extends ContentEntityBase { class Contact extends ContentEntityBase { public static function basefielddefinitions(entitytypeinterface $entity_type) { $fields['id'] = BaseFieldDefinition::create('integer') ->setlabel(t('id')) ->setdescription(t('the ID of the Contact entity.')); $fields['uuid'] = BaseFieldDefinition::create('uuid') ->setlabel(t('uuid')) ->setdescription(t('the UUID of the Contact entity.')); $fields['name'] = BaseFieldDefinition::create('string') ->setlabel(t('name')) ->setdescription(t('the name of the Contact entity.')) ->setsettings(array( 'max_length' => 60, )) $fields[ foo ]... } } return $fields;

Minimalistic Approach: Install and Use Installation When installing the module containing the content entity definition, the corresponding schema is automatically created. Core Bug: Without a schema in place, the module cannot be uninstalled! You must define the entity BEFORE installing it!

Usage (CRUD) $my_contact = Contact::create($value_array); $my_contact->name = foo ; $name = $my_contact->name->value; (Content Entity specific) $my_contact->save(); $ids = \Drupal::entityQuery( contact ) ->condition( name, Christophe ) ->sort( name ) ->execute(); Contact::load($id); or Contact::loadMultiple($ids); $my_contact->delete();

Making Content Entities useful in Drupal Extended field definitions Handlers Links Entity Views Integration Field UI / Administration

Extended field definitions $fields['name'] = BaseFieldDefinition::create('string') ->setlabel(t('name')) ->setdescription(t('the name of the Contact entity.')) ->setrequired(true) ->setdefaultvalue( Foo ) ->setsettings(array( 'max_length' => 60, )) Basic definition ->setdisplayoptions('view', array( 'label' => 'above', 'type' => 'string', 'weight' => -6, )) Formatter ->setdisplayoptions('form', array( 'type' => 'string', 'weight' => -6, )) Form Widget ->setdisplayconfigurable('form', TRUE) ->setdisplayconfigurable('view', TRUE); Show Form and Display Widgets in UI

Handlers Handler Classes, declared in the Entity Class, triggered by the routing definition entity.content_entity_example_contact.canonical: path: '/content_entity_example_contact/{content_entity_example_contact}' defaults: _entity_view: 'content_entity_example_contact' * handlers = { entity.content_entity_example_contact.collection: path: '/content_entity_example_contact/list' defaults: _entity_list: 'content_entity_example_contact' content_entity_example.contact_add: path: '/content_entity_example_contact/add' defaults: _entity_form: content_entity_example_contact.add * "view_builder" = "Drupal\Core\Entity\EntityViewBuilder", * "list_builder" = "Drupal\content_entity_example\Entity\Controller\ContactListBuilder", * "form" = { * "add" = "Drupal\content_entity_example\Form\ContactForm", * "edit" = "Drupal\content_entity_example\Form\ContactForm", * "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm", * }, * "access" = "Drupal\content_entity_example\ContactAccessControlHandler", * }, Controls create/edit/delete access for entity and fields Shortcut: Specify admin_permission = administer contacts

Links Routing entity.content_entity_example_contact.canonical: path: '/content_entity_example_contact/{content_entity_example_contact}' defaults: # Calls the view builder, defined in the annotation of the contact entity _entity_view: 'content_entity_example_contact' _title: 'Contact Content' requirements: # Calls the access control handler of the entity, $operation 'view' _entity_access: 'content_entity_example_contact.view' Additional Entity handler: * "route_provider" = { * "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider", * }, * links = { * "canonical" = "/content_entity_example_contact/{content_entity_example_contact}", * "edit-form" = "/content_entity_example_contact/{content_entity_example_contact}/edit", * "delete-form" = "/contact/{content_entity_example_contact}/delete", * "collection" = "/content_entity_example_contact/list"

Field UI and Administration * field_ui_base_route = "content_entity_example.contact_settings",

Views Integration Additional Entity Handler * "views_data" = "Drupal\content_entity_example\ContactViewsData", Class definition <?php namespace Drupal\content_entity_example; use Drupal\views\EntityViewsData; class ContactViewsData extends EntityViewsData { } public function getviewsdata() { $data = parent::getviewsdata(); // Customize views data definitions... return $data; }

Summary It is non-trivial It ist very powerful There is much more to it Bundles Revisions BUT there is Drupal Console 1) drupal generate:module 2) drupal generate:entity:content

Tools You need an IDE Examples Module for Developers https://www.drupal.org/project/examples Content Entity Documentation https://www.drupal.org/node/2192175 Entity Cheat Sheet http://wizzlern.nl/drupal/drupal-8-entity-cheat-sheet Drupal Console http://drupalconsole.com/

The End Questions?