Completed
Push — master ( aa2f0e...9144ee )
by Aimeos
03:14
created
admin/jsonadm/src/Admin/JsonAdm/Catalog/Standard.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @param integer &$status Variable which contains the HTTP status afterwards
109 109
 	 * @return string Content for response body
110 110
 	 */
111
-	public function get( $body, array &$header, &$status )
111
+	public function get($body, array &$header, &$status)
112 112
 	{
113 113
 		/** admin/jsonadm/partials/catalog/template-data
114 114
 		 * Relative path to the data partial template file for the catalog client
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
 		 * @since 2016.07
126 126
 		 * @category Developer
127 127
 		 */
128
-		$this->getView()->assign( array( 'partial-data' => 'admin/jsonadm/partials/catalog/template-data' ) );
128
+		$this->getView()->assign(array('partial-data' => 'admin/jsonadm/partials/catalog/template-data'));
129 129
 
130
-		return parent::get( $body, $header, $status );
130
+		return parent::get($body, $header, $status);
131 131
 	}
132 132
 
133 133
 
@@ -138,14 +138,14 @@  discard block
 block discarded – undo
138 138
 	 * @param array $include List of resource types that should be fetched
139 139
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Iface
140 140
 	 */
141
-	protected function getChildItems( array $items, array $include )
141
+	protected function getChildItems(array $items, array $include)
142 142
 	{
143 143
 		$list = array();
144 144
 
145
-		if( in_array( 'catalog', $include ) )
145
+		if (in_array('catalog', $include))
146 146
 		{
147
-			foreach( $items as $item ) {
148
-				$list = array_merge( $list, $item->getChildren() );
147
+			foreach ($items as $item) {
148
+				$list = array_merge($list, $item->getChildren());
149 149
 			}
150 150
 		}
151 151
 
@@ -159,27 +159,27 @@  discard block
 block discarded – undo
159 159
 	 * @param \Aimeos\MW\View\Iface $view View instance
160 160
 	 * @return \Aimeos\MW\View\Iface View instance with additional data assigned
161 161
 	 */
162
-	protected function getItems( \Aimeos\MW\View\Iface $view )
162
+	protected function getItems(\Aimeos\MW\View\Iface $view)
163 163
 	{
164
-		$include = ( ( $include = $view->param( 'include' ) ) !== null ? explode( ',', $include ) : array() );
165
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' );
166
-		$search = $this->initCriteria( $manager->createSearch(), $view->param() );
164
+		$include = (($include = $view->param('include')) !== null ? explode(',', $include) : array());
165
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog');
166
+		$search = $this->initCriteria($manager->createSearch(), $view->param());
167 167
 		$total = 1;
168 168
 
169
-		if( ( $id = $view->param( 'id' ) ) == null )
169
+		if (($id = $view->param('id')) == null)
170 170
 		{
171
-			$view->data = $manager->searchItems( $search, array(), $total );
172
-			$view->listItems = $this->getListItems( $view->data, $include );
173
-			$view->childItems = $this->getChildItems( $view->data, $include );
171
+			$view->data = $manager->searchItems($search, array(), $total);
172
+			$view->listItems = $this->getListItems($view->data, $include);
173
+			$view->childItems = $this->getChildItems($view->data, $include);
174 174
 		}
175 175
 		else
176 176
 		{
177
-			$view->data = $manager->getTree( $id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search );
178
-			$view->listItems = $this->getListItems( array( $id => $view->data ), $include );
179
-			$view->childItems = $this->getChildItems( array( $view->data ), $include );
177
+			$view->data = $manager->getTree($id, array(), \Aimeos\MW\Tree\Manager\Base::LEVEL_LIST, $search);
178
+			$view->listItems = $this->getListItems(array($id => $view->data), $include);
179
+			$view->childItems = $this->getChildItems(array($view->data), $include);
180 180
 		}
181 181
 
182
-		$view->refItems = $this->getRefItems( $view->listItems );
182
+		$view->refItems = $this->getRefItems($view->listItems);
183 183
 		$view->total = $total;
184 184
 
185 185
 		return $view;
@@ -193,18 +193,18 @@  discard block
 block discarded – undo
193 193
 	 * @param array $include List of resource types that should be fetched
194 194
 	 * @return array List of items implementing \Aimeos\MShop\Common\Item\Lists\Iface
195 195
 	 */
196
-	protected function getListItems( array $items, array $include )
196
+	protected function getListItems(array $items, array $include)
197 197
 	{
198
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
198
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
199 199
 
200 200
 		$search = $manager->createSearch();
201 201
 		$expr = array(
202
-			$search->compare( '==', 'catalog.lists.parentid', array_keys( $items ) ),
203
-			$search->compare( '==', 'catalog.lists.domain', $include ),
202
+			$search->compare('==', 'catalog.lists.parentid', array_keys($items)),
203
+			$search->compare('==', 'catalog.lists.domain', $include),
204 204
 		);
205
-		$search->setConditions( $search->combine( '&&', $expr ) );
205
+		$search->setConditions($search->combine('&&', $expr));
206 206
 
207
-		return $manager->searchItems( $search );
207
+		return $manager->searchItems($search);
208 208
 	}
209 209
 
210 210
 
@@ -215,32 +215,32 @@  discard block
 block discarded – undo
215 215
 	 * @param \stdClass $entry Object including "id" and "attributes" elements
216 216
 	 * @return \Aimeos\MShop\Common\Item\Iface New or updated item
217 217
 	 */
218
-	protected function saveEntry( \Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry )
218
+	protected function saveEntry(\Aimeos\MShop\Common\Manager\Iface $manager, \stdClass $entry)
219 219
 	{
220
-		$targetId = ( isset( $entry->targetid ) ? $entry->targetid : null );
221
-		$refId = ( isset( $entry->refid ) ? $entry->refid : null );
220
+		$targetId = (isset($entry->targetid) ? $entry->targetid : null);
221
+		$refId = (isset($entry->refid) ? $entry->refid : null);
222 222
 
223
-		if( isset( $entry->id ) )
223
+		if (isset($entry->id))
224 224
 		{
225
-			$item = $manager->getItem( $entry->id );
226
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
227
-			$manager->saveItem( $item );
225
+			$item = $manager->getItem($entry->id);
226
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
227
+			$manager->saveItem($item);
228 228
 
229
-			if( isset( $entry->parentid ) && $targetId !== null ) {
230
-				$manager->moveItem( $item->getId(), $entry->parentid, $targetId, $refId );
229
+			if (isset($entry->parentid) && $targetId !== null) {
230
+				$manager->moveItem($item->getId(), $entry->parentid, $targetId, $refId);
231 231
 			}
232 232
 		}
233 233
 		else
234 234
 		{
235 235
 			$item = $manager->createItem();
236
-			$item = $this->addItemData( $manager, $item, $entry, $item->getResourceType() );
237
-			$manager->insertItem( $item, $targetId, $refId );
236
+			$item = $this->addItemData($manager, $item, $entry, $item->getResourceType());
237
+			$manager->insertItem($item, $targetId, $refId);
238 238
 		}
239 239
 
240
-		if( isset( $entry->relationships ) ) {
241
-			$this->saveRelationships( $manager, $item, $entry->relationships );
240
+		if (isset($entry->relationships)) {
241
+			$this->saveRelationships($manager, $item, $entry->relationships);
242 242
 		}
243 243
 
244
-		return $manager->getItem( $item->getId() );
244
+		return $manager->getItem($item->getId());
245 245
 	}
246 246
 }
Please login to merge, or discard this patch.