当前位置: 首页>>代码示例>>PHP>>正文


PHP Entity\ContentEntityBase类代码示例

本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityBase的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityBase类的具体用法?PHP ContentEntityBase怎么用?PHP ContentEntityBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ContentEntityBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAbsoluteUri

 /**
  * Gets the absolute URI of an entity.
  *
  * @param \Drupal\Core\Entity\ContentEntityBase $entity
  *   The entity for which to generate the URI.
  *
  * @return string
  *   The absolute URI.
  */
 protected function getAbsoluteUri($entity)
 {
     return $entity->url('canonical', array('absolute' => TRUE));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:13,代码来源:FieldRdfaTestBase.php

示例2: preCreate

 /**
  * {@inheritdoc}
  */
 public static function preCreate(EntityStorageInterface $storage, array &$values)
 {
     parent::preCreate($storage, $values);
     if (empty($values['type'])) {
         $values['type'] = $storage->getEntityTypeId();
     }
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:10,代码来源:EntityTest.php

示例3: preSave

 /**
  * {@inheritdoc}
  */
 public function preSave(EntityStorageInterface $storage)
 {
     parent::preSave($storage);
     // If no owner has been set explicitly, make the current user the owner.
     if (!$this->getOwner()) {
         $this->setOwnerId($this->getCurrentUserId());
     }
 }
开发者ID:marmouset,项目名称:drupal,代码行数:11,代码来源:Store.php

示例4: baseFieldDefinitions

 /**
  * {@inheritdoc}
  */
 public static function baseFieldDefinitions(EntityTypeInterface $entity_type)
 {
     $fields = parent::baseFieldDefinitions($entity_type);
     $fields['name'] = BaseFieldDefinition::create('string')->setLabel(t('Name'))->setDescription(t('The name of the test entity.'))->setTranslatable(TRUE)->setSetting('max_length', 32)->setDisplayOptions('view', array('label' => 'hidden', 'type' => 'string', 'weight' => -5))->setDisplayOptions('form', array('type' => 'string_textfield', 'weight' => -5));
     $fields['created'] = BaseFieldDefinition::create('created')->setLabel(t('Authored on'))->setDescription(t('Time the entity was created'))->setTranslatable(TRUE);
     $fields['user_id'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('User ID'))->setDescription(t('The ID of the associated user.'))->setSetting('target_type', 'user')->setSetting('handler', 'default')->setDefaultValue(array(0 => array('target_id' => 1)))->setTranslatable(TRUE)->setDisplayOptions('form', array('type' => 'entity_reference_autocomplete', 'weight' => -1, 'settings' => array('match_operator' => 'CONTAINS', 'size' => '60', 'placeholder' => '')));
     return $fields;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:11,代码来源:EntityTest.php

示例5: preCreate

 /**
  * {@inheritdoc}
  */
 public static function preCreate(EntityStorageInterface $storage_controller, array &$values)
 {
     parent::preCreate($storage_controller, $values);
     $values += array('user_id' => \Drupal::currentUser()->id());
     if (isset($values['issue_type'])) {
         $values['issue_type'] = \Drupal::service('checkstyle.issue.nodemapper')->getCheckstyleTypeId($values['issue_type']);
     }
     return FALSE;
 }
开发者ID:malcomio,项目名称:drupalytics,代码行数:12,代码来源:CheckstyleIssue.php

示例6: postLoad

 /**
  * {@inheritdoc}
  */
 public static function postLoad(EntityStorageInterface $storage, array &$orders)
 {
     parent::postLoad($storage, $orders);
     foreach ($orders as $id => $order) {
         $order->products = \Drupal::entityManager()->getStorage('uc_order_product')->loadByProperties(['order_id' => $id]);
         // Load line items... has to be last after everything has been loaded.
         $order->line_items = $order->getLineItems();
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:12,代码来源:Order.php

示例7: preSaveRevision

 /**
  * {@inheritdoc}
  */
 public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record)
 {
     parent::preSaveRevision($storage, $record);
     if (!$this->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {
         // If we are updating an existing entity without adding a new
         // revision and the user did not supply a revision log, keep the existing
         // one.
         $record->revision_log = $this->original->getRevisionLog();
     }
 }
开发者ID:heddn,项目名称:content_entity_base,代码行数:13,代码来源:EntityBase.php

示例8: postSave

 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // Only change the parents if a value is set, keep the existing values if
     // not.
     if (isset($this->parent->target_id)) {
         $storage->deleteTermHierarchy(array($this->id()));
         $storage->updateTermHierarchy($this);
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:13,代码来源:Term.php

示例9: testLabel

 /**
  * @covers ::label
  */
 public function testLabel()
 {
     // Make a mock with one method that we use as the entity's label callback.
     // We check that it is called, and that the entity's label is the callback's
     // return value.
     $callback_label = $this->randomMachineName();
     $callback_container = $this->getMock(get_class());
     $callback_container->expects($this->once())->method(__FUNCTION__)->will($this->returnValue($callback_label));
     $this->entityType->expects($this->once())->method('getLabelCallback')->will($this->returnValue(array($callback_container, __FUNCTION__)));
     $this->assertSame($callback_label, $this->entity->label());
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:ContentEntityBaseUnitTest.php

示例10: testDenormalize

 /**
  * Tests denormalization of an entity.
  */
 public function testDenormalize()
 {
     $normalized = $this->serializer->normalize($this->entity);
     foreach (array('json', 'xml') as $type) {
         $denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, array('entity_type' => 'entity_test_mulrev'));
         $this->assertTrue($denormalized instanceof $this->entityClass, SafeMarkup::format('Denormalized entity is an instance of @class', array('@class' => $this->entityClass)));
         $this->assertIdentical($denormalized->getEntityTypeId(), $this->entity->getEntityTypeId(), 'Expected entity type found.');
         $this->assertIdentical($denormalized->bundle(), $this->entity->bundle(), 'Expected entity bundle found.');
         $this->assertIdentical($denormalized->uuid(), $this->entity->uuid(), 'Expected entity UUID found.');
     }
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:14,代码来源:EntitySerializationTest.php

示例11: postLoad

 /**
  * {@inheritdoc}
  */
 public static function postLoad(EntityStorageInterface $storage, array &$items)
 {
     foreach ($items as $item) {
         $item->product = uc_product_load_variant($item->nid->target_id, $item->data->first()->toArray());
         if ($item->product) {
             $item->title = $item->product->label();
             $item->model = $item->product->model;
             $item->cost = $item->product->cost->value;
             $item->price = $item->product->price;
             $item->weight = $item->product->weight->value;
             $item->weight_units = $item->product->weight->units;
         }
         $item->module = $item->data->module;
     }
     parent::postLoad($storage, $items);
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:19,代码来源:CartItem.php

示例12: postSave

 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     // If no order number has been set explicitly, set it to the order id.
     if (!$this->getOrderNumber()) {
         $this->setOrderNumber($this->id());
         $this->save();
     }
     // Ensure there's a back-reference on each line item.
     foreach ($this->getLineItems() as $line_item) {
         if ($line_item->order_id->isEmpty()) {
             $line_item->order_id = $this->id();
             $line_item->save();
         }
     }
 }
开发者ID:marmouset,项目名称:drupal,代码行数:19,代码来源:Order.php

示例13: postDelete

 /**
  * {@inheritdoc}
  */
 public static function postDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::postDelete($storage, $entities);
     $uids = array_keys($entities);
     \Drupal::service('user.data')->delete(NULL, $uids);
 }
开发者ID:ravindrasingh22,项目名称:Drupal-8-rc,代码行数:9,代码来源:User.php

示例14: preDelete

 /**
  * {@inheritdoc}
  */
 public static function preDelete(EntityStorageInterface $storage, array $entities)
 {
     parent::preDelete($storage, $entities);
     /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
     $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
     foreach ($entities as $menu_link) {
         /** @var \Drupal\menu_link_content\Entity\MenuLinkContent $menu_link */
         $menu_link_manager->removeDefinition($menu_link->getPluginId(), FALSE);
     }
 }
开发者ID:shumer,项目名称:blog,代码行数:13,代码来源:MenuLinkContent.php

示例15: access

 /**
  * {@inheritdoc}
  */
 public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE)
 {
     if ($operation == 'create') {
         return parent::access($operation, $account, $return_as_object);
     }
     return \Drupal::entityManager()->getAccessControlHandler($this->entityTypeId)->access($this, $operation, $this->prepareLangcode(), $account, $return_as_object);
 }
开发者ID:brstde,项目名称:gap1,代码行数:10,代码来源:Node.php


注:本文中的Drupal\Core\Entity\ContentEntityBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。