distidution

parent 5951f21b
......@@ -38,3 +38,8 @@ entity.gel_school.add_form:
title: 'Add Gel_school'
appears_on:
- entity.gel_school.collection
entity.gelstudenthighschool.add_form:
route_name: entity.gelstudenthighschool.add_form
title: 'Add Gelstudenthighschool'
appears_on:
- entity.gelstudenthighschool.collection
......@@ -110,3 +110,17 @@ gel_school.admin.structure.settings:
description: 'Configure Gel_school entities'
route_name: gel_school.settings
parent: system.admin_structure
# Gelstudenthighschool menu items definition
entity.gelstudenthighschool.collection:
title: 'Gelstudenthighschool list'
route_name: entity.gelstudenthighschool.collection
description: 'List Gelstudenthighschool entities'
parent: system.admin_structure
weight: 100
gelstudenthighschool.admin.structure.settings:
title: 'Gelstudenthighschool settings'
description: 'Configure Gelstudenthighschool entities'
route_name: gelstudenthighschool.settings
parent: system.admin_structure
......@@ -174,3 +174,25 @@ entity.gel_school.delete_form:
title: Delete
weight: 10
# Gelstudenthighschool routing definition
gelstudenthighschool.settings_tab:
route_name: gelstudenthighschool.settings
title: 'Settings'
base_route: gelstudenthighschool.settings
entity.gelstudenthighschool.canonical:
route_name: entity.gelstudenthighschool.canonical
base_route: entity.gelstudenthighschool.canonical
title: 'View'
entity.gelstudenthighschool.edit_form:
route_name: entity.gelstudenthighschool.edit_form
base_route: entity.gelstudenthighschool.canonical
title: 'Edit'
entity.gelstudenthighschool.delete_form:
route_name: entity.gelstudenthighschool.delete_form
base_route: entity.gelstudenthighschool.canonical
title: Delete
weight: 10
......@@ -150,3 +150,22 @@ view published gel_school entities:
view unpublished gel_school entities:
title: 'View unpublished Gel_school entities'
add gelstudenthighschool entities:
title: 'Create new Gelstudenthighschool entities'
administer gelstudenthighschool entities:
title: 'Administer Gelstudenthighschool entities'
description: 'Allow to access the administration form to configure Gelstudenthighschool entities.'
restrict access: true
delete gelstudenthighschool entities:
title: 'Delete Gelstudenthighschool entities'
edit gelstudenthighschool entities:
title: 'Edit Gelstudenthighschool entities'
view published gelstudenthighschool entities:
title: 'View published Gelstudenthighschool entities'
view unpublished gelstudenthighschool entities:
title: 'View unpublished Gelstudenthighschool entities'
......@@ -54,3 +54,43 @@ gel.applicant.creationpdf:
_controller: '\Drupal\gel\Controller\PdfCreator::createApplicantPDF'
requirements:
_user_is_logged_in: 'TRUE'
gel.getjuniorhighschool:
path: '/gel/getjunorhighschoolperdide'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\gel\Controller\GelDistribution::getJuniorHighSchoolperDide'
requirements:
_user_is_logged_in: 'TRUE'
gel.gethighschool:
path: '/gel/gethighschoolperdide'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\gel\Controller\GelDistribution::getHighSchoolperDide'
requirements:
_user_is_logged_in: 'TRUE'
gel.getstudentsperschool:
path: '/gel/getstudentsperschool/{schoolid}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\gel\Controller\GelDistribution::getStudentsPerSchool'
requirements:
_user_is_logged_in: 'TRUE'
gel.savehighscoolselection:
path: '/gel/saveselection/{studentid}/{schoolid}/{oldschool}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\gel\Controller\GelDistribution::SaveHighSchoolSelection'
requirements:
_user_is_logged_in: 'TRUE'
gel.gethighschoolperstudent:
path: '/gel/gethighschoolperstudent/{id}'
options:
_auth: [ 'basic_auth' ]
defaults:
_controller: '\Drupal\gel\Controller\GelDistribution::gethighschoolperstudent'
requirements:
_user_is_logged_in: 'TRUE'
<?php
/**
* @file
* Contains gelstudenthighschool.page.inc.
*
* Page callback for Gelstudenthighschool entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Gelstudenthighschool templates.
*
* Default template: gelstudenthighschool.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_gelstudenthighschool(array &$variables) {
// Fetch gelstudenthighschool Entity Object.
$gelstudenthighschool = $variables['elements']['#gelstudenthighschool'];
// 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\gel\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 Gelstudenthighschool entity.
*
* @ingroup gel
*
* @ContentEntityType(
* id = "gelstudenthighschool",
* label = @Translation("Gelstudenthighschool"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\gel\gelstudenthighschoolListBuilder",
* "views_data" = "Drupal\gel\Entity\gelstudenthighschoolViewsData",
*
* "form" = {
* "default" = "Drupal\gel\Form\gelstudenthighschoolForm",
* "add" = "Drupal\gel\Form\gelstudenthighschoolForm",
* "edit" = "Drupal\gel\Form\gelstudenthighschoolForm",
* "delete" = "Drupal\gel\Form\gelstudenthighschoolDeleteForm",
* },
* "access" = "Drupal\gel\gelstudenthighschoolAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\gel\gelstudenthighschoolHtmlRouteProvider",
* },
* },
* base_table = "gelstudenthighschool",
* admin_permission = "administer gelstudenthighschool entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/gelstudenthighschool/{gelstudenthighschool}",
* "add-form" = "/admin/structure/gelstudenthighschool/add",
* "edit-form" = "/admin/structure/gelstudenthighschool/{gelstudenthighschool}/edit",
* "delete-form" = "/admin/structure/gelstudenthighschool/{gelstudenthighschool}/delete",
* "collection" = "/admin/structure/gelstudenthighschool",
* },
* field_ui_base_route = "gelstudenthighschool.settings"
* )
*/
class gelstudenthighschool extends ContentEntityBase implements gelstudenthighschoolInterface {
use EntityChangedTrait;
/**
* {@inheritdoc}
*/
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'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;
}
public function getschool_id()
{
return $this->get('school_id')->value;
}
/**
* {@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 Gelstudenthighschool entity.'))
->setRevisionable(TRUE)
->setSetting('target_type', 'user')
->setSetting('handler', 'default')
->setTranslatable(TRUE)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'author',
'weight' => 0,
])
->setDisplayOptions('form', [
'type' => 'entity_reference_autocomplete',
'weight' => 5,
'settings' => [
'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 Gelstudenthighschool entity.'))
->setSettings([
'max_length' => 50,
'text_processing' => 0,
])
->setDefaultValue('')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'string',
'weight' => -4,
])
->setDisplayOptions('form', [
'type' => 'string_textfield',
'weight' => -4,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE)
->setRequired(TRUE);
$fields['student_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Id Μαθητή'))
->setDescription(t('Δώσε το id μαθητή.'))
->setSetting('target_type', 'gel_student')
->setSetting('handler', 'default')
->setRequired(true)
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'author',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => -4,
'settings' => array(
'match_operator' => 'CONTAINS',
'size' => '60',
'autocomplete_type' => 'tags',
'placeholder' => '',
),
))
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
$fields['school_id'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Id σχολείου'))
->setDescription(t(' το id του σχολείου.'))
->setSetting('target_type', 'gel_school')
->setSetting('handler', 'default')
->setRequired(true)
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'label' => 'above',
'type' => 'author',
'weight' => -4,
))
->setDisplayOptions('form', array(
'type' => 'entity_reference_autocomplete',
'weight' => -4,
'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 Gelstudenthighschool is published.'))
->setDefaultValue(TRUE)
->setDisplayOptions('form', [
'type' => 'boolean_checkbox',
'weight' => -3,
]);
$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\gel\Entity;
use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\user\EntityOwnerInterface;
/**
* Provides an interface for defining Gelstudenthighschool entities.
*
* @ingroup gel
*/
interface gelstudenthighschoolInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
// Add get/set methods for your configuration properties here.
/**
* Gets the Gelstudenthighschool name.
*
* @return string
* Name of the Gelstudenthighschool.
*/
public function getName();
/**
* Sets the Gelstudenthighschool name.
*
* @param string $name
* The Gelstudenthighschool name.
*
* @return \Drupal\gel\Entity\gelstudenthighschoolInterface
* The called Gelstudenthighschool entity.
*/
public function setName($name);
/**
* Gets the Gelstudenthighschool creation timestamp.
*
* @return int
* Creation timestamp of the Gelstudenthighschool.
*/
public function getCreatedTime();
/**
* Sets the Gelstudenthighschool creation timestamp.
*
* @param int $timestamp
* The Gelstudenthighschool creation timestamp.
*
* @return \Drupal\gel\Entity\gelstudenthighschoolInterface
* The called Gelstudenthighschool entity.
*/
public function setCreatedTime($timestamp);
/**
* Returns the Gelstudenthighschool published status indicator.
*
* Unpublished Gelstudenthighschool are only visible to restricted users.
*
* @return bool
* TRUE if the Gelstudenthighschool is published.
*/
public function isPublished();
/**
* Sets the published status of a Gelstudenthighschool.
*
* @param bool $published
* TRUE to set this Gelstudenthighschool to published, FALSE to set it to unpublished.
*
* @return \Drupal\gel\Entity\gelstudenthighschoolInterface
* The called Gelstudenthighschool entity.
*/
public function setPublished($published);
}
<?php
namespace Drupal\gel\Entity;
use Drupal\views\EntityViewsData;
/**
* Provides Views data for Gelstudenthighschool entities.
*/
class gelstudenthighschoolViewsData extends EntityViewsData {
/**
* {@inheritdoc}
*/
public function getViewsData() {
$data = parent::getViewsData();
// Additional information for Views integration, such as table joins, can be
// put here.
return $data;
}
}
<?php
namespace Drupal\gel\Form;
use Drupal\Core\Entity\ContentEntityDeleteForm;
/**
* Provides a form for deleting Gelstudenthighschool entities.
*
* @ingroup gel
*/
class gelstudenthighschoolDeleteForm extends ContentEntityDeleteForm {
}
<?php
namespace Drupal\gel\Form;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;
/**
* Form controller for Gelstudenthighschool edit forms.
*
* @ingroup gel
*/
class gelstudenthighschoolForm extends ContentEntityForm {
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\gel\Entity\gelstudenthighschool */
$form = parent::buildForm($form, $form_state);
$entity = $this->entity;
return $form;
}
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$status = parent::save($form, $form_state);
switch ($status) {
case SAVED_NEW:
drupal_set_message($this->t('Created the %label Gelstudenthighschool.', [
'%label' => $entity->label(),
]));
break;
default:
drupal_set_message($this->t('Saved the %label Gelstudenthighschool.', [
'%label' => $entity->label(),
]));
}
$form_state->setRedirect('entity.gelstudenthighschool.canonical', ['gelstudenthighschool' => $entity->id()]);
}
}
<?php
namespace Drupal\gel\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class gelstudenthighschoolSettingsForm.
*
* @ingroup gel
*/
class gelstudenthighschoolSettingsForm extends FormBase {
/**
* Returns a unique string identifying the form.
*
* @return string
* The unique string identifying the form.
*/
public function getFormId() {
return 'gelstudenthighschool_settings';
}
/**
* Form submission handler.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Empty implementation of the abstract submit class.
}
/**
* Defines the settings form for Gelstudenthighschool entities.
*
* @param array $form
* An associative array containing the structure of the form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @return array
* Form definition array.
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['gelstudenthighschool_settings']['#markup'] = 'Settings form for Gelstudenthighschool entities. Manage field settings here.';
return $form;
}
}
<?php
namespace Drupal\gel;
use Drupal\Core\Entity\EntityAccessControlHandler;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessResult;
/**
* Access controller for the Gelstudenthighschool entity.
*
* @see \Drupal\gel\Entity\gelstudenthighschool.
*/
class gelstudenthighschoolAccessControlHandler extends EntityAccessControlHandler {
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\gel\Entity\gelstudenthighschoolInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished gelstudenthighschool entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published gelstudenthighschool entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit gelstudenthighschool entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete gelstudenthighschool entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
/**
* {@inheritdoc}
*/
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
return AccessResult::allowedIfHasPermission($account, 'add gelstudenthighschool entities');
}
}
<?php
namespace Drupal\gel;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
use Symfony\Component\Routing\Route;