initial app skeleton with sample drupal modules for testing

parents
dist/*
node_modules/*
!drupal/
drupal/*
!drupal/modules/
drupal/modules/*
!drupal/modules/epal/
!drupal/modules/epalreadydata/
# Logs
*.log
# Runtime data
pids
*.pid
*.seed
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Sass cache folder
.sass-cache
# Users Environment Variables
npm-debug*
# bower_components
# Project reference
# typings
{
"name": "drupal/epal",
"type": "drupal-module",
"description": "EPAL Registration",
"keywords": ["Drupal"],
"license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/epal",
"minimum-stability": "dev",
"support": {
"issues": "https://www.drupal.org/project/issues/epal",
"source": "http://cgit.drupalcode.org/epal"
},
"require": { }
}
name: epal
type: module
description: EPAL Registration
core: 8.x
package: epal
entity.epal_student.add_form:
route_name: entity.epal_student.add_form
title: 'Add EPAL Student'
appears_on:
- entity.epal_student.collection
entity.epal_student_class.add_form:
route_name: entity.epal_student_class.add_form
title: 'Add EPAL Student Class'
appears_on:
- entity.epal_student_class.collection
# EPAL Student menu items definition
entity.epal_student.collection:
title: 'EPAL Student list'
route_name: entity.epal_student.collection
description: 'List EPAL Student entities'
parent: system.admin_epal
weight: 100
epal_student.admin.structure.settings:
title: EPAL Student settings
description: 'Configure EPAL Student entities'
route_name: epal_student.settings
parent: system.admin_structure
# EPAL Student Class menu items definition
entity.epal_student_class.collection:
title: 'EPAL Student Class list'
route_name: entity.epal_student_class.collection
description: 'List EPAL Student Class entities'
parent: system.admin_epal
weight: 100
epal_student_class.admin.structure.settings:
title: EPAL Student Class settings
description: 'Configure EPAL Student Class entities'
route_name: epal_student_class.settings
parent: system.admin_structure
# EPAL Student routing definition
epal_student.settings_tab:
route_name: epal_student.settings
title: 'Settings'
base_route: epal_student.settings
entity.epal_student.canonical:
route_name: entity.epal_student.canonical
base_route: entity.epal_student.canonical
title: 'View'
entity.epal_student.edit_form:
route_name: entity.epal_student.edit_form
base_route: entity.epal_student.canonical
title: 'Edit'
entity.epal_student.delete_form:
route_name: entity.epal_student.delete_form
base_route: entity.epal_student.canonical
title: Delete
weight: 10
# EPAL Student Class routing definition
epal_student_class.settings_tab:
route_name: epal_student_class.settings
title: 'Settings'
base_route: epal_student_class.settings
entity.epal_student_class.canonical:
route_name: entity.epal_student_class.canonical
base_route: entity.epal_student_class.canonical
title: 'View'
entity.epal_student_class.edit_form:
route_name: entity.epal_student_class.edit_form
base_route: entity.epal_student_class.canonical
title: 'Edit'
entity.epal_student_class.delete_form:
route_name: entity.epal_student_class.delete_form
base_route: entity.epal_student_class.canonical
title: Delete
weight: 10
<?php
/**
* @file
* Contains epal.module.
*/
use Drupal\Core\Routing\RouteMatchInterface;
/**
* Implements hook_help().
*/
function epal_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
// Main module help for the epal module.
case 'help.page.epal':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('EPAL Registration') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_theme().
*/
function epal_theme() {
return [
'epal' => [
'template' => 'epal',
'render element' => 'children',
],
];
}
add epal student entities:
title: 'Create new EPAL Student entities'
administer epal student entities:
title: 'Administer EPAL Student entities'
description: 'Allow to access the administration form to configure EPAL Student entities.'
restrict access: true
delete epal student entities:
title: 'Delete EPAL Student entities'
edit epal student entities:
title: 'Edit EPAL Student entities'
access epal student overview:
title: 'Access the EPAL Student overview page'
view published epal student entities:
title: 'View published EPAL Student entities'
view unpublished epal student entities:
title: 'View unpublished EPAL Student entities'
add epal student class entities:
title: 'Create new EPAL Student Class entities'
administer epal student class entities:
title: 'Administer EPAL Student Class entities'
description: 'Allow to access the administration form to configure EPAL Student Class entities.'
restrict access: true
delete epal student class entities:
title: 'Delete EPAL Student Class entities'
edit epal student class entities:
title: 'Edit EPAL Student Class entities'
access epal student class overview:
title: 'Access the EPAL Student Class overview page'
view published epal student class entities:
title: 'View published EPAL Student Class entities'
view unpublished epal student class entities:
title: 'View unpublished EPAL Student Class entities'
<?php
/**
* @file
* Contains epal_student.page.inc.
*
* Page callback for EPAL Student entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for EPAL Student templates.
*
* Default template: epal_student.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_epal_student(array &$variables) {
// Fetch EpalStudent Entity Object.
$epal_student = $variables['elements']['#epal_student'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?php
/**
* @file
* Contains epal_student_class.page.inc.
*
* Page callback for EPAL Student Class entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for EPAL Student Class templates.
*
* Default template: epal_student_class.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_epal_student_class(array &$variables) {
// Fetch EpalStudentClass Entity Object.
$epal_student_class = $variables['elements']['#epal_student_class'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
This diff is collapsed.
<?php
namespace Drupal\epal\Entity;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\user\UserInterface;
/**
* Defines the EPAL Student Class entity.
*
* @ingroup epal
*
* @ContentEntityType(
* id = "epal_student_class",
* label = @Translation("EPAL Student Class"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\epal\EpalStudentClassListBuilder",
* "views_data" = "Drupal\epal\Entity\EpalStudentClassViewsData",
* "translation" = "Drupal\epal\EpalStudentClassTranslationHandler",
*
* "form" = {
* "default" = "Drupal\epal\Form\EpalStudentClassForm",
* "add" = "Drupal\epal\Form\EpalStudentClassForm",
* "edit" = "Drupal\epal\Form\EpalStudentClassForm",
* "delete" = "Drupal\epal\Form\EpalStudentClassDeleteForm",
* },
* "access" = "Drupal\epal\EpalStudentClassAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\epal\EpalStudentClassHtmlRouteProvider",
* },
* },
* base_table = "epal_student_class",
* data_table = "epal_student_class_field_data",
* translatable = TRUE,
* admin_permission = "administer epal student class entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* "minno" = "minno",
* "maxno" = "maxno",
* },
* links = {
* "canonical" = "/admin/epal/epal_student_class/{epal_student_class}",
* "add-form" = "/admin/epal/epal_student_class/add",
* "edit-form" = "/admin/epal/epal_student_class/{epal_student_class}/edit",
* "delete-form" = "/admin/epal/epal_student_class/{epal_student_class}/delete",
* "collection" = "/admin/epal/epal_student_class",
* },
* field_ui_base_route = "epal_student_class.settings"
* )
*/
class EpalStudentClass extends ContentEntityBase implements EpalStudentClassInterface {
use EntityChangedTrait;
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += array(
'user_id' => \Drupal::currentUser()->id(),
);
}
/**
* {@inheritdoc}
*/
public function getName() {
return $this->get('name')->value;
}
/**
* {@inheritdoc}
*/
public function setName($name) {
$this->set('name', $name);
return $this;
}
/**
* {@inheritdoc}
*/
public function getCreatedTime() {
return $this->get('created')->value;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime($timestamp) {
$this->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwner() {
return $this->get('user_id')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
return $this->get('user_id')->target_id;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid) {
$this->set('user_id', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this->set('user_id', $account->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function isPublished() {
return (bool) $this->getEntityKey('status');
}
/**
* {@inheritdoc}
*/
public function setPublished($published) {
$this->set('status', $published ? TRUE : FALSE);
return $this;
}
/**
* {@inheritdoc}
*/
public function getMinno() {
return $this->get('minno')->value;
}
/**
* {@inheritdoc}
*/
public function setMinno($minno) {
$this->set('minno', $minno);
return $this;
}
/**
* {@inheritdoc}
*/
public function getMaxno() {
return $this->get('maxno')->value;
}
/**
* {@inheritdoc}
*/
public function setMaxno($maxno) {
$this->set('maxno', $maxno);
return $this;
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = parent::baseFieldDefinitions($entity_type);
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Authored by'))
->setDescription(t('The user ID of author of the EPAL Student Class entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['name'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
->setDescription(t('The name of the EPAL Student Class entity.'))
->setSettings(array(
'max_length' => 50,
'text_processing' => 0,
))
->setDefaultValue('')
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'string',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'string_textfield',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the EPAL Student Class is published.'))
->setDefaultValue(TRUE);
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(t('Created'))
->setDescription(t('The time that the entity was created.'));
$fields['changed'] = BaseFieldDefinition::create('changed')
->setLabel(t('Changed'))
->setDescription(t('The time that the entity was last edited.'));
$fields['maxno'] = BaseFieldDefinition::create('integer')
->setLabel(t('Max Number of Students'))
->setDescription(t('The maximum number of students in class.'))
->setSettings(array(
'max_length' => 2,
'text_processing' => 0,
))
->setDefaultValue(25)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'integer',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'integer',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['minno'] = BaseFieldDefinition::create('integer')
->setLabel(t('Min Number of Students'))
->setDescription(t('The minimum number of students in class.'))
->setSettings(array(
'max_length' => 2,
'text_processing' => 0,
))
->setDefaultValue(25)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'integer',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'integer',
'weight' => -4,
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
return $fields;
}
}
<?php
namespace Drupal\epal\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\user\EntityOwnerInterface;
/**
* Provides an interface for defining EPAL Student Class entities.
*
* @ingroup epal
*/
interface EpalStudentClassInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
// Add get/set methods for your configuration properties here.
/**
* Gets the EPAL Student Class name.
*
* @return string
* Name of the EPAL Student Class.
*/
public function getName();
/**
* Sets the EPAL Student Class name.
*
* @param string $name
* The EPAL Student Class name.
*
* @return \Drupal\epal\Entity\EpalStudentClassInterface
* The called EPAL Student Class entity.
*/
public function setName($name);
/**
* Gets the EPAL Student Class creation timestamp.
*
* @return int
* Creation timestamp of the EPAL Student Class.
*/
public function getCreatedTime();
/**
* Sets the EPAL Student Class creation timestamp.
*
* @param int $timestamp
* The EPAL Student Class creation timestamp.
*
* @return \Drupal\epal\Entity\EpalStudentClassInterface
* The called EPAL Student Class entity.
*/
public function setCreatedTime($timestamp);
/**
* Returns the EPAL Student Class published status indicator.
*
* Unpublished EPAL Student Class are only visible to restricted users.
*
* @return bool
* TRUE if the EPAL Student Class is published.
*/
public function isPublished();
/**
* Sets the published status of a EPAL Student Class.
*
* @param bool $published
* TRUE to set this EPAL Student Class to published, FALSE to set it to unpublished.
*
* @return \Drupal\epal\Entity\EpalStudentClassInterface
* The called EPAL Student Class entity.
*/
public function setPublished($published);
/**
* Gets the EPAL Student Class Minno.
*
* @return int
* Creation timestamp of the EPAL Student Class.
*/
public function getMinno();
/**
* Sets the EPAL Student Class Minno.
*
* @param int $minno
* The EPAL Student Class Minno.
*
* @return \Drupal\epal\Entity\EpalStudentClassInterface
* The called EPAL Student Class entity.
*/
public function setMinno($minno);
/**
* Gets the EPAL Student Class Maxno.