Generate route and save route-path.

@param AbstractMappingEvent $event
482757
public function handlePersist(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();
        if (!$document instanceof RoutablePageBehavior) {
            return;
        }

        $document->setUuid($event->getNode()->getIdentifier());

        $propertyName = $this->getRoutePathPropertyName($document->getStructureType(), $event->getLocale());
        $routePath = $event->getNode()->getPropertyValueWithDefault($propertyName, null);

        $route = $this->conflictResolver->resolve($this->chainRouteGenerator->generate($document, $routePath));
        $document->setRoutePath($route->getPath());

        $event->getNode()->setProperty($propertyName, $route->getPath());

        if (!$document instanceof ChildrenBehavior) {
            return;
        }

        foreach ($document->getChildren() as $child) {
            if (!$child instanceof RoutablePageBehavior) {
                continue;
            }

            $route = $this->chainRouteGenerator->generate($child);
            $child->setRoutePath($route->getPath());

            $node = $this->documentInspector->getNode($child);
            $node->setProperty($propertyName, $route->getPath());
        }
    }
656210
private function callAppEvent(AbstractApp $app, string $event)
    {
        if (method_exists($app, $event)) {
            return call_user_func([
                $app,
                $event
            ]);
        }
    }
692854
private function executeEvent(AbstractEvent $event)
    {
        $eventName = ClassUtils::getShortName($event);
        $method    = sprintf('apply%s', (string) $eventName);

        if (!method_exists($this, $method)) {
            throw new BadMethodCallException(
                sprintf(
                    'You must define the %s::%s(%s $event) method in order to apply event named "%s".',
                    get_class($this),
                    $method,
                    get_class($event),
                    $eventName
                )
            );
        }

        $this->$method($event);
    }
941723
public function handle(string $event, callable $callback): Route
    {
        $route = $this->data
            ->createRoute($event, $callback)
            ->set('priority', $this->crtPriority);

        $this->data->sort();

        return $route;
    }
742728
public function run($event='before') {
		if (!isset($this->routes[$event]))
			return true;
		$paths=[];
		foreach ($keys=array_keys($this->routes[$event]) as $key) {
			$path=preg_replace('/@\w+/','*@',$key);
			if (substr($path,-1)!='*')
				$path.='+';
			$paths[]=$path;
		}
		$vals=array_values($this->routes[$event]);
		array_multisort($paths,SORT_DESC,$keys,$vals);
		$this->routes[$event]=array_combine($keys,$vals);
		// Convert to BASE-relative URL
		$req=urldecode($this->f3['PATH']);
		foreach ($this->routes[$event] as $pattern=>$routes) {
			if (!$args=$this->f3->mask($pattern,$req))
				continue;
			ksort($args);
			$route=NULL;
			$ptr=$this->f3->CLI?\Base::REQ_CLI:$this->f3->AJAX+1;
			if (isset($routes[$ptr][$this->f3->VERB]) ||
				isset($routes[$ptr=0]))
				$route=$routes[$ptr];
			if (!$route)
				continue;
			if ($this->f3->VERB!='OPTIONS' &&
				isset($route[$this->f3->VERB])) {
				if ($this->f3['VERB']=='GET' &&
					preg_match('/.+\/$/',$this->f3['PATH']))
					$this->f3->reroute(substr($this->f3['PATH'],0,-1).
						($this->f3['QUERY']?('?'.$this->f3['QUERY']):''));
				$handler=$route[$this->f3->VERB][0];
				$alias=$route[$this->f3->VERB][3];
				if (is_string($handler)) {
					// Replace route pattern tokens in handler if any
					$handler=preg_replace_callback('/({)?@(\w+\b)(?(1)})/',
						function($id) use($args) {
							$pid=count($id)>2?2:1;
							return isset($args[$id[$pid]])?
								$args[$id[$pid]]:
								$id[0];
						},
						$handler
					);
					if (preg_match('/(.+)\h*(?:->|::)/',$handler,$match) &&
						!class_exists($match[1]))
						$this->f3->error(500,'PreRoute handler not found');
				}
				if (!$this->f3['RAW'] && !$this->f3['BODY'])
					$this->f3['BODY']=file_get_contents('php://input');
				// Call route handler
				return $this->f3->call($handler,array($this->f3,$args,$alias),
					'beforeroute,afterroute') !== FALSE;
			}
		}
		return true;
	}
