本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface::isDefaultSearch方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface::isDefaultSearch方法的具体用法?PHP EntityInterface::isDefaultSearch怎么用?PHP EntityInterface::isDefaultSearch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::isDefaultSearch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
{
/** @var $entity \Drupal\search\SearchPageInterface */
if (in_array($operation, array('delete', 'disable')) && $entity->isDefaultSearch()) {
return FALSE;
}
if ($operation == 'view') {
if (!$entity->status()) {
return FALSE;
}
$plugin = $entity->getPlugin();
if ($plugin instanceof AccessibleInterface) {
return $plugin->access($operation, $account);
}
return TRUE;
}
return parent::checkAccess($entity, $operation, $langcode, $account);
}
示例2: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
{
/** @var $entity \Drupal\search\SearchPageInterface */
if (in_array($operation, array('delete', 'disable'))) {
if ($entity->isDefaultSearch()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
} else {
return parent::checkAccess($entity, $operation, $account)->addCacheableDependency($entity);
}
}
if ($operation == 'view') {
if (!$entity->status()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
$plugin = $entity->getPlugin();
if ($plugin instanceof AccessibleInterface) {
return $plugin->access($operation, $account, TRUE)->addCacheableDependency($entity);
}
return AccessResult::allowed()->addCacheableDependency($entity);
}
return parent::checkAccess($entity, $operation, $account);
}
示例3: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/** @var $entity \Drupal\search\SearchPageInterface */
$row['label'] = $entity->label();
$row['url']['#markup'] = 'search/' . $entity->getPath();
// If the search page is active, link to it.
if ($entity->status()) {
$row['url'] = array('#type' => 'link', '#title' => $row['url'], '#url' => Url::fromRoute('search.view_' . $entity->id()));
}
$definition = $entity->getPlugin()->getPluginDefinition();
$row['plugin']['#markup'] = $definition['title'];
if ($entity->isDefaultSearch()) {
$status = $this->t('Default');
} elseif ($entity->status()) {
$status = $this->t('Enabled');
} else {
$status = $this->t('Disabled');
}
$row['status']['#markup'] = $status;
if ($entity->isIndexable()) {
$status = $entity->getPlugin()->indexStatus();
$row['progress']['#markup'] = $this->t('%num_indexed of %num_total indexed', array('%num_indexed' => $status['total'] - $status['remaining'], '%num_total' => $status['total']));
} else {
$row['progress']['#markup'] = $this->t('Does not use index');
}
return $row + parent::buildRow($entity);
}