本文整理匯總了PHP中Drupal\Core\Entity\EntityInterface::getThirdPartySetting方法的典型用法代碼示例。如果您正苦於以下問題:PHP EntityInterface::getThirdPartySetting方法的具體用法?PHP EntityInterface::getThirdPartySetting怎麽用?PHP EntityInterface::getThirdPartySetting使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal\Core\Entity\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::getThirdPartySetting方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: buildRow
/**
* 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);
}
示例2: view
/**
* {@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;
}