Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
199 lars 1
<?php namespace Clockwork\Support\Symfony;
2
 
3
use Symfony\Component\Config\Loader\Loader;
4
use Symfony\Component\Routing\Route;
5
use Symfony\Component\Routing\RouteCollection;
6
 
7
class ClockworkLoader extends Loader
8
{
9
	protected $support;
10
 
11
	public function __construct(ClockworkSupport $support)
12
	{
13
		$this->support = $support;
14
	}
15
 
16
	public function load($resource, $type = null)
17
	{
18
		$routes = new RouteCollection();
19
 
20
		$routes->add('clockwork', new Route('/__clockwork/{id}/{direction}/{count}', [
21
			'_controller' => [ ClockworkController::class, 'getData' ],
22
			'direction' => null,
23
			'count' => null
24
		], [ 'id' => '(?!(app|auth))([a-z0-9-]+|latest)', 'direction' => '(next|previous)', 'count' => '\d+' ]));
25
 
26
		$routes->add('clockwork.auth', new Route('/__clockwork/auth', [
27
			'_controller' => [ ClockworkController::class, 'authenticate' ]
28
		]));
29
 
30
		if (! $this->support->isWebEnabled()) return $routes;
31
 
32
		foreach ($this->support->webPaths() as $path) {
33
			$routes->add("clockwork.webRedirect.{$path}", new Route("{$path}", [
34
				'_controller' => [ ClockworkController::class, 'webRedirect' ]
35
			]));
36
 
37
			$routes->add("clockwork.webIndex.{$path}", new Route("{$path}/app", [
38
				'_controller' => [ ClockworkController::class, 'webIndex' ]
39
			]));
40
 
41
			$routes->add("clockwork.webAsset.{$path}", new Route("{$path}/{path}", [
42
				'_controller' => [ ClockworkController::class, 'webAsset' ]
43
			], [ 'path' => '.+' ]));
44
		}
45
 
46
		return $routes;
47
	}
48
 
49
	public function supports($resource, $type = null)
50
	{
51
		return $type == 'clockwork';
52
	}
53
}