本文整理汇总了PHP中Drupal\Core\Entity\EntityInterface类的典型用法代码示例。如果您正苦于以下问题:PHP EntityInterface类的具体用法?PHP EntityInterface怎么用?PHP EntityInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了EntityInterface类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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']);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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();
}
}
示例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)));
}
示例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));
}
示例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);
}
示例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');
}
示例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);
}
示例11: isModeratedEntity
/**
* {@inheritdoc}
*/
public function isModeratedEntity(EntityInterface $entity)
{
if (!$entity instanceof ContentEntityInterface) {
return FALSE;
}
return $this->shouldModerateEntitiesOfBundle($entity->getEntityType(), $entity->bundle());
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}