本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface类的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface类的具体用法?PHP EntityInterface怎么用?PHP EntityInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntityInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: updateStatus
/**
* Entity builder: updates the product status with the submitted value.
*
* @param string $entity_type
* The entity type.
* @param \Drupal\commerce_product\Entity\ProductInterface $entity
* The product updated with the submitted values.
* @param array $form
* The complete form array.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*
* @see \Drupal\node\NodeForm::form()
*/
public static function updateStatus($entity_type, EntityInterface $entity, array $form, FormStateInterface $form_state)
{
$element = $form_state->getTriggeringElement();
if (isset($element['#published_status'])) {
$entity->setPublished($element['#published_status']);
}
}
开发者ID:mglaman,项目名称:drupalcamp-base,代码行数:21,代码来源:EnhancedContentEntityFormBase.php
示例2: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/* @var $entity \Drupal\brand\Entity\brand */
$row['id'] = $entity->id();
$row['name'] = \Drupal::l($this->getLabel($entity), new Url('entity.brand.edit_form', array('brand' => $entity->id())));
return $row + parent::buildRow($entity);
}
开发者ID:ashkarrrahman,项目名称:brand,代码行数:10,代码来源:brandListController.php
示例3: renderLink
/**
* Alters the field to render a link.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* @param \Drupal\views\ResultRow $values
* The current row of the views result.
*
* @return string
* The acutal rendered text (without the link) of this field.
*/
protected function renderLink(EntityInterface $entity, ResultRow $values)
{
$text = !empty($this->options['text']) ? $this->options['text'] : t('View');
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = $entity->getSystemPath();
return $text;
}
开发者ID:alnutile,项目名称:drunatra,代码行数:17,代码来源:Link.php
示例4: getForm
/**
* {@inheritdoc}
*/
public function getForm(EntityInterface $entity, $operation = 'default', array $form_state_additions = array())
{
$form_object = $this->entityManager->getFormObject($entity->getEntityTypeId(), $operation);
$form_object->setEntity($entity);
$form_state = (new FormState())->setFormState($form_state_additions);
return $this->formBuilder->buildForm($form_object, $form_state);
}
开发者ID:318io,项目名称:318-io,代码行数:10,代码来源:EntityFormBuilder.php
示例5: renderLink
/**
* Prepares the link to the profile.
*
* @param \Drupal\Core\Entity\EntityInterface $profile
* The profile entity this field belongs to.
* @param ResultRow $values
* The values retrieved from the view's result set.
*
* @return string
* Returns a string for the link text.
*/
protected function renderLink($profile, ResultRow $values) {
if ($profile->access('view')) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'profile/' . $profile->id();
return $profile->label();
}
}
开发者ID:housineali,项目名称:drpl8_dv,代码行数:18,代码来源:Label.php
示例6: getLabelAndConfig
/**
* Renders the Metatag defaults lable plus its configuration.
*
* @param EntityInterface $entity
* The Metatag defaults entity.
* @return
* Render array for a table cell.
*/
public function getLabelAndConfig(EntityInterface $entity)
{
$output = '<div>';
$prefix = '';
$inherits = '';
if ($entity->id() != 'global') {
$prefix = '<div class="indentation"></div>';
$inherits .= 'Global';
}
if (strpos($entity->id(), '__') !== FALSE) {
$prefix .= '<div class="indentation"></div>';
list($entity_label, $bundle_label) = explode(': ', $entity->get('label'));
$inherits .= ', ' . $entity_label;
}
$output .= '<div>
<p>Inherits meta tags from: ' . $inherits . '</p>
</div>';
$tags = $entity->get('tags');
if (count($tags)) {
$output .= '<table>
<tbody>';
foreach ($tags as $tag_id => $tag_value) {
$output .= '<tr><td>' . $tag_id . ':</td><td>' . $tag_value . '</td></tr>';
}
$output .= '</tbody></table>';
}
$output .= '</div></div>';
return array('data' => array('#type' => 'details', '#prefix' => $prefix, '#title' => $this->getLabel($entity), 'config' => array('#markup' => $output)));
}
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:37,代码来源:MetatagDefaultsListBuilder.php
示例7: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/* @var $entity \Drupal\eck\Entity\EckEntity */
$row['id'] = $entity->id();
$row['title'] = \Drupal::l($this->getLabel($entity), Url::fromRoute('entity.' . $this->entityTypeId . '.canonical', array($this->entityTypeId => $entity->id())));
return array_merge($row, parent::buildRow($entity));
}
开发者ID:jokas,项目名称:d8.dev,代码行数:10,代码来源:EckEntityListBuilder.php
示例8: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/* @var $entity \Drupal\my_first_entity\Entity\Course */
$row['id'] = $entity->id();
$row['name'] = \Drupal::l($this->getLabel($entity), new Url('entity.course.edit_form', array('course' => $entity->id())));
return $row + parent::buildRow($entity);
}
开发者ID:vinhgiang,项目名称:Learning-Drupal-8,代码行数:10,代码来源:CourseListController.php
示例9: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
{
if ($operation == 'delete' && $entity->getFieldStorageDefinition()->isLocked()) {
return FALSE;
}
return $account->hasPermission('administer ' . $entity->entity_type . ' fields');
}
开发者ID:anatalsceo,项目名称:en-classe,代码行数:10,代码来源:FieldInstanceConfigAccessController.php
示例10: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
$row['label'] = $entity->label();
$row['id'] = $entity->id();
// You probably want a few more properties here...
return $row + parent::buildRow($entity);
}
开发者ID:emilienGallet,项目名称:DrupalUnicef,代码行数:10,代码来源:DefaultEntityListBuilder.php
示例11: isModeratedEntity
/**
* {@inheritdoc}
*/
public function isModeratedEntity(EntityInterface $entity)
{
if (!$entity instanceof ContentEntityInterface) {
return FALSE;
}
return $this->shouldModerateEntitiesOfBundle($entity->getEntityType(), $entity->bundle());
}
开发者ID:eigentor,项目名称:tommiblog,代码行数:10,代码来源:ModerationInformation.php
示例12: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $payment, $operation, AccountInterface $account)
{
/** @var \Drupal\payment\Entity\PaymentInterface $payment */
if ($operation == 'update_status') {
$payment_method = $payment->getPaymentMethod();
if ($payment_method instanceof PaymentMethodUpdatePaymentStatusInterface && !$payment_method->updatePaymentStatusAccess($account)) {
return AccessResult::forbidden();
}
} elseif ($operation == 'capture') {
$payment_method = $payment->getPaymentMethod();
if ($payment_method instanceof PaymentMethodCapturePaymentInterface) {
return AccessResult::allowedIf($payment_method instanceof PaymentMethodCapturePaymentInterface)->andIf(AccessResult::allowedIf($payment_method->capturePaymentAccess($account)))->andIf($this->checkAccessPermission($payment, $operation, $account));
}
return AccessResult::forbidden();
} elseif ($operation == 'refund') {
$payment_method = $payment->getPaymentMethod();
if ($payment_method instanceof PaymentMethodRefundPaymentInterface) {
return AccessResult::allowedIf($payment_method->refundPaymentAccess($account))->andIf($this->checkAccessPermission($payment, $operation, $account));
}
return AccessResult::forbidden();
} elseif ($operation == 'complete') {
if ($payment->getPaymentMethod()) {
return AccessResult::allowedIf($payment->getOwnerId() == $account->id())->orIf(AccessResult::forbiddenIf($payment->getPaymentMethod()->getPaymentExecutionResult()->isCompleted()));
} else {
return AccessResult::forbidden();
}
}
return $this->checkAccessPermission($payment, $operation, $account);
}
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:32,代码来源:PaymentAccessControlHandler.php
示例13: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/* @var $entity \Drupal\dinodb\Entity\Dinosaur */
$row['id'] = $entity->id();
$row['name'] = $this->l($this->getLabel($entity), new Url('entity.dinosaur.edit_form', array('dinosaur' => $entity->id())));
return $row + parent::buildRow($entity);
}
开发者ID:joshuataylor,项目名称:dinodb,代码行数:10,代码来源:DinosaurListBuilder.php
示例14: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $filter_format, $operation, $langcode, AccountInterface $account)
{
/** @var \Drupal\filter\FilterFormatInterface $filter_format */
// All users are allowed to use the fallback filter.
if ($operation == 'use') {
if ($filter_format->isFallbackFormat()) {
return AccessResult::allowed();
} else {
return AccessResult::allowedIfHasPermission($account, $filter_format->getPermissionName());
}
}
// The fallback format may not be disabled.
if ($operation == 'disable' && $filter_format->isFallbackFormat()) {
return AccessResult::forbidden();
}
// We do not allow filter formats to be deleted through the UI, because that
// would render any content that uses them unusable.
if ($operation == 'delete') {
return AccessResult::forbidden();
}
if (in_array($operation, array('disable', 'update'))) {
return parent::checkAccess($filter_format, $operation, $langcode, $account);
}
// No opinion.
return AccessResult::neutral();
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:29,代码来源:FilterFormatAccessControlHandler.php
示例15: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
$row['type'] = $entity->link();
$row['registration'] = $entity->getRegistration() ? t('Yes') : t('No');
$row['multiple'] = $entity->getMultiple() ? t('Yes') : t('No');
return $row + parent::buildRow($entity);
}
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:10,代码来源:ProfileTypeListBuilder.php
示例16: checkAccess
/**
* {@inheritdoc}
*/
public function checkAccess(EntityInterface $entity, Route $route, AccountInterface $account, $operation, $graph_name)
{
if (!$entity) {
return FALSE;
}
// For now, we only have the view operation but this is not the only
// operation so we will check anyway.
$map = ['view' => 'view all graphs'];
$entity_type_id = $entity->getEntityTypeId();
$type_map = ['view' => "view {$entity_type_id} {$graph_name} graph"];
// If the operation is not supported, do not allow access.
if (!isset($map[$operation]) || !isset($type_map[$operation])) {
return FALSE;
}
// @todo: This probably needs to be cached manually creating a cid.
// @see: \Drupal\node\Access\NodeRevisionAccessCheck::checkAccess().
// @todo: This needs also to check cache for cached permission.
// @see: \Drupal\Core\Entity\EntityAccessControlHandler::access().
$has_permission = $account->hasPermission($map[$operation]) || $account->hasPermission($type_map[$operation]);
$access = $has_permission ? AccessResult::allowed() : AccessResult::neutral();
$arguments = [$entity, $operation, $account, $graph_name];
$access_array = array_merge([$access], $this->moduleHandler->invokeAll('entity_graph_access', $arguments), $this->moduleHandler->invokeAll($entity_type_id . '_graph_access', $arguments));
$return = $this->processAccessHookResults($access_array);
return $return->isAllowed();
}
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:28,代码来源:RdfGraphAccessCheck.php
示例17: buildRow
/**
* {@inheritdoc}
*/
public function buildRow(EntityInterface $entity)
{
/* @var $entity \Drupal\scheduled_updates\Entity\ScheduledUpdate */
$row['name'] = $this->l($entity->label(), new Url('entity.scheduled_update.edit_form', array('scheduled_update' => $entity->id())));
$row['type'] = $this->updateUtils->getUpdateTypeLabel($entity);
return $row + parent::buildRow($entity);
}
开发者ID:tedbow,项目名称:scheduled-updates-demo,代码行数:10,代码来源:ScheduledUpdateListBuilder.php
示例18: getTranslationMetadata
/**
* {@inheritdoc}
*/
public function getTranslationMetadata(EntityInterface $translation)
{
// We need a new instance of the metadata handler wrapping each translation.
$entity_type = $translation->getEntityType();
$class = $entity_type->get('content_translation_metadata');
return new $class($translation, $this->getTranslationHandler($entity_type->id()));
}
开发者ID:HakS,项目名称:drupal8_training,代码行数:10,代码来源:ContentTranslationManager.php
示例19: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
/** @var \Drupal\entityqueue\EntitySubqueueInterface $entity */
switch ($operation) {
case 'view':
return AccessResult::allowedIfHasPermission($account, 'access content');
break;
case 'update':
return AccessResult::allowedIfHasPermissions($account, ["update {$entity->bundle()} entityqueue", 'manipulate all entityqueues', 'administer entityqueue'], 'OR');
break;
case 'delete':
$can_delete_subqueue = AccessResult::allowedIf(!$entity->getQueue()->getHandlerPlugin()->hasAutomatedSubqueues());
$access_result = AccessResult
::allowedIfHasPermissions($account, ["delete {$entity->bundle()} entityqueue", 'manipulate all entityqueues', 'administer entityqueue'], 'OR')
->andIf($can_delete_subqueue);
return $access_result;
break;
default:
// No opinion.
return AccessResult::neutral();
}
}
开发者ID:jkyto,项目名称:agolf,代码行数:29,代码来源:EntitySubqueueAccessControlHandler.php
示例20: checkAccess
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
{
/** @var \Drupal\user\UserInterface $entity*/
// The anonymous user's profile can neither be viewed, updated nor deleted.
if ($entity->isAnonymous()) {
return AccessResult::forbidden();
}
// Administrators can view/update/delete all user profiles.
if ($account->hasPermission('administer users')) {
return AccessResult::allowed()->cachePerRole();
}
switch ($operation) {
case 'view':
// Only allow view access if the account is active.
if ($account->hasPermission('access user profiles') && $entity->isActive()) {
return AccessResult::allowed()->cachePerRole()->cacheUntilEntityChanges($entity);
} else {
if ($account->id() == $entity->id()) {
return AccessResult::allowed()->cachePerUser();
}
}
break;
case 'update':
// Users can always edit their own account.
return AccessResult::allowedIf($account->id() == $entity->id())->cachePerUser();
case 'delete':
// Users with 'cancel account' permission can cancel their own account.
return AccessResult::allowedIf($account->id() == $entity->id() && $account->hasPermission('cancel account'))->cachePerRole()->cachePerUser();
}
// No opinion.
return AccessResult::neutral();
}
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:UserAccessControlHandler.php
注:本文中的Drupal\Core\Entity\EntityInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论