Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Χάρης Παπαδόπουλος
e-epal
Commits
5a353c67
Commit
5a353c67
authored
May 23, 2017
by
Χάρης Παπαδόπουλος
Browse files
Merge branch 'component_updates' into 'develop'
Component updates See merge request !97
parents
606154d1
a811d76e
Changes
17
Hide whitespace changes
Inline
Side-by-side
drupal/modules/epal/epal.links.action.yml
View file @
5a353c67
...
...
@@ -43,3 +43,8 @@ entity.epal_class_limits.add_form:
title
:
'
Add
Epal
class
limits'
appears_on
:
-
entity.epal_class_limits.collection
entity.epal_config.add_form
:
route_name
:
entity.epal_config.add_form
title
:
'
Add
Epal
config'
appears_on
:
-
entity.epal_config.collection
drupal/modules/epal/epal.links.menu.yml
View file @
5a353c67
...
...
@@ -124,3 +124,16 @@ epal_class_limits.admin.structure.settings:
description
:
'
Configure
Epal
class
limits
entities'
route_name
:
epal_class_limits.settings
parent
:
system.admin_structure
# Epal config menu items definition
entity.epal_config.collection
:
title
:
'
Epal
config
list'
route_name
:
entity.epal_config.collection
description
:
'
List
Epal
config
entities'
parent
:
system.admin_structure
weight
:
100
epal_config.admin.structure.settings
:
title
:
Epal config settings
description
:
'
Configure
Epal
config
entities'
route_name
:
epal_config.settings
parent
:
system.admin_structure
drupal/modules/epal/epal.links.task.yml
View file @
5a353c67
...
...
@@ -196,3 +196,24 @@ entity.epal_class_limits.delete_form:
title
:
Delete
weight
:
10
# Epal config routing definition
epal_config.settings_tab
:
route_name
:
epal_config.settings
title
:
'
Settings'
base_route
:
epal_config.settings
entity.epal_config.canonical
:
route_name
:
entity.epal_config.canonical
base_route
:
entity.epal_config.canonical
title
:
'
View'
entity.epal_config.edit_form
:
route_name
:
entity.epal_config.edit_form
base_route
:
entity.epal_config.canonical
title
:
Edit
entity.epal_config.delete_form
:
route_name
:
entity.epal_config.delete_form
base_route
:
entity.epal_config.canonical
title
:
Delete
weight
:
10
drupal/modules/epal/epal.module
View file @
5a353c67
<?php
<?php
/**
* @file
...
...
@@ -46,7 +46,6 @@ function epal_mail($key, &$message, $params) {
$message
[
'subject'
]
=
t
(
'Σύστημα υποβολής αιτήσεων εγγραφής σε ΕΠΑΛ: Επιβεβαίωση e-mail'
,
$options
);
$message
[
'body'
][]
=
$params
[
'message'
];
break
;
case
'massive_mail'
:
$message
[
'from'
]
=
\
Drupal
::
config
(
'system.site'
)
->
get
(
'mail'
);
$message
[
'subject'
]
=
t
(
'Μη ικανοποίηση ηλεκτρονικής αίτησης για εγγραφή σε ΕΠΑΛ'
,
$options
);
...
...
drupal/modules/epal/epal.permissions.yml
View file @
5a353c67
...
...
@@ -196,3 +196,22 @@ view published epal class limits entities:
view unpublished epal class limits entities
:
title
:
'
View
unpublished
Epal
class
limits
entities'
add epal config entities
:
title
:
'
Create
new
Epal
config
entities'
administer epal config entities
:
title
:
'
Administer
Epal
config
entities'
description
:
'
Allow
to
access
the
administration
form
to
configure
Epal
config
entities.'
restrict access
:
true
delete epal config entities
:
title
:
'
Delete
Epal
config
entities'
edit epal config entities
:
title
:
'
Edit
Epal
config
entities'
view published epal config entities
:
title
:
'
View
published
Epal
config
entities'
view unpublished epal config entities
:
title
:
'
View
unpublished
Epal
config
entities'
drupal/modules/epal/epal_config.page.inc
0 → 100644
View file @
5a353c67
<?php
/**
* @file
* Contains epal_config.page.inc.
*
* Page callback for Epal config entities.
*/
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Link
;
use
Drupal\Core\Url
;
/**
* Prepares variables for Epal config templates.
*
* Default template: epal_config.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_config
(
array
&
$variables
)
{
// Fetch EpalConfig Entity Object.
$epal_config
=
$variables
[
'elements'
][
'#epal_config'
];
// Helpful $content variable for templates.
foreach
(
Element
::
children
(
$variables
[
'elements'
])
as
$key
)
{
$variables
[
'content'
][
$key
]
=
$variables
[
'elements'
][
$key
];
}
}
drupal/modules/epal/src/Entity/EpalConfig.php
0 → 100644
View file @
5a353c67
<?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\epal\EpalConfigInterface
;
use
Drupal\user\UserInterface
;
/**
* Defines the Epal config entity.
*
* @ingroup epal
*
* @ContentEntityType(
* id = "epal_config",
* label = @Translation("Epal config"),
* handlers = {
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "list_builder" = "Drupal\epal\EpalConfigListBuilder",
* "views_data" = "Drupal\epal\Entity\EpalConfigViewsData",
*
* "form" = {
* "default" = "Drupal\epal\Form\EpalConfigForm",
* "add" = "Drupal\epal\Form\EpalConfigForm",
* "edit" = "Drupal\epal\Form\EpalConfigForm",
* "delete" = "Drupal\epal\Form\EpalConfigDeleteForm",
* },
* "access" = "Drupal\epal\EpalConfigAccessControlHandler",
* "route_provider" = {
* "html" = "Drupal\epal\EpalConfigHtmlRouteProvider",
* },
* },
* base_table = "epal_config",
* admin_permission = "administer epal config entities",
* entity_keys = {
* "id" = "id",
* "label" = "name",
* "uuid" = "uuid",
* "uid" = "user_id",
* "langcode" = "langcode",
* "status" = "status",
* },
* links = {
* "canonical" = "/admin/structure/epal_config/{epal_config}",
* "add-form" = "/admin/structure/epal_config/add",
* "edit-form" = "/admin/structure/epal_config/{epal_config}/edit",
* "delete-form" = "/admin/structure/epal_config/{epal_config}/delete",
* "collection" = "/admin/structure/epal_config",
* },
* field_ui_base_route = "epal_config.settings"
* )
*/
class
EpalConfig
extends
ContentEntityBase
implements
EpalConfigInterface
{
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
?
NODE_PUBLISHED
:
NODE_NOT_PUBLISHED
);
return
$this
;
}
/**
* {@inheritdoc}
*/
public
static
function
baseFieldDefinitions
(
EntityTypeInterface
$entity_type
)
{
$fields
[
'id'
]
=
BaseFieldDefinition
::
create
(
'integer'
)
->
setLabel
(
t
(
'ID'
))
->
setDescription
(
t
(
'The ID of the Epal config entity.'
))
->
setReadOnly
(
TRUE
);
$fields
[
'uuid'
]
=
BaseFieldDefinition
::
create
(
'uuid'
)
->
setLabel
(
t
(
'UUID'
))
->
setDescription
(
t
(
'The UUID of the Epal config entity.'
))
->
setReadOnly
(
TRUE
);
$fields
[
'user_id'
]
=
BaseFieldDefinition
::
create
(
'entity_reference'
)
->
setLabel
(
t
(
'Authored by'
))
->
setDescription
(
t
(
'The user ID of author of the Epal config entity.'
))
->
setRevisionable
(
TRUE
)
->
setSetting
(
'target_type'
,
'user'
)
->
setSetting
(
'handler'
,
'default'
)
->
setDefaultValueCallback
(
'Drupal\node\Entity\Node::getCurrentUserId'
)
->
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 config 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
[
'lock_school_capacity'
]
=
BaseFieldDefinition
::
create
(
'boolean'
)
->
setLabel
(
t
(
'Lock School Capacity'
))
->
setDescription
(
t
(
'Lock School Capacity.'
))
->
setSettings
(
array
(
'text_processing'
=>
0
,
))
->
setRequired
(
TRUE
)
->
setDefaultValue
(
FALSE
)
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'boolean'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'boolean'
,
'weight'
=>
-
4
,
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'lock_school_students_view'
]
=
BaseFieldDefinition
::
create
(
'boolean'
)
->
setLabel
(
t
(
'Lock School Students View'
))
->
setDescription
(
t
(
'Lock School Students View.'
))
->
setSettings
(
array
(
'text_processing'
=>
0
,
))
->
setRequired
(
TRUE
)
->
setDefaultValue
(
FALSE
)
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'boolean'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'boolean'
,
'weight'
=>
-
4
,
))
->
setDisplayConfigurable
(
'form'
,
TRUE
)
->
setDisplayConfigurable
(
'view'
,
TRUE
);
$fields
[
'lock_application'
]
=
BaseFieldDefinition
::
create
(
'boolean'
)
->
setLabel
(
t
(
'Lock Application'
))
->
setDescription
(
t
(
'Lock Application.'
))
->
setSettings
(
array
(
'text_processing'
=>
0
,
))
->
setRequired
(
TRUE
)
->
setDefaultValue
(
FALSE
)
->
setDisplayOptions
(
'view'
,
array
(
'label'
=>
'above'
,
'type'
=>
'boolean'
,
'weight'
=>
-
4
,
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'boolean'
,
'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 config is published.'
))
->
setDefaultValue
(
TRUE
);
$fields
[
'langcode'
]
=
BaseFieldDefinition
::
create
(
'language'
)
->
setLabel
(
t
(
'Language code'
))
->
setDescription
(
t
(
'The language code for the Epal config entity.'
))
->
setDisplayOptions
(
'form'
,
array
(
'type'
=>
'language_select'
,
'weight'
=>
10
,
))
->
setDisplayConfigurable
(
'form'
,
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
;
}
}
drupal/modules/epal/src/Entity/EpalConfigViewsData.php
0 → 100644
View file @
5a353c67
<?php
namespace
Drupal\epal\Entity
;
use
Drupal\views\EntityViewsData
;
use
Drupal\views\EntityViewsDataInterface
;
/**
* Provides Views data for Epal config entities.
*/
class
EpalConfigViewsData
extends
EntityViewsData
implements
EntityViewsDataInterface
{
/**
* {@inheritdoc}
*/
public
function
getViewsData
()
{
$data
=
parent
::
getViewsData
();
$data
[
'epal_config'
][
'table'
][
'base'
]
=
array
(
'field'
=>
'id'
,
'title'
=>
$this
->
t
(
'Epal config'
),
'help'
=>
$this
->
t
(
'The Epal config ID.'
),
);
return
$data
;
}
}
drupal/modules/epal/src/EpalConfigAccessControlHandler.php
0 → 100644
View file @
5a353c67
<?php
namespace
Drupal\epal
;
use
Drupal\Core\Entity\EntityAccessControlHandler
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Access\AccessResult
;
/**
* Access controller for the Epal config entity.
*
* @see \Drupal\epal\Entity\EpalConfig.
*/
class
EpalConfigAccessControlHandler
extends
EntityAccessControlHandler
{
/**
* {@inheritdoc}
*/
protected
function
checkAccess
(
EntityInterface
$entity
,
$operation
,
AccountInterface
$account
)
{
/** @var \Drupal\epal\EpalConfigInterface $entity */
switch
(
$operation
)
{
case
'view'
:
if
(
!
$entity
->
isPublished
())
{
return
AccessResult
::
allowedIfHasPermission
(
$account
,
'view unpublished epal config entities'
);
}
return
AccessResult
::
allowedIfHasPermission
(
$account
,
'view published epal config entities'
);
case
'update'
:
return
AccessResult
::
allowedIfHasPermission
(
$account
,
'edit epal config entities'
);
case
'delete'
:
return
AccessResult
::
allowedIfHasPermission
(
$account
,
'delete epal config entities'
);
}
// Unknown operation, no opinion.
return
AccessResult
::
neutral
();
}
/**
* {@inheritdoc}
*/
protected
function
checkCreateAccess
(
AccountInterface
$account
,
array
$context
,
$entity_bundle
=
NULL
)
{
return
AccessResult
::
allowedIfHasPermission
(
$account
,
'add epal config entities'
);
}
}
drupal/modules/epal/src/EpalConfigHtmlRouteProvider.php
0 → 100644
View file @
5a353c67
<?php
namespace
Drupal\epal
;
use
Drupal\Core\Entity\EntityTypeInterface
;
use
Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
;
use
Symfony\Component\Routing\Route
;
/**
* Provides routes for Epal config entities.
*
* @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
* @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
*/
class
EpalConfigHtmlRouteProvider
extends
AdminHtmlRouteProvider
{
/**
* {@inheritdoc}
*/
public
function
getRoutes
(
EntityTypeInterface
$entity_type
)
{
$collection
=
parent
::
getRoutes
(
$entity_type
);
$entity_type_id
=
$entity_type
->
id
();
if
(
$collection_route
=
$this
->
getCollectionRoute
(
$entity_type
))
{
$collection
->
add
(
"entity.
{
$entity_type_id
}
.collection"
,
$collection_route
);
}
if
(
$add_form_route
=
$this
->
getAddFormRoute
(
$entity_type
))
{
$collection
->
add
(
"entity.
{
$entity_type_id
}
.add_form"
,
$add_form_route
);
}
if
(
$settings_form_route
=
$this
->
getSettingsFormRoute
(
$entity_type
))
{
$collection
->
add
(
"
$entity_type_id
.settings"
,
$settings_form_route
);
}
return
$collection
;
}
/**
* Gets the collection route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected
function
getCollectionRoute
(
EntityTypeInterface
$entity_type
)
{
if
(
$entity_type
->
hasLinkTemplate
(
'collection'
)
&&
$entity_type
->
hasListBuilderClass
())
{
$entity_type_id
=
$entity_type
->
id
();
$route
=
new
Route
(
$entity_type
->
getLinkTemplate
(
'collection'
));
$route
->
setDefaults
([
'_entity_list'
=>
$entity_type_id
,
'_title'
=>
"
{
$entity_type
->
getLabel
()
}
list"
,
])
->
setRequirement
(
'_permission'
,
'view epal config entities'
)
->
setOption
(
'_admin_route'
,
TRUE
);
return
$route
;
}
}
/**
* Gets the add-form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected
function
getAddFormRoute
(
EntityTypeInterface
$entity_type
)
{
if
(
$entity_type
->
hasLinkTemplate
(
'add-form'
))
{
$entity_type_id
=
$entity_type
->
id
();
$parameters
=
[
$entity_type_id
=>
[
'type'
=>
'entity:'
.
$entity_type_id
],
];
$route
=
new
Route
(
$entity_type
->
getLinkTemplate
(
'add-form'
));
// Use the add form handler, if available, otherwise default.
$operation
=
'default'
;
if
(
$entity_type
->
getFormClass
(
'add'
))
{
$operation
=
'add'
;
}
$route
->
setDefaults
([
'_entity_form'
=>
"
{
$entity_type_id
}
.
{
$operation
}
"
,
'_title'
=>
"Add
{
$entity_type
->
getLabel
()
}
"
,
])
->
setRequirement
(
'_entity_create_access'
,
$entity_type_id
);
$route
->
setOption
(
'parameters'
,
$parameters
)
->
setOption
(
'_admin_route'
,
TRUE
);
return
$route
;
}
}
/**
* Gets the settings form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected
function
getSettingsFormRoute
(
EntityTypeInterface
$entity_type
)
{
if
(
!
$entity_type
->
getBundleEntityType
())
{
$route
=
new
Route
(
"/admin/structure/
{
$entity_type
->
id
()
}
/settings"
);
$route
->
setDefaults
([