Results

09.06.2025
entity_type_access_conditions 1.0.1 :: tests/src/Kernel/NodeAccessConditionsTest.php
    // 1. Grant permission to create content, condition not set.
    $this->grantPermissionsToTestRole([$add_perm, 'access content', 'access content overview']);
    $this->assertTrue($this->checkRouteAccess('node.add', $node_add_route_params)->isAllowed(), 'User should be able to access node add form with permission.');

    // 2. Apply condition, set to met.
    $this->clearConditionsFromEntityTypeConfig('node_type', $this->nodeType->id());
    $this->applyConditionToEntityTypeConfig('node_type', $this->nodeType->id(), 'test_condition', ['condition_met' => TRUE]);
    $this->nodeType = NodeType::load($this->nodeType->id());
    $this->nodeAccessHandler->resetCache();
    $this->nodeType = NodeType::load($this->nodeType->id());
    $this->nodeAccessHandler->resetCache();
    $this->assertTrue($this->checkRouteAccess('node.add', $node_add_route_params)->isAllowed(), 'User should be able to access node add form when condition is met.');

    // 3. Set condition to not met.
    $this->clearConditionsFromEntityTypeConfig('node_type', $this->nodeType->id());
    $this->applyConditionToEntityTypeConfig('node_type', $this->nodeType->id(), 'test_condition', ['condition_met' => FALSE]);
    $this->nodeType = NodeType::load($this->nodeType->id());
    $this->nodeAccessHandler->resetCache();
    $this->nodeType = NodeType::load($this->nodeType->id());
    $this->nodeAccessHandler->resetCache();
    $this->assertFalse($this->checkRouteAccess('node.add', $node_add_route_params)->isAllowed(), 'User should NOT be able to access node add form when condition is not met.');

    // 4. Clear conditions.
    $this->clearConditionsFromEntityTypeConfig('node_type', $this->nodeType->id());
    $this->nodeType = NodeType::load($this->nodeType->id());
    $this->nodeAccessHandler->resetCache();
    $this->assertTrue($this->checkRouteAccess('node.add', $node_add_route_params)->isAllowed(), 'User should be able to access node add form after conditions are cleared.');
  }

  /**
   * Tests access to the node edit form.
   */
  public function testNodeEditAccess(): void {
14.09.2025
ai_accessibility 1.0.2 :: ai_accessibility.module
  $route_name = \Drupal::routeMatch()->getRouteName();
  // Attach only on node edit/add forms (basic heuristic).
  if (strpos($route_name, 'entity.node.edit_form') === 0 || strpos($route_name, 'node.add') === 0) {
    $attachments['#attached']['library'][] = 'ai_accessibility/editor_integration';
  }
}
20.06.2025
invoicemgmt 1.0.0 :: invoicemgmt.module
        '#type' => 'link',
        '#title' => t('Add Client'),
        '#url' => Url::fromRoute('node.add', ['node_type' => 'client']),
        '#attributes' => [
          'target' => '_blank',
          'class' => ['button', 'button--small'],
          'style' => 'margin-left: 10px;',
        ],
      ];
02.05.2020
add_child_page 8.x-1.0 :: src/Controller/AddChildPage.php
          $type = ($default ? $default_content : $node->bundle());
          return $this->redirect(
            'node.add',
            ['node_type' => $type],
            [
              'query' => [
                'plid' => $plid,
                'menu' => $menu_name,
              ],
26.07.2020
add_content_by_bundle 1.0.1 :: src/Plugin/views/area/AddContentByBundle.php
      if (!$url) {
        // Link to add a node of the specified type, then return to our view.
        $url = Url::fromRoute('node.add', ['node_type' => $bundle_type], ['query' => $params]);
        $access = $this->accessManager->checkNamedRoute('node.add', ['node_type' => $bundle_type], $account);
      }
    }
    elseif ($entity_type === 'taxonomy_term') {
      // Link to add a term of the specified type, then return to our view.
      $url = Url::fromRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $bundle_type], ['query' => $params]);
      $access = $this->accessManager->checkNamedRoute('entity.taxonomy_term.add_form', ['taxonomy_vocabulary' => $bundle_type], $account);
