reinstalled all contribs with composer

need to run :
drush ev 'drupal_flush_all_caches();'
drush cr
and restart nginx and php-fpm before loading the website
This commit is contained in:
2019-04-30 19:27:47 +02:00
parent e1f9bb3cd0
commit 9da6cf9927
373 changed files with 3392 additions and 5 deletions
@@ -0,0 +1,18 @@
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 13-12-2017
# @Email: bachir@figureslibres.io
# @Filename: edlp_corpus.routing.yml
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
name: Edlp Agenda
type: module
description: Manage agenda for edlp d8.
core: 8.x
package: Edlp
# dependencies:
# - migrate_drupal
# - migrate_plus
# - migrate_tools
@@ -0,0 +1,27 @@
<?php
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 13-12-2017
# @Email: bachir@figureslibres.io
# @Filename: edlp_corpus.routing.yml
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
/**
* Implements hook_theme().
*/
function edlp_agenda_theme($existing, $type, $theme, $path) {
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
return array(
'edlp_agenda' => array(
// 'render element' => '',
'file' => 'includes/edlp_agenda.inc',
'variables' => array(
'next_event_node' => NULL,
'coming_events_nodes' => NULL,
'past_events_nodes' => NULL
),
),
);
}
@@ -0,0 +1,23 @@
# @Author: Bachir Soussi Chiadmi <bach>
# @Date: 13-12-2017
# @Email: bachir@figureslibres.io
# @Filename: edlp_corpus.routing.yml
# @Last modified by: bach
# @Last modified time: 20-12-2017
# @License: GPL-V3
edlp_agenda.agenda:
path: '/agenda'
defaults:
_controller: '\Drupal\edlp_agenda\Controller\AgendaController::agenda'
_title: 'Agenda'
requirements:
_permission: 'access content'
edlp_agenda.agendaajax:
path: '/agenda/ajax'
defaults:
_controller: '\Drupal\edlp_agenda\Controller\AgendaController::agendajson'
_title: 'Agenda'
requirements:
_permission: 'access content'
@@ -0,0 +1,71 @@
<?php
// use Drupal\Core\Url;
function template_preprocess_edlp_agenda(&$vars){
// dpm($vars);
/*
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
*/
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
// if(isset($vars['next_event_node'])){
// $vars['next_event'] = array(
// "#markup"=>"<h3>Prochaine Date</h3>",
// "event"=>$view_builder->view($vars['next_event_node'], 'default')
// );
// }
if(count($vars['coming_events_nodes'])){
$future_list = array (
'#theme' => 'item_list',
'#items' => [],
);
foreach($vars['coming_events_nodes'] as $node){
$future_list['#items'][] = $view_builder->view($node, 'teaser');
}
$vars['coming_events'] = array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['future-events']
),
"#markup"=>"<h3>".t("Upcoming Events")."</h3>",
"future_events"=>$future_list
);
}
$past_list = array (
'#theme' => 'item_list',
'#items' => [],
);
foreach($vars['past_events_nodes'] as $node){
$past_list['#items'][] = $view_builder->view($node, 'teaser');
}
$vars['past_events'] = array(
"#type"=>"container",
"#attributes"=>array(
"class"=>['past-events']
),
"#markup"=>"<h3>".t("Past Events")."</h3>",
"past_events"=>$past_list
);
// return array(
// "#type" => "container",
// "#attributes"=>array(
// "id"=>['agenda']
// ),
// "future_past"=>array(
// "#type"=>"container",
// "#attributes"=>array(
// "class"=>['future-past-events', 'column', 'os-scroll']
// ),
// "future"=>,
// "past"=>
// )
// );
}
@@ -0,0 +1,118 @@
<?php
namespace Drupal\edlp_agenda\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface;
// use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\core\render\RenderContext;
class AgendaController extends ControllerBase {
private function query() {
// @see https://www.webomelette.com/query-entities-using-dates-drupal-8
$now = new DrupalDateTime('now');
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'evenement')
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
->sort('field_date');
$this->future_nids = $query->execute();
$this->future_nodes = entity_load_multiple('node', $this->future_nids);
// $this->next_event_node = array_shift($this->future_nodes);
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'evenement')
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '<')
->sort('field_date', 'DESC');
$this->past_nids = $query->execute();
$this->past_nodes = entity_load_multiple('node', $this->past_nids);
}
private function toRenderable(){
$this->query();
// dpm($this->next_event_node);
return array(
"#theme"=>'edlp_agenda',
// '#next_event_node' => $this->next_event_node,
"#coming_events_nodes" => $this->future_nodes,
"#past_events_nodes" => $this->past_nodes,
);
}
/**
* Display agenda as a page.
*
* @return renderable array
*/
public function agenda() {
return $this->toRenderable();
}
/**
* Get agenda data as json through ajax.
*
* @return json
*/
public function agendajson() {
$renderable = $this->toRenderable();
// $rendered = render($renderable);
// We can't render directly the entity as it throw an exception with cachable data
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
return render($renderable);
});
$data = [
'rendered'=> $rendered,
'title'=>'Agenda',
];
// translations links
// use Drupal\Core\Url;
// use Drupal\Core\Language\LanguageInterface;
$route_name = 'edlp_agenda.agenda';
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
if (isset($links->links)) {
$translations_build = [
'#theme' => 'links__language_block',
'#links' => $links->links,
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
$data['translations_links'] = $translations_rendered;
}
$data['#cache'] = [
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
'tags' => ['edlp-agenda-cache'],
'contexts' => [
'languages:language_content'
]
];
// $response = new JsonResponse();
// $response->setData($data);
$response = new CacheableJsonResponse($data);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
return $response;
}
}
@@ -0,0 +1,3 @@
{# next_event #}
{{ coming_events }}
{{ past_events }}