refactored : entity fil -> entity composition
started to display add to chutier link to contents
This commit is contained in:
@@ -0,0 +1,5 @@
|
|||||||
|
(function ($, Drupal) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
})(jQuery, Drupal);
|
||||||
+7
-7
@@ -2,26 +2,26 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Contains fil.page.inc.
|
* Contains composition.page.inc.
|
||||||
*
|
*
|
||||||
* Page callback for Fil entities.
|
* Page callback for Composition entities.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use Drupal\Core\Render\Element;
|
use Drupal\Core\Render\Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepares variables for Fil templates.
|
* Prepares variables for Composition templates.
|
||||||
*
|
*
|
||||||
* Default template: fil.html.twig.
|
* Default template: composition.html.twig.
|
||||||
*
|
*
|
||||||
* @param array $variables
|
* @param array $variables
|
||||||
* An associative array containing:
|
* An associative array containing:
|
||||||
* - elements: An associative array containing the user information and any
|
* - elements: An associative array containing the user information and any
|
||||||
* - attributes: HTML attributes for the containing element.
|
* - attributes: HTML attributes for the containing element.
|
||||||
*/
|
*/
|
||||||
function template_preprocess_fil(array &$variables) {
|
function template_preprocess_composition(array &$variables) {
|
||||||
// Fetch Fil Entity Object.
|
// Fetch Composition Entity Object.
|
||||||
$fil = $variables['elements']['#fil'];
|
$composition = $variables['elements']['#composition'];
|
||||||
|
|
||||||
// Helpful $content variable for templates.
|
// Helpful $content variable for templates.
|
||||||
foreach (Element::children($variables['elements']) as $key) {
|
foreach (Element::children($variables['elements']) as $key) {
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
name: 'Edlp Studio'
|
name: 'Edlp Studio'
|
||||||
type: module
|
type: module
|
||||||
description: 'Edlp module that handle chutier and fils entities'
|
description: 'Edlp module that handle chutier and Compositions entities'
|
||||||
core: 8.x
|
core: 8.x
|
||||||
package: 'edlp'
|
package: 'edlp'
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
edlp_studio-library:
|
||||||
|
js:
|
||||||
|
js/edlp_studio.js: {}
|
||||||
@@ -3,8 +3,8 @@ entity.chutier.add_form:
|
|||||||
title: 'Add Chutier'
|
title: 'Add Chutier'
|
||||||
appears_on:
|
appears_on:
|
||||||
- entity.chutier.collection
|
- entity.chutier.collection
|
||||||
entity.fil.add_form:
|
entity.composition.add_form:
|
||||||
route_name: entity.fil.add_form
|
route_name: entity.composition.add_form
|
||||||
title: 'Add Fil'
|
title: 'Add Composition'
|
||||||
appears_on:
|
appears_on:
|
||||||
- entity.fil.collection
|
- entity.composition.collection
|
||||||
|
|||||||
@@ -19,16 +19,16 @@ chutier.admin.structure.settings:
|
|||||||
route_name: chutier.settings
|
route_name: chutier.settings
|
||||||
parent: edlp_studio.studio
|
parent: edlp_studio.studio
|
||||||
|
|
||||||
# Fil menu items definition
|
# Composition menu items definition
|
||||||
entity.fil.collection:
|
entity.composition.collection:
|
||||||
title: 'Fil list'
|
title: 'Composition list'
|
||||||
route_name: entity.fil.collection
|
route_name: entity.composition.collection
|
||||||
description: 'List Fil entities'
|
description: 'List Composition entities'
|
||||||
parent: edlp_studio.studio
|
parent: edlp_studio.studio
|
||||||
weight: 100
|
weight: 100
|
||||||
|
|
||||||
fil.admin.structure.settings:
|
composition.admin.structure.settings:
|
||||||
title: 'Fil settings'
|
title: 'Composition settings'
|
||||||
description: 'Configure Fil entities'
|
description: 'Configure Composition entities'
|
||||||
route_name: fil.settings
|
route_name: composition.settings
|
||||||
parent: edlp_studio.studio
|
parent: edlp_studio.studio
|
||||||
|
|||||||
@@ -20,24 +20,24 @@ entity.chutier.delete_form:
|
|||||||
title: Delete
|
title: Delete
|
||||||
weight: 10
|
weight: 10
|
||||||
|
|
||||||
# Fil routing definition
|
# Composition routing definition
|
||||||
fil.settings_tab:
|
composition.settings_tab:
|
||||||
route_name: fil.settings
|
route_name: composition.settings
|
||||||
title: 'Settings'
|
title: 'Settings'
|
||||||
base_route: fil.settings
|
base_route: composition.settings
|
||||||
|
|
||||||
entity.fil.canonical:
|
entity.composition.canonical:
|
||||||
route_name: entity.fil.canonical
|
route_name: entity.composition.canonical
|
||||||
base_route: entity.fil.canonical
|
base_route: entity.composition.canonical
|
||||||
title: 'View'
|
title: 'View'
|
||||||
|
|
||||||
entity.fil.edit_form:
|
entity.composition.edit_form:
|
||||||
route_name: entity.fil.edit_form
|
route_name: entity.composition.edit_form
|
||||||
base_route: entity.fil.canonical
|
base_route: entity.composition.canonical
|
||||||
title: 'Edit'
|
title: 'Edit'
|
||||||
|
|
||||||
entity.fil.delete_form:
|
entity.composition.delete_form:
|
||||||
route_name: entity.fil.delete_form
|
route_name: entity.composition.delete_form
|
||||||
base_route: entity.fil.canonical
|
base_route: entity.composition.canonical
|
||||||
title: Delete
|
title: Delete
|
||||||
weight: 10
|
weight: 10
|
||||||
|
|||||||
@@ -16,9 +16,54 @@ function edlp_studio_help($route_name, RouteMatchInterface $route_match) {
|
|||||||
case 'help.page.edlp_studio':
|
case 'help.page.edlp_studio':
|
||||||
$output = '';
|
$output = '';
|
||||||
$output .= '<h3>' . t('About') . '</h3>';
|
$output .= '<h3>' . t('About') . '</h3>';
|
||||||
$output .= '<p>' . t('Edlp module that handle chutier and fils entities') . '</p>';
|
$output .= '<p>' . t('Edlp module that handle chutier and compositions entities') . '</p>';
|
||||||
return $output;
|
return $output;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hook_entity_extra_field_info()
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function edlp_studio_entity_extra_field_info(){
|
||||||
|
$extra = [];
|
||||||
|
// TODO: get node content type by settings @see readme
|
||||||
|
$extra['node']['enregistrement']['display']['add_to_chutier'] = [
|
||||||
|
'label' => t('Add to chutier link'),
|
||||||
|
'description' => 'Display a link to add the content to chutier',
|
||||||
|
'weight' => 99,
|
||||||
|
'visible' => FALSE,
|
||||||
|
];
|
||||||
|
return $extra;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_ENTITY_TYPE_view().
|
||||||
|
* @see https://www.amazeelabs.com/en/render-menu-tree-custom-code-drupal-8
|
||||||
|
*/
|
||||||
|
function edlp_studio_node_view(array &$build, \Drupal\Core\Entity\EntityInterface $entity, \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, $view_mode) {
|
||||||
|
$display_settings = $display->getComponent('add_to_chutier');
|
||||||
|
if (!empty($display_settings)) {
|
||||||
|
// dpm($entity);
|
||||||
|
// dpm($entity->id());
|
||||||
|
$url = Url::fromRoute('edlp_studio.chutier_controller_add_content', ['id'=>$entity->id()], array(
|
||||||
|
'attributes' => array(
|
||||||
|
'class' => ['add-to-chutier-link', 'ajax-link'],
|
||||||
|
'target_id' => $entity->id(),
|
||||||
|
)
|
||||||
|
));
|
||||||
|
$build['add_to_chutier'] = array(
|
||||||
|
'#title' => t("Add this content to chutier."),
|
||||||
|
'#type' => 'link',
|
||||||
|
'#url' => $url,
|
||||||
|
'#options'=>array(
|
||||||
|
'attributes' => array(
|
||||||
|
'data-drupal-link-system-path' => $url->getInternalPath()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -31,32 +31,35 @@ view any unpublished chutier entities:
|
|||||||
view own unpublished chutier entities:
|
view own unpublished chutier entities:
|
||||||
title: 'View own unpublished Chutier entities'
|
title: 'View own unpublished Chutier entities'
|
||||||
|
|
||||||
# Fils
|
use chutier:
|
||||||
add fil entities:
|
title: 'use chutier'
|
||||||
title: 'Create new Fil entities'
|
|
||||||
|
|
||||||
administer fil entities:
|
# Compositions
|
||||||
title: 'Administer Fil entities'
|
add composition entities:
|
||||||
description: 'Allow to access the administration form to configure Fil entities.'
|
title: 'Create new Composition entities'
|
||||||
|
|
||||||
|
administer composition entities:
|
||||||
|
title: 'Administer Composition entities'
|
||||||
|
description: 'Allow to access the administration form to configure Composition entities.'
|
||||||
restrict access: true
|
restrict access: true
|
||||||
|
|
||||||
delete any fil entities:
|
delete any composition entities:
|
||||||
title: 'Delete any Fil entities'
|
title: 'Delete any Composition entities'
|
||||||
|
|
||||||
edit any fil entities:
|
edit any composition entities:
|
||||||
title: 'Edit any Fil entities'
|
title: 'Edit any Composition entities'
|
||||||
|
|
||||||
delete own fil entities:
|
delete own composition entities:
|
||||||
title: 'Delete own Fil entities'
|
title: 'Delete own Composition entities'
|
||||||
|
|
||||||
edit own fil entities:
|
edit own composition entities:
|
||||||
title: 'Edit own Fil entities'
|
title: 'Edit own Composition entities'
|
||||||
|
|
||||||
view published fil entities:
|
view published composition entities:
|
||||||
title: 'View published Fil entities'
|
title: 'View published Composition entities'
|
||||||
|
|
||||||
view any unpublished fil entities:
|
view any unpublished composition entities:
|
||||||
title: 'View any unpublished Fil entities'
|
title: 'View any unpublished Composition entities'
|
||||||
|
|
||||||
view own unpublished fil entities:
|
view own unpublished composition entities:
|
||||||
title: 'View own unpublished Fil entities'
|
title: 'View own unpublished Composition entities'
|
||||||
|
|||||||
@@ -5,3 +5,11 @@ edlp_studio.studio:
|
|||||||
_title: 'Studio'
|
_title: 'Studio'
|
||||||
requirements:
|
requirements:
|
||||||
_permission: 'administer studio'
|
_permission: 'administer studio'
|
||||||
|
|
||||||
|
edlp_studio.chutier_controller_add_content:
|
||||||
|
path: '/studio/chutier/add/{id}'
|
||||||
|
defaults:
|
||||||
|
_controller: '\Drupal\edlp_studio\Controller\ChutierController::addContent'
|
||||||
|
_title: 'Add content to chutier'
|
||||||
|
requirements:
|
||||||
|
_permission: 'use chutier'
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
# Edlp Studio
|
||||||
|
|
||||||
|
## Chutier
|
||||||
|
|
||||||
|
TODO: get content types that could be added to chutier by settings ( maybe per each contenttypes settings )
|
||||||
|
|
||||||
|
|
||||||
|
## Composition
|
||||||
+12
-12
@@ -8,40 +8,40 @@ use Drupal\Core\Session\AccountInterface;
|
|||||||
use Drupal\Core\Access\AccessResult;
|
use Drupal\Core\Access\AccessResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access controller for the Fil entity.
|
* Access controller for the Composition entity.
|
||||||
*
|
*
|
||||||
* @see \Drupal\edlp_studio\Entity\Fil.
|
* @see \Drupal\edlp_studio\Entity\Composition.
|
||||||
*/
|
*/
|
||||||
class FilAccessControlHandler extends EntityAccessControlHandler {
|
class CompositionAccessControlHandler extends EntityAccessControlHandler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||||
/** @var \Drupal\edlp_studio\Entity\FilInterface $entity */
|
/** @var \Drupal\edlp_studio\Entity\CompositionInterface $entity */
|
||||||
switch ($operation) {
|
switch ($operation) {
|
||||||
case 'view':
|
case 'view':
|
||||||
if (!$entity->isPublished()) {
|
if (!$entity->isPublished()) {
|
||||||
if($account->hasPermission('view own unpublished fil entities') && $account->isAuthenticated() && $account->id() == $entity->getOwnerId() ){
|
if($account->hasPermission('view own unpublished composition entities') && $account->isAuthenticated() && $account->id() == $entity->getOwnerId() ){
|
||||||
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
|
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
|
||||||
}else{
|
}else{
|
||||||
return AccessResult::allowedIfHasPermission($account, 'view any unpublished fil entities');
|
return AccessResult::allowedIfHasPermission($account, 'view any unpublished composition entities');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return AccessResult::allowedIfHasPermission($account, 'view published fil entities');
|
return AccessResult::allowedIfHasPermission($account, 'view published composition entities');
|
||||||
|
|
||||||
case 'update':
|
case 'update':
|
||||||
if($account->hasPermission('edit own fil entities') && $account->isAuthenticated() && $account->id() == $entity->getOwnerId() ){
|
if($account->hasPermission('edit own composition entities') && $account->isAuthenticated() && $account->id() == $entity->getOwnerId() ){
|
||||||
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
|
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
|
||||||
}else{
|
}else{
|
||||||
return AccessResult::allowedIfHasPermission($account, 'edit any fil entities');
|
return AccessResult::allowedIfHasPermission($account, 'edit any composition entities');
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'delete':
|
case 'delete':
|
||||||
if($account->hasPermission('delete own fil entities') && $account->isAuthenticated() && $account->id() == $entity->getOwnerId() ){
|
if($account->hasPermission('delete own composition entities') && $account->isAuthenticated() && $account->id() == $entity->getOwnerId() ){
|
||||||
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
|
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($entity);
|
||||||
}else{
|
}else{
|
||||||
return AccessResult::allowedIfHasPermission($account, 'delete fil entities');
|
return AccessResult::allowedIfHasPermission($account, 'delete composition entities');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ class FilAccessControlHandler extends EntityAccessControlHandler {
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
|
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
|
||||||
return AccessResult::allowedIfHasPermission($account, 'add fil entities');
|
return AccessResult::allowedIfHasPermission($account, 'add composition entities');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
-3
@@ -7,12 +7,12 @@ use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
|
|||||||
use Symfony\Component\Routing\Route;
|
use Symfony\Component\Routing\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides routes for Fil entities.
|
* Provides routes for Composition entities.
|
||||||
*
|
*
|
||||||
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
|
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
|
||||||
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
|
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
|
||||||
*/
|
*/
|
||||||
class FilHtmlRouteProvider extends AdminHtmlRouteProvider {
|
class CompositionHtmlRouteProvider extends AdminHtmlRouteProvider {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -43,7 +43,7 @@ class FilHtmlRouteProvider extends AdminHtmlRouteProvider {
|
|||||||
$route = new Route("/admin/structure/studio/{$entity_type->id()}/settings");
|
$route = new Route("/admin/structure/studio/{$entity_type->id()}/settings");
|
||||||
$route
|
$route
|
||||||
->setDefaults([
|
->setDefaults([
|
||||||
'_form' => 'Drupal\edlp_studio\Form\FilSettingsForm',
|
'_form' => 'Drupal\edlp_studio\Form\CompositionSettingsForm',
|
||||||
'_title' => "{$entity_type->getLabel()} settings",
|
'_title' => "{$entity_type->getLabel()} settings",
|
||||||
])
|
])
|
||||||
->setRequirement('_permission', $entity_type->getAdminPermission())
|
->setRequirement('_permission', $entity_type->getAdminPermission())
|
||||||
+6
-6
@@ -7,18 +7,18 @@ use Drupal\Core\Entity\EntityListBuilder;
|
|||||||
use Drupal\Core\Link;
|
use Drupal\Core\Link;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a class to build a listing of Fil entities.
|
* Defines a class to build a listing of Composition entities.
|
||||||
*
|
*
|
||||||
* @ingroup edlp_studio
|
* @ingroup edlp_studio
|
||||||
*/
|
*/
|
||||||
class FilListBuilder extends EntityListBuilder {
|
class CompositionListBuilder extends EntityListBuilder {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildHeader() {
|
public function buildHeader() {
|
||||||
$header['id'] = $this->t('Fil ID');
|
$header['id'] = $this->t('Composition ID');
|
||||||
$header['name'] = $this->t('Name');
|
$header['name'] = $this->t('Name');
|
||||||
return $header + parent::buildHeader();
|
return $header + parent::buildHeader();
|
||||||
}
|
}
|
||||||
@@ -27,12 +27,12 @@ class FilListBuilder extends EntityListBuilder {
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildRow(EntityInterface $entity) {
|
public function buildRow(EntityInterface $entity) {
|
||||||
/* @var $entity \Drupal\edlp_studio\Entity\Fil */
|
/* @var $entity \Drupal\edlp_studio\Entity\Composition */
|
||||||
$row['id'] = $entity->id();
|
$row['id'] = $entity->id();
|
||||||
$row['name'] = Link::createFromRoute(
|
$row['name'] = Link::createFromRoute(
|
||||||
$entity->label(),
|
$entity->label(),
|
||||||
'entity.fil.edit_form',
|
'entity.composition.edit_form',
|
||||||
['fil' => $entity->id()]
|
['composition' => $entity->id()]
|
||||||
);
|
);
|
||||||
return $row + parent::buildRow($entity);
|
return $row + parent::buildRow($entity);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\edlp_studio\Controller;
|
||||||
|
|
||||||
|
use Drupal\Core\Controller\ControllerBase;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class ChutierController.
|
||||||
|
*/
|
||||||
|
class ChutierController extends ControllerBase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello.
|
||||||
|
*
|
||||||
|
* @return json
|
||||||
|
* Return Hello string.
|
||||||
|
*/
|
||||||
|
public function AddContent($id) {
|
||||||
|
// TODO: get current user
|
||||||
|
// TODO: check if default chutier exists ? yes use it : no create and use it.
|
||||||
|
// TODO: add $id to documents field
|
||||||
|
// TODO: return status
|
||||||
|
|
||||||
|
$response = new JsonResponse();
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'test' => 'Hello chutier',
|
||||||
|
);
|
||||||
|
|
||||||
|
$response->setData($data);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
// return array(
|
||||||
|
// '#markup'=>'Hello Chutier'
|
||||||
|
// ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -216,6 +216,7 @@ class Chutier extends ContentEntityBase implements ChutierInterface {
|
|||||||
->setDescription(t('Documents from collection.'))
|
->setDescription(t('Documents from collection.'))
|
||||||
->setSetting('target_type', 'node')
|
->setSetting('target_type', 'node')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
|
// TODO: check node content type by settings @see readme
|
||||||
->setSetting('handler_settings',['target_bundles'=>['enregistrement'=>'enregistrement']] )
|
->setSetting('handler_settings',['target_bundles'=>['enregistrement'=>'enregistrement']] )
|
||||||
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
|
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
|
||||||
->setDisplayOptions('view', array(
|
->setDisplayOptions('view', array(
|
||||||
|
|||||||
+23
-23
@@ -10,31 +10,31 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
|||||||
use Drupal\user\UserInterface;
|
use Drupal\user\UserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the Fil entity.
|
* Defines the Composition entity.
|
||||||
*
|
*
|
||||||
* @ingroup edlp_studio
|
* @ingroup edlp_studio
|
||||||
*
|
*
|
||||||
* @ContentEntityType(
|
* @ContentEntityType(
|
||||||
* id = "fil",
|
* id = "composition",
|
||||||
* label = @Translation("Fil"),
|
* label = @Translation("Composition"),
|
||||||
* handlers = {
|
* handlers = {
|
||||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||||
* "list_builder" = "Drupal\edlp_studio\FilListBuilder",
|
* "list_builder" = "Drupal\edlp_studio\CompositionListBuilder",
|
||||||
* "views_data" = "Drupal\edlp_studio\Entity\FilViewsData",
|
* "views_data" = "Drupal\edlp_studio\Entity\CompositionViewsData",
|
||||||
*
|
*
|
||||||
* "form" = {
|
* "form" = {
|
||||||
* "default" = "Drupal\edlp_studio\Form\FilForm",
|
* "default" = "Drupal\edlp_studio\Form\CompositionForm",
|
||||||
* "add" = "Drupal\edlp_studio\Form\FilForm",
|
* "add" = "Drupal\edlp_studio\Form\CompositionForm",
|
||||||
* "edit" = "Drupal\edlp_studio\Form\FilForm",
|
* "edit" = "Drupal\edlp_studio\Form\CompositionForm",
|
||||||
* "delete" = "Drupal\edlp_studio\Form\FilDeleteForm",
|
* "delete" = "Drupal\edlp_studio\Form\CompositionDeleteForm",
|
||||||
* },
|
* },
|
||||||
* "access" = "Drupal\edlp_studio\FilAccessControlHandler",
|
* "access" = "Drupal\edlp_studio\CompositionAccessControlHandler",
|
||||||
* "route_provider" = {
|
* "route_provider" = {
|
||||||
* "html" = "Drupal\edlp_studio\FilHtmlRouteProvider",
|
* "html" = "Drupal\edlp_studio\CompositionHtmlRouteProvider",
|
||||||
* },
|
* },
|
||||||
* },
|
* },
|
||||||
* base_table = "fil",
|
* base_table = "composition",
|
||||||
* admin_permission = "administer fil entities",
|
* admin_permission = "administer composition entities",
|
||||||
* entity_keys = {
|
* entity_keys = {
|
||||||
* "id" = "id",
|
* "id" = "id",
|
||||||
* "label" = "name",
|
* "label" = "name",
|
||||||
@@ -44,16 +44,16 @@ use Drupal\user\UserInterface;
|
|||||||
* "status" = "status",
|
* "status" = "status",
|
||||||
* },
|
* },
|
||||||
* links = {
|
* links = {
|
||||||
* "canonical" = "/admin/structure/studio/fil/{fil}",
|
* "canonical" = "/admin/structure/studio/composition/{composition}",
|
||||||
* "add-form" = "/admin/structure/studio/fil/add",
|
* "add-form" = "/admin/structure/studio/composition/add",
|
||||||
* "edit-form" = "/admin/structure/studio/fil/{fil}/edit",
|
* "edit-form" = "/admin/structure/studio/composition/{composition}/edit",
|
||||||
* "delete-form" = "/admin/structure/studio/fil/{fil}/delete",
|
* "delete-form" = "/admin/structure/studio/composition/{composition}/delete",
|
||||||
* "collection" = "/admin/structure/studio/fil",
|
* "collection" = "/admin/structure/studio/composition",
|
||||||
* },
|
* },
|
||||||
* field_ui_base_route = "fil.settings"
|
* field_ui_base_route = "composition.settings"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
class Fil extends ContentEntityBase implements FilInterface {
|
class Composition extends ContentEntityBase implements CompositionInterface {
|
||||||
|
|
||||||
use EntityChangedTrait;
|
use EntityChangedTrait;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ class Fil extends ContentEntityBase implements FilInterface {
|
|||||||
|
|
||||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||||
->setLabel(t('Authored by'))
|
->setLabel(t('Authored by'))
|
||||||
->setDescription(t('The user ID of author of the Fil entity.'))
|
->setDescription(t('The user ID of author of the Composition entity.'))
|
||||||
->setRevisionable(TRUE)
|
->setRevisionable(TRUE)
|
||||||
->setSetting('target_type', 'user')
|
->setSetting('target_type', 'user')
|
||||||
->setSetting('handler', 'default')
|
->setSetting('handler', 'default')
|
||||||
@@ -175,7 +175,7 @@ class Fil extends ContentEntityBase implements FilInterface {
|
|||||||
|
|
||||||
$fields['name'] = BaseFieldDefinition::create('string')
|
$fields['name'] = BaseFieldDefinition::create('string')
|
||||||
->setLabel(t('Name'))
|
->setLabel(t('Name'))
|
||||||
->setDescription(t('The name of the Fil entity.'))
|
->setDescription(t('The name of the Composition entity.'))
|
||||||
->setSettings([
|
->setSettings([
|
||||||
'max_length' => 50,
|
'max_length' => 50,
|
||||||
'text_processing' => 0,
|
'text_processing' => 0,
|
||||||
@@ -196,7 +196,7 @@ class Fil extends ContentEntityBase implements FilInterface {
|
|||||||
|
|
||||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||||
->setLabel(t('Publishing status'))
|
->setLabel(t('Publishing status'))
|
||||||
->setDescription(t('A boolean indicating whether the Fil is published.'))
|
->setDescription(t('A boolean indicating whether the Composition is published.'))
|
||||||
->setDefaultValue(TRUE)
|
->setDefaultValue(TRUE)
|
||||||
->setDisplayOptions('form', [
|
->setDisplayOptions('form', [
|
||||||
'type' => 'boolean_checkbox',
|
'type' => 'boolean_checkbox',
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\edlp_studio\Entity;
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\ContentEntityInterface;
|
||||||
|
use Drupal\Core\Entity\EntityChangedInterface;
|
||||||
|
use Drupal\user\EntityOwnerInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an interface for defining Composition entities.
|
||||||
|
*
|
||||||
|
* @ingroup edlp_studio
|
||||||
|
*/
|
||||||
|
interface CompositionInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
|
||||||
|
|
||||||
|
// Add get/set methods for your configuration properties here.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Composition name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* Name of the Composition.
|
||||||
|
*/
|
||||||
|
public function getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Composition name.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* The Composition name.
|
||||||
|
*
|
||||||
|
* @return \Drupal\edlp_studio\Entity\CompositionInterface
|
||||||
|
* The called Composition entity.
|
||||||
|
*/
|
||||||
|
public function setName($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the Composition creation timestamp.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* Creation timestamp of the Composition.
|
||||||
|
*/
|
||||||
|
public function getCreatedTime();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the Composition creation timestamp.
|
||||||
|
*
|
||||||
|
* @param int $timestamp
|
||||||
|
* The Composition creation timestamp.
|
||||||
|
*
|
||||||
|
* @return \Drupal\edlp_studio\Entity\CompositionInterface
|
||||||
|
* The called Composition entity.
|
||||||
|
*/
|
||||||
|
public function setCreatedTime($timestamp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the Composition published status indicator.
|
||||||
|
*
|
||||||
|
* Unpublished Composition are only visible to restricted users.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
* TRUE if the Composition is published.
|
||||||
|
*/
|
||||||
|
public function isPublished();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the published status of a Composition.
|
||||||
|
*
|
||||||
|
* @param bool $published
|
||||||
|
* TRUE to set this Composition to published, FALSE to set it to unpublished.
|
||||||
|
*
|
||||||
|
* @return \Drupal\edlp_studio\Entity\CompositionInterface
|
||||||
|
* The called Composition entity.
|
||||||
|
*/
|
||||||
|
public function setPublished($published);
|
||||||
|
|
||||||
|
}
|
||||||
+2
-2
@@ -5,9 +5,9 @@ namespace Drupal\edlp_studio\Entity;
|
|||||||
use Drupal\views\EntityViewsData;
|
use Drupal\views\EntityViewsData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides Views data for Fil entities.
|
* Provides Views data for Composition entities.
|
||||||
*/
|
*/
|
||||||
class FilViewsData extends EntityViewsData {
|
class CompositionViewsData extends EntityViewsData {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\edlp_studio\Entity;
|
|
||||||
|
|
||||||
use Drupal\Core\Entity\ContentEntityInterface;
|
|
||||||
use Drupal\Core\Entity\EntityChangedInterface;
|
|
||||||
use Drupal\user\EntityOwnerInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides an interface for defining Fil entities.
|
|
||||||
*
|
|
||||||
* @ingroup edlp_studio
|
|
||||||
*/
|
|
||||||
interface FilInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
|
|
||||||
|
|
||||||
// Add get/set methods for your configuration properties here.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Fil name.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* Name of the Fil.
|
|
||||||
*/
|
|
||||||
public function getName();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Fil name.
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
* The Fil name.
|
|
||||||
*
|
|
||||||
* @return \Drupal\edlp_studio\Entity\FilInterface
|
|
||||||
* The called Fil entity.
|
|
||||||
*/
|
|
||||||
public function setName($name);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the Fil creation timestamp.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
* Creation timestamp of the Fil.
|
|
||||||
*/
|
|
||||||
public function getCreatedTime();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Fil creation timestamp.
|
|
||||||
*
|
|
||||||
* @param int $timestamp
|
|
||||||
* The Fil creation timestamp.
|
|
||||||
*
|
|
||||||
* @return \Drupal\edlp_studio\Entity\FilInterface
|
|
||||||
* The called Fil entity.
|
|
||||||
*/
|
|
||||||
public function setCreatedTime($timestamp);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the Fil published status indicator.
|
|
||||||
*
|
|
||||||
* Unpublished Fil are only visible to restricted users.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* TRUE if the Fil is published.
|
|
||||||
*/
|
|
||||||
public function isPublished();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the published status of a Fil.
|
|
||||||
*
|
|
||||||
* @param bool $published
|
|
||||||
* TRUE to set this Fil to published, FALSE to set it to unpublished.
|
|
||||||
*
|
|
||||||
* @return \Drupal\edlp_studio\Entity\FilInterface
|
|
||||||
* The called Fil entity.
|
|
||||||
*/
|
|
||||||
public function setPublished($published);
|
|
||||||
|
|
||||||
}
|
|
||||||
+2
-2
@@ -5,11 +5,11 @@ namespace Drupal\edlp_studio\Form;
|
|||||||
use Drupal\Core\Entity\ContentEntityDeleteForm;
|
use Drupal\Core\Entity\ContentEntityDeleteForm;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a form for deleting Fil entities.
|
* Provides a form for deleting Composition entities.
|
||||||
*
|
*
|
||||||
* @ingroup edlp_studio
|
* @ingroup edlp_studio
|
||||||
*/
|
*/
|
||||||
class FilDeleteForm extends ContentEntityDeleteForm {
|
class CompositionDeleteForm extends ContentEntityDeleteForm {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+6
-6
@@ -6,17 +6,17 @@ use Drupal\Core\Entity\ContentEntityForm;
|
|||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form controller for Fil edit forms.
|
* Form controller for Composition edit forms.
|
||||||
*
|
*
|
||||||
* @ingroup edlp_studio
|
* @ingroup edlp_studio
|
||||||
*/
|
*/
|
||||||
class FilForm extends ContentEntityForm {
|
class CompositionForm extends ContentEntityForm {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||||
/* @var $entity \Drupal\edlp_studio\Entity\Fil */
|
/* @var $entity \Drupal\edlp_studio\Entity\Composition */
|
||||||
$form = parent::buildForm($form, $form_state);
|
$form = parent::buildForm($form, $form_state);
|
||||||
|
|
||||||
$entity = $this->entity;
|
$entity = $this->entity;
|
||||||
@@ -34,17 +34,17 @@ class FilForm extends ContentEntityForm {
|
|||||||
|
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case SAVED_NEW:
|
case SAVED_NEW:
|
||||||
drupal_set_message($this->t('Created the %label Fil.', [
|
drupal_set_message($this->t('Created the %label Composition.', [
|
||||||
'%label' => $entity->label(),
|
'%label' => $entity->label(),
|
||||||
]));
|
]));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
drupal_set_message($this->t('Saved the %label Fil.', [
|
drupal_set_message($this->t('Saved the %label Composition.', [
|
||||||
'%label' => $entity->label(),
|
'%label' => $entity->label(),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
$form_state->setRedirect('entity.fil.canonical', ['fil' => $entity->id()]);
|
$form_state->setRedirect('entity.composition.canonical', ['composition' => $entity->id()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+5
-5
@@ -6,11 +6,11 @@ use Drupal\Core\Form\FormBase;
|
|||||||
use Drupal\Core\Form\FormStateInterface;
|
use Drupal\Core\Form\FormStateInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class FilSettingsForm.
|
* Class CompositionSettingsForm.
|
||||||
*
|
*
|
||||||
* @ingroup edlp_studio
|
* @ingroup edlp_studio
|
||||||
*/
|
*/
|
||||||
class FilSettingsForm extends FormBase {
|
class CompositionSettingsForm extends FormBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a unique string identifying the form.
|
* Returns a unique string identifying the form.
|
||||||
@@ -19,7 +19,7 @@ class FilSettingsForm extends FormBase {
|
|||||||
* The unique string identifying the form.
|
* The unique string identifying the form.
|
||||||
*/
|
*/
|
||||||
public function getFormId() {
|
public function getFormId() {
|
||||||
return 'fil_settings';
|
return 'composition_settings';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -35,7 +35,7 @@ class FilSettingsForm extends FormBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the settings form for Fil entities.
|
* Defines the settings form for Composition entities.
|
||||||
*
|
*
|
||||||
* @param array $form
|
* @param array $form
|
||||||
* An associative array containing the structure of the form.
|
* An associative array containing the structure of the form.
|
||||||
@@ -46,7 +46,7 @@ class FilSettingsForm extends FormBase {
|
|||||||
* Form definition array.
|
* Form definition array.
|
||||||
*/
|
*/
|
||||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||||
$form['fil_settings']['#markup'] = 'Settings form for Fil entities. Manage field settings here.';
|
$form['composition_settings']['#markup'] = 'Settings form for Composition entities. Manage field settings here.';
|
||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
+5
-5
@@ -1,21 +1,21 @@
|
|||||||
{#
|
{#
|
||||||
/**
|
/**
|
||||||
* @file fil.html.twig
|
* @file composition.html.twig
|
||||||
* Default theme implementation to present Fil data.
|
* Default theme implementation to present Composition data.
|
||||||
*
|
*
|
||||||
* This template is used when viewing Fil pages.
|
* This template is used when viewing Composition pages.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Available variables:
|
* Available variables:
|
||||||
* - content: A list of content items. Use 'content' to print all content, or
|
* - content: A list of content items. Use 'content' to print all content, or
|
||||||
* - attributes: HTML attributes for the container element.
|
* - attributes: HTML attributes for the container element.
|
||||||
*
|
*
|
||||||
* @see template_preprocess_fil()
|
* @see template_preprocess_composition()
|
||||||
*
|
*
|
||||||
* @ingroup themeable
|
* @ingroup themeable
|
||||||
*/
|
*/
|
||||||
#}
|
#}
|
||||||
<div{{ attributes.addClass('fil') }}>
|
<div{{ attributes.addClass('composition') }}>
|
||||||
{% if content %}
|
{% if content %}
|
||||||
{{- content -}}
|
{{- content -}}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
+11
-6
@@ -12,6 +12,8 @@ dependencies:
|
|||||||
- field.field.node.enregistrement.field_langues
|
- field.field.node.enregistrement.field_langues
|
||||||
- field.field.node.enregistrement.field_locuteurs
|
- field.field.node.enregistrement.field_locuteurs
|
||||||
- field.field.node.enregistrement.field_son
|
- field.field.node.enregistrement.field_son
|
||||||
|
- field.field.node.enregistrement.field_transcript_trad
|
||||||
|
- field.field.node.enregistrement.field_transcript_vo
|
||||||
- field.field.node.enregistrement.field_workflow
|
- field.field.node.enregistrement.field_workflow
|
||||||
- node.type.enregistrement
|
- node.type.enregistrement
|
||||||
module:
|
module:
|
||||||
@@ -22,6 +24,11 @@ targetEntityType: node
|
|||||||
bundle: enregistrement
|
bundle: enregistrement
|
||||||
mode: player_cartel
|
mode: player_cartel
|
||||||
content:
|
content:
|
||||||
|
add_to_chutier:
|
||||||
|
weight: 1
|
||||||
|
region: content
|
||||||
|
settings: { }
|
||||||
|
third_party_settings: { }
|
||||||
content_moderation_control:
|
content_moderation_control:
|
||||||
weight: -20
|
weight: -20
|
||||||
region: content
|
region: content
|
||||||
@@ -35,18 +42,13 @@ content:
|
|||||||
type: text_default
|
type: text_default
|
||||||
region: content
|
region: content
|
||||||
field_entrees:
|
field_entrees:
|
||||||
weight: 1
|
weight: 0
|
||||||
label: hidden
|
label: hidden
|
||||||
settings:
|
settings:
|
||||||
link: false
|
link: false
|
||||||
third_party_settings: { }
|
third_party_settings: { }
|
||||||
type: entity_reference_label
|
type: entity_reference_label
|
||||||
region: content
|
region: content
|
||||||
links:
|
|
||||||
weight: 0
|
|
||||||
region: content
|
|
||||||
settings: { }
|
|
||||||
third_party_settings: { }
|
|
||||||
hidden:
|
hidden:
|
||||||
body: true
|
body: true
|
||||||
field_collectionneurs: true
|
field_collectionneurs: true
|
||||||
@@ -54,5 +56,8 @@ hidden:
|
|||||||
field_langues: true
|
field_langues: true
|
||||||
field_locuteurs: true
|
field_locuteurs: true
|
||||||
field_son: true
|
field_son: true
|
||||||
|
field_transcript_trad: true
|
||||||
|
field_transcript_vo: true
|
||||||
field_workflow: true
|
field_workflow: true
|
||||||
langcode: true
|
langcode: true
|
||||||
|
links: true
|
||||||
|
|||||||
Reference in New Issue
Block a user