12.09.2022
add_content_modal 1.0.x-dev :: add_content_modal.module
    if ($isAllowed && isset($link['route_name']) && in_array($link['route_name'],
        [
          'node.add', 'entity.node.edit_form',
        ])) {

      $link = _add_content_modal_add_modal_options($config, $link);
    }
  }
}
17.10.2020
addanother 8.x-1.1 :: src/Controller/AddAnotherController.php
   */
  public function addAnotherGoTo(NodeInterface $node) {
    return $this->redirect('node.add', [
      'node_type' => $node->getType(),
    ]);
  }

  /**
   * Takes the user to the node creation page for the type of a given node.
17.10.2020
addanother 8.x-1.1 :: addanother.module
  if ($node = $form_state->getFormObject()->getEntity()) {
    $type = $node->getType();
    $form_state->setRedirect('node.add', ['node_type' => $type]);
    _addanother_quelch_message($node);
    \Drupal::messenger()->addMessage(t('You may now create another.'));
  }
}

/**
  if ($node = $form_state->getFormObject()->getEntity()) {
    _addanother_quelch_message($node);
    $type_url = Url::fromRoute('node.add', [
      'node_type' => $node->getType(),
    ]);
    $t_args = [
      '@type' => node_get_type_label($node),
      ':type_url' => $type_url->toString(),
    ];
20.10.2020
admin_toolbar 8.x-2.x-dev :: admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php
        'weight' => -2,
      ] + $base_plugin_definition;
      $links['node.add'] = [
        'title' => $this->t('Add content'),
        'route_name' => 'node.add_page',
        'parent' => 'system.admin_content',
      ] + $base_plugin_definition;
      // Adds node links for each content type.
      foreach ($this->entityTypeManager->getStorage('node_type')->loadMultiple() as $type) {
      foreach ($this->entityTypeManager->getStorage('node_type')->loadMultiple() as $type) {
        $links['node.add.' . $type->id()] = [
          'route_name' => 'node.add',
          'parent' => $base_plugin_definition['id'] . ':node.add',
          'route_parameters' => ['node_type' => $type->id()],
          'class' => 'Drupal\admin_toolbar_tools\Plugin\Menu\MenuLinkEntity',
          'metadata' => [
            'entity_type' => $type->getEntityTypeId(),
            'entity_id' => $type->id(),
18.11.2020
admin_toolbar_content 1.0.0 :: src/Plugin/AdminToolbarContent/AdminToolbarContentContentPlugin.php
    $this->createCollectionLinks('system.admin_content');
    $this->createItemLinks('system.admin_content', 'type');
    $this->createItemAddLinks('node.add');
    $this->createItemRecentContentLinks('node');
  }

  /**
   * {@inheritdoc}
   */
18.11.2020
admin_toolbar_content 1.0.0 :: admin_toolbar_content.module
    case 'node.add_page':
      $route_name = 'node.add';
      $entity_type_id = 'node_type';
      $cache = TRUE;

      break;

    case 'entity.media.add_page':
24.09.2020
aggrid 8.x-1.x-dev :: tests/src/Functional/AggridTableReferenceTest.php
    /* @var aggrid \Drupal\aggrid\Entity\Aggrid */
    $aggrid = reset($aggrid);
    $this->drupalGet(Url::fromRoute('node.add', ['node_type' => $type->id()]));
    $this->submitForm([
      'title[0][value]' => 'title',
      'field_aggrid[0][target_id]' => $aggrid->label(),
    ], 'Save');
    $assert->statusCodeEquals(200);
    $assert->pageTextContains($aggrid->label());
