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

PHP Query\QueryFactory类代码示例

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

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



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

示例1: setUp

 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->entityQuery = $this->getMockBuilder('Drupal\\Core\\Entity\\Query\\QueryInterface')->disableOriginalConstructor()->getMock();
     $this->entityQueryFactory = $this->getMockBuilder('Drupal\\Core\\Entity\\Query\\QueryFactory')->disableOriginalConstructor()->getMock();
     $this->entityQueryFactory->expects($this->any())->method('get')->will($this->returnValue($this->entityQuery));
     parent::setUp();
 }
开发者ID:ravibarnwal,项目名称:laraitassociate.in,代码行数:10,代码来源:DedupeEntityTest.php


示例2: __construct

 /**
  * Generates IVW tracking information.
  *
  * @param EntityManagerInterface $entity_manager
  *   The entity query object for taxonomy terms.
  * @param QueryFactory $query
  *   The entity query object for taxonomy terms.
  * @param ConfigFactoryInterface $config_factory
  *   The config factory service.
  * @param PathMatcher $path_match
  *   The current path match.
  * @param CurrentRouteMatch $current_route_match
  *   The current route match.
  * @param Token $token
  *   Token service.
  */
 public function __construct(EntityManagerInterface $entity_manager, QueryFactory $query, ConfigFactoryInterface $config_factory, PathMatcher $path_match, CurrentRouteMatch $current_route_match, Token $token)
 {
     $this->termStorage = $entity_manager->getStorage('taxonomy_term');
     $this->nodeQuery = $query->get('node');
     $this->configFactory = $config_factory;
     $this->pathMatch = $path_match;
     $this->currentRouteMatch = $current_route_match;
     $this->token = $token;
 }
开发者ID:Cyberschorsch,项目名称:module-ivw_integration,代码行数:25,代码来源:BddIvwTracker.php


示例3: exists

 /**
  * Checks for an existing ECK entity type.
  *
  * @param string|int $entity_id
  *   The entity ID.
  * @param array $element
  *   The form element.
  * @param FormStateInterface $form_state
  *   The form state.
  *
  * @return bool
  *   TRUE if this format already exists, FALSE otherwise.
  */
 public function exists($entity_id, array $element, FormStateInterface $form_state)
 {
     // Use the query factory to build a new event entity query.
     $query = $this->entityQueryFactory->get('eck_entity_type');
     // Query the entity ID to see if its in use.
     $result = $query->condition('id', $element['#field_prefix'] . $entity_id)->execute();
     // We don't need to return the ID, only if it exists or not.
     return (bool) $result;
 }
开发者ID:jokas,项目名称:d8.dev,代码行数:22,代码来源:EckEntityTypeFormBase.php


