/** * Builds a row for an entity in the entity listing. * * @param \Drupal\migrate\Entity\EntityInterface $migration * The entity for which to build the row. * * @return array * A render array of the table row for displaying the entity. * * @see Drupal\Core\Entity\EntityListController::render() */ public function buildRow(EntityInterface $migration) { $row['label'] = $migration->label(); $row['machine_name'] = $migration->id(); $row['status'] = $migration->getStatusLabel(); // Derive the stats $source_plugin = $migration->getSourcePlugin(); $row['total'] = $source_plugin->count(); $map = $migration->getIdMap(); $row['imported'] = $map->importedCount(); // -1 indicates uncountable sources. if ($row['total'] == -1) { $row['total'] = $this->t('N/A'); $row['unprocessed'] = $this->t('N/A'); } else { $row['unprocessed'] = $row['total'] - $map->processedCount(); } $migration_group = $migration->getThirdPartySetting('migrate_plus', 'migration_group'); if (!$migration_group) { $migration_group = 'default'; } $route_parameters = array('migration_group' => $migration_group, 'migration' => $migration->id()); $row['messages'] = array('data' => array('#type' => 'link', '#title' => $map->messageCount(), '#url' => Url::fromRoute("migrate_tools.messages", $route_parameters))); $migrate_last_imported_store = \Drupal::keyValue('migrate_last_imported'); $last_imported = $migrate_last_imported_store->get($migration->id(), FALSE); if ($last_imported) { /** @var DateFormatter $date_formatter */ $date_formatter = \Drupal::service('date.formatter'); $row['last_imported'] = $date_formatter->format($last_imported / 1000, 'custom', 'Y-m-d H:i:s'); } else { $row['last_imported'] = ''; } return $row; // + parent::buildRow($migration); }
/** * {@inheritdoc} */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { if ($entity->status()) { $message = $this->contactMessageStorage->create([ 'contact_form' => $entity->id(), ]); $form = $this->entityFormBuilder->getForm($message); $form['#title'] = $entity->label(); $form['#cache']['contexts'][] = 'user.permissions'; $this->renderer->addCacheableDependency($form, $this->config); } else { // Form disabled, display a custom message using a template. $form['disabled_form_error'] = array( '#theme' => 'contact_storage_disabled_form', '#contact_form' => $entity, '#redirect_uri' => $entity->getThirdPartySetting('contact_storage', 'redirect_uri', ''), '#disabled_form_message' => $entity->getThirdPartySetting('contact_storage', 'disabled_form_message', t('This contact form has been disabled.')), ); } // Add required cacheability metadata from the contact form entity, so that // changing it invalidates the cache. $this->renderer->addCacheableDependency($form, $entity); return $form; }