18.07.2021
argue 2.0.0-alpha4 :: modules/argue_structure/argue_structure.module
    if(\Drupal::currentUser()->hasPermission('create rule content')) {
      $text = t('Add rule handling this problem');
      $url = Url::fromRoute('node.add', ['node_type' => 'rule']);
      $field_section = $entity->get('field_sector')->getValue();
      $sector = count($field_section) ? $field_section[0]['target_id'] : 0;
      $url->setOption('query', [
        'causal_problem' => $entity->id(),
        'sector' => $sector
      ]);
12.04.2020
bee_hotel 1.x-dev :: modules/beehotel_pricealterators/src/Form/SpecialNights.php
    ];

    $url = Url::fromRoute('node.add', ['node_type' => 'special_night']);
    $link = Link::fromTextAndUrl($this->t('add Special Night'), $url);
    $link = $link->toRenderable();

    $form['nodes']['table'] = [
      '#type' => 'tableselect',
      '#header' => $header,
09.10.2025
block_editor 1.0.x-dev :: src/EventSubscriber/BlockEditorRequestSubscriber.php
    $is_add_route = str_contains($route_name, '.add_form')
                    || str_contains($route_name, '.add')
                    || $route_name === 'node.add';

    if (!$is_add_route) {
      return FALSE;
    }

    $request = $event->getRequest();
20.06.2020
blog 3.0.1 :: blog.links.action.yml
blog.blog_all:
  route_name: 'node.add'
  title: 'Create new blog entry'
  route_parameters:
    node_type: 'blog_post'
  appears_on:
    - view.blog.blog_all
blog.blog_user_all:
    - view.blog.blog_all
blog.blog_user_all:
  route_name: 'node.add'
  title: 'Create new blog entry'
  route_parameters:
    node_type: 'blog_post'
  appears_on:
    - view.blog.blog_user_all
18.06.2024
book 2.0.x-dev :: book.module
          $book_links['book_add_child'] = [
            'title' => t('Add child page'),
            'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->id()]]),
          ];
        }
        if (!empty($node->book['pid']) && $book_access instanceof AccessResultAllowed) {
          $book_links['book_add_sibling'] = [
            'title' => t('Add sibling page'),
            'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->book['pid']]]),
          ];
        }
        $print_access = \Drupal::service('access_check.book.node_print')->access($node);
        if ($print_access instanceof AccessResultAllowed) {
          $book_links['book_printer'] = [
            'title' => t('Printer-friendly version'),
04.05.2020
book_blocks 8.x-1.4 :: src/Plugin/Block/BookBlocksEditBlock.php
              $variables['#child_link']['hint'] = t('Add a new book page below this one');
              $variables['#child_link']['url'] =
                Url::fromRoute('node.add',
                               ['node_type' => $child_type],
                               ['query' => ['parent' => $node->id()]])->toString();

              if ($book_link['pid']) {
                $variables['#sibling_link']['name'] = t('Add sibling page');
                $variables['#sibling_link']['hint'] = t('Add a new book page at the same level as this');
                $variables['#sibling_link']['hint'] = t('Add a new book page at the same level as this');
                $variables['#sibling_link']['url'] =
                  Url::fromRoute('node.add',
                                 ['node_type' => $child_type],
                                 ['query' => ['parent' => $book_link['pid']]])->toString();
              }
            }
          }
16.10.2020
breadcrumbs_visibility 8.x-1.x-dev :: tests/src/Functional/EntityTest.php
  public function testNodeForm() {
    $title = $this->randomString();
    $this->drupalGet(Url::fromRoute('node.add', ['node_type' => 'test']));
    $this->assertSession()->fieldValueEquals('display_breadcrumbs[value]', '1');
    $this->getSession()->getPage()->fillField('title[0][value]', $title);
    $this->getSession()->getPage()->findButton('Save')->submit();
    $node = $this->getNodeByTitle($title);
    $this->assertEquals("1", $node->display_breadcrumbs->value);
    $title = $this->randomString();
    $this->drupalGet(Url::fromRoute('node.add', ['node_type' => 'test']));
    $this->getSession()->getPage()->fillField('title[0][value]', $title);
    $this->getSession()->getPage()->uncheckField('display_breadcrumbs[value]');
    $this->getSession()->getPage()->findButton('Save')->submit();
    $node = $this->getNodeByTitle($title);
    $this->assertEquals("0", $node->display_breadcrumbs->value);
  }
08.10.2020
bt_blog 8.x-1.x-dev :: bt_blog.links.action.yml
bt_add_block_action:
  route_name: 'node.add'
  title: 'Create a new blog post'
  route_parameters:
    node_type: 'blog_post'
  appears_on:
      - view.blog.page

Pages

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc