• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Entity\EntityTypeManagerInterface类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __construct

 /**
  * Constructs a new TaxTypeImporter.
  *
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
  *   The entity type manager.
  * @param string
  *   The tax types folder of definitions.
  */
 public function __construct(EntityTypeManagerInterface $entityTypeManager, TranslationInterface $stringTranslation, $taxTypesFolder = NULL) {
   $this->taxTypeStorage = $entityTypeManager->getStorage('commerce_tax_type');
   $this->taxRateStorage = $entityTypeManager->getStorage('commerce_tax_rate');
   $this->taxRateAmountStorage = $entityTypeManager->getStorage('commerce_tax_rate_amount');
   $this->stringTranslation = $stringTranslation;
   $this->taxTypeRepository = new TaxTypeRepository($taxTypesFolder);
 }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:15,代码来源:TaxTypeImporter.php


示例2: __construct

 /**
 * Constructs a new AddToCartForm object.
 *
 * @param \Drupal\commerce_cart\CartManagerInterface $cart_manager
 *   The cart manager.
 * @param \Drupal\commerce_cart\CartProviderInterface $cart_provider
 *   The cart provider.
 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   49   The entity type manager.
 * @param \Drupal\commerce_store\StoreContextInterface $store_context
 *   The store context.
 */
 public function __construct(CartManagerInterface $cart_manager, CartProviderInterface $cart_provider, EntityTypeManagerInterface $entity_type_manager, StoreContextInterface $store_context)
 {
     $this->cartManager = $cart_manager;
     $this->cartProvider = $cart_provider;
     $this->variationStorage = $entity_type_manager->getStorage('commerce_product_variation');
     $this->storeContext = $store_context;
 }
开发者ID:marmouset,项目名称:drupal,代码行数:19,代码来源:AddToCartForm.php


