예제 #1
0
 /**
  * {@inheritdoc}
  */
 protected function getId($create = TRUE)
 {
     if ($this->currentUser->isAuthenticated()) {
         return $this->currentUser->id();
     } elseif (!$this->session->has('uc_cart_id') && $create) {
         $this->session->set('uc_cart_id', md5(uniqid(rand(), TRUE)));
     }
     return $this->session->has('uc_cart_id') ? $this->session->get('uc_cart_id') : FALSE;
 }
 /**
  * Builds file manager page.
  */
 public function buildPage()
 {
     $page = array();
     $page['#attached']['library'][] = 'imce/drupal.imce';
     // Add meta for robots.
     $robots = array('#tag' => 'meta', '#attributes' => array('name' => 'robots', 'content' => 'noindex,nofollow'));
     $page['#attached']['html_head'][] = array($robots, 'robots');
     // Disable cache
     $page['#cache']['max-age'] = 0;
     // Run builders of available plugins
     \Drupal::service('plugin.manager.imce.plugin')->buildPage($page, $this);
     // Add active path to the conf.
     $conf = $this->conf;
     if (!isset($conf['active_path'])) {
         if ($folder = $this->activeFolder) {
             $conf['active_path'] = $folder->getPath();
         } elseif ($this->user->isAuthenticated() && $this->request && ($path = $this->request->getSession()->get('imce_active_path'))) {
             if ($this->checkFolder($path)) {
                 $conf['active_path'] = $path;
             }
         }
     }
     // Set initial messages.
     if ($messages = $this->getMessages()) {
         $conf['messages'] = $messages;
     }
     $page['#attached']['drupalSettings']['imce'] = $conf;
     return $page;
 }