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

PHP shortcut_current_displayed_set函数代码示例

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

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



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

示例1: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, UserInterface $user = NULL)
 {
     $account = $this->currentUser();
     $this->user = $user;
     // Prepare the list of shortcut sets.
     $options = array_map(function (ShortcutSet $set) {
         return $set->label();
     }, $this->shortcutSetStorage->loadMultiple());
     $current_set = shortcut_current_displayed_set($this->user);
     // Only administrators can add shortcut sets.
     $add_access = $account->hasPermission('administer shortcuts');
     if ($add_access) {
         $options['new'] = $this->t('New set');
     }
     $account_is_user = $this->user->id() == $account->id();
     if (count($options) > 1) {
         $form['set'] = array('#type' => 'radios', '#title' => $account_is_user ? $this->t('Choose a set of shortcuts to use') : $this->t('Choose a set of shortcuts for this user'), '#options' => $options, '#default_value' => $current_set->id());
         $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#description' => $this->t('The new set is created by copying items from your default shortcut set.'), '#access' => $add_access, '#states' => array('visible' => array(':input[name="set"]' => array('value' => 'new')), 'required' => array(':input[name="set"]' => array('value' => 'new'))));
         $form['id'] = array('#type' => 'machine_name', '#machine_name' => array('exists' => array($this, 'exists'), 'replace_pattern' => '[^a-z0-9-]+', 'replace' => '-'), '#maxlength' => 23, '#states' => array('required' => array(':input[name="set"]' => array('value' => 'new'))), '#required' => FALSE);
         if (!$account_is_user) {
             $default_set = $this->shortcutSetStorage->getDefaultSet($this->user);
             $form['new']['#description'] = $this->t('The new set is created by copying items from the %default set.', array('%default' => $default_set->label()));
         }
         $form['actions'] = array('#type' => 'actions');
         $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Change set'));
     } else {
         // There is only 1 option, so output a message in the $form array.
         $form['info'] = array('#markup' => '<p>' . $this->t('You are currently using the %set-name shortcut set.', array('%set-name' => $current_set->label())) . '</p>');
     }
     return $form;
 }
开发者ID:HakS,项目名称:drupal8_training,代码行数:34,代码来源:SwitchShortcutSet.php


示例2: testShortcutSetUsersMigration

 /**
  * Test the shortcut set migration.
  */
 public function testShortcutSetUsersMigration() {
   // Check if migrated user has correct migrated shortcut set assigned.
   $account = User::load(2);
   $shortcut_set = shortcut_current_displayed_set($account);
   /** @var \Drupal\shortcut\ShortcutSetInterface $shortcut_set */
   $this->assertIdentical('shortcut_set_2', $shortcut_set->id());
 }
开发者ID:Greg-Boggs,项目名称:electric-dev,代码行数:10,代码来源:MigrateShortcutSetUsersTest.php


示例3: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account)
 {
     switch ($operation) {
         case 'update':
             if ($account->hasPermission('administer shortcuts')) {
                 return AccessResult::allowed()->cachePerPermissions();
             }
             if (!$account->hasPermission('access shortcuts')) {
                 return AccessResult::neutral()->cachePerPermissions();
             }
             return AccessResult::allowedIf($account->hasPermission('customize shortcut links') && $entity == shortcut_current_displayed_set($account))->cachePerPermissions()->addCacheableDependency($entity);
         case 'delete':
             return AccessResult::allowedIf($account->hasPermission('administer shortcuts') && $entity->id() != 'default')->cachePerPermissions();
         default:
             // No opinion.
             return AccessResult::neutral();
     }
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:21,代码来源:ShortcutSetAccessControlHandler.php


示例4: checkAccess

 /**
  * {@inheritdoc}
  */
 protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account)
 {
     switch ($operation) {
         case 'update':
             if ($account->hasPermission('administer shortcuts')) {
                 return TRUE;
             }
             if (!$account->hasPermission('access shortcuts')) {
                 return FALSE;
             }
             if ($account->hasPermission('customize shortcut links')) {
                 return $entity == shortcut_current_displayed_set($account);
             }
             return FALSE;
             break;
         case 'delete':
             if (!$account->hasPermission('administer shortcuts')) {
                 return FALSE;
             }
             return $entity->id() != 'default';
             break;
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:26,代码来源:ShortcutSetAccessController.php


示例5: testShortcutSetUnassign

 /**
  * Tests unassigning a shortcut set.
  */
 function testShortcutSetUnassign()
 {
     $new_set = $this->generateShortcutSet($this->randomMachineName());
     $shortcut_set_storage = \Drupal::entityManager()->getStorage('shortcut_set');
     $shortcut_set_storage->assignUser($new_set, $this->shortcutUser);
     $shortcut_set_storage->unassignUser($this->shortcutUser);
     $current_set = shortcut_current_displayed_set($this->shortcutUser);
     $default_set = shortcut_default_set($this->shortcutUser);
     $this->assertTrue($current_set->id() == $default_set->id(), "Successfully unassigned another user's shortcut set.");
 }
开发者ID:318io,项目名称:318-io,代码行数:13,代码来源:ShortcutSetsTest.php


示例6: build

 /**
  * {@inheritdoc}
  */
 public function build()
 {
     return array(shortcut_renderable_links(shortcut_current_displayed_set()));
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:7,代码来源:ShortcutsBlock.php


示例7: testShortcutSetUnassign

 /**
  * Tests unassigning a shortcut set.
  */
 function testShortcutSetUnassign()
 {
     $new_set = $this->generateShortcutSet($this->randomMachineName());
     shortcut_set_assign_user($new_set, $this->shortcut_user);
     shortcut_set_unassign_user($this->shortcut_user);
     $current_set = shortcut_current_displayed_set($this->shortcut_user);
     $default_set = shortcut_default_set($this->shortcut_user);
     $this->assertTrue($current_set->id() == $default_set->id(), "Successfully unassigned another user's shortcut set.");
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:12,代码来源:ShortcutSetsTest.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP shorten函数代码示例发布时间:2022-05-24
下一篇:
PHP shortcode_unautop函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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