php Drupal-Core-Entity-EntityTypeInterface类(方法)实例源码

下面列出了php Drupal-Core-Entity-EntityTypeInterface 类(方法)源码代码实例,从而了解它的用法。

作者:housineal    项目:drpl8_d   
/**
  * {@inheritdoc}
  */
 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
   return new static(
     $entity_type,
     $container->get('entity.manager')->getStorage($entity_type->id()),
     $container->get('date.formatter')
   );
 }

作者:ec-europ    项目:joinup-de   
/**
  * Build the route for the actual download path.
  */
 protected function getDownloadRoute(EntityTypeInterface $entity_type)
 {
     $entity_type_id = $entity_type->id();
     $route = new Route("/rdf-export/{$entity_type_id}/{{$entity_type_id}}/{export_format}");
     $route->addDefaults(['_controller' => '\\Drupal\\rdf_export\\Controller\\RdfExportController::download', '_title' => 'RDF Export'])->addRequirements(['_permission' => 'export rdf metadata'])->setOption('entity_type_id', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
     return $route;
 }

作者:tedbo    项目:scheduled-updates-dem   
/**
  * {@inheritdoc}
  */
 public function isModeratableBundle(EntityTypeInterface $entity_type, $bundle)
 {
     if ($bundle_entity = $this->loadBundleEntity($entity_type->getBundleEntityType(), $bundle)) {
         return $bundle_entity->getThirdPartySetting('workbench_moderation', 'enabled', FALSE);
     }
     return FALSE;
 }

作者:brstd    项目:gap   
/**
  * Constructs a new EntityViewBuilder.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
  *   The entity manager service.
  * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
  *   The language manager.
  */
 public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager)
 {
     $this->entityTypeId = $entity_type->id();
     $this->entityType = $entity_type;
     $this->entityManager = $entity_manager;
     $this->languageManager = $language_manager;
 }

作者:housineal    项目:drpl8_d   
/**
  * {@inheritdoc}
  */
 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
   return new static(
     $container->get('entity.manager'),
     $container->get('module_handler'),
     $entity_type->id()
   );
 }

作者:eigento    项目:tommiblo   
/**
  * {@inheritdoc}
  */
 public function shouldModerateEntitiesOfBundle(EntityTypeInterface $entity_type, $bundle)
 {
     if ($bundle_entity = $this->loadBundleEntity($entity_type->getBundleEntityType(), $bundle)) {
         return $bundle_entity->getThirdPartySetting('content_moderation', 'enabled', FALSE);
     }
     return FALSE;
 }

作者:mglama    项目:panelizer-d8-prototyp   
/**
  * Constructs a new EntityViewBuilder.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
  *   The entity manager service.
  * @param \Drupal\panelizer\Plugin\PanelizerEntityManager $panelizer_manager
  *   The Panelizer entity manager.
  * @param \Drupal\Panels\PanelsDisplayManagerInterface $panels_manager
  *   The Panels display manager.
  */
 public function __construct(EntityTypeInterface $entity_type, EntityTypeManagerInterface $entity_type_manager, PanelizerEntityManager $panelizer_manager, PanelsDisplayManagerInterface $panels_manager)
 {
     $this->entityTypeId = $entity_type->id();
     $this->entityType = $entity_type;
     $this->entityTypeManager = $entity_type_manager;
     $this->panelizerManager = $panelizer_manager;
     $this->panelsManager = $panels_manager;
 }

作者:AshishNaik02    项目:iimisac-d   
/**
  * {@inheritdoc}
  */
 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
   return new static(
     $entity_type,
     $container->get('entity.manager')->getStorage($entity_type->id()),
     $container->get('url_generator'),
     $container->get('string_translation')
   );
 }

作者:anatalsce    项目:en-class   
/**
  * Constructs an EntityStorageBase instance.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type definition.
  */
 public function __construct(EntityTypeInterface $entity_type)
 {
     $this->entityTypeId = $entity_type->id();
     $this->entityType = $entity_type;
     $this->idKey = $this->entityType->getKey('id');
     $this->uuidKey = $this->entityType->getKey('uuid');
     $this->entityClass = $this->entityType->getClass();
 }

作者:tedbo    项目:scheduled-updates-dem   
/**
  * Gets the moderation-form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getModerationFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('moderation-form') && $entity_type->getFormClass('moderation')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($entity_type->getLinkTemplate('moderation-form'));
         $route->setDefaults(['_entity_form' => "{$entity_type_id}.moderation", '_title' => 'Moderation'])->setRequirement('_permission', 'administer moderation states')->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
         return $route;
     }
 }

作者:sgtsaughte    项目:d8portfoli   
/**
  * Gets the devel render route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getDevelRenderRoute(EntityTypeInterface $entity_type)
 {
     if ($devel_render = $entity_type->getLinkTemplate('devel-render')) {
         $entity_type_id = $entity_type->id();
         $route = new Route($devel_render);
         $route->addDefaults(['_controller' => '\\Drupal\\devel\\Controller\\DevelController::entityRender', '_title' => 'Devel Render'])->addRequirements(['_permission' => 'access devel information'])->setOption('_admin_route', TRUE)->setOption('_devel_entity_type_id', $entity_type_id)->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
         return $route;
     }
 }

作者:ddrozdi    项目:dmap   
/**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->entityTypeId = $this->randomMachineName();
     $this->provider = $this->randomMachineName();
     $this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue($this->provider));
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with($this->entityTypeId)->will($this->returnValue($this->entityType));
 }

作者:hedd    项目:content_entity_bas   
protected function addFormRoute(EntityTypeInterface $entity_type)
 {
     $route = new Route('entity.' . $entity_type->id() . '.add-form');
     $route->setDefault('_controller', '\\Drupal\\content_entity_base\\Entity\\Controller\\EntityBaseController::addForm');
     $route->setDefault('_title_callback', '\\Drupal\\content_entity_base\\Entity\\Controller\\EntityBaseController::getAddFormTitle');
     $route->setDefault('entity_type', $entity_type->id());
     $route->setRequirement('_entity_create_access', $entity_type->id());
     return $route;
 }

作者:eloi    项目:botafoc.ca   
/**
  * {@inheritdoc}
  */
 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
   return new static(
     $entity_type,
     $container->get('entity.manager')->getStorage($entity_type->id()),
     $container->get('theme.manager'),
     $container->get('form_builder'),
     $container->get('entity.manager')->getStorage('block_visibility_group'),
     $container->get('state')
   );
 }

