/**
  * {@inheritdoc}
  *
  * TODO: Use $langcode.
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     $element = array();
     $settings = $this->getFieldSettings();
     $count = 0;
     // TODO: Is there a better way to get an accurate count of the
     // items from the FieldItemList that doesn't count blank items?
     // Possibly \Countable->count()?
     $storage = \Drupal::entityTypeManager()->getStorage('field_collection_item');
     foreach ($items as $delta => $item) {
         if ($item->value !== NULL) {
             $count++;
             $field_collection_item = $storage->loadRevision($item->revision_id);
             if ($field_collection_item->isDefaultRevision()) {
                 $links = \Drupal::l($this->fieldDefinition->getName() . ' ' . $delta, Url::FromRoute('entity.field_collection_item.canonical', array('field_collection_item' => $item->value)));
                 $links .= ' ' . $this->getEditLinks($item);
             } else {
                 $links = \Drupal::l($this->fieldDefinition->getName() . ' ' . $delta, Url::FromRoute('field_collection_item.revision_show', ['field_collection_item' => $item->value, 'field_collection_item_revision' => $item->revision_id]));
             }
             $element[$delta] = array('#markup' => $links);
         }
     }
     $cardinality = $this->fieldDefinition->getFieldStorageDefinition()->getCardinality();
     if ($cardinality == -1 || $count < $cardinality) {
         $element['#suffix'] = '<ul class="action-links action-links-field-collection-add"><li>';
         $element['#suffix'] .= $this->getAddLink($items->getEntity());
         $element['#suffix'] .= '</li></ul>';
     }
     return $element;
 }
 /**
  * Setup archive directory and internal migrate data struct.
  *
  * @param array $environment
  *   Environment to migrate to, from NSPI acquia_agent_cloud_migration_environments()
  * @return array $migration
  */
 public function prepare($environment)
 {
     // Internal migration store is an array because objects cannot be stored
     // by Drupal's Batch API.
     $local_env = $this->checkEnv();
     if ($local_env['error'] !== FALSE) {
         return $local_env;
     }
     // Modify environment URL if SSL is available for use.
     if (in_array('ssl', stream_get_transports(), TRUE) && !defined('ACQUIA_DEVELOPMENT_NOSSL')) {
         $uri = parse_url($environment['url']);
         if (isset($uri['host'])) {
             $environment['url'] = $uri['host'];
         }
         $environment['url'] .= isset($uri['port']) ? ':' . $uri['port'] : '';
         $environment['url'] .= isset($uri['path']) && isset($uri['host']) ? $uri['path'] : '';
         $environment['url'] = 'https://' . $environment['url'];
     }
     $time = REQUEST_TIME;
     $date = gmdate('Ymd_his', $time);
     $migration = array('error' => FALSE, 'id' => uniqid() . '_' . $date, 'date' => $date, 'time' => $time, 'compression_ext' => $local_env['compression_ext'], 'request_params' => array('r' => Url::FromRoute('acquia_connector.settings', array(), array('absolute' => TRUE))->toString(), 'y' => 'sar', 'stage' => $environment['stage'], 'nonce' => $environment['nonce']), 'env' => $environment, 'no_data_tables' => array());
     // Set up local storage of archive.
     $this->destination($migration);
     return $migration;
 }
 protected function getAddLink(ContentEntityInterface $host)
 {
     $link = '';
     if ($host->access('update', \Drupal::currentUser())) {
         $link = '<ul class="action-links action-links-field-collection-add"><li>';
         $link .= \Drupal::l(t('Add'), Url::FromRoute('field_collection_item.add_page', ['field_collection' => $this->fieldDefinition->getName(), 'host_type' => $host->getEntityTypeId(), 'host_id' => $host->id()]));
         $link .= '</li></ul>';
     }
     return $link;
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function submitForm(array &$form, FormStateInterface $form_state)
 {
     $filter = $form_state->getValue('name');
     $form_state->setRedirectUrl(Url::FromRoute('devel.configs_list', array('filter' => Html::escape($filter))));
 }