コード例 #1
0
ファイル: ShortcutSet.php プロジェクト: nstielau/drops-8
 /**
  * {@inheritdoc}
  */
 public function postSave(EntityStorageInterface $storage, $update = TRUE)
 {
     parent::postSave($storage, $update);
     if (!$update && !$this->isSyncing()) {
         // Save a new shortcut set with links copied from the user's default set.
         $default_set = shortcut_default_set();
         // This is the default set, do not copy shortcuts.
         if ($default_set->id() != $this->id()) {
             foreach ($default_set->getShortcuts() as $shortcut) {
                 $shortcut = $shortcut->createDuplicate();
                 $shortcut->enforceIsNew();
                 $shortcut->shortcut_set->target_id = $this->id();
                 $shortcut->save();
             }
         }
     }
 }
コード例 #2
0
ファイル: ShortcutSetsTest.php プロジェクト: 318io/318-io
 /**
  * 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.");
 }
コード例 #3
0
ファイル: GradeScaleTest.php プロジェクト: dakala/gradebook
 /**
  * Tests unassigning a shortcut set.
  */
 function testGradeScaleUnassign()
 {
     $new_set = $this->generateGradeScale($this->randomMachineName());
     $grade_scale_storage = \Drupal::entityManager()->getStorage('grade_scale');
     $grade_scale_storage->assignUser($new_set, $this->shortcutUser);
     $grade_scale_storage->unassignUser($this->shortcutUser);
     $current_set = grade_scale_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 grade scale.");
 }
コード例 #4
0
 /**
  * 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.");
 }