update epal module with new entities

parent c160894c
......@@ -2,4 +2,4 @@ name: epal
type: module
description: EPAL Registration
core: 8.x
package: epal
package: EPAL
......@@ -8,3 +8,18 @@ entity.epal_student_class.add_form:
title: 'Add EPAL Student Class'
appears_on:
- entity.epal_student_class.collection
entity.epal_student_epal_chosen.add_form:
route_name: entity.epal_student_epal_chosen.add_form
title: 'Add Epal student epal chosen'
appears_on:
- entity.epal_student_epal_chosen.collection
entity.epal_student_course_field.add_form:
route_name: entity.epal_student_course_field.add_form
title: 'Add Epal student course field'
appears_on:
- entity.epal_student_course_field.collection
entity.epal_users.add_form:
route_name: entity.epal_users.add_form
title: 'Add Epal users'
appears_on:
- entity.epal_users.collection
......@@ -26,3 +26,45 @@ epal_student_class.admin.structure.settings:
description: 'Configure EPAL Student Class entities'
route_name: epal_student_class.settings
parent: system.admin_structure
# Epal student epal chosen menu items definition
entity.epal_student_epal_chosen.collection:
title: 'Epal student epal chosen list'
route_name: entity.epal_student_epal_chosen.collection
description: 'List Epal student epal chosen entities'
parent: system.admin_structure
weight: 100
epal_student_epal_chosen.admin.structure.settings:
title: Epal student epal chosen settings
description: 'Configure Epal student epal chosen entities'
route_name: epal_student_epal_chosen.settings
parent: system.admin_structure
# Epal student course field menu items definition
entity.epal_student_course_field.collection:
title: 'Epal student course field list'
route_name: entity.epal_student_course_field.collection
description: 'List Epal student course field entities'
parent: system.admin_structure
weight: 100
epal_student_course_field.admin.structure.settings:
title: Epal student course field settings
description: 'Configure Epal student course field entities'
route_name: epal_student_course_field.settings
parent: system.admin_structure
# Epal users menu items definition
entity.epal_users.collection:
title: 'Epal users list'
route_name: entity.epal_users.collection
description: 'List Epal users entities'
parent: system.admin_structure
weight: 100
epal_users.admin.structure.settings:
title: Epal users settings
description: 'Configure Epal users entities'
route_name: epal_users.settings
parent: system.admin_structure
......@@ -42,3 +42,69 @@ entity.epal_student_class.delete_form:
title: Delete
weight: 10
# Epal student epal chosen routing definition
epal_student_epal_chosen.settings_tab:
route_name: epal_student_epal_chosen.settings
title: 'Settings'
base_route: epal_student_epal_chosen.settings
entity.epal_student_epal_chosen.canonical:
route_name: entity.epal_student_epal_chosen.canonical
base_route: entity.epal_student_epal_chosen.canonical
title: 'View'
entity.epal_student_epal_chosen.edit_form:
route_name: entity.epal_student_epal_chosen.edit_form
base_route: entity.epal_student_epal_chosen.canonical
title: 'Edit'
entity.epal_student_epal_chosen.delete_form:
route_name: entity.epal_student_epal_chosen.delete_form
base_route: entity.epal_student_epal_chosen.canonical
title: Delete
weight: 10
# Epal student course field routing definition
epal_student_course_field.settings_tab:
route_name: epal_student_course_field.settings
title: 'Settings'
base_route: epal_student_course_field.settings
entity.epal_student_course_field.canonical:
route_name: entity.epal_student_course_field.canonical
base_route: entity.epal_student_course_field.canonical
title: 'View'
entity.epal_student_course_field.edit_form:
route_name: entity.epal_student_course_field.edit_form
base_route: entity.epal_student_course_field.canonical
title: 'Edit'
entity.epal_student_course_field.delete_form:
route_name: entity.epal_student_course_field.delete_form
base_route: entity.epal_student_course_field.canonical
title: Delete
weight: 10
# Epal users routing definition
epal_users.settings_tab:
route_name: epal_users.settings
title: 'Settings'
base_route: epal_users.settings
entity.epal_users.canonical:
route_name: entity.epal_users.canonical
base_route: entity.epal_users.canonical
title: 'View'
entity.epal_users.edit_form:
route_name: entity.epal_users.edit_form
base_route: entity.epal_users.canonical
title: 'Edit'
entity.epal_users.delete_form:
route_name: entity.epal_users.delete_form
base_route: entity.epal_users.canonical
title: Delete
weight: 10
......@@ -42,3 +42,69 @@ view published epal student class entities:
view unpublished epal student class entities:
title: 'View unpublished EPAL Student Class entities'
add epal student epal chosen entities:
title: 'Create new Epal student epal chosen entities'
administer epal student epal chosen entities:
title: 'Administer Epal student epal chosen entities'
description: 'Allow to access the administration form to configure Epal student epal chosen entities.'
restrict access: true
delete epal student epal chosen entities:
title: 'Delete Epal student epal chosen entities'
edit epal student epal chosen entities:
title: 'Edit Epal student epal chosen entities'
access epal student epal chosen overview:
title: 'Access the Epal student epal chosen overview page'
view published epal student epal chosen entities:
title: 'View published Epal student epal chosen entities'
view unpublished epal student epal chosen entities:
title: 'View unpublished Epal student epal chosen entities'
add epal student course field entities:
title: 'Create new Epal student course field entities'
administer epal student course field entities:
title: 'Administer Epal student course field entities'
description: 'Allow to access the administration form to configure Epal student course field entities.'
restrict access: true
delete epal student course field entities:
title: 'Delete Epal student course field entities'
edit epal student course field entities:
title: 'Edit Epal student course field entities'
access epal student course field overview:
title: 'Access the Epal student course field overview page'
view published epal student course field entities:
title: 'View published Epal student course field entities'
view unpublished epal student course field entities:
title: 'View unpublished Epal student course field entities'
add epal users entities:
title: 'Create new Epal users entities'
administer epal users entities:
title: 'Administer Epal users entities'
description: 'Allow to access the administration form to configure Epal users entities.'
restrict access: true
delete epal users entities:
title: 'Delete Epal users entities'
edit epal users entities:
title: 'Edit Epal users entities'
access epal users overview:
title: 'Access the Epal users overview page'
view published epal users entities:
title: 'View published Epal users entities'
view unpublished epal users entities:
title: 'View unpublished Epal users entities'
<?php
/**
* @file
* Contains epal_student_course_field.page.inc.
*
* Page callback for Epal student course field entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal student course field templates.
*
* Default template: epal_student_course_field.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_course_field(array &$variables) {
// Fetch EpalStudentCourseField Entity Object.
$epal_student_course_field = $variables['elements']['#epal_student_course_field'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?php
/**
* @file
* Contains epal_student_epal_chosen.page.inc.
*
* Page callback for Epal student epal chosen entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal student epal chosen templates.
*
* Default template: epal_student_epal_chosen.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_epal_chosen(array &$variables) {
// Fetch EpalStudentEpalChosen Entity Object.
$epal_student_epal_chosen = $variables['elements']['#epal_student_epal_chosen'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?php
/**
* @file
* Contains epal_users.page.inc.
*
* Page callback for Epal users entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal users templates.
*
* Default template: epal_users.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_users(array &$variables) {
// Fetch EpalUsers Entity Object.
$epal_users = $variables['elements']['#epal_users'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?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 course field entity.
*
* @ingroup epal
*
* @ContentEntityType(
* id = "epal_student_course_field",
* label = @Translation("Epal student course field"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\epal\EpalStudentCourseFieldListBuilder",
* "views_data" = "Drupal\epal\Entity\EpalStudentCourseFieldViewsData",
* "translation" = "Drupal\epal\EpalStudentCourseFieldTranslationHandler",
*
* "form" = {
* "default" = "Drupal\epal\Form\EpalStudentCourseFieldForm",
* "add" = "Drupal\epal\Form\EpalStudentCourseFieldForm",
* "edit" = "Drupal\epal\Form\EpalStudentCourseFieldForm",
* "delete" = "Drupal\epal\Form\EpalStudentCourseFieldDeleteForm",
* },
* "access" = "Drupal\epal\EpalStudentCourseFieldAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\epal\EpalStudentCourseFieldHtmlRouteProvider",
* },
* },
* base_table = "epal_student_course_field",
* data_table = "epal_student_course_field_field_data",
* translatable = TRUE,
* admin_permission = "administer epal student course field entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/epal_student_course_field/{epal_student_course_field}",
* "add-form" = "/admin/structure/epal_student_course_field/add",
* "edit-form" = "/admin/structure/epal_student_course_field/{epal_student_course_field}/edit",
* "delete-form" = "/admin/structure/epal_student_course_field/{epal_student_course_field}/delete",
* "collection" = "/admin/structure/epal_student_course_field",
* },
* field_ui_base_route = "epal_student_course_field.settings"
* )
*/
class EpalStudentCourseField extends ContentEntityBase implements EpalStudentCourseFieldInterface {
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 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 course field 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 course field 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['student_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Student id'))
->setDescription(t('Δώσε το id μαθητή.'))
->setSetting('target_type', 'epal_student')
->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['courseField_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Specialty id'))
->setDescription(t('Δώσε το id ειδικότητας που επέλεξε ο μαθητής.'))
->setSetting('target_type', 'eepal_specialty')
->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['status'] = BaseFieldDefinition::create('boolean')
->setLabel(t('Publishing status'))
->setDescription(t('A boolean indicating whether the Epal student course field 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.'));
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 course field entities.
*
* @ingroup epal
*/
interface EpalStudentCourseFieldInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
// Add get/set methods for your configuration properties here.
/**
* Gets the Epal student course field name.
*
* @return string
* Name of the Epal student course field.
*/
public function getName();
/**
* Sets the Epal student course field name.
*
* @param string $name
* The Epal student course field name.
*
* @return \Drupal\epal\Entity\EpalStudentCourseFieldInterface
* The called Epal student course field entity.
*/
public function setName($name);
/**
* Gets the Epal student course field creation timestamp.
*
* @return int