Переглянути джерело

started materio_home module

Bachir Soussi Chiadmi 6 роки тому
батько
коміт
e514a876c2

+ 7 - 0
web/modules/custom/materio_home/includes/materio_home.inc

@@ -0,0 +1,7 @@
+<?php
+
+use Drupal\Core\Url;
+
+function template_preprocess_materio_home(&$vars){
+
+}

+ 6 - 0
web/modules/custom/materio_home/materio_home.info.yml

@@ -0,0 +1,6 @@
+name: Materio Home
+type: module
+description: Defines home contents for materiO.
+core: 8.x
+package: Materio
+dependencies:

+ 16 - 0
web/modules/custom/materio_home/materio_home.module

@@ -0,0 +1,16 @@
+<?php
+
+/**
+ * Implements hook_theme().
+ */
+function materio_home_theme($existing, $type, $theme, $path) {
+  // @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
+
+  return array(
+    'materio_home' => array(
+      // 'render element' => '',
+      'file' => 'includes/materio_home.inc',
+      'variables' => array(),
+    ),
+  );
+}

+ 23 - 0
web/modules/custom/materio_home/materio_home.routing.yml

@@ -0,0 +1,23 @@
+materio_home.home:
+  path: '/home'
+  defaults:
+    _controller: '\Drupal\materio_home\Controller\HomeController::home'
+    _title: 'Home'
+  requirements:
+    _permission: 'access content'
+
+# materio_home.home_mobile:
+#   path: '/home_m'
+#   defaults:
+#     _controller: '\Drupal\materio_home\Controller\HomeController::home_mobile'
+#     _title: 'Home'
+#   requirements:
+#     _permission: 'access content'
+#
+# materio_home.home_mobileajax:
+#   path: '/home_m/ajax'
+#   defaults:
+#     _controller: '\Drupal\materio_home\Controller\HomeController::home_mobilejson'
+#     _title: 'Home'
+#   requirements:
+#     _permission: 'access content'

+ 35 - 0
web/modules/custom/materio_home/src/Controller/HomeController.php

@@ -0,0 +1,35 @@
+<?php
+
+namespace Drupal\materio_home\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Datetime\DrupalDateTime;
+use Drupal\taxonomy\Entity\Term;
+use Drupal\workflow\Entity\WorkflowManager;
+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 HomeController extends ControllerBase {
+
+  /**
+   * Display home as a page.
+   *
+   * @return renderable array
+   */
+  public function home() {
+
+    // $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
+
+    $contents = array("#theme"=>'materio_home');
+
+    return $contents;
+  }
+
+
+}

+ 1 - 0
web/modules/custom/materio_home/templates/materio-home.html.twig

@@ -0,0 +1 @@
+Hello Materio :)