示例4: __construct

 /**
  * Constructor.
  *
  * @param \Drupal\Core\Entity\EntityFieldManagerInterface $entityFieldManager
  *   The entity field manager.
  * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
  *   The event displatcher.
  * @param \Drupal\Core\Entity\Query\QueryFactory $query_factory
  *   The entity query factory.
  * @param \Drupal\Core\Database\Connection $connection
  *   The database connection.
  * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
  *   The config factory to get flippy settings.
  * @param \Drupal\Core\Utility\Token
  *   Drupal token service.
  * @param \Drupal\Core\Language\LanguageManager
  *   Drupal Language manager service.
  */
 public function __construct(EntityFieldManagerInterface $entityFieldManager, EventDispatcherInterface $event_dispatcher, QueryFactory $query_factory, Connection $connection, ConfigFactoryInterface $config_factory, Token $token, LanguageManager $languageManager)
 {
     $this->entityFieldManager = $entityFieldManager;
     $this->eventDispatcher = $event_dispatcher;
     $this->nodeQuery = $query_factory->get('node');
     $this->connection = $connection;
     $this->flippySettings = $config_factory->get('flippy.settings');
     $this->token = $token;
     $this->languageManager = $languageManager;
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:28,代码来源:FlippyPager.php


示例5: buildOverviewForm

 /**
  * Form constructor to edit an entire menu tree at once.
  *
  * Shows for one menu the menu links accessible to the current user and
  * relevant operations.
  *
  * This form constructor can be integrated as a section into another form. It
  * relies on the following keys in $form_state:
  * - menu: A menu entity.
  * - menu_overview_form_parents: An array containing the parent keys to this
  *   form.
  * Forms integrating this section should call menu_overview_form_submit() from
  * their form submit handler.
  */
 protected function buildOverviewForm(array &$form, array &$form_state)
 {
     // Ensure that menu_overview_form_submit() knows the parents of this form
     // section.
     $form['#tree'] = TRUE;
     $form['#theme'] = 'menu_overview_form';
     $form_state += array('menu_overview_form_parents' => array());
     $form['#attached']['css'] = array(drupal_get_path('module', 'menu') . '/css/menu.admin.css');
     $links = array();
     $query = $this->entityQueryFactory->get('menu_link')->condition('menu_name', $this->entity->id());
     for ($i = 1; $i <= MENU_MAX_DEPTH; $i++) {
         $query->sort('p' . $i, 'ASC');
     }
     $result = $query->execute();
     if (!empty($result)) {
         $links = $this->menuLinkStorage->loadMultiple($result);
     }
     $delta = max(count($links), 50);
     // We indicate that a menu administrator is running the menu access check.
     $this->getRequest()->attributes->set('_menu_admin', TRUE);
     $tree = $this->menuTree->buildTreeData($links);
     $this->getRequest()->attributes->set('_menu_admin', FALSE);
     $form = array_merge($form, $this->buildOverviewTreeForm($tree, $delta));
     $form['#empty_text'] = t('There are no menu links yet. <a href="@link">Add link</a>.', array('@link' => url('admin/structure/menu/manage/' . $this->entity->id() . '/add')));
     return $form;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:40,代码来源:MenuForm.php


示例6: build

 /**
  * {@inheritdoc}
  */
 public function build()
 {
     $items = array();
     // When on a node page, the parameter is already upcast as a node.
     $node = \Drupal::routeMatch()->getParameter('node');
     if ($node) {
         // Read about entity query at http://www.sitepoint.com/drupal-8-version-entityfieldquery/.
         // See query API at https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Query%21QueryInterface.php/interface/QueryInterface/8.
         // The static method for using the query service would have been:
         // $query = \Drupal::entityQuery('node');
         // Use injected queryFactory to look for items that are related
         // to the show that matches the input nid.
         $query = $this->entity_query->get('node')->condition('status', 1)->condition('type', 'tv_episode')->sort('field_related_season.entity.field_season_number.value', 'DESC')->sort('field_episode_number', 'DESC')->range(0, 5)->condition('field_related_season.entity.field_related_show.entity.nid', $node->id());
         $nids = $query->execute();
         // Note that entity_load() is deprecated.
         // The static method of loading the entity would have been:
         // \Drupal\node\Entity\Node::load();
         // Use the injected entityManager to load the results into an array of node objects.
         $nodes = $this->entity_manager->getStorage('node')->loadMultiple($nids);
         foreach ($nodes as $node) {
             // Create a render array for each title field.
             // Note that field_view_field() is deprecated, use the view method on the field.
             $title = $node->title->view('full');
             // Entities have a handy toLink() method.
             $items[] = $node->toLink($title);
         }
     }
     // Return a render array for a html list.
     return ['#theme' => 'item_list', '#items' => $items, '#cache' => ['contexts' => ['route']]];
 }
开发者ID:Lullabot,项目名称:challenge4,代码行数:33,代码来源:DemoBlock.php


示例7: helloWorld

 /**
  * Say hello to the world.
  *
  * @return string
  *   Return "Hello world!" string.
  */
 public function helloWorld(EntityViewModeInterface $viewmode)
 {
     $content = ['#type' => 'markup', '#markup' => $this->t('Hello world!')];
     // Second version displaying the opening hours of the library.
     $opening_hours = $this->config('happy_alexandrie.library_config')->get('opening_hours');
     if (!empty($opening_hours)) {
         $content = ['#markup' => $this->t('<p>Greetings dear adventurer!</p><p>Opening hours:<br />@opening_hours</p>', array('@opening_hours' => $opening_hours))];
     }
     // Third version with the query
     // Query against our entities.
     $query = $this->query_factory->get('node')->condition('status', 1)->condition('type', 'alexandrie_book')->condition('changed', REQUEST_TIME, '<')->range(0, 5);
     $nids = $query->execute();
     if ($nids) {
         // Load the storage manager of our entity.
         $storage = $this->entity_manager->getStorage('node');
         // Now we can load the entities.
         $nodes = $storage->loadMultiple($nids);
         list($entity_type, $viewmode_name) = explode('.', $viewmode->getOriginalId());
         // Get the EntityViewBuilder instance.
         $render_controller = $this->entity_manager->getViewBuilder('node');
         $build = $render_controller->viewMultiple($nodes, $viewmode_name);
         $build['#markup'] = $this->t('Happy Query by view mode: @label', array('@label' => $viewmode->label()));
         $content[] = $build;
     } else {
         $content[] = array('#markup' => $this->t('No result'));
     }
     return $content;
 }
开发者ID:Happyculture,项目名称:exercices,代码行数:34,代码来源:AlexandrieController.php


示例8: interact

 /**
  * {@inheritdoc}
  */
 protected function interact(InputInterface $input, OutputInterface $output)
 {
     $io = new DrupalStyle($input, $output);
     $viewId = $input->getArgument('view-id');
     if (!$viewId) {
         $views = $this->entityQuery->get('view')->condition('status', 1)->execute();
         $viewId = $io->choiceNoList($this->trans('commands.views.debug.arguments.view-id'), $views);
         $input->setArgument('view-id', $viewId);
     }
 }
开发者ID:ddrozdik,项目名称:DrupalConsole,代码行数:13,代码来源:DisableCommand.php


示例9: load

 /**
  * {@inheritdoc}
  */
 public function load()
 {
     $entity_query = $this->queryFactory->get('user');
     $entity_query->condition('uid', 0, '<>');
     $entity_query->pager(50);
     $header = $this->buildHeader();
     $entity_query->tableSort($header);
     $uids = $entity_query->execute();
     return $this->storage->loadMultiple($uids);
 }
开发者ID:shumer,项目名称:blog,代码行数:13,代码来源:UserListBuilder.php


示例10: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $blocks = $this->queryFactory->get('block_content')->condition('type', $this->entity->id())->execute();
     if (!empty($blocks)) {
         $caption = '<p>' . format_plural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '</p>';
         $form['description'] = array('#markup' => $caption);
         return $form;
     } else {
         return parent::buildForm($form, $form_state);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:14,代码来源:BlockContentTypeDeleteForm.php


示例11: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $num_nodes = $this->queryFactory->get('node')->condition('type', $this->entity->id())->count()->execute();
     if ($num_nodes) {
         $caption = '<p>' . format_plural($num_nodes, '%type is used by 1 piece of content on your site. You can not remove this content type until you have removed all of the %type content.', '%type is used by @count pieces of content on your site. You may not remove %type until you have removed all of the %type content.', array('%type' => $this->entity->label())) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = array('#markup' => $caption);
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:14,代码来源:NodeTypeDeleteConfirm.php


示例12: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $product_count = $this->queryFactory->get('commerce_product')->condition('type', $this->entity->id())->count()->execute();
     if ($product_count) {
         $caption = '<p>' . $this->formatPlural($product_count, '%type is used by 1 product on your site. You can not remove this product type until you have removed all of the %type products.', '%type is used by @count products on your site. You may not remove %type until you have removed all of the %type products.', ['%type' => $this->entity->label()]) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = ['#markup' => $caption];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:marmouset,项目名称:drupal,代码行数:14,代码来源:ProductTypeDeleteForm.php


示例13: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $num_profiles = $this->queryFactory->get('profile')->condition('type', $this->entity->id())->count()->execute();
     if ($num_profiles) {
         $caption = '<p>' . \Drupal::translation()->formatPlural($num_profiles, '%type is used by 1 profile on your site. You can not remove this profile type until you have removed all of the %type profiles.', '%type is used by @count profiles on your site. You may not remove %type until you have removed all of the %type profiles.', ['%type' => $this->entity->label()]) . '</p>';
         $form['#title'] = $this->entity->label();
         $form['description'] = ['#markup' => $caption];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:darrylri,项目名称:protovbmwmo,代码行数:14,代码来源:ProfileTypeDeleteForm.php


示例14: titleQuery

 /**
  * Override the behavior of titleQuery(). Get the filenames.
  */
 public function titleQuery()
 {
     $fids = $this->entityQuery->get('file')->condition('fid', $this->value, 'IN')->execute();
     $controller = $this->entityManager->getStorage('file');
     $files = $controller->loadMultiple($fids);
     $titles = array();
     foreach ($files as $file) {
         $titles[] = $file->getFilename();
     }
     return $titles;
 }
开发者ID:neetumorwani,项目名称:blogging,代码行数:14,代码来源:Fid.php


示例15: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $num_support_tickets = $this->queryFactory->get('support_ticket')->condition('support_ticket_type', $this->entity->id())->count()->execute();
     if ($num_support_tickets) {
         $caption = '<p>' . $this->formatPlural($num_support_tickets, '%type is used by 1 ticket on your site. You can not remove this support ticket type until you have removed all of the %type tickets.', '%type is used by @count tickets on your site. You may not remove %type until you have removed all of the %type tickets.', array('%type' => $this->entity->label())) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = array('#markup' => $caption);
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:14,代码来源:SupportTicketTypeDeleteConfirm.php


示例16: validatePath

 /**
  * {@inheritdoc}
  */
 public function validatePath(&$element, FormStateInterface $form_state)
 {
     // Ensure the path has a leading slash.
     $value = '/' . trim($element['#value'], '/');
     $form_state->setValueForElement($element, $value);
     // Ensure each path is unique.
     $path = $this->entityQuery->get('page')->condition('path', $value)->condition('id', $form_state->getValue('id'), '<>')->execute();
     if ($path) {
         $form_state->setErrorByName('path', $this->t('The page path must be unique.'));
     }
 }
开发者ID:neeravbm,项目名称:unify-d8,代码行数:14,代码来源:PageFormBase.php


示例17: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $num_paragraphs = $this->queryFactory->get('paragraph')->condition('type', $this->entity->id())->count()->execute();
     if ($num_paragraphs) {
         $caption = '<p>' . $this->formatPlural($num_paragraphs, '%type Paragraphs type is used by 1 piece of content on your site. You can not remove this %type Paragraphs type until you have removed all from the content.', '%type Paragraphs type is used by @count pieces of content on your site. You may not remove %type Paragraphs type until you have removed all from the content.', ['%type' => $this->entity->label()]) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = ['#markup' => $caption];
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:eric-shell,项目名称:eric-shell-d8,代码行数:14,代码来源:ParagraphsTypeDeleteConfirm.php


示例18: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Check if any entity of this type already exists.
     $content_number = $this->queryFactory->get($this->entity->getEntityType()->getBundleOf())->condition('type', $this->entity->id())->count()->execute();
     if (!empty($content_number)) {
         $warning_message = '<p>' . $this->formatPlural($content_number, '%type is used by 1 entity on your site. You can not remove this entity type until you have removed all of the %type entities.', '%type is used by @count entities on your site. You may not remove %type until you have removed all of the %type entities.', array('%type' => $this->entity->label())) . '</p>';
         $form['#title'] = $this->getQuestion();
         $form['description'] = array('#markup' => $warning_message);
         return $form;
     }
     return parent::buildForm($form, $form_state);
 }
开发者ID:jokas,项目名称:d8.dev,代码行数:15,代码来源:EckEntityBundleDeleteConfirm.php


示例19: getDerivativeDefinitions

 /**
  * {@inheritdoc}
  */
 public function getDerivativeDefinitions($base_plugin_definition)
 {
     // Get all custom menu links which should be rediscovered.
     $entity_ids = $this->queryFactory->get('menu_link_content')->condition('rediscover', TRUE)->execute();
     $plugin_definitions = [];
     $menu_link_content_entities = $this->entityManager->getStorage('menu_link_content')->loadMultiple($entity_ids);
     /** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */
     foreach ($menu_link_content_entities as $menu_link_content) {
         $plugin_definitions[$menu_link_content->uuid()] = $menu_link_content->getPluginDefinition();
     }
     return $plugin_definitions;
 }
开发者ID:sarahwillem,项目名称:OD8,代码行数:15,代码来源:MenuLinkContentDeriver.php


示例20: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     // Get the custom entity ID.
     $custom_entity_id = $this->entity->getEntityType()->getBundleOf();
     $entities = $this->queryFactory->get($custom_entity_id)->condition('type', $this->entity->id())->execute();
     if (!empty($entities)) {
         $caption = '<p>' . $this->formatPlural(count($entities), '%label is used by 1 entity on your site. You can not remove this entity type until you have removed all of the %label entities.', '%label is used by @count entities on your site. You may not remove %label until you have removed all of the %label entities.', ['%label' => $this->entity->label()]) . '</p>';
         $form['description'] = array('#markup' => $caption);
         return $form;
     } else {
         return parent::buildForm($form, $form_state);
     }
 }
开发者ID:jmolivas,项目名称:content_entity_base,代码行数:16,代码来源:EntityTypeBaseDeleteForm.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Extension\ExtensionDiscovery类代码示例发布时间:2022-05-23
下一篇:
PHP Entity\EntityViewDisplay类代码示例发布时间: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