In the 1990s, tamagotchi were released to the public.
Small, hand-held digital device
colorful and simplistically designed creatures
Tamagotchis are a small alien species that deposited an egg
on Earth to see what life was like, and it is up to the
player to raise the egg into an adult creature.
better care resulting in an adult creature that is smarter, happier, and requires less attention.
You would feed it, play with it, and discipline it

This is how you send CSV data LIKE A BOSS.
Segue: The most common example is just returning a file off disk...

use Symfony\Component\HttpFoundation\BinaryFileResponse;
class MyControllers {
public function helloFile() {
$response = new BinaryFileResponse('hello_world.png');
// Do this in settings.php if you know you're on nginx or
// have the Apache module enabled.
$response::trustXSendfileTypeHeader();
return $response;
}
}

not too hard to write/read and maps to arrays
what does this snippet look like to you?
new line characters denote end of value
indenting allows for more complex data structures
note the use of single quotes! different from Annotations

Forms and Configuration

FormInterface

buildForm

validateForm

submitForm

Admin settings use case

forms now rely on the FormInterface
build, validate, submit - methods
each form is its own class
pretty straightforward and all in one place! easy to read!
system settings have a special use case where the form can rely on module configuration
switch to netbeans and click through classes and interfaces

Forms

Create Admin Settings for Drupalgotchi

Allow administrator to set values:

drupalgotchi name

attention setting

show the admin setting in your site
i need config settings for my module...
something an admin can maniuplate via the UI.

Settings Form Need

a route

a menut item

configuration schema

default values

a form that extends ConfigFormBase

Start with branch:

git checkout lab-02-controller-complete
you need a route
a menu item so it appears in Configuration
you need a settings schema
you probably want default setting values
you need form that extends SystemConfigFormBase

machine name in getFormID() - easy enough
buildForm (don't those args look familiar?!)
and look at that $form array...we can handle that!
now we see the power of the configFactory in submitForm
set the values and call save()

Plugins

starts: 2:30 pm
10 minutes
stops: 2:40 pm
exercise is next
(hit 's' on your keyboard to see me.)
What is a plugin?

Plugins

A narrow set of functionality

Plugin Systems

allows customization and extension of the original system

e.g. graphics software: processing image files

In Drupal 7?

in general plugins provide a narrow set of functionality
a plugin framework or system allows customization and extension of the original system
examples outside of drupal
graphics software use plugins to apply filters and other processes to an image (photoshop) file
web browsers use plugins for playing video and java apps
in d7 we have most notably ctools plugins
who knows of any other plugin systems in D7? jquery plugins? others?

One plugin system for all

a new universal plugin system supports:

plugin types

plugin discovery

plugin factory

Managers define and manage plugin types

BlockManager

ArchiverManager

EditorManager

in d8, we have a new universal plugin system available via core.
This system has three base elements:
plugin types - a controlling class that defines how plugins will be discovered and instantiated. plugin types are the OO solution for info hooks.
plugin discovery - finds plugins in the code base to apply
plugin factory - instantiates specific plugins as needed
each type of plugin has a manager that defines and controls these things
e.g. BlockManager, ArchiverManager, EditorManager

(maybe) other components that could be useful:
plugin derivatives, discovery decorators and plugin mappers.

What is Plugin "Discovery"?

designed to replace info hooks
finds plugins, finds metadata and parses it
takes returned metadata and instantiates objects(factory)
annotated class discovery - use this one
plugins are all located in the same place no matter if it's a core module or contrib