本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface::isPublished方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface::isPublished方法的具体用法?PHP EntityInterface::isPublished怎么用?PHP EntityInterface::isPublished使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\EntityInterface
的用法示例。
在下文中一共展示了EntityInterface::isPublished方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/** @var \Drupal\conference_sessions\Entity\RoomTypeInterface $entity */
$product_type = RoomType::load($entity->bundle());
$row['title']['data'] = ['#type' => 'link', '#title' => $entity->label()] + $entity->toUrl()->toRenderArray();
$row['type'] = $product_type->label();
$row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');
return $row + parent::buildRow($entity);
}
示例2: entityFormEntityBuild
/**
* {@inheritdoc}
*/
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
{
if ($form_state->hasValue('content_translation')) {
$translation =& $form_state->getValue('content_translation');
/** @var \Drupal\comment\CommentInterface $entity */
$translation['status'] = $entity->isPublished();
$translation['name'] = $entity->getAuthorName();
}
parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
}
示例3: entityFormEntityBuild
/**
* {@inheritdoc}
*/
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
{
if ($form_state->hasValue('content_translation')) {
$translation =& $form_state->getValue('content_translation');
$translation['status'] = $entity->isPublished();
$account = $entity->uid->entity;
$translation['uid'] = $account ? $account->id() : 0;
$translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O');
}
parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
}
示例4: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
{
/** @var \Drupal\Core\Entity\EntityInterface|\Drupal\user\EntityOwnerInterface $entity */
switch ($operation) {
case 'view':
if ($account->hasPermission('access comments') && $entity->isPublished() || $account->hasPermission('administer comments')) {
return $entity->getCommentedEntity()->access($operation, $account);
}
break;
case 'update':
return $account->id() && $account->id() == $entity->getOwnerId() && $entity->isPublished() && $account->hasPermission('edit own comments') || $account->hasPermission('administer comments');
break;
case 'delete':
return $account->hasPermission('administer comments');
break;
case 'approve':
return $account->hasPermission('administer comments');
break;
}
}
示例5: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity) {
/* @var $entity \Drupal\commerce_product\Entity\Product */
$productType = ProductType::load($entity->bundle());
$row['title']['data'] = [
'#type' => 'link',
'#title' => $entity->label(),
] + $entity->urlInfo()->toRenderArray();
$row['type'] = $productType->label();
$row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');
return $row + parent::buildRow($entity);
}
示例6: entityFormEntityBuild
/**
* {@inheritdoc}
*/
public function entityFormEntityBuild($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
{
if ($form_state->hasValue('content_translation')) {
$translation =& $form_state->getValue('content_translation');
$translation['status'] = $entity->isPublished();
// $form['content_translation']['name'] is the equivalent field
// for translation author uid.
$account = $entity->uid->entity;
$translation['name'] = $account ? $account->getUsername() : '';
$translation['created'] = format_date($entity->created->value, 'custom', 'Y-m-d H:i:s O');
}
parent::entityFormEntityBuild($entity_type, $entity, $form, $form_state);
}
示例7: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $support_ticket, $operation, AccountInterface $account)
{
/** @var \Drupal\support_ticket\SupportTicketInterface $support_ticket */
// Fetch information from the support_ticket object if possible.
$status = $support_ticket->isPublished();
$uid = $support_ticket->getOwnerId();
// Check if authors can view their own unpublished support tickets.
if ($operation === 'view' && !$status && $account->hasPermission('view own unpublished support tickets') && $account->isAuthenticated() && $account->id() == $uid) {
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->cacheUntilEntityChanges($support_ticket);
}
if ($operation === 'view') {
return AccessResult::allowedIf($status)->cacheUntilEntityChanges($support_ticket);
}
// No opinion.
return AccessResult::neutral();
}
示例8: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
{
/** @var \Drupal\custom_page\CustomPageInterface $entity */
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished custom page entities');
}
return AccessResult::allowedIfHasPermission($account, 'view published custom page entities');
case 'update':
return AccessResult::allowedIfHasPermission($account, 'edit custom page entities');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete custom page entities');
}
// Unknown operation, no opinion.
return AccessResult::neutral();
}
示例9: checkAccess
/**
* {@inheritdoc}
*
* Link the activities to the permissions. checkAccess is called with the
* $operation as defined in the routing.yml file.
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
{
if (!$entity instanceof RdfInterface) {
throw new \Exception('Can only handle access of Rdf entity instances.');
}
$entity_bundle = $entity->bundle();
switch ($operation) {
case 'view':
if (!$entity->isPublished()) {
return AccessResult::allowedIfHasPermission($account, 'view unpublished rdf entity');
}
return AccessResult::allowedIfHasPermission($account, 'view rdf entity');
case 'edit':
return AccessResult::allowedIfHasPermission($account, 'edit ' . $entity_bundle . ' rdf entity');
case 'delete':
return AccessResult::allowedIfHasPermission($account, 'delete ' . $entity_bundle . ' rdf entity');
}
return AccessResult::neutral();
}
示例10: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $node, $operation, AccountInterface $account)
{
/** @var \Drupal\node\NodeInterface $node */
// Fetch information from the node object if possible.
$status = $node->isPublished();
$uid = $node->getOwnerId();
// Check if authors can view their own unpublished nodes.
if ($operation === 'view' && !$status && $account->hasPermission('view own unpublished content') && $account->isAuthenticated() && $account->id() == $uid) {
return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
}
// Evaluate node grants.
return $this->grantStorage->access($node, $operation, $account);
}
示例11: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/* @var $entity \Drupal\rdf_entity\Entity\Rdf */
$row['id'] = $entity->link();
$row['rid'] = $entity->bundle();
$row['status'] = $entity->isPublished() ? $this->t('Published') : $this->t('Unpublished');
return $row + parent::buildRow($entity);
}