Skip to content
Snippets Groups Projects

Issue #3188521: Improve content form detection

Merged paul121 requested to merge issue/gin-3188521:3188521-improve-content-form into 8.x-3.x

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 <?php
2
3 namespace Drupal\gin;
4
5 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
6 use Drupal\Core\Extension\ModuleHandlerInterface;
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\Core\Routing\RouteMatchInterface;
9 use Drupal\Core\Session\AccountInterface;
10 use Drupal\Core\StringTranslation\StringTranslationTrait;
11 use Drupal\Core\Theme\ThemeManagerInterface;
12 use Symfony\Component\DependencyInjection\ContainerInterface;
13
14 /**
15 * Service to handle overridden user settings.
  • Christian Fritsch
    Christian Fritsch @chr.fritsch started a thread on an outdated change in commit 22ed9291
  • 66 }
    67
    68 /**
    69 * {@inheritdoc}
    70 */
    71 public static function create(ContainerInterface $container) {
    72 return new static(
    73 $container->get('current_user'),
    74 $container->get('module_handler'),
    75 $container->get('current_route_match'),
    76 $container->get('theme.manager'),
    77 );
    78 }
    79
    80 /**
    81 * Alter the entity form to add access unpublished elements.
  • Christian Fritsch
    Christian Fritsch @chr.fritsch started a thread on an outdated change in commit 22ed9291
  • 79
    80 /**
    81 * Alter the entity form to add access unpublished elements.
    82 *
    83 * @param array $form
    84 * An associative array containing the structure of the form.
    85 * @param \Drupal\Core\Form\FormStateInterface $form_state
    86 * The current state of the form.
    87 * @param string $form_id
    88 * The form id.
    89 *
    90 * @see hook_form_alter()
    91 */
    92 public function formAlter(array &$form, FormStateInterface $form_state, $form_id) {
    93 // Are we on an edit form?
    94 if ($this->isContentForm($form, $form_state, $form_id)) {
  • Christian Fritsch
    Christian Fritsch @chr.fritsch started a thread on an outdated change in commit 22ed9291
  • 177 }
    178
    179 // Attach library.
    180 $form['#attached']['library'][] = 'gin/gin_editform';
    181 }
    182
    183 // If not logged in hide changed and author node info on add forms.
    184 $not_logged_in = $this->currentUser->isAnonymous();
    185 $route = $this->routeMatch->getRouteName();
    186
    187 if ($not_logged_in && $route == 'node.add') {
    188 unset($form['meta']['changed']);
    189 unset($form['meta']['author']);
    190 }
    191
    192 // User form (Login, Register or Forgot password).
  • Christian Fritsch
    Christian Fritsch @chr.fritsch started a thread on an outdated change in commit 22ed9291
  • 204 $form['header'][$bulk_form]['actions']['submit']['#attributes']['class'][] = 'button--small';
    205
    206 // Remove double entry of submit button.
    207 unset($form['actions']['submit']);
    208 }
    209 }
    210 }
    211 }
    212
    213 /**
    214 * Check if we´re on a content edit form.
    215 *
    216 * _gin_is_content_form() is replaced by
    217 * \Drupal::classResolver(GinContentForm::class)->isContentForm().
    218 */
    219 public function isContentForm($form = NULL, $form_state = NULL, $form_id = NULL) {
  • added 1 commit

    • a9620238 - addressed issues from review by chr.fritsch

    Compare with previous version

  • added 1 commit

    • 90da476b - Do not enable the content form for taxonomy terms

    Compare with previous version

  • 2
    3 namespace Drupal\gin;
    4
    5 use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
    6 use Drupal\Core\Extension\ModuleHandlerInterface;
    7 use Drupal\Core\Form\FormStateInterface;
    8 use Drupal\Core\Routing\RouteMatchInterface;
    9 use Drupal\Core\Session\AccountInterface;
    10 use Drupal\Core\StringTranslation\StringTranslationTrait;
    11 use Drupal\Core\Theme\ThemeManagerInterface;
    12 use Symfony\Component\DependencyInjection\ContainerInterface;
    13
    14 /**
    15 * Service to handle content form overrides.
    16 */
    17 class GinContentForm implements ContainerInjectionInterface {
  • added 1 commit

    Compare with previous version

  • added 1 commit

    Compare with previous version

  • added 7 commits

    Compare with previous version

  • gin.api.php 0 → 100644
    1 <?php
    2
    3 /**
    4 * @file
    5 * Hooks for file module.
    6 */
    7
  • James Wilson added 1 commit

    added 1 commit

    • 9f438dab - fix grammar and examples in gin.api.php

    Compare with previous version

  • James Wilson added 43 commits

    added 43 commits

    • 9f438dab...9c91c8b9 - 31 commits from branch project:8.x-3.x
    • 4c5a37f8 - Apply 3188521-8.patch.
    • c5e0081d - Use the page--node template when using the node content form.
    • 9455f287 - Specify necessary node form theme and library.
    • b96f5af9 - Ensure correct settings for advanced, meta and revision form elements.
    • 1d7a3e30 - TEMPORARY: Demonstrate node content form for taxonomy terms.
    • 667fcfe5 - move functionality to service
    • 04dd1bf8 - update api doc
    • e1df6a34 - addressed issues from review by chr.fritsch
    • 9b2f23ff - Do not enable the content form for taxonomy terms
    • bb156006 - Renamed class
    • 10ee8d93 - missed renaming file
    • b1cdc6bd - fix grammar and examples in gin.api.php

    Compare with previous version

  • Bálint Csuthy added 45 commits

    added 45 commits

    • b1cdc6bd...7e1d2f6a - 42 commits from branch project:8.x-3.x
    • b8adb777 - Merge branch '8.x-3.x-source' into 3188521-improve-content-form
    • e572911f - Apply gin.theme changes from issue
    • 9e59d959 - Apply changes from source branch

    Compare with previous version

  • added 9 commits

    Compare with previous version

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading