Completed
Push — master ( 2799b7...e402b8 )
by Aimeos
02:31
created
src/Aimeos/Shop/Base/Support.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
 	 * @param \Aimeos\Shop\Base\Context $context Context provider
45 45
 	 * @param \Aimeos\Shop\Base\Locale $locale Locale provider
46 46
 	 */
47
-	public function __construct( \Aimeos\Shop\Base\Context $context, \Aimeos\Shop\Base\Locale $locale )
47
+	public function __construct(\Aimeos\Shop\Base\Context $context, \Aimeos\Shop\Base\Locale $locale)
48 48
 	{
49 49
 		$this->context = $context;
50 50
 		$this->locale = $locale;
@@ -58,29 +58,29 @@  discard block
 block discarded – undo
58 58
 	 * @param string|array $groupcodes Unique user/customer group codes that are allowed
59 59
 	 * @return boolean True if user is part of the group, false if not
60 60
 	 */
61
-	public function checkUserGroup( \Illuminate\Foundation\Auth\User $user, $groupcodes )
61
+	public function checkUserGroup(\Illuminate\Foundation\Auth\User $user, $groupcodes)
62 62
 	{
63
-		$groups = ( is_array( $groupcodes ) ? implode( ',', $groupcodes ) : $groupcodes );
63
+		$groups = (is_array($groupcodes) ? implode(',', $groupcodes) : $groupcodes);
64 64
 
65
-		if( isset( $this->cache[$user->id][$groups] ) ) {
65
+		if (isset($this->cache[$user->id][$groups])) {
66 66
 			return $this->cache[$user->id][$groups];
67 67
 		}
68 68
 
69 69
 		$this->cache[$user->id][$groups] = false;
70
-		$context = $this->context->get( false );
70
+		$context = $this->context->get(false);
71 71
 
72 72
 		try {
73
-			$site = \Aimeos\MShop\Factory::createManager( $context, 'locale/site' )->getItem( $user->siteid )->getCode();
74
-		} catch( \Exception $e ) {
75
-			$site = ( Route::current() ? Route::input( 'site', Input::get( 'site', 'default' ) ) : 'default' );
73
+			$site = \Aimeos\MShop\Factory::createManager($context, 'locale/site')->getItem($user->siteid)->getCode();
74
+		} catch (\Exception $e) {
75
+			$site = (Route::current() ? Route::input('site', Input::get('site', 'default')) : 'default');
76 76
 		}
77 77
 
78
-		$context->setLocale( $this->locale->getBackend( $context, $site ) );
78
+		$context->setLocale($this->locale->getBackend($context, $site));
79 79
 
80
-		foreach( array_reverse( $context->getLocale()->getSitePath() ) as $siteid )
80
+		foreach (array_reverse($context->getLocale()->getSitePath()) as $siteid)
81 81
 		{
82
-			if( (string) $user->siteid === (string) $siteid ) {
83
-				$this->cache[$user->id][$groups] = $this->checkGroups( $context, $user->id, $groupcodes );
82
+			if ((string) $user->siteid === (string) $siteid) {
83
+				$this->cache[$user->id][$groups] = $this->checkGroups($context, $user->id, $groupcodes);
84 84
 			}
85 85
 		}
86 86
 
@@ -96,20 +96,20 @@  discard block
 block discarded – undo
96 96
 	 * @return boolean True if user is part of the group, false if not
97 97
 	 * @deprecated Use checkUserGroup() instead
98 98
 	 */
99
-	public function checkGroup( $userid, $groupcodes )
99
+	public function checkGroup($userid, $groupcodes)
100 100
 	{
101
-		$groups = ( is_array( $groupcodes ) ? implode( ',', $groupcodes ) : $groupcodes );
101
+		$groups = (is_array($groupcodes) ? implode(',', $groupcodes) : $groupcodes);
102 102
 
103
-		if( isset( $this->cache[$userid][$groups] ) ) {
103
+		if (isset($this->cache[$userid][$groups])) {
104 104
 			return $this->cache[$userid][$groups];
105 105
 		}
106 106
 
107
-		$site = ( Route::current() ? Route::input( 'site', Input::get( 'site', 'default' ) ) : 'default' );
107
+		$site = (Route::current() ? Route::input('site', Input::get('site', 'default')) : 'default');
108 108
 
109
-		$context = $this->context->get( false );
110
-		$context->setLocale( $this->locale->getBackend( $context, $site ) );
109
+		$context = $this->context->get(false);
110
+		$context->setLocale($this->locale->getBackend($context, $site));
111 111
 
112
-		return $this->cache[$userid][$groups] = $this->checkGroups( $context, $userid, $groupcodes );
112
+		return $this->cache[$userid][$groups] = $this->checkGroups($context, $userid, $groupcodes);
113 113
 	}
114 114
 
115 115
 
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item
120 120
 	 * @return string[] List of group codes
121 121
 	 */
122
-	public function getGroups( \Aimeos\MShop\Context\Item\Iface $context )
122
+	public function getGroups(\Aimeos\MShop\Context\Item\Iface $context)
123 123
 	{
124 124
 		$list = array();
125
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/group' );
125
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/group');
126 126
 
127 127
 		$search = $manager->createSearch();
128
-		$search->setConditions( $search->compare( '==', 'customer.group.id', $context->getGroupIds() ) );
128
+		$search->setConditions($search->compare('==', 'customer.group.id', $context->getGroupIds()));
129 129
 
130
-		foreach( $manager->searchItems( $search ) as $item ) {
130
+		foreach ($manager->searchItems($search) as $item) {
131 131
 			$list[] = $item->getCode();
132 132
 		}
133 133
 
@@ -143,26 +143,26 @@  discard block
 block discarded – undo
143 143
 	 * @param string[] $groupcodes List of group codes to check against
144 144
 	 * @return boolean True if the user is in one of the groups, false if not
145 145
 	 */
146
-	protected function checkGroups( \Aimeos\MShop\Context\Item\Iface $context, $userid, $groupcodes )
146
+	protected function checkGroups(\Aimeos\MShop\Context\Item\Iface $context, $userid, $groupcodes)
147 147
 	{
148
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/group' );
148
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/group');
149 149
 
150 150
 		$search = $manager->createSearch();
151
-		$search->setConditions( $search->compare( '==', 'customer.group.code', (array) $groupcodes ) );
152
-		$groupItems = $manager->searchItems( $search );
151
+		$search->setConditions($search->compare('==', 'customer.group.code', (array) $groupcodes));
152
+		$groupItems = $manager->searchItems($search);
153 153
 
154 154
 
155
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' );
155
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists');
156 156
 
157 157
 		$search = $manager->createSearch();
158 158
 		$expr = array(
159
-			$search->compare( '==', 'customer.lists.parentid', $userid ),
160
-			$search->compare( '==', 'customer.lists.refid', array_keys( $groupItems ) ),
161
-			$search->compare( '==', 'customer.lists.domain', 'customer/group' ),
159
+			$search->compare('==', 'customer.lists.parentid', $userid),
160
+			$search->compare('==', 'customer.lists.refid', array_keys($groupItems)),
161
+			$search->compare('==', 'customer.lists.domain', 'customer/group'),
162 162
 		);
163
-		$search->setConditions( $search->combine( '&&', $expr ) );
164
-		$search->setSlice( 0, 1 );
163
+		$search->setConditions($search->combine('&&', $expr));
164
+		$search->setSlice(0, 1);
165 165
 
166
-		return (bool) count( $manager->searchItems( $search ) );
166
+		return (bool) count($manager->searchItems($search));
167 167
 	}
168 168
 }
Please login to merge, or discard this patch.