237794
public function handleSetNodeOnPersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        $options = $event->getOptions();
        if (!$document instanceof RouteBehavior || !array_key_exists('path', $options)) {
            return;
        }

        $parentPath = PathHelper::getParentPath($options['path']);
        $parentNode = $this->nodeManager->createPath($parentPath);

        $nodeName = PathHelper::getNodeName($options['path']);
        if (!$parentNode->hasNode($nodeName)) {
            return;
        }

        $node = $parentNode->getNode($nodeName);
        if ($node->hasProperty(self::NODE_HISTORY_FIELD)) {
            return;
        }

        $event->setNode($node);
        $event->setParentNode($parentNode);
    }
479336
public function handleHydrate(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();

        if (!$document instanceof ShadowLocaleBehavior || !$event->getOption('load_shadow_content')) {
            return;
        }

        $node = $event->getNode();
        $locale = $this->inspector->getOriginalLocale($document);
        $shadowLocaleEnabled = $this->getShadowLocaleEnabled($node, $locale);
        $document->setShadowLocaleEnabled($shadowLocaleEnabled);

        if (!$shadowLocaleEnabled) {
            return;
        }

        $shadowLocale = $this->getShadowLocale($node, $locale);
        $document->setShadowLocale($shadowLocale);
        $event->setLocale($shadowLocale);
        $document->setLocale($shadowLocale);
    }
581135
private function getBasePath(Event $event)
    {
        $config = $event->getComposer()->getConfig();
        return realpath($config->get("vendor-dir") . "/../");
    }
1320603
protected function createRoute(
        $domain,
        CustomUrlBehavior $document,
        Localization $locale,
        $persistedLocale,
        $routesPath
    ) {
        $path = sprintf('%s/%s', $routesPath, $domain);
        $routeDocument = $this->findOrCreateRoute($path, $persistedLocale, $document, $domain);
        $routeDocument->setTargetDocument($document);
        $routeDocument->setLocale($locale->getLocale());
        $routeDocument->setHistory(false);

        $this->documentManager->persist(
            $routeDocument,
            $persistedLocale,
            [
                'path' => $path,
                'auto_create' => true,
            ]
        );
        $this->documentManager->publish($routeDocument, $persistedLocale);

        return $routeDocument;
    }
758456
public function addContextual($event)
    {
        $bottomRightNavbar = $this->menuBuilder->getBottomRightNavbar();

        //if there is a template, we add the link in the top bar
        $bottomRightNavbar->addChild('menu.page.settings',
            [
                'route'           => 'victoire_business_template_edit',
                'routeParameters' => ['id' => $event->getPage()->getId()],
                'linkAttributes'  => [
                    'class' => 'v-btn v-btn--sm v-btn--transparent',
                ],
            ]
        )->setLinkAttribute('data-toggle', 'vic-modal');
        $bottomRightNavbar->addChild('menu.page.seoSettings',
            [
                'route'           => 'victoire_seo_pageSeo_settings',
                'routeParameters' => ['id' => $event->getPage()->getId()],
                'linkAttributes'  => [
                    'class' => 'v-btn v-btn--sm v-btn--transparent',
                ],
            ]
        )->setLinkAttribute('data-toggle', 'vic-modal');
    }
1179065
public function handleMap(MapEvent $event)
    {
        $formatter = $this->getFormatter();
        $map = $event->getMap();

        foreach ($this->pointCollector->collect($map) as $point) {
            $event->addCode($formatter->renderContainerAssignment(
                $map,
                $this->pointRenderer->render($point),
                'base.points',
                $point
            ));
        }
    }
