/**
   * {@inheritdoc}
   */
  protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
    $access_result = AccessResult::allowedIfHasPermissions($account, ["create {$entity_bundle} entityqueue", 'manipulate all entityqueues', 'administer entityqueue'], 'OR');

    if ($entity_bundle) {
      $queue = EntityQueue::load($entity_bundle);
      $access_result = AccessResult::allowedIf(!$queue->getHandlerPlugin()->hasAutomatedSubqueues());
    }

    return $access_result;
  }
  /**
   * {@inheritdoc}
   */
  public function calculateDependencies() {
    $dependencies = parent::calculateDependencies();

    if ($this->options['limit_queue']) {
      $queue = EntityQueue::load($this->options['limit_queue']);
      $dependencies[$queue->getConfigDependencyKey()][] = $queue->getConfigDependencyName();
    }

    return $dependencies;
  }
Beispiel #3
0
  /**
   * {@inheritdoc}
   */
  public function getQueueListBuilderOperations() {
    // Add an operation to list all subqueues by default.
    $operations['view_subqueues'] = [
      'title' => t('View subqueues'),
      'weight' => -9,
      'url' => $this->queue->urlInfo('subqueue-list'),
    ];

    return $operations;
  }
Beispiel #4
0
  /**
   * @param \Drupal\entityqueue\Entity\EntityQueue $queue
   *
   * @return array
   */
  public function buildPermissions(EntityQueue $queue) {
    $queue_id = $queue->id();

    if ($queue->getHandlerPlugin()->supportsMultipleSubqueues()) {
      $permissions["create $queue_id entityqueue"] = array(
        'title' => t('Add %queue subqueues', array('%queue' => $queue->label())),
        'description' => t('Access to create new subqueue to the %queue queue.', array('%queue' => $queue->label())),
      );
      $permissions["delete $queue_id entityqueue"] = array(
        'title' => t('Delete %queue subqueues', array('%queue' => $queue->label())),
        'description' => t('Access to delete subqueues of the %queue queue.', array('%queue' => $queue->label())),
      );
    }

    $permissions["update $queue_id entityqueue"] = array(
      'title' => t('Manipulate %queue queue', array('%queue' => $queue->label())),
      'description' => t('Access to update the %queue queue.', array('%queue' => $queue->label())),
    );

    return $permissions;
  }
Beispiel #5
0
 /**
  * {@inheritdoc}
  */
 public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
   // Change the target type of the 'items' field to the one defined by the
   // parent queue (i.e. bundle).
   if ($queue = EntityQueue::load($bundle)) {
     $fields['items'] = clone $base_field_definitions['items'];
     $fields['items']->setSetting('target_type', $queue->getTargetEntityTypeId());
     return $fields;
   }
   return [];
 }