OO: Geting the Uh-oh’s out of Object Oriented Drupal 8.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

Become a Panels Rockstar. Audience Survey Have you tried Panels? Are you a …. –Themer / Designer? –Developer / Code Junkie? –Information Architect?
INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
© by Pearson Education, Inc. All Rights Reserved.
Chapter 6 Multiform Projects Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. McGraw-Hill.
2 Object-Oriented Analysis and Design with the Unified Process Objectives  Explain how statecharts can be used to describe system behaviors  Use statecharts.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Object-oriented Programming Concepts
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
C++ fundamentals.
Walking the walk and talking the talk… T HE L ANGUAGE OF D RUPAL.
Drupal 7 as an enterprise web application framework Why as a developer you should use Drupal to build web applications? Klaus Harris DrupalCon Munich 2012.
Drupal Content Management System Mallikarjuna Pinjala CIS 764, Nov
1 Chapter One A First Program Using C#. 2 Objectives Learn about programming tasks Learn object-oriented programming concepts Learn about the C# programming.
V Avon High School Tech Club Agenda Old Business –Delete Files New Business –Week 16 Topics: Intro to HTML/CSS –Questions? Tech Club Forums.
A First Program Using C#
Overview of Previous Lesson(s) Over View  OOP  A class is a data type that you define to suit customized application requirements.  A class can be.
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Zhonghua Qu and Ovidiu Daescu December 24, 2009 University of Texas at Dallas.
COMP 410 & Sky.NET May 2 nd, What is COMP 410? Forming an independent company The customer The planning Learning teamwork.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
Writing various AJAX forms in Drupal 7 1. Overview of Form API 2. Ctools 2.1 Ctools features 3. Ajax 3.1 Ajax Forms in Drupal 4. Putting it all together.
Codeigniter is an open source web application. It occupies a very small amount of space in the memory and is most useful for developers who aim to develop.
|Tecnologie Web L-A Anno Accademico Laboratorio di Tecnologie Web Introduzione ad Eclipse e Tomcat
LiveCycle Data Services Introduction Part 2. Part 2? This is the second in our series on LiveCycle Data Services. If you missed our first presentation,
Agenda Review Unix Review Algorithms Your first program Compiling programs What are functions? What is Object Oriented Programming? Variables Data Types.
Multi-Part Requests/ Parent & Child Service Items.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Utterly Useless Widget creating your own Chameleon widget...
OOP IN PHP `Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For.
GEMVC. The Setup Folders Views Value Objects (VOs) Custom Events Service CFCs Controller Model Application Main MXML.
What you don’t know you don’t know about Drupal 6 Dan Harris daneesia on drupal.org.
Drupal Overview Prepared by : Agustin D. Gumogda Jr. Instructor.
Associations INFO 2310: Topics in Web Design and Programming.
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Multiform Projects.
Introduction to Module Development John Fiala and Ezra Barnett Gildesgame.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
How does Drupal Work? Information Systems 337 Prof. Harry Plantinga.
1.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Nested componentization for advanced Web portal solutions Svebor Prstačić, dipl. ing., Dr. sc. Ivan Voras, Dr. sc. Mario Žagar.
Design Patterns David Talby. This Lecture Re-routing method calls Chain of Responsibility Coding partial algorithms Template Method The Singleton Pattern.
JSP BASICS AND ARCHITECTURE. Goals of JSP Simplify Creation of dynamic pages. Separate Dynamic and Static content.
Object Oriented Programming Session # 03.  Abstraction: Process of forming of general and relevant information from a complex scenarios.  Encapsulation:
Overview of Previous Lesson(s) Over View 3 Program.
PHP Form Processing * referenced from
A PC Wakes Up A STORY BY VICTOR NORMAN. Once upon a time…  a PC (we’ll call him “H”) is connected to a network and turned on. Aside: The network looks.
New Project Model UI Primary Author: Mikhail Sennikovsky Major contributors: Mikhail Voronin, Oleg Krasilnikov, Leo Treggiari Intel Corporation September,
Design Patterns. Outline Purpose Purpose Useful Definitions Useful Definitions Pattern Overview Pattern Overview.
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
Structure A Data structure is a collection of variable which can be same or different types. You can refer to a structure as a single variable, and to.
Perl Subroutines User Input Perl on linux Forks and Pipes.
Building KFS using KNS Presented by James SmithJustin Beltran University of ArizonaUniversity of California, Irvine.
How to develop a VoIP softphone in C# by using OZEKI VoIP SIP SDK This presentation demonstrates the first steps concerning to how to develop a fully-functional.
Top 12 PHP Frameworks 2016.
Data Virtualization Tutorial: Introduction to SQL Script
z/Ware 2.0 Technical Overview
Play Framework: Introduction
Character (String) Data
Content Management System
IT Atoumation / Conf. Mgmt...
Application Development Theory
Intro to PHP & Variables
Global Drupal Training Day
SharePoint Essentials Toolkit
Functions BIS1523 – Lecture 17.
Object oriented vs procedural programming
Hans Zaunere, Managing Member
Presentation transcript:

OO: Geting the Uh-oh’s out of Object Oriented Drupal 8

2 Hello My Name is Dagobeto Aceves Achieve Internet +5 Years Drupal Developer Native San Diegan New Father

3 HelloKen extends Hello My Name is Ken Gilbert Achieve Internet +2 Years Drupalist Outlander Native Coachella Valley-ian (Palm Springs) New Father Husband

4 Agenda My Name is Dagobeto Aceves Drupal and how it got to OO Glance OO Concepts OO Drupal A look at a Drupal OO example - building a simple page callback and a simple form. A line by line analysis of code. Associating example code with OO concepts. A line by line analysis of a form callback. Scaffolding with Console Q&A

Where we began Steep Curve But Doable

6 Drupal of Old Global global everwhere Wild West of Code Global Variables $user $base_path More Global Functions l() t() More

7 Every Can Drupal Easy to use Positives: Global variables can be used everywhere Global functions can be executed anywhere Module functions can be executed everywhere Everyone can Drupal!

8 Every Can Drupal Easy to use Negatives: Global variables can be used everywhere Global functions can be executed anywhere Module functions can be executed everywhere Requires more User memory

OO: Programming The Drop Off

10 10,000 ft view These topics are lager than the appear. New and Exciting Symfony Framework New backend handling incoming requests PSR-4 PHP Standard Recommendation Specification for autoloading classes from file paths Object Oriented Programming The rabbit hole. Decoupled and Reusable Components Parts of the code that handle data don’t deal with how its displayed and vice-versa.

OO Rabbit Hole

12 Object Disoriented $OO->listAllTopics() Data Abstraction Represent features without including details Data Encapsulation Wrapping data and associated function in one single unit. Inheritance Capability of one class to inherit properties from other class Objects and Classes Templates for creating Objects. OO Design Patterns Creation patterns Singleton Factory Etc… Behavioral Design Patterns Command Observer Etc… So many more…

13 Let’s see scary Drupal 8 stuff

14 Drupal OO Stay on the path Creating a simple page callback Drupal 7 you needed: Create a folder “page_example” in {DOCROOT}/sites/all/modules/custom *.module *.info Implement hook_menu Define the page callback function and maybe pass in some arguments to your callback

15 Drupal 8 Stay on the path Creating a simple page callback Create a folder “page_example” in {DOCROOT}/modules/custom *.info.yml *.routing.yml PageExampleController.php YML (rhymes with camel) is not OO PHP. Nifty human-readable data serialization language. YML content easily maps high-level language data types such as lists, associative arrays.

16 Drupal 8 Stay on the path Create a ‘page_example’ directory Create a ‘page_example.info.yml’ file with this content. You now have a module you can enable. Really! That’s all you need. Lets enable it. It doesn’t do anything but lets get to that next.

17 Drupal 8 Stay on the path Create a ‘page_example.routing.yml’ file with this content. Replace hook_menu with a serialized array. Can you spot the path? The page_callback? The Access Permissions? See more on routing

18 Drupal 8 Stay on the path Create PageExampleController in the ‘src/Controller’ directory.

19 Drupal 8 Stay on the path Add our “methods”. Which are just functions for our class.

20 Drupal 8 Stay on the path Add our “methods”. Just functions for our class.

21 PHP Magic – Becoming an OO Master Hidden Give Me Methods __construct() When a class object is created, do some setup first. __destruct() When a class object is destroyed, do some cleanup first. __toString() When a class object is printed as a string, print this instead of showing me a nasty PHP error. And many more

22 Drupal 8 Stay on the path Add our “methods”. Just functions for our class. More on render arrays.

23 Drupal 8 Stay on the path Lets visit our pages!

24 I see the pages…and the menus?

25 Drupal 8 More yaml Create page_example.links.menu.yml

26 Drupal 8 Menus yey! Lets look at those menu items on the admin screen.

27 How about a form?

28 Drupal 8 Stay on the path New file PageExampleForm.php in page_example/src/Form

29 Methods for our form Form Id and Build Form

30 Methods for our form Validate and Submit

31 Lets look at our page But first we need a route...oy

32 Now can we see it? Yes…. Now you can. Lets go look at our page!

33 Just the form please Not all forms are pages.

34 Lets look at these “worms”

35 Lets take closer look Woms man... Worms! Of the code written you can ONLY delete the function validateForm. Everything else is necessary.. Forgot to type in: Array? – it breaks FormStateInterface? – bork One of the ‘use’s? – bork bork bork The errors will be cryptic until you learn more OO but the gist of all the errors are either: You’re missing something that you told me to use. You’re missing something that what you’ll telling me to use requires. Lets go break the code to see what I mean!

36 You said OO is good? Tell me more

37 Lets take closer look again Type Declarations Including the FormBase makes sense since we are inheriting from that class. Which variables and methods can you use? FormStateInterface seems like something you just should have known... But really how would you have? You got me there. But there’s ways around remembering.

38 Improved Support Drupal Console Patterns can be automated so you don’t have to remember what to include, let the machines remember for you! Improved Performance Things are there only when you need them. Standard Code Structure Forms go in forms Controllers in controllers Blocks are PlugIn we didn’t talk about this one but it would be the next step. IDE Candy Improved support form IDEs because we’re following a standard now. No more wild west.

39 Improved Support Drupal Console generate generate:authentication:provider Generate an Authentication Provider generate:command Generate commands for the console. generate:controller Generate & Register a controller generate:doc:dash Generate the DrupalConsole.docset package for Dash generate:doc:gitbook Generate documentations for Commands generate:entity:bundle Generate a new content type (node / entity bundle) generate:entity:config Generate a new config entity generate:entity:content Generate a new content entity generate:event:subscriber Generate an event subscriber generate:form Generate a new "FormBase" generate:form:alter Generate an implementation of hook_form_alter() or hook_form_FORM_ID_alter generate:form:config Generate a new "ConfigFormBase" generate:module Generate a module. generate:permissions Generate module permissions generate:plugin:block Generate a plugin block generate:plugin:condition Generate a plugin condition. generate:plugin:rulesaction Generate a plugin rule action generate:plugin:type:annotation Generate a plugin type with annotation discovery generate:plugin:type:yaml Generate a plugin type with Yaml discovery generate:plugin:views:field Generate a custom plugin view field. generate:service Generate service generate:theme Generate a theme.

40 What did we see Example Controllers using basic Class Creating and using namespaces Scope Resolution Operator ‘::’ for calling methods from classes Basic Inheritence using Extend Basic Concept of an Interfaces and implementing Type Declarations Automated support for developing

41 Questions Go. ?

42 Thanks Go. :)

43 References Go