/**
  * Set up the tests object
  */
 public function setUp()
 {
     parent::setUp();
     $token = new Token();
     foreach ($this->tokenConsts as $scope) {
         $this->tokensCollection[$scope] = Collection::make();
         for ($i = 0; $i <= 4; $i++) {
             $item = $token->newInstance(['token_name' => 'val_' . ($i + 1), 'token_value' => "val-{$scope}-" . ($i + 1), 'token_scope' => $scope]);
             $this->tokensCollection[$scope]->add($item);
         }
     }
 }
 /**
  * Inject the tokens into each scope
  *
  * @param CmsController $controller
  *
  * @return $this
  */
 public function initScopeTokens(CmsController $controller = null)
 {
     if (!$controller instanceof CmsController) {
         return $this;
     }
     $scopeBase =& $controller->vars['this'];
     foreach ($this->getScopeTokens() as $tokenScope) {
         $tokens = TokensModel::tokenScope($tokenScope)->get();
         if (self::TOKEN_SCOPE_GLOBAL === $tokenScope) {
             $scopeBase[$this->tmplTag] = new \stdClass();
             $scope =& $scopeBase[$this->tmplTag];
         } else {
             $scopeBase[$tokenScope]->tk = new \stdClass();
             $scope =& $scopeBase[$tokenScope]->{$this->tmplTag};
         }
         $scope = $this->initScope($tokenScope, $tokens);
         unset($scope);
     }
     return $this;
 }
 /**
  * Delete one or more tokens
  *
  * @return mixed
  *
  * @throws TokenException
  */
 public function onDelete()
 {
     $checkedIds = post('checked') ?: (array) post('record_id');
     try {
         if (is_array($checkedIds) && count($checkedIds)) {
             foreach ($checkedIds as $recordId) {
                 if (!($record = Token::find($recordId))) {
                     continue;
                 }
                 $record->delete();
             }
             Flash::success(Lang::get('backend::lang.list.delete_selected_success'));
         } else {
             Flash::error(Lang::get('backend::lang.list.delete_selected_empty'));
         }
     } catch (QueryException $exc) {
         App::make('Illuminate\\Contracts\\Debug\\ExceptionHandler')->report($exc);
         throw new TokenException('', $exc->getCode());
     }
     return $this->listRefresh();
 }
 public function run()
 {
     Token::create(['token_name' => 'app_name', 'token_value' => BrandSetting::get('app_name'), 'token_scope' => TokensService::TOKEN_SCOPE_GLOBAL]);
     Token::create(['token_name' => 'app_tagline', 'token_value' => BrandSetting::get('app_tagline'), 'token_scope' => TokensService::TOKEN_SCOPE_GLOBAL]);
 }