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


PHP NodeInterface::getEntityTypeId方法代码示例

本文整理汇总了PHP中Drupal\node\NodeInterface::getEntityTypeId方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getEntityTypeId方法的具体用法?PHP NodeInterface::getEntityTypeId怎么用?PHP NodeInterface::getEntityTypeId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\node\NodeInterface的用法示例。


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

示例1: testConfigurableEventHandler

 /**
  * Tests ConfigurableEventHandlerEntityBundle.
  *
  * Test that rules are triggered correctly based upon the fully qualified
  * event name as well as the base event name.
  *
  * @todo Add integrity check that node.field_integer is detected by Rules.
  */
 public function testConfigurableEventHandler()
 {
     // Create rule1 with the 'rules_entity_presave:node--page' event.
     $rule1 = $this->expressionManager->createRule();
     $rule1->addAction('rules_test_log', ContextConfig::create()->map('message', 'node.field_integer.0.value'));
     $config_entity1 = $this->storage->create(['id' => 'test_rule1']);
     $config_entity1->set('events', [['event_name' => 'rules_entity_presave:node--page']]);
     $config_entity1->set('expression', $rule1->getConfiguration());
     $config_entity1->save();
     // Create rule2 with the 'rules_entity_presave:node' event.
     $rule2 = $this->expressionManager->createRule();
     $rule2->addAction('rules_test_log', ContextConfig::create()->map('message', 'node.field_integer.1.value'));
     $config_entity2 = $this->storage->create(['id' => 'test_rule2']);
     $config_entity2->set('events', [['event_name' => 'rules_entity_presave:node']]);
     $config_entity2->set('expression', $rule2->getConfiguration());
     $config_entity2->save();
     // The logger instance has changed, refresh it.
     $this->logger = $this->container->get('logger.channel.rules');
     // Add node.field_integer.0.value to rules log message, read result.
     $this->node->field_integer->setValue(['0' => 11, '1' => 22]);
     // Trigger node save.
     $entity_type_id = $this->node->getEntityTypeId();
     $event = new EntityEvent($this->node, [$entity_type_id => $this->node]);
     $event_dispatcher = \Drupal::service('event_dispatcher');
     $event_dispatcher->dispatch("rules_entity_presave:{$entity_type_id}", $event);
     // Test that the action in the rule1 logged node value.
     $this->assertRulesLogEntryExists(11, 1);
     // Test that the action in the rule2 logged node value.
     $this->assertRulesLogEntryExists(22, 0);
 }
开发者ID:Progressable,项目名称:openway8,代码行数:38,代码来源:ConfigurableEventHandlerTest.php


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