Generate a new token.

@param  int|string $action
@return string
770193
public function generateToken( $action = -1 ) {
		$action = $action === -1 ? session_id() : $action;
		$this->token = wp_create_nonce( $action );
		return $this->getToken();
	}
560692
public function actionClass(string $action): string
    {
        switch ($action) {
            case ModelHistory::ACTION_CREATE:
                $class = 'success';
                break;
            case ModelHistory::ACTION_DELETE:
                $class = 'danger';
                break;
            case ModelHistory::ACTION_COMMENT:
                $class = 'active';
                break;
            case ModelHistory::ACTION_UPDATE:
            default:
                $class = 'info';
                break;
        }

        return $class;
    }
337687
public function setAction($action)
    {
        $this->action = is_string($action) ? $action : $this->$action;
        $this->prepareUrl();

        return $this;
    }
1071946
public function getActionResult($action = null)
    {
        $result = $this->results;

        if (!empty($action)) {
            $result = $this->results[$action];
        }

        return $result;
    }
965521
public function Link($action = null)
    {
        $link = Controller::join_links(
            AdminRootController::admin_url(),
            $this->config()->get('url_segment'), // in case we want to change the segment
            '/', // trailing slash needed if $action is null!
            "$action"
        );
        $this->extend('updateLink', $link);
        return $link;
    }
923326
public function handle(string $action = null)
    {
        if (!$action)
        {
            $action = $this->request()->getAttribute($this->attribute);
        }

        if ($action === null)
        {
            throw new Path('Action `' . $this->attribute . '` name not found!');
        }

        if (!method_exists($this, $action))
        {
            throw new Runtime('Action `' . $action . '` not found');
        }

        $data = $this->$action(...$this->arguments());

        if (is_object($data) && $data instanceof Dispatcher)
        {
            return $data;
        }

        if (is_string($data) && class_exists($data))
        {
            return new $data($this->factory, $this, $this->cookies);
        }

        return $this->processing($data);
    }
980511
public function getByActionToken(string $token)
	{
		return $this->setAuthorizer($this->getModel()->where('action_token', '=', $token)->first());
	}
297927
protected function getActionPath(string $action): string
    {
        $modelName = $this->getModelName();
        $nameSpace = ucfirst($modelName);

        $className = ucfirst(Str::camel($action)).'Request';

        return app_path('Http/Requests/Api/Admin/'.$nameSpace.'/'.$className.'.php');
    }
1353010
private function createItemAction($action)
    {
        $label = mb_substr($action->label, 0, 12);

        switch (strtolower($action->type)) {
            case Action::TYPE_POSTBACK:
                return new PostbackTemplateActionBuilder($label, $action->value);
            case Action::TYPE_URI:
                return new UriTemplateActionBuilder($label, $action->value);
            default:
                return new MessageTemplateActionBuilder($label, $action->value);
        }
    }
785510
public static function generateToken($payload = null)
    {
        if (empty($payload)) {
            return false;
        }

        $token = JWT::encode($payload, Configure::read('ApiRequest.jwtAuth.cypherKey'), Configure::read('ApiRequest.jwtAuth.tokenAlgorithm'));

        return $token;
    }
464873
public function generateToken()
    {
        do {
            $token = sha1(microtime());
        } while ($this->newQuery()->where(['token' => $token])->count() > 0);

        return $token;
    }
3779
public function urlAdd(string $action, $data = null, string $url = null): string
    {
        if ($this->viaApi($action)) {
            $action = $this->addApiVersion($action);
        }
        $url = $this->urlRemove($url ?: $this->bestUrl($action));

        // $url = $this->c::removeUrlQueryArgs(['utm_source', 'utm_medium', 'utm_campaign', 'utm_content', 'utm_term'], $url);
        // `utm_*` variables are stripped to avoid duplicate sessions as a result of reposting to a URL that included them.
        // Duplicated sessions occur in GA; i.e., a new set of `utm_*` vars triggers a new GA session. Need to avoid this.
        // @TODO ↑ Instead of stripping these away, convert them to `utm-*` internal variables.

        $url = $this->c::addUrlQueryArgs([$this->var => $action, $this->data_var => $data], $url);
        // NOTE: If `$data` is null, it will simply not be included in the URL.

        if (!empty($this->registered_actions[$action]['requires_valid_nonce'])) {
            $url = $this->s::addUrlNonce($url, $action);
        }
        return $url;
    }
820907
private static IAction createAction(String action) {
        IAction actn = null;
        
        if (!StringUtils.isEmpty(action)) {
            if ((actn = ActionRegistry.getRegisteredAction(action)) == null) {
                actn = ActionUtil.createAction(null, action);
            }
        }
        
        return actn;
    }
426891
public static function getMethodFromAction(string $action): string
    {
        $method = str_replace(['.', '-', '_'], ' ', $action);
        $method = ucwords($method);
        $method = str_replace(' ', '', $method);
        $method = lcfirst($method);
        $method .= 'Action';
        return $method;
    }
695820
protected function getTemplateFile(string $action = null) : string
    {
        $path = '/controller/' . lcfirst($this->getControllerName()) . '/';

        return $path . ($action ? $action : $this->getActionName());
    }
551439
public function addAction($action)
    {
        if ($action instanceof Action) {
            $action = $action->getName();
        }
        $this->actionList[] = $action;
        $this->valid = null;

        return $this;
    }
912159
private function createActions($actions)
    {
        $actionBuilders = [];

        foreach ($actions as $action) {
            switch (strtolower($action->type)) {
                case Action::TYPE_POSTBACK:
                    $actionBuilders[] = new PostbackTemplateActionBuilder($action->label, $action->value);
                    break;
                case Action::TYPE_URI:
                    $actionBuilders[] = new UriTemplateActionBuilder($action->label, $action->value);
                    break;
                default:
                    $actionBuilders[] = new MessageTemplateActionBuilder($action->label, $action->value);
            }
        }

        return $actionBuilders;
    }