Browse Source

Fixed directory structure
changed Content Entity such as to have bundles

logicp 7 years ago
parent
commit
ee8be6d396

+ 12 - 0
config/schema/status_type.schema.yml

@@ -0,0 +1,12 @@
+statusmessage.status_type.*:
+  type: config_entity
+  label: 'Status type config'
+  mapping:
+    id:
+      type: string
+      label: 'ID'
+    label:
+      type: label
+      label: 'Label'
+    uuid:
+      type: string

+ 96 - 0
src/Controller/StatusAddController.php

@@ -0,0 +1,96 @@
+<?php
+
+namespace Drupal\statusmessage\Controller;
+
+use Drupal\Core\Controller\ControllerBase;
+use Drupal\Core\Entity\EntityInterface;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
+use Drupal\Core\Entity\EntityStorageInterface;
+use Drupal\Core\Url;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\HttpFoundation\Request;
+
+
+/**
+ * Class StatusAddController.
+ *
+ * @package Drupal\statusmessage\Controller
+ */
+class StatusAddController extends ControllerBase {
+    public function __construct(EntityStorageInterface $storage, EntityStorageInterface $type_storage) {
+      $this->storage = $storage;
+      $this->typeStorage = $type_storage;
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public static function create(ContainerInterface $container) {
+      /** @var EntityTypeManagerInterface $entity_type_manager */
+      $entity_type_manager = $container->get('entity_type.manager');
+      return new static(
+        $entity_type_manager->getStorage('status'),
+        $entity_type_manager->getStorage('status_type')
+      );
+    }
+    /**
+     * Displays add links for available bundles/types for entity status .
+     *
+     * @param \Symfony\Component\HttpFoundation\Request $request
+     *   The current request object.
+     *
+     * @return array
+     *   A render array for a list of the status bundles/types that can be added or
+     *   if there is only one type/bunlde defined for the site, the function returns the add page for that bundle/type.
+     */
+    public function add(Request $request) {
+      $types = $this->typeStorage->loadMultiple();
+      if ($types && count($types) == 1) {
+        $type = reset($types);
+        return $this->addForm($type, $request);
+      }
+      if (count($types) === 0) {
+        return array(
+          '#markup' => $this->t('You have not created any %bundle types yet. @link to add a new type.', [
+            '%bundle' => 'Status',
+            '@link' => $this->l($this->t('Go to the type creation page'), Url::fromRoute('entity.status_type.add_form')),
+          ]),
+        );
+      }
+      return array('#theme' => 'status_content_add_list', '#content' => $types);
+    }
+
+    /**
+     * Presents the creation form for status entities of given bundle/type.
+     *
+     * @param EntityInterface $status_type
+     *   The custom bundle to add.
+     * @param \Symfony\Component\HttpFoundation\Request $request
+     *   The current request object.
+     *
+     * @return array
+     *   A form array as expected by drupal_render().
+     */
+    public function addForm(EntityInterface $status_type, Request $request) {
+      $entity = $this->storage->create(array(
+        'type' => $status_type->id()
+      ));
+      return $this->entityFormBuilder()->getForm($entity);
+    }
+
+    /**
+     * Provides the page title for this controller.
+     *
+     * @param EntityInterface $status_type
+     *   The custom bundle/type being added.
+     *
+     * @return string
+     *   The page title.
+     */
+    public function getAddFormTitle(EntityInterface $status_type) {
+      return t('Create of bundle @label',
+        array('@label' => $status_type->label())
+      );
+    }
+
+}

+ 17 - 2
statusmessage/src/Entity/Status.php → src/Entity/Status.php

@@ -18,6 +18,7 @@ use Drupal\user\UserInterface;
  * @ContentEntityType(
  *   id = "status",
  *   label = @Translation("Status"),
+ *   bundle_label = @Translation("Status type"),
  *   handlers = {
  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
  *     "list_builder" = "Drupal\statusmessage\StatusListBuilder",
@@ -38,6 +39,7 @@ use Drupal\user\UserInterface;
  *   admin_permission = "administer status entities",
  *   entity_keys = {
  *     "id" = "id",
+ *     "bundle" = "type",
  *     "label" = "name",
  *     "uuid" = "uuid",
  *     "uid" = "user_id",
@@ -46,12 +48,13 @@ use Drupal\user\UserInterface;
  *   },
  *   links = {
  *     "canonical" = "/admin/structure/status/{status}",
- *     "add-form" = "/admin/structure/status/add",
+ *     "add-form" = "/admin/structure/status/add/{status_type}",
  *     "edit-form" = "/admin/structure/status/{status}/edit",
  *     "delete-form" = "/admin/structure/status/{status}/delete",
  *     "collection" = "/admin/structure/status",
  *   },
- *   field_ui_base_route = "status.settings"
+ *   bundle_entity_type = "status_type",
+ *   field_ui_base_route = "entity.status_type.edit_form"
  * )
  */
 class Status extends ContentEntityBase implements StatusInterface {
@@ -66,6 +69,13 @@ class Status extends ContentEntityBase implements StatusInterface {
     );
   }
 
+  /**
+   * {@inheritdoc}
+   */
+  public function getType() {
+    return $this->bundle();
+  }
+
   /**
    * {@inheritdoc}
    */
@@ -149,6 +159,11 @@ class Status extends ContentEntityBase implements StatusInterface {
       ->setLabel(t('ID'))
       ->setDescription(t('The ID of the Status entity.'))
       ->setReadOnly(TRUE);
+    $fields['type'] = BaseFieldDefinition::create('entity_reference')
+      ->setLabel(t('Type'))
+      ->setDescription(t('The Status type/bundle.'))
+      ->setSetting('target_type', 'status_type')
+      ->setRequired(TRUE);
     $fields['uuid'] = BaseFieldDefinition::create('uuid')
       ->setLabel(t('UUID'))
       ->setDescription(t('The UUID of the Status entity.'))

+ 57 - 0
src/Entity/StatusType.php

@@ -0,0 +1,57 @@
+<?php
+
+namespace Drupal\statusmessage\Entity;
+
+use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
+use Drupal\statusmessage\StatusTypeInterface;
+
+/**
+ * Defines the Status type entity.
+ *
+ * @ConfigEntityType(
+ *   id = "status_type",
+ *   label = @Translation("Status type"),
+ *   handlers = {
+ *     "list_builder" = "Drupal\statusmessage\StatusTypeListBuilder",
+ *     "form" = {
+ *       "add" = "Drupal\statusmessage\Form\StatusTypeForm",
+ *       "edit" = "Drupal\statusmessage\Form\StatusTypeForm",
+ *       "delete" = "Drupal\statusmessage\Form\StatusTypeDeleteForm"
+ *     },
+ *     "route_provider" = {
+ *       "html" = "Drupal\statusmessage\StatusTypeHtmlRouteProvider",
+ *     },
+ *   },
+ *   config_prefix = "status_type",
+ *   admin_permission = "administer site configuration",
+ *   bundle_of = "status",
+ *   entity_keys = {
+ *     "id" = "id",
+ *     "label" = "label",
+ *     "uuid" = "uuid"
+ *   },
+ *   links = {
+ *     "canonical" = "/ls/status_type/{status_type}",
+ *     "add-form" = "/ls/status_type/add",
+ *     "edit-form" = "/ls/status_type/{status_type}/edit",
+ *     "delete-form" = "/ls/status_type/{status_type}/delete",
+ *     "collection" = "/ls/status_type"
+ *   }
+ * )
+ */
+class StatusType extends ConfigEntityBundleBase implements StatusTypeInterface {
+  /**
+   * The Status type ID.
+   *
+   * @var string
+   */
+  protected $id;
+
+  /**
+   * The Status type label.
+   *
+   * @var string
+   */
+  protected $label;
+
+}

+ 0 - 0
statusmessage/src/Entity/StatusViewsData.php → src/Entity/StatusViewsData.php


+ 0 - 0
statusmessage/src/Form/StatusDeleteForm.php → src/Form/StatusDeleteForm.php


+ 0 - 0
statusmessage/src/Form/StatusForm.php → src/Form/StatusForm.php


+ 0 - 0
statusmessage/src/Form/StatusSettingsForm.php → src/Form/StatusSettingsForm.php


+ 52 - 0
src/Form/StatusTypeDeleteForm.php

@@ -0,0 +1,52 @@
+<?php
+
+namespace Drupal\statusmessage\Form;
+
+use Drupal\Core\Entity\EntityConfirmFormBase;
+use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Url;
+
+/**
+ * Builds the form to delete Status type entities.
+ */
+class StatusTypeDeleteForm extends EntityConfirmFormBase {
+  /**
+   * {@inheritdoc}
+   */
+  public function getQuestion() {
+    return $this->t('Are you sure you want to delete %name?', array('%name' => $this->entity->label()));
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getCancelUrl() {
+    return new Url('entity.status_type.collection');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getConfirmText() {
+    return $this->t('Delete');
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function submitForm(array &$form, FormStateInterface $form_state) {
+    $this->entity->delete();
+
+    drupal_set_message(
+      $this->t('content @type: deleted @label.',
+        [
+          '@type' => $this->entity->bundle(),
+          '@label' => $this->entity->label(),
+        ]
+        )
+    );
+
+    $form_state->setRedirectUrl($this->getCancelUrl());
+  }
+
+}

+ 66 - 0
src/Form/StatusTypeForm.php

@@ -0,0 +1,66 @@
+<?php
+
+namespace Drupal\statusmessage\Form;
+
+use Drupal\Core\Entity\EntityForm;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Class StatusTypeForm.
+ *
+ * @package Drupal\statusmessage\Form
+ */
+class StatusTypeForm extends EntityForm {
+  /**
+   * {@inheritdoc}
+   */
+  public function form(array $form, FormStateInterface $form_state) {
+    $form = parent::form($form, $form_state);
+
+    $status_type = $this->entity;
+    $form['label'] = array(
+      '#type' => 'textfield',
+      '#title' => $this->t('Label'),
+      '#maxlength' => 255,
+      '#default_value' => $status_type->label(),
+      '#description' => $this->t("Label for the Status type."),
+      '#required' => TRUE,
+    );
+
+    $form['id'] = array(
+      '#type' => 'machine_name',
+      '#default_value' => $status_type->id(),
+      '#machine_name' => array(
+        'exists' => '\Drupal\statusmessage\Entity\StatusType::load',
+      ),
+      '#disabled' => !$status_type->isNew(),
+    );
+
+    /* You will need additional form elements for your custom properties. */
+
+    return $form;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function save(array $form, FormStateInterface $form_state) {
+    $status_type = $this->entity;
+    $status = $status_type->save();
+
+    switch ($status) {
+      case SAVED_NEW:
+        drupal_set_message($this->t('Created the %label Status type.', [
+          '%label' => $status_type->label(),
+        ]));
+        break;
+
+      default:
+        drupal_set_message($this->t('Saved the %label Status type.', [
+          '%label' => $status_type->label(),
+        ]));
+    }
+    $form_state->setRedirectUrl($status_type->urlInfo('collection'));
+  }
+
+}

+ 0 - 0
statusmessage/src/StatusAccessControlHandler.php → src/StatusAccessControlHandler.php


+ 31 - 8
statusmessage/src/StatusHtmlRouteProvider.php → src/StatusHtmlRouteProvider.php

@@ -29,6 +29,9 @@ class StatusHtmlRouteProvider extends AdminHtmlRouteProvider {
       $collection->add("entity.{$entity_type_id}.add_form", $add_form_route);
     }
 
+    $add_page_route = $this->getAddPageRoute($entity_type);
+    $collection->add("$entity_type_id.add_page", $add_page_route);
+
     if ($settings_form_route = $this->getSettingsFormRoute($entity_type)) {
       $collection->add("$entity_type_id.settings", $settings_form_route);
     }
@@ -78,17 +81,15 @@ class StatusHtmlRouteProvider extends AdminHtmlRouteProvider {
       ];
 
       $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';
-      }
+      $bundle_entity_type_id = $entity_type->getBundleEntityType();
+      // Content entities with bundles are added via a dedicated controller.
       $route
         ->setDefaults([
-          '_entity_form' => "{$entity_type_id}.{$operation}",
-          '_title' => "Add {$entity_type->getLabel()}",
+          '_controller' => 'Drupal\statusmessage\Controller\StatusAddController::addForm',
+          '_title_callback' => 'Drupal\statusmessage\Controller\StatusAddController::getAddFormTitle',
         ])
-        ->setRequirement('_entity_create_access', $entity_type_id);
+        ->setRequirement('_entity_create_access', $entity_type_id . ':{' . $bundle_entity_type_id . '}');
+      $parameters[$bundle_entity_type_id] = ['type' => 'entity:' . $bundle_entity_type_id];
 
       $route
         ->setOption('parameters', $parameters)
@@ -98,6 +99,28 @@ class StatusHtmlRouteProvider extends AdminHtmlRouteProvider {
     }
   }
 
+  /**
+   * Gets the add page route.
+   *
+   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+   *   The entity type.
+   *
+   * @return \Symfony\Component\Routing\Route|null
+   *   The generated route, if available.
+   */
+  protected function getAddPageRoute(EntityTypeInterface $entity_type) {
+    $route = new Route("/admin/structure/{$entity_type->id()}/add");
+    $route
+      ->setDefaults([
+        '_controller' => 'Drupal\statusmessage\Controller\StatusAddController::add',
+        '_title' => "Add {$entity_type->getLabel()}",
+      ])
+      ->setRequirement('_entity_create_access', $entity_type->id())
+      ->setOption('_admin_route', TRUE);
+
+    return $route;
+  }
+
   /**
    * Gets the settings form route.
    *

+ 8 - 0
statusmessage/src/StatusInterface.php → src/StatusInterface.php

@@ -13,6 +13,14 @@ use Drupal\user\EntityOwnerInterface;
  */
 interface StatusInterface extends ContentEntityInterface, EntityChangedInterface, EntityOwnerInterface {
   // Add get/set methods for your configuration properties here.
+  /**
+   * Gets the Status type.
+   *
+   * @return string
+   *   The Status type.
+   */
+  public function getType();
+
   /**
    * Gets the Status name.
    *

+ 0 - 0
statusmessage/src/StatusListBuilder.php → src/StatusListBuilder.php


+ 95 - 0
src/StatusTypeHtmlRouteProvider.php

@@ -0,0 +1,95 @@
+<?php
+
+namespace Drupal\statusmessage;
+
+use Drupal\Core\Entity\EntityTypeInterface;
+use Drupal\Core\Entity\Routing\AdminHtmlRouteProvider;
+use Symfony\Component\Routing\Route;
+
+/**
+ * Provides routes for Status type entities.
+ *
+ * @see Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
+ * @see Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider
+ */
+class StatusTypeHtmlRouteProvider 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);
+    }
+
+    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,
+          // Make sure this is not a TranslatableMarkup object as the
+          // TitleResolver translates this string again.
+          '_title' => (string) $entity_type->getLabel(),
+        ])
+        ->setRequirement('_permission', $entity_type->getAdminPermission())
+        ->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();
+      $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)
+        ->setOption('parameters', [
+          $entity_type_id => ['type' => 'entity:' . $entity_type_id],
+        ])
+        ->setOption('_admin_route', TRUE);
+
+      return $route;
+    }
+  }
+
+}

