Commit fe61b7b3 authored by Νίκος Κατσαούνος's avatar Νίκος Κατσαούνος

updated application.form.main component with income and social criteria, added...

updated application.form.main component with income and social criteria, added entities EpalCriteria, EpalStudentMoria, EpalClassLimits in Drupal module epal, updated entity EpalStudentClass in Drupal module epal, updated entity EepalSchool with metathesisRegion field in Drupal module epalreadydata, updated Drupal module epaldeploysystem with new rest resources
parents 3d116645 b1353277
......@@ -28,3 +28,18 @@ entity.epal_student_sector_field.add_form:
title: 'Add Epal student sector field'
appears_on:
- entity.epal_student_sector_field.collection
entity.epal_criteria.add_form:
route_name: entity.epal_criteria.add_form
title: 'Add Epal criteria'
appears_on:
- entity.epal_criteria.collection
entity.epal_student_moria.add_form:
route_name: entity.epal_student_moria.add_form
title: 'Add Epal student moria'
appears_on:
- entity.epal_student_moria.collection
entity.epal_class_limits.add_form:
route_name: entity.epal_class_limits.add_form
title: 'Add Epal class limits'
appears_on:
- entity.epal_class_limits.collection
......@@ -82,3 +82,45 @@ epal_student_sector_field.admin.structure.settings:
description: 'Configure Epal student sector field entities'
route_name: epal_student_sector_field.settings
parent: system.admin_structure
# Epal criteria menu items definition
entity.epal_criteria.collection:
title: 'Epal criteria list'
route_name: entity.epal_criteria.collection
description: 'List Epal criteria entities'
parent: system.admin_structure
weight: 100
epal_criteria.admin.structure.settings:
title: Epal criteria settings
description: 'Configure Epal criteria entities'
route_name: epal_criteria.settings
parent: system.admin_structure
# Epal student moria menu items definition
entity.epal_student_moria.collection:
title: 'Epal student moria list'
route_name: entity.epal_student_moria.collection
description: 'List Epal student moria entities'
parent: system.admin_structure
weight: 100
epal_student_moria.admin.structure.settings:
title: Epal student moria settings
description: 'Configure Epal student moria entities'
route_name: epal_student_moria.settings
parent: system.admin_structure
# Epal class limits menu items definition
entity.epal_class_limits.collection:
title: 'Epal class limits list'
route_name: entity.epal_class_limits.collection
description: 'List Epal class limits entities'
parent: system.admin_structure
weight: 100
epal_class_limits.admin.structure.settings:
title: Epal class limits settings
description: 'Configure Epal class limits entities'
route_name: epal_class_limits.settings
parent: system.admin_structure
......@@ -130,3 +130,69 @@ entity.epal_student_sector_field.delete_form:
title: Delete
weight: 10
# Epal criteria routing definition
epal_criteria.settings_tab:
route_name: epal_criteria.settings
title: 'Settings'
base_route: epal_criteria.settings
entity.epal_criteria.canonical:
route_name: entity.epal_criteria.canonical
base_route: entity.epal_criteria.canonical
title: 'View'
entity.epal_criteria.edit_form:
route_name: entity.epal_criteria.edit_form
base_route: entity.epal_criteria.canonical
title: 'Edit'
entity.epal_criteria.delete_form:
route_name: entity.epal_criteria.delete_form
base_route: entity.epal_criteria.canonical
title: Delete
weight: 10
# Epal student moria routing definition
epal_student_moria.settings_tab:
route_name: epal_student_moria.settings
title: 'Settings'
base_route: epal_student_moria.settings
entity.epal_student_moria.canonical:
route_name: entity.epal_student_moria.canonical
base_route: entity.epal_student_moria.canonical
title: 'View'
entity.epal_student_moria.edit_form:
route_name: entity.epal_student_moria.edit_form
base_route: entity.epal_student_moria.canonical
title: 'Edit'
entity.epal_student_moria.delete_form:
route_name: entity.epal_student_moria.delete_form
base_route: entity.epal_student_moria.canonical
title: Delete
weight: 10
# Epal class limits routing definition
epal_class_limits.settings_tab:
route_name: epal_class_limits.settings
title: 'Settings'
base_route: epal_class_limits.settings
entity.epal_class_limits.canonical:
route_name: entity.epal_class_limits.canonical
base_route: entity.epal_class_limits.canonical
title: 'View'
entity.epal_class_limits.edit_form:
route_name: entity.epal_class_limits.edit_form
base_route: entity.epal_class_limits.canonical
title: 'Edit'
entity.epal_class_limits.delete_form:
route_name: entity.epal_class_limits.delete_form
base_route: entity.epal_class_limits.canonical
title: Delete
weight: 10
......@@ -130,3 +130,69 @@ view published epal student sector field entities:
view unpublished epal student sector field entities:
title: 'View unpublished Epal student sector field entities'
add epal criteria entities:
title: 'Create new Epal criteria entities'
administer epal criteria entities:
title: 'Administer Epal criteria entities'
description: 'Allow to access the administration form to configure Epal criteria entities.'
restrict access: true
delete epal criteria entities:
title: 'Delete Epal criteria entities'
edit epal criteria entities:
title: 'Edit Epal criteria entities'
access epal criteria overview:
title: 'Access the Epal criteria overview page'
view published epal criteria entities:
title: 'View published Epal criteria entities'
view unpublished epal criteria entities:
title: 'View unpublished Epal criteria entities'
add epal student moria entities:
title: 'Create new Epal student moria entities'
administer epal student moria entities:
title: 'Administer Epal student moria entities'
description: 'Allow to access the administration form to configure Epal student moria entities.'
restrict access: true
delete epal student moria entities:
title: 'Delete Epal student moria entities'
edit epal student moria entities:
title: 'Edit Epal student moria entities'
access epal student moria overview:
title: 'Access the Epal student moria overview page'
view published epal student moria entities:
title: 'View published Epal student moria entities'
view unpublished epal student moria entities:
title: 'View unpublished Epal student moria entities'
add epal class limits entities:
title: 'Create new Epal class limits entities'
administer epal class limits entities:
title: 'Administer Epal class limits entities'
description: 'Allow to access the administration form to configure Epal class limits entities.'
restrict access: true
delete epal class limits entities:
title: 'Delete Epal class limits entities'
edit epal class limits entities:
title: 'Edit Epal class limits entities'
access epal class limits overview:
title: 'Access the Epal class limits overview page'
view published epal class limits entities:
title: 'View published Epal class limits entities'
view unpublished epal class limits entities:
title: 'View unpublished Epal class limits entities'
......@@ -4,6 +4,14 @@ epal_is_logged_in:
_controller: '\Drupal\epal\Controller\Login::helloWorld'
requirements:
_access: 'TRUE'
epal_entityapi_test:
path: '/epal/entityapi/test'
options:
_auth: [ 'basic_auth' ]
requirements:
_user_is_logged_in: 'TRUE'
defaults:
_controller: '\Drupal\epal\Controller\Login::testQuery'
epal_auth_test:
path: 'epal/auth/test'
options:
......@@ -14,3 +22,9 @@ epal_auth_test:
requirements:
_permission: 'access content'
_user_is_logged_in: 'TRUE'
current_user:
path: '/epal/curuser'
defaults:
_controller: '\Drupal\epal\Controller\CurrentUser::content'
requirements:
_access: 'TRUE'
<?php
/**
* @file
* Contains epal_class_limits.page.inc.
*
* Page callback for Epal class limits entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal class limits templates.
*
* Default template: epal_class_limits.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_class_limits(array &$variables) {
// Fetch EpalClassLimits Entity Object.
$epal_class_limits = $variables['elements']['#epal_class_limits'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?php
/**
* @file
* Contains epal_criteria.page.inc.
*
* Page callback for Epal criteria entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal criteria templates.
*
* Default template: epal_criteria.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_criteria(array &$variables) {
// Fetch EpalCriteria Entity Object.
$epal_criteria = $variables['elements']['#epal_criteria'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?php
/**
* @file
* Contains epal_student_moria.page.inc.
*
* Page callback for Epal student moria entities.
*/
use Drupal\Core\Render\Element;
/**
* Prepares variables for Epal student moria templates.
*
* Default template: epal_student_moria.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_moria(array &$variables) {
// Fetch EpalStudentMoria Entity Object.
$epal_student_moria = $variables['elements']['#epal_student_moria'];
// Helpful $content variable for templates.
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
<?php
/**
* @file
* Contains \Drupal\query_example\Controller\QueryExampleController.
*/
namespace Drupal\epal\Controller;
use Drupal\Core\Entity\Query\QueryFactory;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
class CurrentUser extends ControllerBase {
public function content() {
// $name = \Drupal\user\Entity\User::load(\Drupal::currentUser()->id());
$name = "LALALA";
$authToken = "no authToken";
$accessKey = "no accessKey";
if (\Drupal::request()->headers->has('X-AUTH-TOKEN')) {
$authToken = \Drupal::request()->headers->get( 'X-AUTH-TOKEN' );
}
if (\Drupal::request()->headers->has('X-ACCESS-KEY')) {
$accessKey = \Drupal::request()->headers->get( 'X-ACCESS-KEY' );
}
$response = new JsonResponse([$name]);
$response->headers->set('X-AUTH-TOKEN', 'HELLOTOKEN');
return $response;
}
}
......@@ -11,25 +11,30 @@ use Drupal\Core\Entity\EntityTypeManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Entity\EntityFieldManagerInterface;
/**
* Controller routines for page example routes.
*/
class Login extends ControllerBase {
protected $query_factory;
protected $entityTypeManager;
protected $entityFieldManager;
public function __construct(EntityTypeManagerInterface $entityTypeManager, QueryFactory $query_factory) {
public function __construct(EntityTypeManagerInterface $entityTypeManager, QueryFactory $query_factory, EntityFieldManagerInterface $entityFieldManager) {
// public function __construct(QueryFactory $query_factory) {
$this->entityTypeManager = $entityTypeManager;
$this->query_factory = $query_factory;
$this->entityFieldManager = $entityFieldManager;
}
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('entity.query')
$container->get('entity_type.manager'),
$container->get('entity.query'),
$container->get('entity_field.manager')
);
}
......@@ -67,7 +72,57 @@ public function helloWorld() {
}
return array_values($arrayToReturn);
}
public function object_2_array($result) {
$array = array();
foreach ($result as $key=>$value)
{
if (is_object($value))
{
$array[$key]=$this->object_2_array($value);
}
elseif (is_array($value))
{
$array[$key]=$this->object_2_array($value);
}
else
{
$array[$key]=$value;
}
}
return $array;
}
public function testQuery() {
$query = $this->query_factory->get('epal_users');
// ->condition('status', 1);
$scids = $query->execute();
$epalUsers_storage = $this->entityTypeManager->getStorage('epal_users');
$epalUsers = $epalUsers_storage->loadMultiple($scids);
$arrayToReturn = array();
$j=0;
foreach ($epalUsers as $epalUser) {
// print_r($epalUser);
// $arrayToReturn[$j] = implode(",", $this->object_2_array($epalUser->id) );
$arrayToReturn[$j] = $epalUser->user_id->target_id;
$j++;
/* foreach ($epalUser->name as $delta => $item) {
$arrayToReturn[$delta] = $item->value;
} */
/* array_push($arrayToReturn,
$epalUser->surname->getValue()); */
}
// return array_values($arrayToReturn);
$response = new JsonResponse($arrayToReturn);
return $response;
}
public function basicQuery() {
return [
......@@ -130,3 +185,6 @@ public function helloWorld() {
}
}
<?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 class limits entity.
*
* @ingroup epal
*
* @ContentEntityType(
* id = "epal_class_limits",
* label = @Translation("Epal class limits"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\epal\EpalClassLimitsListBuilder",
* "views_data" = "Drupal\epal\Entity\EpalClassLimitsViewsData",
*
* "form" = {
* "default" = "Drupal\epal\Form\EpalClassLimitsForm",
* "add" = "Drupal\epal\Form\EpalClassLimitsForm",
* "edit" = "Drupal\epal\Form\EpalClassLimitsForm",
* "delete" = "Drupal\epal\Form\EpalClassLimitsDeleteForm",
* },
* "access" = "Drupal\epal\EpalClassLimitsAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\epal\EpalClassLimitsHtmlRouteProvider",
* },
* },
* base_table = "epal_class_limits",
* admin_permission = "administer epal class limits entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/epal_class_limits/{epal_class_limits}",
* "add-form" = "/admin/structure/epal_class_limits/add",
* "edit-form" = "/admin/structure/epal_class_limits/{epal_class_limits}/edit",
* "delete-form" = "/admin/structure/epal_class_limits/{epal_class_limits}/delete",
* "collection" = "/admin/structure/epal_class_limits",
* },
* field_ui_base_route = "epal_class_limits.settings"
* )
*/
class EpalClassLimits extends ContentEntityBase implements EpalClassLimitsInterface {
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 class limits 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('Ονομασία τύπου τμήματος'))
->setDescription(t('Ονομασία τύπου τμήματος.'))
->setSettings(array(
'max_length' => 80,
'text_processing' => 0,
))
->setDefaultValue('')