本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface::status方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface::status方法的具体用法?PHP EntityInterface::status怎么用?PHP EntityInterface::status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::status方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
$row['label'] = $entity->label();
$definition = $entity->getPlugin()->getPluginDefinition();
$row['plugin']['#markup'] = $definition['name'];
$row['status']['#markup'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
return $row + parent::buildRow($entity);
}
示例2: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
$plugin = $this->shippingQuotePluginManager->createInstance($entity->getPluginId(), $entity->getPluginConfiguration());
$row['label'] = $entity->label();
$row['description']['#markup'] = $plugin->getDescription();
$row['status']['#markup'] = $entity->status() ? $this->t('Enabled') : $this->t('Disabled');
return $row + parent::buildRow($entity);
}
示例3: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $currency, $operation, AccountInterface $account)
{
/** @var \Drupal\currency\Entity\CurrencyInterface $currency */
// Don't let the default currency be deleted.
if ($currency->getCurrencyCode() == 'XXX' && $operation == 'delete') {
return AccessResult::forbidden();
}
// The "enable" and "disable" operations are aliases for "update", but with
// extra checks.
if ($operation == 'enable') {
return $currency->status() ? AccessResult::forbidden() : $this->access($currency, 'update', $account, TRUE);
}
if ($operation == 'disable') {
return $currency->status() ? $this->access($currency, 'update', $account, TRUE) : AccessResult::forbidden();
}
return AccessResult::allowedIfHasPermission($account, 'currency.currency.' . $operation);
}
示例4: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
{
/** @var \Drupal\page_manager\PageInterface $entity */
if ($operation == 'view') {
if (!$entity->status()) {
return AccessResult::forbidden()->addCacheableDependency($entity);
}
$contexts = $entity->getContexts();
$conditions = $entity->getAccessConditions();
foreach ($conditions as $condition) {
if ($condition instanceof ContextAwarePluginInterface) {
$this->contextHandler()->applyContextMapping($condition, $contexts);
}
}
return AccessResult::allowedIf($this->resolveConditions($conditions, $entity->getAccessLogic()));
}
return parent::checkAccess($entity, $operation, $account);
}
示例5: 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);
}
示例6: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
{
/** @var $entity \Drupal\page_manager\PageInterface */
if ($operation == 'view') {
if (!$entity->status()) {
return AccessResult::forbidden()->cacheUntilEntityChanges($entity);
}
$conditions = $entity->getAccessConditions();
$contexts = $entity->getExecutable()->getContexts();
foreach ($conditions as $condition) {
if ($condition instanceof ContextAwarePluginInterface) {
$this->contextHandler()->applyContextMapping($condition, $contexts);
}
}
return AccessResult::allowedIf($this->resolveConditions($conditions, $entity->getAccessLogic()));
}
if ($operation == 'delete' && $entity->isFallbackPage()) {
return AccessResult::forbidden()->cacheUntilEntityChanges($entity);
}
return parent::checkAccess($entity, $operation, $langcode, $account);
}
示例7: 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);
}
示例8: getDisplayPaths
/**
* Gets a list of paths assigned to the view.
*
* @param \Drupal\Core\Entity\EntityInterface $view
* The view entity.
*
* @return array
* An array of paths for this view.
*/
protected function getDisplayPaths(EntityInterface $view)
{
$all_paths = array();
$executable = $view->getExecutable();
$executable->initDisplay();
foreach ($executable->displayHandlers as $display) {
if ($display->hasPath()) {
$path = $display->getPath();
if ($view->status() && strpos($path, '%') === FALSE) {
// @todo Views should expect and store a leading /. See:
// https://www.drupal.org/node/2423913
$all_paths[] = \Drupal::l('/' . $path, Url::fromUserInput('/' . $path));
} else {
$all_paths[] = '/' . $path;
}
}
}
return array_unique($all_paths);
}
示例9: getDisplayPaths
/**
* Gets a list of paths assigned to the view.
*
* @param \Drupal\Core\Entity\EntityInterface $view
* The view entity.
*
* @return array
* An array of paths for this view.
*/
protected function getDisplayPaths(EntityInterface $view)
{
$all_paths = array();
$executable = $view->getExecutable();
$executable->initDisplay();
foreach ($executable->displayHandlers as $display) {
if ($display->hasPath()) {
$path = $display->getPath();
if ($view->status() && strpos($path, '%') === FALSE) {
$all_paths[] = _l('/' . $path, $path);
} else {
$all_paths[] = String::checkPlain('/' . $path);
}
}
}
return array_unique($all_paths);
}
示例10: 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;
}