Zum Inhalt springen

Modulentwicklung Dateien: Unterschied zwischen den Versionen

Aus Computech CMS Wiki
Stefan.thalmann (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Stefan.thalmann (Diskussion | Beiträge)
Keine Bearbeitungszusammenfassung
Zeile 8: Zeile 8:
   Grund: '''YAML Spezifikation''' ([http://yaml.org/spec/1.2/spec.html])
   Grund: '''YAML Spezifikation''' ([http://yaml.org/spec/1.2/spec.html])


Hier ein Zitat aus den FAQs bei YAML:
<blockquote>"Tabs have been outlawed since they are treated differently by different editors and tools. And since indentation is so critical to proper interpretation of YAML, this issue is just too tricky to even attempt. Indeed Guido van Rossum of Python has acknowledged that allowing TABs in Python source is a headache for many people and that were he to design Python again, he would forbid them. ([http://www.yaml.org/faq.html FAQ YAML.org FAQ], Nr. 2.)"</blockquote>
<blockquote>"Tabs have been outlawed since they are treated differently by different editors and tools. And since indentation is so critical to proper interpretation of YAML, this issue is just too tricky to even attempt. Indeed Guido van Rossum of Python has acknowledged that allowing TABs in Python source is a headache for many people and that were he to design Python again, he would forbid them. ([http://www.yaml.org/faq.html FAQ YAML.org FAQ], Nr. 2.)"</blockquote>



Version vom 12. Januar 2017, 13:14 Uhr

Wichtiger Hinweis zum Coding von YAML-Dateien

  • Einrückungen innerhalb von yml-Dateien NUR MIT [Whitespace] realisieren!
 Grund: YAML Spezifikation ([1])

Hier ein Zitat aus den FAQs bei YAML:

"Tabs have been outlawed since they are treated differently by different editors and tools. And since indentation is so critical to proper interpretation of YAML, this issue is just too tricky to even attempt. Indeed Guido van Rossum of Python has acknowledged that allowing TABs in Python source is a headache for many people and that were he to design Python again, he would forbid them. (FAQ YAML.org FAQ, Nr. 2.)"


[modulname].info.yml

Bermerkung: zwingend notwendig Kurzbeschreibung: Moduldefinition

 name: [Modulname]
 type: module
 description: [Modul-Beschreibung]
 package: [Package-Name z.B. zeberliEDV]
 core: 8.x
  • Optional: Abhängigkeiten deklarieren (Beispiel: Versionsabhängigkeit, Modul-Abhängigkeiten)
 version: 8.x-1.x
 dependencies:
 - block
 - examples
 - node
 
 
  • Optional: Regions deklarieren (Beispiel)
 regions:
   header: 'Header'

navigation: 'Menu' slider: 'Slider' highlighted: 'hilighted' content: 'Content' sidebar_first: 'Links sidebar' ...usw...

[modulname].module.yml

 <?php
 
 /**
  * @file
  * An example field using the Field Types API.
  */
 
 /**
  * @defgroup field_example Example: Field Types API
  * @ingroup examples
  * @{
  * Examples using Field Types API.
  *
  * Providing a field requires:
  * - Defining an entity field item. Entity field items are typed data objects
  *   containing the field values.
  *   - Drupal\field_example\Plugin\Field\FieldType\RgbItem
  * - Defining a field type schema at config/schema/[module_name].schema.yml
  *   - config/schema/field_example.schema.yml
  * - One or more widgets specifying how the field appears in edit forms
  *   - Drupal\field_example\Plugin\Field\TextWidget
  *   - Drupal\field_example\Plugin\Field\Text3Widget
  *   - Drupal\field_example\Plugin\Field\ColorPickerWidgetWidget
  * - One or more formatters specifying how the field appears in displayed
  *   entities
  *   - Drupal\field_example\Plugin\FieldFormatter\SimpleTextFormatter
  *   - Drupal\field_example\Plugin\FieldFormatter\ColorBackgroundFormatter
  *
  * @see field_types
  * @see field
  * @see schemaapi
  *
  * @} End of "defgroup field_example".
  */

[modulname].routing.yml

Bemerkung: meist zwingend notwendig Kurzbeschreibung: Diese Datei wird verwendet, um die php-Klasse (bzw. deren Funktion) via Namespace zu deklarieren.

 path: '/Pfad/zu/[modulname]'
 defaults:
   _controller: '[namespace - definiert in php-Datei im /src-Verzeichnis]\[Klassenname]' (Optional mit Funktionsaufruf: [...]::[public Klassen-Funktion]")
   _title: [Titel]
 requirements:
   _permission: 'access content'


[modulname].links.menu.yml

Bemerkung: optional Kurzbeschreibung: Backend-Menüeinbindung im Modul

 [modulname].admin:
   title: [Titel der Settings-Seite]
   description: [Beschreibung der Settings-Seite]
   parent: system.admin_config_development
   route_name: [modulname].content
   weight: 100
  • Optional: Route definieren
   route_name: [modulname]

[modulname].libraries.yml

Bemerkung: optional Kurzbeschreibung: Einbindung von js-, css- und anderen Bibliotheken

 global-styling:
   version: 1.x
     css:
       theme:
         css/slider.css: {}
         fonts/css/font-awesome.css: {}
         ...usw...