Piwik\Tracker\Action::factory PHP Метод

factory() публичный статический Метод

Makes the correct Action object based on the request.
public static factory ( Request $request ) : Action
$request Request
Результат Action
    public static function factory(Request $request)
    {
        /** @var Action[] $actions */
        $actions = self::getAllActions($request);
        foreach ($actions as $actionType) {
            if (empty($action)) {
                $action = $actionType;
                continue;
            }
            $posPrevious = self::getPriority($action);
            $posCurrent = self::getPriority($actionType);
            if ($posCurrent > $posPrevious) {
                $action = $actionType;
            }
        }
        if (!empty($action)) {
            return $action;
        }
        return new ActionPageview($request);
    }

Usage Example

 public function processRequestParams(VisitProperties $visitProperties, Request $request)
 {
     // normal page view, potentially triggering a URL matching goal
     $action = Action::factory($request);
     $action->writeDebugInfo();
     $request->setMetadata('Actions', 'action', $action);
     // save the exit actions of the last action in this visit as the referrer actions for the action being tracked.
     // when the visit is updated, these columns will be changed, so we have to do this before recordLogs
     $request->setMetadata('Actions', 'idReferrerActionUrl', $visitProperties->getProperty('visit_exit_idaction_url'));
     $request->setMetadata('Actions', 'idReferrerActionName', $visitProperties->getProperty('visit_exit_idaction_name'));
 }
All Usage Examples Of Piwik\Tracker\Action::factory