作者:tedbo    项目:scheduled-updates-dem   
/**
  * Adds base field info to an entity type.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   Entity type for adding base fields to.
  *
  * @return \Drupal\Core\Field\BaseFieldDefinition[]
  *   New fields added by moderation state.
  */
 public function entityBaseFieldInfo(EntityTypeInterface $entity_type)
 {
     if ($entity_type->isRevisionable()) {
         $fields = [];
         // @todo write a test for this.
         $fields['moderation_state'] = BaseFieldDefinition::create('entity_reference')->setLabel(t('Moderation state'))->setDescription(t('The moderation state of this piece of content.'))->setSetting('target_type', 'moderation_state')->setTargetEntityTypeId($entity_type->id())->setRevisionable(TRUE)->setDisplayOptions('view', ['label' => 'hidden', 'type' => 'string', 'weight' => -5])->setDisplayOptions('form', ['type' => 'moderation_state_default', 'weight' => 5, 'settings' => []])->addConstraint('ModerationState', [])->setDisplayConfigurable('form', FALSE)->setDisplayConfigurable('view', TRUE);
         return $fields;
     }
     return [];
 }

作者:ec-europ    项目:joinup-de   
/**
  * Gets the devel load route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function getRdfGraphRoute(EntityTypeInterface $entity_type, $graph_definition)
 {
     if ($rdf_draft = $entity_type->getLinkTemplate('rdf-draft-' . $graph_definition['name'])) {
         $entity_type_id = $entity_type->id();
         $route = new Route($rdf_draft);
         $route->addDefaults(['_controller' => '\\Drupal\\rdf_draft\\Controller\\RdfController::view', '_title' => (string) t('View @title', ['@title' => (string) $graph_definition['title']])])->addRequirements(['_access_rdf_graph' => 'TRUE'])->setOption('entity_type_id', $entity_type_id)->setOption('graph_name', $graph_definition['name'])->setOption('parameters', [$entity_type_id => ['type' => 'entity:' . $entity_type_id]]);
         return $route;
     }
     return NULL;
 }

作者:CIGIHu    项目:bsia-drupal   
/**
  * Returns the delete multiple form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function deleteMultipleFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('delete-multiple-form')) {
         $route = new Route($entity_type->getLinkTemplate('delete-multiple-form'));
         $route->setDefault('_form', '\\Drupal\\entity\\Form\\DeleteMultiple');
         $route->setDefault('entity_type_id', $entity_type->id());
         $route->setRequirement('_permission', $entity_type->getAdminPermission());
         return $route;
     }
 }

作者:jasonruyl    项目:crm_cor   
/**
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
  *
  * @return mixed
  */
 protected function permissionLabels(EntityTypeInterface $entity_info)
 {
     $labels = $entity_info->get("permission_labels");
     if (!isset($labels['singular'])) {
         $labels['singular'] = $entity_info->getLabel();
     }
     if (!isset($labels['plural'])) {
         $labels['plural'] = $entity_info->getLabel();
     }
     return $labels;
 }

作者:darrylr    项目:protovbmwm   
/**
  * Returns the add form route.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
  *   The entity type.
  *
  * @return \Symfony\Component\Routing\Route|null
  *   The generated route, if available.
  */
 protected function addFormRoute(EntityTypeInterface $entity_type)
 {
     if ($entity_type->hasLinkTemplate('add-form')) {
         $route = new Route($entity_type->getLinkTemplate('add-form'));
         $route->setDefault('_controller', '\\Drupal\\entity\\Controller\\EntityCreateController::addForm');
         $route->setDefault('_title_callback', '\\Drupal\\entity\\Controller\\EntityCreateController::addFormTitle');
         $route->setDefault('entity_type_id', $entity_type->id());
         $route->setRequirement('_entity_create_access', $entity_type->id());
         return $route;
     }
 }

作者:neetumorwan    项目:bloggin   
/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityType = $this->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
     $this->entityType->expects($this->any())->method('getProvider')->will($this->returnValue('responsive_image'));
     $this->entityManager = $this->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
     $this->entityManager->expects($this->any())->method('getDefinition')->with('responsive_image_style')->will($this->returnValue($this->entityType));
     $this->breakpointManager = $this->getMock('\\Drupal\\breakpoint\\BreakpointManagerInterface');
     $container = new ContainerBuilder();
     $container->set('entity.manager', $this->entityManager);
     $container->set('breakpoint.manager', $this->breakpointManager);
     \Drupal::setContainer($container);
 }


问题


面经


文章

微信
公众号

扫码关注公众号