當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PluginManagerInterface::getAllEntityQueueHandlers方法代碼示例

本文整理匯總了PHP中Drupal\Component\Plugin\PluginManagerInterface::getAllEntityQueueHandlers方法的典型用法代碼示例。如果您正苦於以下問題:PHP PluginManagerInterface::getAllEntityQueueHandlers方法的具體用法?PHP PluginManagerInterface::getAllEntityQueueHandlers怎麽用?PHP PluginManagerInterface::getAllEntityQueueHandlers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Component\Plugin\PluginManagerInterface的用法示例。


在下文中一共展示了PluginManagerInterface::getAllEntityQueueHandlers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: form

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    $queue = $this->entity;
    $form['label'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Label'),
      '#maxlength' => 255,
      '#default_value' => $queue->label(),
      '#description' => $this->t("Label for the EntityQueue."),
      '#required' => TRUE,
    ];

    $form['id'] = [
      '#type' => 'machine_name',
      '#default_value' => $queue->id(),
      '#machine_name' => [
        'exists' => '\Drupal\entityqueue\Entity\EntityQueue::load',
      ],
      '#disabled' => !$queue->isNew(),
    ];

    $handlers = $this->entityQueueHandlerManager->getAllEntityQueueHandlers();
    $form['handler'] = [
      '#type' => 'radios',
      '#title' => $this->t('Handler'),
      '#options' => $handlers,
      '#default_value' => $queue->getHandler(),
      '#required' => TRUE,
      '#disabled' => !$queue->isNew(),
    ];

    // @todo It should be up to the queue handler to determine what entity types
    // are queue-able.
    $form['target_type'] = [
      '#type' => 'select',
      '#title' => $this->t('Type of items to queue'),
      '#options' => \Drupal::entityManager()->getEntityTypeLabels(TRUE),
      '#default_value' => $queue->getTargetEntityTypeId(),
      '#required' => TRUE,
      '#disabled' => !$queue->isNew(),
      '#size' => 1,
    ];

    $form['settings'] = [
      '#type' => 'vertical_tabs',
    ];

    $form['properties'] = [
      '#type' => 'details',
      '#title' => $this->t('Queue properties'),
      '#open' => TRUE,
      '#group' => 'settings',
    ];
    $form['properties']['size'] = [
      '#type' => 'container',
      '#attributes' => ['class' => ['form--inline', 'clearfix']],
    ];
    $form['properties']['size']['min_size'] = [
      '#type' => 'number',
      '#size' => 2,
      '#default_value' => $queue->getMinimumSize(),
      '#field_prefix' => $this->t('Restrict this queue to a minimum of'),
    ];
    $form['properties']['size']['max_size'] = [
      '#type' => 'number',
      '#default_value' => $queue->getMaximumSize(),
      '#field_prefix' => $this->t('and a maximum of'),
      '#field_suffix' => $this->t('items.'),
    ];
    $form['properties']['act_as_queue'] = [
      '#type' => 'checkbox',
      '#title' => t('Act as queue'),
      '#default_value' => $queue->getActAsQueue(),
      '#description' => $this->t('When enabled, adding more than the maximum number of items will remove extra items from the top of the queue.'),
      '#states' => [
        'invisible' => [
          ':input[name="max_size"]' => ['value' => 0],
        ],
      ],
    ];

    return $form;
  }
開發者ID:jkyto,項目名稱:agolf,代碼行數:87,代碼來源:EntityQueueForm.php


注:本文中的Drupal\Component\Plugin\PluginManagerInterface::getAllEntityQueueHandlers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。