301743
public function onGenerateResourceTracking(GenericDataEvent $event)
    {
        $data = $event->getData();
        $node = $data['resourceNode'];
        $user = $data['user'];
        $startDate = $data['startDate'];

        $logs = $this->evaluationManager->getLogsForResourceTracking(
            $node,
            $user,
            ['resource-read', 'resource-icap_wiki-section_create', 'resource-icap_wiki-section_update'],
            $startDate
        );
        $nbLogs = count($logs);

        if ($nbLogs > 0) {
            $this->om->startFlushSuite();
            $tracking = $this->evaluationManager->getResourceUserEvaluation($node, $user);
            $tracking->setDate($logs[0]->getDateLog());
            $status = AbstractResourceEvaluation::STATUS_UNKNOWN;
            $nbAttempts = 0;
            $nbOpenings = 0;

            foreach ($logs as $log) {
                switch ($log->getAction()) {
                    case 'resource-read':
                        ++$nbOpenings;

                        if (AbstractResourceEvaluation::STATUS_UNKNOWN === $status) {
                            $status = AbstractResourceEvaluation::STATUS_OPENED;
                        }
                        break;
                    case 'resource-icap_wiki-section_create':
                    case 'resource-icap_wiki-section_update':
                        ++$nbAttempts;
                        $status = AbstractResourceEvaluation::STATUS_PARTICIPATED;
                        break;
                }
            }
            $tracking->setStatus($status);
            $tracking->setNbAttempts($nbAttempts);
            $tracking->setNbOpenings($nbOpenings);
            $this->om->persist($tracking);
            $this->om->endFlushSuite();
        }
        $event->stopPropagation();
    }
300432
public function addPrefix(RouteEvent $event)
    {
        $route = $event->getRoute();

        $route->setPath($this->prefix . $route->getPath());
    }
122554
public function routeSave(MvcEvent $event)
    {
        $match = $event->getRouteMatch();
        if(!$match) {
            return;
        }
    
        if($event->getParam('route-cached') || !$event->getParam('route-cacheable')) {
            return;
        }
    
        $path = $event->getRequest()
                      ->getUri()
                      ->getPath();
    
        // save the route match into the cache.
        $cache = $event->getApplication()->getServiceManager()->get('var-cache');
        $cacheKey = $this->getCacheKey($path);
        $data = array (
            'name'  => $event->getRouteMatch()->getMatchedRouteName(),
            'route' => $path,
            'defaults' => $event->getRouteMatch()->getParams(),
        );
        $cache->setItem($cacheKey, $data);
    }
264921
function (event) {
				var href = event.oSource.getHref() || event.oSource.getTarget();
				href = href.replace("#/", "").split('/');
				/** @type string */
				var page = href[0];
				/** @type string */
				var parameter = href[1];

				event.preventDefault();
				this.getRouter().navTo(page, {id: parameter}, true);
			}
877239
public function onPostSerialize(ObjectEvent $event)
    {
        $visitor = $event->getVisitor();
        $document = $event->getObject();

        if (!$document instanceof PathBehavior || !$this->documentRegistry->hasDocument($document)) {
            return;
        }

        $visitor->addData('path', $this->documentInspector->getContentPath($document));
    }
1334111
public function setETag(EventInterface $event) {
        $response = $event->getResponse();
        $request = $event->getRequest();

        $routesWithETags = [
            'user' => true,
            'images' => true,
            'image' => true,
            'metadata' => true,
            'globalshorturl' => true,
        ];
        $currentRoute = (string) $request->getRoute();

        if (!isset($routesWithETags[$currentRoute])) {
            // The current route does not use ETags
            return;
        }

        if ($response->isOk()) {
            $response->setETag('"' . md5($response->getContent()) . '"');
        }
    }