@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | * @return \Aimeos\Controller\Frontend\Iface New frontend controller |
27 | 27 | * @throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found |
28 | 28 | */ |
29 | - static public function createController( \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
29 | + static public function createController(\Aimeos\MShop\Context\Item\Iface $context, $path) |
|
30 | 30 | { |
31 | - return self::create( $context, $path ); |
|
31 | + return self::create($context, $path); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @param boolean $value True to enable caching, false to disable it. |
39 | 39 | * @return boolean Previous cache setting |
40 | 40 | */ |
41 | - static public function setCache( $value ) |
|
41 | + static public function setCache($value) |
|
42 | 42 | { |
43 | - return self::cache( $value ); |
|
43 | + return self::cache($value); |
|
44 | 44 | } |
45 | 45 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param boolean $value True to enable caching, false to disable it. |
28 | 28 | * @return boolean Previous cache setting |
29 | 29 | */ |
30 | - static public function cache( $value ) |
|
30 | + static public function cache($value) |
|
31 | 31 | { |
32 | 32 | $old = self::$cache; |
33 | 33 | self::$cache = (boolean) $value; |
@@ -44,11 +44,11 @@ discard block |
||
44 | 44 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
45 | 45 | * @param string $path Path describing the controller to clear, e.g. "basket" |
46 | 46 | */ |
47 | - static public function clear( $id = null, $path = null ) |
|
47 | + static public function clear($id = null, $path = null) |
|
48 | 48 | { |
49 | - if( $id !== null ) |
|
49 | + if ($id !== null) |
|
50 | 50 | { |
51 | - if( $path !== null ) { |
|
51 | + if ($path !== null) { |
|
52 | 52 | self::$controllers[$id][$path] = null; |
53 | 53 | } else { |
54 | 54 | self::$controllers[$id] = []; |
@@ -76,37 +76,37 @@ discard block |
||
76 | 76 | * @return \Aimeos\Controller\Frontend\Iface New frontend controller |
77 | 77 | * @throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found |
78 | 78 | */ |
79 | - static public function create( \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
79 | + static public function create(\Aimeos\MShop\Context\Item\Iface $context, $path) |
|
80 | 80 | { |
81 | - if( empty( $path ) ) { |
|
82 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) ); |
|
81 | + if (empty($path)) { |
|
82 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Controller path is empty')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $id = (string) $context; |
86 | 86 | |
87 | - if( self::$cache === false || !isset( self::$controllers[$id][$path] ) ) |
|
87 | + if (self::$cache === false || !isset(self::$controllers[$id][$path])) |
|
88 | 88 | { |
89 | - $parts = explode( '/', $path ); |
|
89 | + $parts = explode('/', $path); |
|
90 | 90 | |
91 | - foreach( $parts as $key => $part ) |
|
91 | + foreach ($parts as $key => $part) |
|
92 | 92 | { |
93 | - if( ctype_alnum( $part ) === false ) { |
|
94 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s" in "%2$s"', $part, $path ) ); |
|
93 | + if (ctype_alnum($part) === false) { |
|
94 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in controller name "%1$s" in "%2$s"', $part, $path)); |
|
95 | 95 | } |
96 | 96 | |
97 | - $parts[$key] = ucwords( $part ); |
|
97 | + $parts[$key] = ucwords($part); |
|
98 | 98 | } |
99 | 99 | |
100 | - $factory = '\\Aimeos\\Controller\\Frontend\\' . join( '\\', $parts ) . '\\Factory'; |
|
100 | + $factory = '\\Aimeos\\Controller\\Frontend\\' . join('\\', $parts) . '\\Factory'; |
|
101 | 101 | |
102 | - if( class_exists( $factory ) === false ) { |
|
103 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) ); |
|
102 | + if (class_exists($factory) === false) { |
|
103 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $factory)); |
|
104 | 104 | } |
105 | 105 | |
106 | - $manager = call_user_func_array( array( $factory, 'createController' ), array( $context ) ); |
|
106 | + $manager = call_user_func_array(array($factory, 'createController'), array($context)); |
|
107 | 107 | |
108 | - if( $manager === false ) { |
|
109 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); |
|
108 | + if ($manager === false) { |
|
109 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid factory "%1$s"', $factory)); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | self::$controllers[$id][$path] = $manager; |
@@ -13,94 +13,94 @@ |
||
13 | 13 | { |
14 | 14 | public function testCreateController() |
15 | 15 | { |
16 | - $controller = \Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), 'basket' ); |
|
17 | - $this->assertInstanceOf( '\\Aimeos\\Controller\\Frontend\\Iface', $controller ); |
|
16 | + $controller = \Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), 'basket'); |
|
17 | + $this->assertInstanceOf('\\Aimeos\\Controller\\Frontend\\Iface', $controller); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | |
21 | 21 | public function testCreateControllerEmpty() |
22 | 22 | { |
23 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
24 | - \Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), '' ); |
|
23 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
24 | + \Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), ''); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | |
28 | 28 | public function testCreateControllerInvalidName() |
29 | 29 | { |
30 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
31 | - \Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), '%^' ); |
|
30 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
31 | + \Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), '%^'); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | |
35 | 35 | public function testCreateControllerNotExisting() |
36 | 36 | { |
37 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
38 | - \Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), 'notexist' ); |
|
37 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
38 | + \Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), 'notexist'); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | 42 | public function testCreateSubControllerNotExisting() |
43 | 43 | { |
44 | - $this->setExpectedException( '\\Aimeos\\Controller\\Frontend\\Exception' ); |
|
45 | - \Aimeos\Controller\Frontend::create( \TestHelperFrontend::getContext(), 'basket/notexist' ); |
|
44 | + $this->setExpectedException('\\Aimeos\\Controller\\Frontend\\Exception'); |
|
45 | + \Aimeos\Controller\Frontend::create(\TestHelperFrontend::getContext(), 'basket/notexist'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
49 | 49 | public function testClear() |
50 | 50 | { |
51 | - $cache = \Aimeos\Controller\Frontend::cache( true ); |
|
51 | + $cache = \Aimeos\Controller\Frontend::cache(true); |
|
52 | 52 | |
53 | 53 | $context = \TestHelperFrontend::getContext(); |
54 | 54 | |
55 | - $controller1 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
55 | + $controller1 = \Aimeos\Controller\Frontend::create($context, 'basket'); |
|
56 | 56 | \Aimeos\Controller\Frontend::clear(); |
57 | - $controller2 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
57 | + $controller2 = \Aimeos\Controller\Frontend::create($context, 'basket'); |
|
58 | 58 | |
59 | - \Aimeos\Controller\Frontend::cache( $cache ); |
|
59 | + \Aimeos\Controller\Frontend::cache($cache); |
|
60 | 60 | |
61 | - $this->assertNotSame( $controller1, $controller2 ); |
|
61 | + $this->assertNotSame($controller1, $controller2); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
65 | 65 | public function testClearSite() |
66 | 66 | { |
67 | - $cache = \Aimeos\Controller\Frontend::cache( true ); |
|
67 | + $cache = \Aimeos\Controller\Frontend::cache(true); |
|
68 | 68 | |
69 | 69 | $context = \TestHelperFrontend::getContext(); |
70 | 70 | |
71 | - $basket1 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
72 | - $catalog1 = \Aimeos\Controller\Frontend::create( $context, 'catalog' ); |
|
71 | + $basket1 = \Aimeos\Controller\Frontend::create($context, 'basket'); |
|
72 | + $catalog1 = \Aimeos\Controller\Frontend::create($context, 'catalog'); |
|
73 | 73 | |
74 | - \Aimeos\Controller\Frontend::clear( (string) $context ); |
|
74 | + \Aimeos\Controller\Frontend::clear((string) $context); |
|
75 | 75 | |
76 | - $basket2 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
77 | - $catalog2 = \Aimeos\Controller\Frontend::create( $context, 'catalog' ); |
|
76 | + $basket2 = \Aimeos\Controller\Frontend::create($context, 'basket'); |
|
77 | + $catalog2 = \Aimeos\Controller\Frontend::create($context, 'catalog'); |
|
78 | 78 | |
79 | - \Aimeos\Controller\Frontend::cache( $cache ); |
|
79 | + \Aimeos\Controller\Frontend::cache($cache); |
|
80 | 80 | |
81 | - $this->assertNotSame( $basket1, $basket2 ); |
|
82 | - $this->assertNotSame( $catalog1, $catalog2 ); |
|
81 | + $this->assertNotSame($basket1, $basket2); |
|
82 | + $this->assertNotSame($catalog1, $catalog2); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
86 | 86 | public function testClearSpecific() |
87 | 87 | { |
88 | - $cache = \Aimeos\Controller\Frontend::cache( true ); |
|
88 | + $cache = \Aimeos\Controller\Frontend::cache(true); |
|
89 | 89 | |
90 | 90 | $context = \TestHelperFrontend::getContext(); |
91 | 91 | |
92 | - $basket1 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
93 | - $catalog1 = \Aimeos\Controller\Frontend::create( $context, 'catalog' ); |
|
92 | + $basket1 = \Aimeos\Controller\Frontend::create($context, 'basket'); |
|
93 | + $catalog1 = \Aimeos\Controller\Frontend::create($context, 'catalog'); |
|
94 | 94 | |
95 | - \Aimeos\Controller\Frontend::clear( (string) $context, 'basket' ); |
|
95 | + \Aimeos\Controller\Frontend::clear((string) $context, 'basket'); |
|
96 | 96 | |
97 | - $basket2 = \Aimeos\Controller\Frontend::create( $context, 'basket' ); |
|
98 | - $catalog2 = \Aimeos\Controller\Frontend::create( $context, 'catalog' ); |
|
97 | + $basket2 = \Aimeos\Controller\Frontend::create($context, 'basket'); |
|
98 | + $catalog2 = \Aimeos\Controller\Frontend::create($context, 'catalog'); |
|
99 | 99 | |
100 | - \Aimeos\Controller\Frontend::cache( $cache ); |
|
100 | + \Aimeos\Controller\Frontend::cache($cache); |
|
101 | 101 | |
102 | - $this->assertNotSame( $basket1, $basket2 ); |
|
103 | - $this->assertSame( $catalog1, $catalog2 ); |
|
102 | + $this->assertNotSame($basket1, $basket2); |
|
103 | + $this->assertSame($catalog1, $catalog2); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
107 | 107 | \ No newline at end of file |