示例3: __construct

 /**
  * Constructs a new instance.
  *
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
  * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
  * @param \Drupal\currency\EventDispatcherInterface $event_dispatcher
  */
 public function __construct(EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, ConfigFactoryInterface $config_factory, EventDispatcherInterface $event_dispatcher)
 {
     $this->configFactory = $config_factory;
     $this->currencyLocaleStorage = $entity_type_manager->getStorage('currency_locale');
     $this->eventDispatcher = $event_dispatcher;
     $this->languageManager = $language_manager;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:15,代码来源:LocaleResolver.php


示例4: __construct

 /**
  * Constructs the target plugin.
  */
 public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityTypeManagerInterface $entity_type_manager, AccountInterface $current_user)
 {
     parent::__construct($configuration, $plugin_id, $plugin_definition, $current_user);
     $this->paragraphStorage = $entity_type_manager->getStorage('paragraph');
     $this->paragraphsTypeStorage = $entity_type_manager->getStorage('paragraphs_type');
     $this->fieldConfigStorage = $entity_type_manager->getStorage('field_config');
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:10,代码来源:Paragraphs.php


示例5: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
     $this->languageManager = $this->prophesize(LanguageManagerInterface::class);
     $this->entityRepository = new EntityRepository($this->entityTypeManager->reveal(), $this->languageManager->reveal());
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:10,代码来源:EntityRepositoryTest.php


示例6: setUp

 /**
  * {@inheritdoc}
  *
  * @covers ::__construct
  */
 protected function setUp()
 {
     $this->pageStorage = $this->prophesize(ConfigEntityStorageInterface::class);
     $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
     $this->entityTypeManager->getStorage('page')->willReturn($this->pageStorage);
     $this->cacheTagsInvalidator = $this->prophesize(CacheTagsInvalidatorInterface::class);
     $this->routeSubscriber = new PageManagerRoutes($this->entityTypeManager->reveal(), $this->cacheTagsInvalidator->reveal());
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:13,代码来源:PageManagerRoutesTest.php


示例7: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->pageVariantStorage = $this->prophesize(ConfigEntityStorageInterface::class);
     $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
     $this->entityTypeManager->getStorage('page_variant')->willReturn($this->pageVariantStorage);
     $this->currentPath = $this->prophesize(CurrentPathStack::class);
     $this->routeFilter = new VariantRouteFilter($this->entityTypeManager->reveal(), $this->currentPath->reveal());
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:11,代码来源:VariantRouteFilterTest.php


示例8: __construct

 /**
  * Constructs a new instance.
  *
  * @param \Drupal\Core\Extension\ModuleHandlerInterface
  *   The module handler.
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface
  *   The event dispatcher.
  * @param \Drupal\Core\Config\TypedConfigManagerInterface $typed_config_manager
  *   THe typed config manager.
  * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
  *   The entity type manager.
  */
 public function __construct(ModuleHandlerInterface $module_handler, EventDispatcherInterface $event_dispatcher, TypedConfigManagerInterface $typed_config_manager, EntityTypeManagerInterface $entity_type_manager)
 {
     $this->currencyResourceRepository = new ResourceRepository();
     $this->currencyStorage = $entity_type_manager->getStorage('currency');
     $this->currencyLocaleStorage = $entity_type_manager->getStorage('currency_locale');
     $this->eventDispatcher = $event_dispatcher;
     $this->moduleHandler = $module_handler;
     $this->typedConfigManager = $typed_config_manager;
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:21,代码来源:ConfigImporter.php


示例9: __construct

  /**
   * Constructs a new PriceDefaultWidget object.
   *
   * @param string $pluginId
   *   The plugin_id for the widget.
   * @param mixed $pluginDefinition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Field\FieldDefinitionInterface $fieldDefinition
   *   The definition of the field to which the widget is associated.
   * @param array $settings
   *   The widget settings.
   * @param array $thirdPartySettings
   *   Any third party settings.
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
   *   The entity type manager.
   * @param \Drupal\commerce_price\NumberFormatterFactoryInterface $numberFormatterFactory
   *   The number formatter factory.
   */
  public function __construct($pluginId, $pluginDefinition, FieldDefinitionInterface $fieldDefinition, array $settings, array $thirdPartySettings, EntityTypeManagerInterface $entityTypeManager, NumberFormatterFactoryInterface $numberFormatterFactory) {
    parent::__construct($pluginId, $pluginDefinition, $fieldDefinition, $settings, $thirdPartySettings);

    $this->currencyStorage = $entityTypeManager->getStorage('commerce_currency');
    $this->numberFormatter = $numberFormatterFactory->createInstance(NumberFormatterInterface::DECIMAL);
    $this->numberFormatter->setMinimumFractionDigits(0);
    $this->numberFormatter->setMaximumFractionDigits(6);
    $this->numberFormatter->setGroupingUsed(FALSE);
  }
开发者ID:housineali,项目名称:drpl8_dv,代码行数:27,代码来源:PriceDefaultWidget.php


示例10: setUp

 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->currencyStorage = $this->getMock(EntityStorageInterface::class);
     $this->currencyLocaleStorage = $this->getMock(EntityStorageInterface::class);
     $this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
     $map = [['currency', $this->currencyStorage], ['currency_locale', $this->currencyLocaleStorage]];
     $this->entityTypeManager->expects($this->atLeastOnce())->method('getStorage')->willReturnMap($map);
     $this->stringTranslation = $this->getStringTranslationStub();
     $this->sut = new FormHelper($this->stringTranslation, $this->entityTypeManager);
 }
开发者ID:nishantkumar155,项目名称:drupal8.crackle,代码行数:13,代码来源:FormHelperTest.php


示例11: access

 /**
  * {@inheritdoc}
  */
 public function access(Route $route, AccountInterface $account, RdfInterface $rdf_entity, $operation = 'view')
 {
     $graph = $route->getOption('graph_name');
     $entity_type_id = $route->getOption('entity_type_id');
     $storage = $this->entityManager->getStorage($entity_type_id);
     if (!$storage instanceof RdfEntitySparqlStorage) {
         throw new \Exception('Storage not supported.');
     }
     // The active graph is the published graph. It is handled by the default
     // operation handler.
     // @todo: getActiveGraph is not the default. We should load from settings.
     $default_graph = $storage->getBundleGraphUri($rdf_entity->bundle(), 'default');
     $requested_graph = $storage->getBundleGraphUri($rdf_entity->bundle(), $graph);
     if ($requested_graph == $default_graph) {
         return AccessResult::neutral();
     }
     $active_graph_type = $storage->getRequestGraphs($rdf_entity->id());
     // Check if there is an entity saved in the passed graph.
     $storage->setRequestGraphs($rdf_entity->id(), [$graph]);
     $entity = $storage->load($rdf_entity->id());
     // Restore active graph.
     $storage->setRequestGraphs($rdf_entity->id(), $active_graph_type);
     // @todo: When the requested graph is the only one and it is not the
     // default, it is loaded in the default view, so maybe there is no need
     // to also show a separate tab.
     return AccessResult::allowedIf($entity && $this->checkAccess($rdf_entity, $route, $account, $operation, $graph))->cachePerPermissions()->addCacheableDependency($rdf_entity);
 }
开发者ID:ec-europa,项目名称:joinup-dev,代码行数:30,代码来源:RdfGraphAccessCheck.php


示例12: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $moduleHandler = $this->moduleHandler;
     $moduleHandler->loadInclude('locale', 'inc', 'locale.translation');
     $moduleHandler->loadInclude('locale', 'module');
     $language = $input->getArgument('language');
     $languagesObjects = locale_translatable_language_list();
     $languages = $this->site->getStandardLanguages();
     if (isset($languagesObjects[$language])) {
         $languageEntity = $languagesObjects[$language];
     } elseif (array_search($language, $languages)) {
         $langcode = array_search($language, $languages);
         $languageEntity = $languagesObjects[$langcode];
     } else {
         $io->error(sprintf($this->trans('commands.locale.language.delete.messages.invalid-language'), $language));
         return 1;
     }
     try {
         $configurable_language_storage = $this->entityTypeManager->getStorage('configurable_language');
         $configurable_language_storage->load($languageEntity->getId())->delete();
         $io->info(sprintf($this->trans('commands.locale.language.delete.messages.language-deleted-successfully'), $languageEntity->getName()));
     } catch (\Exception $e) {
         $io->error($e->getMessage());
         return 1;
     }
     return 0;
 }
开发者ID:ranqiangjun,项目名称:DrupalConsole,代码行数:28,代码来源:LanguageDeleteCommand.php


示例13: setUpEntityTypeDefinitions

 /**
  * Sets up the entity type manager to be tested.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface[]|\Prophecy\Prophecy\ProphecyInterface[] $definitions
  *   (optional) An array of entity type definitions.
  */
 protected function setUpEntityTypeDefinitions($definitions = [])
 {
     $class = $this->getMockClass(EntityInterface::class);
     foreach ($definitions as $key => $entity_type) {
         // \Drupal\Core\Entity\EntityTypeInterface::getLinkTemplates() is called
         // by \Drupal\Core\Entity\EntityManager::processDefinition() so it must
         // always be mocked.
         $entity_type->getLinkTemplates()->willReturn([]);
         // Give the entity type a legitimate class to return.
         $entity_type->getClass()->willReturn($class);
         $definitions[$key] = $entity_type->reveal();
     }
     $this->entityTypeManager->getDefinition(Argument::cetera())->will(function ($args) use($definitions) {
         $entity_type_id = $args[0];
         $exception_on_invalid = $args[1];
         if (isset($definitions[$entity_type_id])) {
             return $definitions[$entity_type_id];
         } elseif (!$exception_on_invalid) {
             return NULL;
         } else {
             throw new PluginNotFoundException($entity_type_id);
         }
     });
     $this->entityTypeManager->getDefinitions()->willReturn($definitions);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:31,代码来源:EntityTypeRepositoryTest.php


示例14: onRulesEvent

 /**
  * Reacts on the given event and invokes configured reaction rules.
  *
  * @param \Symfony\Component\EventDispatcher\Event $event
  *   The event object containing context for the event.
  * @param string $event_name
  *   The event name.
  */
 public function onRulesEvent(Event $event, $event_name)
 {
     // Load reaction rule config entities by $event_name.
     $storage = $this->entityTypeManager->getStorage('rules_reaction_rule');
     // @todo Only load active reaction rules here.
     $configs = $storage->loadByProperties(['event' => $event_name]);
     // Set up an execution state with the event context.
     $event_definition = $this->eventManager->getDefinition($event_name);
     $state = ExecutionState::create();
     foreach ($event_definition['context'] as $context_name => $context_definition) {
         // If this is a GenericEvent get the context for the rule from the event
         // arguments.
         if ($event instanceof GenericEvent) {
             $value = $event->getArgument($context_name);
         } else {
             $value = $event->{$context_name};
         }
         $state->setVariable($context_name, $context_definition, $value);
     }
     // Loop over all rules and execute them.
     foreach ($configs as $config) {
         /** @var \Drupal\rules\Entity\ReactionRuleConfig $config */
         $config->getExpression()->executeWithState($state);
     }
     $state->autoSave();
 }
开发者ID:DrupalTV,项目名称:DrupalTV,代码行数:34,代码来源:GenericEventSubscriber.php


示例15: access

 /**
  * Checks access to create an entity of any bundle for the given route.
  *
  * @param \Symfony\Component\Routing\Route $route
  *   The route to check against.
  * @param \Drupal\Core\Routing\RouteMatchInterface $route_match
  *   The parameterized route.
  * @param \Drupal\Core\Session\AccountInterface $account
  *   The currently logged in account.
  *
  * @return \Drupal\Core\Access\AccessResultInterface
  *   The access result.
  */
 public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account)
 {
     $entity_type_id = $route->getRequirement($this->requirementsKey);
     $entity_type = $this->entityTypeManager->getDefinition($entity_type_id);
     $access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type_id);
     // In case there is no "bundle" entity key, check create access with no
     // bundle specified.
     if (!$entity_type->hasKey('bundle')) {
         return $access_control_handler->createAccess(NULL, $account, [], TRUE);
     }
     $access = AccessResult::neutral();
     $bundles = array_keys($this->entityTypeBundleInfo->getBundleInfo($entity_type_id));
     // Include list cache tag as access might change if more bundles are added.
     if ($entity_type->getBundleEntityType()) {
         $access->addCacheTags($this->entityTypeManager->getDefinition($entity_type->getBundleEntityType())->getListCacheTags());
         // Check if the user is allowed to create new bundles. If so, allow
         // access, so the add page can show a link to create one.
         // @see \Drupal\Core\Entity\Controller\EntityController::addPage()
         $bundle_access_control_handler = $this->entityTypeManager->getAccessControlHandler($entity_type->getBundleEntityType());
         $access = $access->orIf($bundle_access_control_handler->createAccess(NULL, $account, [], TRUE));
         if ($access->isAllowed()) {
             return $access;
         }
     }
     // Check whether an entity of any bundle may be created.
     foreach ($bundles as $bundle) {
         $access = $access->orIf($access_control_handler->createAccess($bundle, $account, [], TRUE));
         // In case there is a least one bundle user can create entities for,
         // access is allowed.
         if ($access->isAllowed()) {
             break;
         }
     }
     return $access;
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:48,代码来源:EntityCreateAnyAccessCheck.php


示例16: alterRoutes

 /**
  * {@inheritdoc}
  */
 protected function alterRoutes(RouteCollection $collection) {
   foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
     if ($route = $this->getEntityCloneRoute($entity_type)) {
       $collection->add("entity.$entity_type_id.clone_form", $route);
     }
   }
 }