+ 12 - 0
src/StatusTypeInterface.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace Drupal\statusmessage;
+
+use Drupal\Core\Config\Entity\ConfigEntityInterface;
+
+/**
+ * Provides an interface for defining Status type entities.
+ */
+interface StatusTypeInterface extends ConfigEntityInterface {
+  // Add get/set methods for your configuration properties here.
+}

+ 31 - 0
src/StatusTypeListBuilder.php

@@ -0,0 +1,31 @@
+<?php
+
+namespace Drupal\statusmessage;
+
+use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
+use Drupal\Core\Entity\EntityInterface;
+
+/**
+ * Provides a listing of Status type entities.
+ */
+class StatusTypeListBuilder extends ConfigEntityListBuilder {
+  /**
+   * {@inheritdoc}
+   */
+  public function buildHeader() {
+    $header['label'] = $this->t('Status type');
+    $header['id'] = $this->t('Machine name');
+    return $header + parent::buildHeader();
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function buildRow(EntityInterface $entity) {
+    $row['label'] = $entity->label();
+    $row['id'] = $entity->id();
+    // You probably want a few more properties here...
+    return $row + parent::buildRow($entity);
+  }
+
+}

+ 62 - 0
status.page.inc

@@ -0,0 +1,62 @@
+<?php
+
+/**
+ * @file
+ * Contains status.page.inc.
+ *
+ * Page callback for Status entities.
+ */
+
+use Drupal\Core\Render\Element;
+use Drupal\Core\Link;
+use Drupal\Core\Url;
+
+/**
+ * Prepares variables for Status templates.
+ *
+ * Default template: status.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_status(array &$variables) {
+  // Fetch Status Entity Object.
+  $status = $variables['elements']['#status'];
+
+  // Helpful $content variable for templates.
+  foreach (Element::children($variables['elements']) as $key) {
+    $variables['content'][$key] = $variables['elements'][$key];
+  }
+}
+
+/**
+* Prepares variables for a custom entity type creation list templates.
+*
+* Default template: status-content-add-list.html.twig.
+*
+* @param array $variables
+*   An associative array containing:
+*   - content: An array of status-types.
+*
+* @see block_content_add_page()
+*/
+function template_preprocess_status_content_add_list(&$variables) {
+  $variables['types'] = array();
+  $query = \Drupal::request()->query->all();
+  foreach ($variables['content'] as $type) {
+    $variables['types'][$type->id()] = array(
+      'link' => Link::fromTextAndUrl($type->label(), new Url('entity.status.add_form', array(
+        'status_type' => $type->id()
+      ), array('query' => $query))),
+      'description' => array(
+      '#markup' => $type->label(),
+      ),
+      'title' => $type->label(),
+      'localized_options' => array(
+      'query' => $query,
+      ),
+    );
+  }
+}

+ 1 - 1
statusmessage/statusmessage.info.yml → statusmessage.info.yml

@@ -1,5 +1,5 @@
 name: StatusMessage
 type: module
-description: Status Messages on a User Profile Timeline
+description: Status Messages for Users
 core: 8.x
 package: StatusMessage

+ 11 - 0
statusmessage.links.action.yml

@@ -0,0 +1,11 @@
+entity.status.add_form:
+  route_name: 'status.add_page'
+  title: 'Add Status'
+  appears_on:
+    - entity.status.collection
+entity.status_type.add_form:
+  route_name: 'entity.status_type.add_form'
+  title: 'Add Status type'
+  appears_on:
+    - entity.status_type.collection
+

+ 7 - 4
statusmessage/statusmessage.links.menu.yml → statusmessage.links.menu.yml

@@ -6,8 +6,11 @@ entity.status.collection:
   parent: system.admin_structure
   weight: 100
 
-status.admin.structure.settings:
-  title: Status settings
-  description: 'Configure Status entities'
-  route_name: status.settings
+# Status type menu items definition
+entity.status_type.collection:
+  title: 'Status type'
+  route_name: entity.status_type.collection
+  description: 'List Status type (bundles)'
   parent: system.admin_structure
+  weight: 99
+

+ 0 - 4
statusmessage/statusmessage.links.task.yml → statusmessage.links.task.yml

@@ -1,8 +1,4 @@
 # Status routing definition
-status.settings_tab:
-  route_name: status.settings
-  title: 'Settings'
-  base_route: status.settings
 entity.status.canonical:
   route_name: entity.status.canonical
   base_route: entity.status.canonical

+ 58 - 0
statusmessage.module

@@ -0,0 +1,58 @@
+<?php
+
+/**
+ * @file
+ * Contains statusmessage.module..
+ */
+
+use Drupal\Core\Routing\RouteMatchInterface;
+
+/**
+ * Implements hook_help().
+ */
+function statusmessage_help($route_name, RouteMatchInterface $route_match) {
+  switch ($route_name) {
+    // Main module help for the statusmessage module.
+    case 'help.page.statusmessage':
+      $output = '';
+      $output .= '<h3>' . t('About') . '</h3>';
+      $output .= '<p>' . t('Status Messages for Users') . '</p>';
+      return $output;
+
+    default:
+  }
+}
+
+/**
+ * Implements hook_theme().
+ */
+function statusmessage_theme() {
+  $theme = [];
+  $theme['status'] = [
+    'render element' => 'elements',
+    'file' => 'status.page.inc',
+    'template' => 'status',
+  ];
+  $theme['status_content_add_list'] = [
+    'render element' => 'content',
+    'variables' => ['content' => NULL],
+    'file' => 'status.page.inc',
+  ];
+  return $theme;
+}
+
+/**
+* Implements hook_theme_suggestions_HOOK().
+*/
+function statusmessage_theme_suggestions_status(array $variables) {
+  $suggestions = array();
+  $entity = $variables['elements']['#status'];
+  $sanitized_view_mode = strtr($variables['elements']['#view_mode'], '.', '_');
+
+  $suggestions[] = 'status__' . $sanitized_view_mode;
+  $suggestions[] = 'status__' . $entity->bundle();
+  $suggestions[] = 'status__' . $entity->bundle() . '__' . $sanitized_view_mode;
+  $suggestions[] = 'status__' . $entity->id();
+  $suggestions[] = 'status__' . $entity->id() . '__' . $sanitized_view_mode;
+  return $suggestions;
+}

+ 0 - 0
statusmessage/statusmessage.permissions.yml → statusmessage.permissions.yml


+ 0 - 32
statusmessage/status.page.inc

@@ -1,32 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains status.page.inc.
- *
- * Page callback for Status entities.
- */
-
-use Drupal\Core\Render\Element;
-use Drupal\Core\Link;
-use Drupal\Core\Url;
-
-/**
- * Prepares variables for Status templates.
- *
- * Default template: status.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_status(array &$variables) {
-  // Fetch Status Entity Object.
-  $status = $variables['elements']['#status'];
-
-  // Helpful $content variable for templates.
-  foreach (Element::children($variables['elements']) as $key) {
-    $variables['content'][$key] = $variables['elements'][$key];
-  }
-}

+ 0 - 5
statusmessage/statusmessage.links.action.yml

@@ -1,5 +0,0 @@
-entity.status.add_form:
-  route_name: entity.status.add_form
-  title: 'Add Status'
-  appears_on:
-    - entity.status.collection

+ 0 - 24
statusmessage/statusmessage.module

@@ -1,24 +0,0 @@
-<?php
-
-/**
- * @file
- * Contains statusmessage.module..
- */
-
-use Drupal\Core\Routing\RouteMatchInterface;
-
-/**
- * Implements hook_help().
- */
-function statusmessage_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    // Main module help for the statusmessage module.
-    case 'help.page.statusmessage':
-      $output = '';
-      $output .= '<h3>' . t('About') . '</h3>';
-      $output .= '<p>' . t('Status Messages on a User Profile Timeline') . '</p>';
-      return $output;
-
-    default:
-  }
-}

+ 23 - 0
templates/status-content-add-list.html.twig

@@ -0,0 +1,23 @@
+{#
+/**
+ * @file
+ * Default theme implementation to present a list of custom content entity types/bundles.
+ *
+ * Available variables:
+ * - types: A collection of all the available custom entity types/bundles.
+ *   Each type/bundle contains the following:
+ *   - link: A link to add a content entity of this type.
+ *   - description: A description of this content entity types/bundle.
+ *
+ * @see template_preprocess_status_content_add_list()
+ *
+ * @ingroup themeable
+ */
+#}
+{% spaceless %}
+  <dl>
+    {% for type in types %}
+      <dt>{{ type.link }}</dt>
+    {% endfor %}
+  </dl>
+{% endspaceless %}

+ 0 - 0
statusmessage/templates/status.html.twig → templates/status.html.twig