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
|
||||
* Contains fil.page.inc.
|
||||
* Contains composition.page.inc.
|
||||
*
|
||||
* Page callback for Fil entities.
|
||||
* Page callback for Composition entities.
|
||||
*/
|
||||
|
||||
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
|
||||
* An associative array containing:
|
||||
* - elements: An associative array containing the user information and any
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
*/
|
||||
function template_preprocess_fil(array &$variables) {
|
||||
// Fetch Fil Entity Object.
|
||||
$fil = $variables['elements']['#fil'];
|
||||
function template_preprocess_composition(array &$variables) {
|
||||
// Fetch Composition Entity Object.
|
||||
$composition = $variables['elements']['#composition'];
|
||||
|
||||
// Helpful $content variable for templates.
|
||||
foreach (Element::children($variables['elements']) as $key) {
|
||||
@@ -1,6 +1,6 @@
|
||||
name: 'Edlp Studio'
|
||||
type: module
|
||||
description: 'Edlp module that handle chutier and fils entities'
|
||||
description: 'Edlp module that handle chutier and Compositions entities'
|
||||
core: 8.x
|
||||
package: 'edlp'
|
||||
dependencies:
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
edlp_studio-library:
|
||||
js:
|
||||
js/edlp_studio.js: {}
|
||||
@@ -3,8 +3,8 @@ entity.chutier.add_form:
|
||||
title: 'Add Chutier'
|
||||
appears_on:
|
||||
- entity.chutier.collection
|
||||
entity.fil.add_form:
|
||||
route_name: entity.fil.add_form
|
||||
title: 'Add Fil'
|
||||
entity.composition.add_form:
|
||||
route_name: entity.composition.add_form
|
||||
title: 'Add Composition'
|
||||
appears_on:
|
||||
- entity.fil.collection
|
||||
- entity.composition.collection
|
||||
|
||||
@@ -19,16 +19,16 @@ chutier.admin.structure.settings:
|
||||
route_name: chutier.settings
|
||||
parent: edlp_studio.studio
|
||||
|
||||
# Fil menu items definition
|
||||
entity.fil.collection:
|
||||
title: 'Fil list'
|
||||
route_name: entity.fil.collection
|
||||
description: 'List Fil entities'
|
||||
# Composition menu items definition
|
||||
entity.composition.collection:
|
||||
title: 'Composition list'
|
||||
route_name: entity.composition.collection
|
||||
description: 'List Composition entities'
|
||||
parent: edlp_studio.studio
|
||||
weight: 100
|
||||
|
||||
fil.admin.structure.settings:
|
||||
title: 'Fil settings'
|
||||
description: 'Configure Fil entities'
|
||||
route_name: fil.settings
|
||||
composition.admin.structure.settings:
|
||||
title: 'Composition settings'
|
||||
description: 'Configure Composition entities'
|
||||
route_name: composition.settings
|
||||
parent: edlp_studio.studio
|
||||
|
||||
@@ -20,24 +20,24 @@ entity.chutier.delete_form:
|
||||
title: Delete
|
||||
weight: 10
|
||||
|
||||
# Fil routing definition
|
||||
fil.settings_tab:
|
||||
route_name: fil.settings
|
||||
# Composition routing definition
|
||||
composition.settings_tab:
|
||||
route_name: composition.settings
|
||||
title: 'Settings'
|
||||
base_route: fil.settings
|
||||
base_route: composition.settings
|
||||
|
||||
entity.fil.canonical:
|
||||
route_name: entity.fil.canonical
|
||||
base_route: entity.fil.canonical
|
||||
entity.composition.canonical:
|
||||
route_name: entity.composition.canonical
|
||||
base_route: entity.composition.canonical
|
||||
title: 'View'
|
||||
|
||||
entity.fil.edit_form:
|
||||
route_name: entity.fil.edit_form
|
||||
base_route: entity.fil.canonical
|
||||
entity.composition.edit_form:
|
||||
route_name: entity.composition.edit_form
|
||||
base_route: entity.composition.canonical
|
||||
title: 'Edit'
|
||||
|
||||
entity.fil.delete_form:
|
||||
route_name: entity.fil.delete_form
|
||||
base_route: entity.fil.canonical
|
||||
entity.composition.delete_form:
|
||||
route_name: entity.composition.delete_form
|
||||
base_route: entity.composition.canonical
|
||||
title: Delete
|
||||
weight: 10
|
||||
|
||||
@@ -16,9 +16,54 @@ function edlp_studio_help($route_name, RouteMatchInterface $route_match) {
|
||||
case 'help.page.edlp_studio':
|
||||
$output = '';
|
||||
$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;
|
||||
|
||||
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:
|
||||
title: 'View own unpublished Chutier entities'
|
||||
|
||||
# Fils
|
||||
add fil entities:
|
||||
title: 'Create new Fil entities'
|
||||
use chutier:
|
||||
title: 'use chutier'
|
||||
|
||||
administer fil entities:
|
||||
title: 'Administer Fil entities'
|
||||
description: 'Allow to access the administration form to configure Fil entities.'
|
||||
# Compositions
|
||||
add composition 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
|
||||
|
||||
delete any fil entities:
|
||||
title: 'Delete any Fil entities'
|
||||
delete any composition entities:
|
||||
title: 'Delete any Composition entities'
|
||||
|
||||
edit any fil entities:
|
||||
title: 'Edit any Fil entities'
|
||||
edit any composition entities:
|
||||
title: 'Edit any Composition entities'
|
||||
|
||||
delete own fil entities:
|
||||
title: 'Delete own Fil entities'
|
||||
delete own composition entities:
|
||||
title: 'Delete own Composition entities'
|
||||
|
||||
edit own fil entities:
|
||||
title: 'Edit own Fil entities'
|
||||
edit own composition entities:
|
||||
title: 'Edit own Composition entities'
|
||||
|
||||
view published fil entities:
|
||||
title: 'View published Fil entities'
|
||||
view published composition entities:
|
||||
title: 'View published Composition entities'
|
||||
|
||||
view any unpublished fil entities:
|
||||
title: 'View any unpublished Fil entities'
|
||||
view any unpublished composition entities:
|
||||
title: 'View any unpublished Composition entities'
|
||||
|
||||
view own unpublished fil entities:
|
||||
title: 'View own unpublished Fil entities'
|
||||
view own unpublished composition entities:
|
||||
title: 'View own unpublished Composition entities'
|
||||
|
||||
@@ -5,3 +5,11 @@ edlp_studio.studio:
|
||||
_title: 'Studio'
|
||||
requirements:
|
||||
_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;
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
/** @var \Drupal\edlp_studio\Entity\FilInterface $entity */
|
||||
/** @var \Drupal\edlp_studio\Entity\CompositionInterface $entity */
|
||||
switch ($operation) {
|
||||
case 'view':
|
||||
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);
|
||||
}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':
|
||||
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);
|
||||
}else{
|
||||
return AccessResult::allowedIfHasPermission($account, 'edit any fil entities');
|
||||
return AccessResult::allowedIfHasPermission($account, 'edit any composition entities');
|
||||
}
|
||||
|
||||
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);
|
||||
}else{
|
||||
return AccessResult::allowedIfHasPermission($account, 'delete fil entities');
|
||||
return AccessResult::allowedIfHasPermission($account, 'delete composition entities');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ class FilAccessControlHandler extends EntityAccessControlHandler {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* Provides routes for Fil entities.
|
||||
* Provides routes for Composition entities.
|
||||
*
|
||||
* @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
|
||||
* @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
|
||||
*/
|
||||
class FilHtmlRouteProvider extends AdminHtmlRouteProvider {
|
||||
class CompositionHtmlRouteProvider extends AdminHtmlRouteProvider {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
@@ -43,7 +43,7 @@ class FilHtmlRouteProvider extends AdminHtmlRouteProvider {
|
||||
$route = new Route("/admin/structure/studio/{$entity_type->id()}/settings");
|
||||
$route
|
||||
->setDefaults([
|
||||
'_form' => 'Drupal\edlp_studio\Form\FilSettingsForm',
|
||||
'_form' => 'Drupal\edlp_studio\Form\CompositionSettingsForm',
|
||||
'_title' => "{$entity_type->getLabel()} settings",
|
||||
])
|
||||
->setRequirement('_permission', $entity_type->getAdminPermission())
|
||||
+6
-6
@@ -7,18 +7,18 @@ use Drupal\Core\Entity\EntityListBuilder;
|
||||
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
|
||||
*/
|
||||
class FilListBuilder extends EntityListBuilder {
|
||||
class CompositionListBuilder extends EntityListBuilder {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildHeader() {
|
||||
$header['id'] = $this->t('Fil ID');
|
||||
$header['id'] = $this->t('Composition ID');
|
||||
$header['name'] = $this->t('Name');
|
||||
return $header + parent::buildHeader();
|
||||
}
|
||||
@@ -27,12 +27,12 @@ class FilListBuilder extends EntityListBuilder {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildRow(EntityInterface $entity) {
|
||||
/* @var $entity \Drupal\edlp_studio\Entity\Fil */
|
||||
/* @var $entity \Drupal\edlp_studio\Entity\Composition */
|
||||
$row['id'] = $entity->id();
|
||||
$row['name'] = Link::createFromRoute(
|
||||
$entity->label(),
|
||||
'entity.fil.edit_form',
|
||||
['fil' => $entity->id()]
|
||||
'entity.composition.edit_form',
|
||||
['composition' => $entity->id()]
|
||||
);
|
||||
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.'))
|
||||
->setSetting('target_type', 'node')
|
||||
->setSetting('handler', 'default')
|
||||
// TODO: check node content type by settings @see readme
|
||||
->setSetting('handler_settings',['target_bundles'=>['enregistrement'=>'enregistrement']] )
|
||||
->setCardinality(BaseFieldDefinition::CARDINALITY_UNLIMITED)
|
||||
->setDisplayOptions('view', array(
|
||||
|
||||
+23
-23
@@ -10,31 +10,31 @@ use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\user\UserInterface;
|
||||
|
||||
/**
|
||||
* Defines the Fil entity.
|
||||
* Defines the Composition entity.
|
||||
*
|
||||
* @ingroup edlp_studio
|
||||
*
|
||||
* @ContentEntityType(
|
||||
* id = "fil",
|
||||
* label = @Translation("Fil"),
|
||||
* id = "composition",
|
||||
* label = @Translation("Composition"),
|
||||
* handlers = {
|
||||
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
|
||||
* "list_builder" = "Drupal\edlp_studio\FilListBuilder",
|
||||
* "views_data" = "Drupal\edlp_studio\Entity\FilViewsData",
|
||||
* "list_builder" = "Drupal\edlp_studio\CompositionListBuilder",
|
||||
* "views_data" = "Drupal\edlp_studio\Entity\CompositionViewsData",
|
||||
*
|
||||
* "form" = {
|
||||
* "default" = "Drupal\edlp_studio\Form\FilForm",
|
||||
* "add" = "Drupal\edlp_studio\Form\FilForm",
|
||||
* "edit" = "Drupal\edlp_studio\Form\FilForm",
|
||||
* "delete" = "Drupal\edlp_studio\Form\FilDeleteForm",
|
||||
* "default" = "Drupal\edlp_studio\Form\CompositionForm",
|
||||
* "add" = "Drupal\edlp_studio\Form\CompositionForm",
|
||||
* "edit" = "Drupal\edlp_studio\Form\CompositionForm",
|
||||
* "delete" = "Drupal\edlp_studio\Form\CompositionDeleteForm",
|
||||
* },
|
||||
* "access" = "Drupal\edlp_studio\FilAccessControlHandler",
|
||||
* "access" = "Drupal\edlp_studio\CompositionAccessControlHandler",
|
||||
* "route_provider" = {
|
||||
* "html" = "Drupal\edlp_studio\FilHtmlRouteProvider",
|
||||
* "html" = "Drupal\edlp_studio\CompositionHtmlRouteProvider",
|
||||
* },
|
||||
* },
|
||||
* base_table = "fil",
|
||||
* admin_permission = "administer fil entities",
|
||||
* base_table = "composition",
|
||||
* admin_permission = "administer composition entities",
|
||||
* entity_keys = {
|
||||
* "id" = "id",
|
||||
* "label" = "name",
|
||||
@@ -44,16 +44,16 @@ use Drupal\user\UserInterface;
|
||||
* "status" = "status",
|
||||
* },
|
||||
* links = {
|
||||
* "canonical" = "/admin/structure/studio/fil/{fil}",
|
||||
* "add-form" = "/admin/structure/studio/fil/add",
|
||||
* "edit-form" = "/admin/structure/studio/fil/{fil}/edit",
|
||||
* "delete-form" = "/admin/structure/studio/fil/{fil}/delete",
|
||||
* "collection" = "/admin/structure/studio/fil",
|
||||
* "canonical" = "/admin/structure/studio/composition/{composition}",
|
||||
* "add-form" = "/admin/structure/studio/composition/add",
|
||||
* "edit-form" = "/admin/structure/studio/composition/{composition}/edit",
|
||||
* "delete-form" = "/admin/structure/studio/composition/{composition}/delete",
|
||||
* "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;
|
||||
|
||||
@@ -150,7 +150,7 @@ class Fil extends ContentEntityBase implements FilInterface {
|
||||
|
||||
$fields['user_id'] = BaseFieldDefinition::create('entity_reference')
|
||||
->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)
|
||||
->setSetting('target_type', 'user')
|
||||
->setSetting('handler', 'default')
|
||||
@@ -175,7 +175,7 @@ class Fil extends ContentEntityBase implements FilInterface {
|
||||
|
||||
$fields['name'] = BaseFieldDefinition::create('string')
|
||||
->setLabel(t('Name'))
|
||||
->setDescription(t('The name of the Fil entity.'))
|
||||
->setDescription(t('The name of the Composition entity.'))
|
||||
->setSettings([
|
||||
'max_length' => 50,
|
||||
'text_processing' => 0,
|
||||
@@ -196,7 +196,7 @@ class Fil extends ContentEntityBase implements FilInterface {
|
||||
|
||||
$fields['status'] = BaseFieldDefinition::create('boolean')
|
||||
->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)
|
||||
->setDisplayOptions('form', [
|
||||
'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;
|
||||
|
||||
/**
|
||||
* Provides Views data for Fil entities.
|
||||
* Provides Views data for Composition entities.
|
||||
*/
|
||||
class FilViewsData extends EntityViewsData {
|
||||
class CompositionViewsData extends EntityViewsData {
|
||||
|
||||
/**
|
||||
* {@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;
|
||||
|
||||
/**
|
||||
* Provides a form for deleting Fil entities.
|
||||
* Provides a form for deleting Composition entities.
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Form controller for Fil edit forms.
|
||||
* Form controller for Composition edit forms.
|
||||
*
|
||||
* @ingroup edlp_studio
|
||||
*/
|
||||
class FilForm extends ContentEntityForm {
|
||||
class CompositionForm extends ContentEntityForm {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
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);
|
||||
|
||||
$entity = $this->entity;
|
||||
@@ -34,17 +34,17 @@ class FilForm extends ContentEntityForm {
|
||||
|
||||
switch ($status) {
|
||||
case SAVED_NEW:
|
||||
drupal_set_message($this->t('Created the %label Fil.', [
|
||||
drupal_set_message($this->t('Created the %label Composition.', [
|
||||
'%label' => $entity->label(),
|
||||
]));
|
||||
break;
|
||||
|
||||
default:
|
||||
drupal_set_message($this->t('Saved the %label Fil.', [
|
||||
drupal_set_message($this->t('Saved the %label Composition.', [
|
||||
'%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;
|
||||
|
||||
/**
|
||||
* Class FilSettingsForm.
|
||||
* Class CompositionSettingsForm.
|
||||
*
|
||||
* @ingroup edlp_studio
|
||||
*/
|
||||
class FilSettingsForm extends FormBase {
|
||||
class CompositionSettingsForm extends FormBase {
|
||||
|
||||
/**
|
||||
* Returns a unique string identifying the form.
|
||||
@@ -19,7 +19,7 @@ class FilSettingsForm extends FormBase {
|
||||
* The unique string identifying the form.
|
||||
*/
|
||||
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
|
||||
* An associative array containing the structure of the form.
|
||||
@@ -46,7 +46,7 @@ class FilSettingsForm extends FormBase {
|
||||
* Form definition array.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,21 +1,21 @@
|
||||
{#
|
||||
/**
|
||||
* @file fil.html.twig
|
||||
* Default theme implementation to present Fil data.
|
||||
* @file composition.html.twig
|
||||
* 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:
|
||||
* - content: A list of content items. Use 'content' to print all content, or
|
||||
* - attributes: HTML attributes for the container element.
|
||||
*
|
||||
* @see template_preprocess_fil()
|
||||
* @see template_preprocess_composition()
|
||||
*
|
||||
* @ingroup themeable
|
||||
*/
|
||||
#}
|
||||
<div{{ attributes.addClass('fil') }}>
|
||||
<div{{ attributes.addClass('composition') }}>
|
||||
{% if content %}
|
||||
{{- content -}}
|
||||
{% endif %}
|
||||
+11
-6
@@ -12,6 +12,8 @@ dependencies:
|
||||
- field.field.node.enregistrement.field_langues
|
||||
- field.field.node.enregistrement.field_locuteurs
|
||||
- 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
|
||||
- node.type.enregistrement
|
||||
module:
|
||||
@@ -22,6 +24,11 @@ targetEntityType: node
|
||||
bundle: enregistrement
|
||||
mode: player_cartel
|
||||
content:
|
||||
add_to_chutier:
|
||||
weight: 1
|
||||
region: content
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
content_moderation_control:
|
||||
weight: -20
|
||||
region: content
|
||||
@@ -35,18 +42,13 @@ content:
|
||||
type: text_default
|
||||
region: content
|
||||
field_entrees:
|
||||
weight: 1
|
||||
weight: 0
|
||||
label: hidden
|
||||
settings:
|
||||
link: false
|
||||
third_party_settings: { }
|
||||
type: entity_reference_label
|
||||
region: content
|
||||
links:
|
||||
weight: 0
|
||||
region: content
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
hidden:
|
||||
body: true
|
||||
field_collectionneurs: true
|
||||
@@ -54,5 +56,8 @@ hidden:
|
||||
field_langues: true
|
||||
field_locuteurs: true
|
||||
field_son: true
|
||||
field_transcript_trad: true
|
||||
field_transcript_vo: true
|
||||
field_workflow: true
|
||||
langcode: true
|
||||
links: true
|
||||
|
||||
Reference in New Issue
Block a user