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


PHP Views::getDisabledViews方法代码示例

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


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

示例1: 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


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