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


PHP Views::getEnabledViews方法代码示例

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


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

示例1: listCalendarViews

 /**
  * Return a list of all calendar views.
  *
  * @return array
  *   A list of all calendar views.
  */
 public static function listCalendarViews()
 {
     $calendar_views = [];
     $views = Views::getEnabledViews();
     foreach ($views as $view) {
         $ve = $view->getExecutable();
         $ve->initDisplay();
         foreach ($ve->displayHandlers->getConfiguration() as $display_id => $display) {
             if ($display_id != 'default' && ($types = $ve->getStyle()->getPluginId() == 'calendar')) {
                 $index = $ve->id() . ':' . $display_id;
                 $calendar_views[$index] = ucfirst($ve->id()) . ' ' . strtolower($display['display_title']) . ' [' . $ve->id() . ':' . $display['id'] . ']';
             }
         }
     }
     return $calendar_views;
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:22,代码来源:CalendarHelper.php

示例2: testViewsListLimit

 /**
  * Tests that the views list does not use a pager.
  */
 public function testViewsListLimit()
 {
     // Check if we can access the main views admin page.
     $this->drupalGet('admin/structure/views');
     $this->assertResponse(200);
     $this->assertLink(t('Add view'));
     // Count default views to be subtracted from the limit.
     $views = count(Views::getEnabledViews());
     // Create multiples views.
     $limit = 51;
     $values = $this->config('views.view.test_view_storage')->get();
     for ($i = 1; $i <= $limit - $views; $i++) {
         $values['id'] = 'test_view_storage_new' . $i;
         unset($values['uuid']);
         $created = View::create($values);
         $created->save();
     }
     $this->drupalGet('admin/structure/views');
     // Check that all the rows are listed.
     $this->assertEqual(count($this->xpath('//tbody/tr[contains(@class,"views-ui-list-enabled")]')), $limit);
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:24,代码来源:ViewsListTest.php

示例3: testLoadFunctions

 /**
  * Tests the load wrapper/helper functions.
  */
 public function testLoadFunctions()
 {
     $this->enableModules(array('field', 'text', 'node'));
     $this->installConfig(array('node'));
     $storage = $this->container->get('entity.manager')->getStorage('view');
     // Test views_view_is_enabled/disabled.
     $archive = $storage->load('archive');
     $this->assertTrue(views_view_is_disabled($archive), 'views_view_is_disabled works as expected.');
     // Enable the view and check this.
     $archive->enable();
     $this->assertTrue(views_view_is_enabled($archive), ' views_view_is_enabled works as expected.');
     // We can store this now, as we have enabled/disabled above.
     $all_views = $storage->loadMultiple();
     // Test Views::getAllViews().
     $this->assertIdentical(array_keys($all_views), array_keys(Views::getAllViews()), 'Views::getAllViews works as expected.');
     // Test Views::getEnabledViews().
     $expected_enabled = array_filter($all_views, function ($view) {
         return views_view_is_enabled($view);
     });
     $this->assertIdentical(array_keys($expected_enabled), array_keys(Views::getEnabledViews()), 'Expected enabled views returned.');
     // Test Views::getDisabledViews().
     $expected_disabled = array_filter($all_views, function ($view) {
         return views_view_is_disabled($view);
     });
     $this->assertIdentical(array_keys($expected_disabled), array_keys(Views::getDisabledViews()), 'Expected disabled views returned.');
     // Test Views::getViewsAsOptions().
     // Test the $views_only parameter.
     $this->assertIdentical(array_keys($all_views), array_keys(Views::getViewsAsOptions(TRUE)), 'Expected option keys for all views were returned.');
     $expected_options = array();
     foreach ($all_views as $id => $view) {
         $expected_options[$id] = $view->label();
     }
     $this->assertIdentical($expected_options, $this->castSafeStrings(Views::getViewsAsOptions(TRUE)), 'Expected options array was returned.');
     // Test the default.
     $this->assertIdentical($this->formatViewOptions($all_views), $this->castSafeStrings(Views::getViewsAsOptions()), 'Expected options array for all views was returned.');
     // Test enabled views.
     $this->assertIdentical($this->formatViewOptions($expected_enabled), $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'enabled')), 'Expected enabled options array was returned.');
     // Test disabled views.
     $this->assertIdentical($this->formatViewOptions($expected_disabled), $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'disabled')), 'Expected disabled options array was returned.');
     // Test the sort parameter.
     $all_views_sorted = $all_views;
     ksort($all_views_sorted);
     $this->assertIdentical(array_keys($all_views_sorted), array_keys(Views::getViewsAsOptions(TRUE, 'all', NULL, FALSE, TRUE)), 'All view id keys returned in expected sort order');
     // Test $exclude_view parameter.
     $this->assertFalse(array_key_exists('archive', Views::getViewsAsOptions(TRUE, 'all', 'archive')), 'View excluded from options based on name');
     $this->assertFalse(array_key_exists('archive:default', Views::getViewsAsOptions(FALSE, 'all', 'archive:default')), 'View display excluded from options based on name');
     $this->assertFalse(array_key_exists('archive', Views::getViewsAsOptions(TRUE, 'all', $archive->getExecutable())), 'View excluded from options based on object');
     // Test the $opt_group parameter.
     $expected_opt_groups = array();
     foreach ($all_views as $view) {
         foreach ($view->get('display') as $display) {
             $expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = (string) t('@view : @display', array('@view' => $view->id(), '@display' => $display['id']));
         }
     }
     $this->assertIdentical($expected_opt_groups, $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'all', NULL, TRUE)), 'Expected option array for an option group returned.');
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:59,代码来源:ModuleTest.php

示例4: checkViewsAccess

 /**
  * @param null $last_check
  * @return array
  */
 private function checkViewsAccess($last_check = NULL)
 {
     $result = TRUE;
     $check_result_value = array();
     $timestamp = NULL;
     $views = \Drupal\views\Views::getEnabledViews();
     // Need review
     foreach ($views as $view) {
         $view_name = $view->get('originalId');
         $view_display = $view->get('display');
         // Access is set in display options of a display.
         foreach ($view_display as $display_name => $display) {
             if (isset($display['display_options']['access']) && $display['display_options']['access']['type'] == 'none') {
                 $check_result_value[$view_name][] = $display_name;
             }
         }
     }
     if (!empty($check_result_value)) {
         $result = FALSE;
     }
     return array('result' => $result, 'value' => $check_result_value);
 }
开发者ID:alexku,项目名称:travisintegrationtest,代码行数:26,代码来源:SecurityReviewController.php


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