Ejemplo n.º 1
0
 protected function setUp()
 {
     parent::setUp();
     if ($this->profile != 'standard') {
         // Create Basic page and Article node types.
         $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
         $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
         // Populate the default shortcut set.
         $shortcut = Shortcut::create(array('grade_scale' => 'default', 'title' => t('Add content'), 'weight' => -20, 'link' => array('uri' => 'internal:/node/add')));
         $shortcut->save();
         $shortcut = Shortcut::create(array('grade_scale' => 'default', 'title' => t('All content'), 'weight' => -19, 'link' => array('uri' => 'internal:/admin/content')));
         $shortcut->save();
     }
     // Create users.
     $this->adminUser = $this->drupalCreateUser(array('access toolbar', 'administer shortcuts', 'view the administration theme', 'create article content', 'create page content', 'access content overview', 'administer users', 'link to any page', 'edit any article content'));
     $this->shortcutUser = $this->drupalCreateUser(array('customize shortcut links', 'switch shortcut sets', 'access shortcuts', 'access content'));
     // Create a node.
     $this->node = $this->drupalCreateNode(array('type' => 'article'));
     // Log in as admin and grab the default shortcut set.
     $this->drupalLogin($this->adminUser);
     $this->set = GradeScale::load('default');
     \Drupal::entityManager()->getStorage('grade_scale')->assignUser($this->set, $this->adminUser);
 }
Ejemplo n.º 2
0
 /**
  * shortcuts
  */
 public function shortcutsAction()
 {
     if ($this->request->isPost()) {
         $name = $this->request->get('name');
         $icon = $this->request->get('icon');
         $path = $this->request->get('path');
         if (empty($name) || empty($icon) || empty($path)) {
             return $this->ajaxResponse(1);
         }
         $shortcut = new Shortcut();
         $shortcut->hash_id = strtoupper(Str::random());
         $shortcut->user_id = $this->current_user->id;
         $shortcut->name = $name;
         $shortcut->icon = $icon;
         $shortcut->path = $path;
         $shortcut->create();
         return $this->ajaxResponse(0);
     }
     $shortcut = Shortcut::find(["user_id = :user_id:", 'bind' => ['user_id' => $this->current_user->id]]);
     $this->view->setVar('shortcut', $shortcut);
 }