Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function renderItems($items)
 {
     if ($this->options['hide_single_bundle'] && $this->bundleCount < 2) {
         return '';
     }
     return parent::renderItems($items);
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function access(AccountInterface $account)
 {
     $bundles = $this->entityManager->getBundleInfo($this->getEntityType());
     if ($this->options['hide_single_bundle'] && count($bundles) <= 1) {
         return FALSE;
     }
     return parent::access($account);
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function access(AccountInterface $account)
 {
     $store_query = $this->entityManager->getStorage('commerce_store')->getQuery();
     $store_count = $store_query->count()->execute();
     if ($this->options['hide_single_store'] && $store_count <= 1) {
         return FALSE;
     }
     return parent::access($account);
 }
Пример #4
0
 /**
  * {@inheritdoc}
  */
 public function getItems(ResultRow $values)
 {
     $items = parent::getItems($values);
     foreach ($items as &$item) {
         // Work out the depth of this comment.
         $comment_thread = $item['rendered']['#markup'];
         $item['rendered']['#markup'] = count(explode('.', $comment_thread)) - 1;
     }
     return $items;
 }
Пример #5
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     $form['convert_spaces'] = array('#title' => $this->t('Convert spaces in term names to hyphens'), '#type' => 'checkbox', '#default_value' => !empty($this->options['convert_spaces']));
     parent::buildOptionsForm($form, $form_state);
 }
Пример #6
0
 /**
  * {@inheritdoc}
  */
 public function renderItems($items)
 {
     if (!$this->options['field_rendering']) {
         if ($this->fallbackHandler instanceof MultiItemsFieldHandlerInterface) {
             return $this->fallbackHandler->renderItems($items);
         }
         return '';
     }
     return parent::renderItems($items);
 }
Пример #7
0
 /**
  * @dataProvider providerSortOrders
  *
  * @param string $order
  *   The sort order.
  *
  * @covers ::clickSort
  */
 public function testClickSortWithConfiguredField($order)
 {
     $definition = ['entity_type' => 'test_entity', 'field_name' => 'body'];
     $handler = new Field([], 'field', $definition, $this->entityManager, $this->formatterPluginManager, $this->fieldTypePluginManager, $this->languageManager, $this->renderer);
     $handler->view = $this->executable;
     $field_storage = $this->getConfigFieldStorage();
     $this->entityManager->expects($this->atLeastOnce())->method('getFieldStorageDefinitions')->with('test_entity')->willReturn(['body' => $field_storage]);
     $table_mapping = $this->getMock('Drupal\\Core\\Entity\\Sql\\TableMappingInterface');
     $table_mapping->expects($this->atLeastOnce())->method('getFieldColumnName')->with($field_storage, 'value')->willReturn('body_value');
     $entity_storage = $this->getMock('Drupal\\Core\\Entity\\Sql\\SqlEntityStorageInterface');
     $entity_storage->expects($this->atLeastOnce())->method('getTableMapping')->willReturn($table_mapping);
     $this->entityManager->expects($this->atLeastOnce())->method('getStorage')->with('test_entity')->willReturn($entity_storage);
     // Setup a click sort configuration.
     $options = ['click_sort_column' => 'value', 'table' => 'test_entity__body'];
     $handler->init($this->executable, $this->display, $options);
     $handler->query = $this->getMockBuilder('Drupal\\views\\Plugin\\views\\query\\Sql')->disableOriginalConstructor()->getMock();
     $handler->query->expects($this->atLeastOnce())->method('ensureTable')->with('test_entity__body', NULL)->willReturn('test_entity__body_alias');
     $handler->query->expects($this->atLeastOnce())->method('addOrderBy')->with(NULL, NULL, $order, 'test_entity__body_alias.body_value', []);
     $handler->clickSort($order);
 }
Пример #8
0
 /**
  * {@inheritdoc}
  */
 public function renderItems($items)
 {
     if ($this->options['hide_single_bundle']) {
         $entity_type = $this->getEntityType();
         $bundles = $this->entityTypeBundleInfo->getBundleInfo($entity_type);
         // Hide bundle name if there's only one bundle.
         if (count($bundles) == 1) {
             return '';
         }
     }
     return parent::renderItems($items);
 }
Пример #9
0
 /**
  * {@inheritdoc}
  */
 public function buildOptionsForm(&$form, FormStateInterface $form_state)
 {
     parent::buildOptionsForm($form, $form_state);
     // Remote the click sort field selector.
     unset($form['click_sort_column']);
 }