开发者ID:eloiv,项目名称:botafoc.cat,代码行数:10,代码来源:RouteSubscriber.php


示例17: checkAccess

 protected function checkAccess(ContentEntityInterface $entity, AccountInterface $account, $operation = 'view')
 {
     $entity_type = $entity->getEntityType();
     $entity_type_id = $entity->getEntityTypeId();
     $entity_access = $this->entityTypeManager->getAccessControlHandler($entity_type_id);
     /** @var \Drupal\Core\Entity\EntityStorageInterface $entity_storage */
     $entity_storage = $this->entityTypeManager->getStorage($entity_type_id);
     $map = ['view' => "view all {$entity_type_id} revisions", 'list' => "view all {$entity_type_id} revisions", 'update' => "revert all {$entity_type_id} revisions", 'delete' => "delete all {$entity_type_id} revisions"];
     $bundle = $entity->bundle();
     $type_map = ['view' => "view {$entity_type_id} {$bundle} revisions", 'list' => "view {$entity_type_id} {$bundle} revisions", 'update' => "revert {$entity_type_id} {$bundle} revisions", 'delete' => "delete {$entity_type_id} {$bundle} revisions"];
     if (!$entity || !isset($map[$operation]) || !isset($type_map[$operation])) {
         // If there was no node to check against, or the $op was not one of the
         // supported ones, we return access denied.
         return FALSE;
     }
     // Statically cache access by revision ID, language code, user account ID,
     // and operation.
     $langcode = $entity->language()->getId();
     $cid = $entity->getRevisionId() . ':' . $langcode . ':' . $account->id() . ':' . $operation;
     if (!isset($this->accessCache[$cid])) {
         // Perform basic permission checks first.
         if (!$account->hasPermission($map[$operation]) && !$account->hasPermission($type_map[$operation]) && !$account->hasPermission('administer nodes')) {
             $this->accessCache[$cid] = FALSE;
             return FALSE;
         }
         if (($admin_permission = $entity_type->getAdminPermission()) && $account->hasPermission($admin_permission)) {
             $this->accessCache[$cid] = TRUE;
         } else {
             // First check the access to the default revision and finally, if the
             // node passed in is not the default revision then access to that, too.
             $this->accessCache[$cid] = $entity_access->access($entity_storage->load($entity->id()), $operation, $account) && ($entity->isDefaultRevision() || $entity_access->access($entity, $operation, $account));
         }
     }
     return $this->accessCache[$cid];
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:35,代码来源:EntityRevisionRouteAccessChecker.php


示例18: deleteExistingTerms

 /**
  * Destroy all existing terms before import
  * @param $vid
  * @param $io
  */
 private function deleteExistingTerms($vid = null, DrupalStyle $io)
 {
     //Load the vid
     $termStorage = $this->entityTypeManager->getStorage('taxonomy_term');
     $vocabularies = $this->entityTypeManager->getStorage('taxonomy_vocabulary')->loadMultiple();
     if ($vid !== 'all') {
         $vid = [$vid];
     } else {
         $vid = array_keys($vocabularies);
     }
     foreach ($vid as $item) {
         if (!isset($vocabularies[$item])) {
             $io->error("Invalid vid: {$item}.");
         }
         $vocabulary = $vocabularies[$item];
         $terms = $termStorage->loadTree($vocabulary->id());
         foreach ($terms as $term) {
             $treal = $termStorage->load($term->tid);
             if ($treal !== null) {
                 $io->info("Deleting '{$term->name}' and all translations.");
                 $treal->delete();
             }
         }
     }
 }
开发者ID:ranqiangjun,项目名称:DrupalConsole,代码行数:30,代码来源:DeleteTermCommand.php


示例19: getDescription

 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     $locked = $this->tempStore->getMetadata($this->entity->id());
     $account = $this->entityTypeManager->getStorage('user')->load($locked->owner);
     $username = array('#theme' => 'username', '#account' => $account);
     return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', array('@user' => $this->renderer->render($username)));
 }
开发者ID:curveagency,项目名称:intranet,代码行数:10,代码来源:IndexBreakLockForm.php


示例20: getDescription

 /**
  * {@inheritdoc}
  */
 public function getDescription()
 {
     $locked = $this->rulesUiHandler->getLockMetaData();
     $account = $this->entityTypeManager->getStorage('user')->load($locked->owner);
     $username = ['#theme' => 'username', '#account' => $account];
     return $this->t('By breaking this lock, any unsaved changes made by @user will be lost.', ['@user' => $this->renderer->render($username)]);
 }
开发者ID:Progressable,项目名称:openway8,代码行数:10,代码来源:BreakLockForm.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Entity\EntityFormDisplay类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\EntityTypeInterface类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap