| Total Complexity | 46 |
| Total Lines | 580 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like Standard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Standard, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 22 | class Standard |
||
| 23 | extends \Aimeos\Admin\JQAdm\Common\Admin\Factory\Base |
||
| 24 | implements \Aimeos\Admin\JQAdm\Common\Admin\Factory\Iface |
||
| 25 | { |
||
| 26 | /** |
||
| 27 | * Copies a resource |
||
| 28 | * |
||
| 29 | * @return string HTML output |
||
| 30 | */ |
||
| 31 | public function copy() |
||
| 32 | { |
||
| 33 | $view = $this->getView(); |
||
| 34 | $context = $this->getContext(); |
||
| 35 | |||
| 36 | try |
||
| 37 | { |
||
| 38 | if( ( $id = $view->param( 'id' ) ) === null ) { |
||
| 39 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) ); |
||
| 40 | } |
||
| 41 | |||
| 42 | $manager = \Aimeos\MShop::create( $context, 'customer' ); |
||
| 43 | $view->item = $manager->getItem( $id, $this->getDomains() ); |
||
| 44 | |||
| 45 | $view->itemData = $this->toArray( $view->item, true ); |
||
| 46 | $view->itemSubparts = $this->getSubClientNames(); |
||
| 47 | $view->itemGroups = $this->getGroupItems(); |
||
| 48 | $view->itemBody = ''; |
||
| 49 | |||
| 50 | foreach( $this->getSubClients() as $idx => $client ) |
||
| 51 | { |
||
| 52 | $view->tabindex = ++$idx + 1; |
||
| 53 | $view->itemBody .= $client->copy(); |
||
| 54 | } |
||
| 55 | } |
||
| 56 | catch( \Aimeos\MShop\Exception $e ) |
||
| 57 | { |
||
| 58 | $error = array( 'customer-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 59 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 60 | $this->logException( $e ); |
||
| 61 | } |
||
| 62 | catch( \Exception $e ) |
||
| 63 | { |
||
| 64 | $error = array( 'customer-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 65 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 66 | $this->logException( $e ); |
||
| 67 | } |
||
| 68 | |||
| 69 | return $this->render( $view ); |
||
| 70 | } |
||
| 71 | |||
| 72 | |||
| 73 | /** |
||
| 74 | * Creates a new resource |
||
| 75 | * |
||
| 76 | * @return string HTML output |
||
| 77 | */ |
||
| 78 | public function create() |
||
| 79 | { |
||
| 80 | $view = $this->getView(); |
||
| 81 | $context = $this->getContext(); |
||
| 82 | |||
| 83 | try |
||
| 84 | { |
||
| 85 | $data = $view->param( 'item', [] ); |
||
| 86 | |||
| 87 | if( !isset( $view->item ) ) { |
||
| 88 | $view->item = \Aimeos\MShop::create( $context, 'customer' )->createItem(); |
||
| 89 | } |
||
| 90 | |||
| 91 | $data['customer.siteid'] = $view->item->getSiteId(); |
||
| 92 | |||
| 93 | $view->itemSubparts = $this->getSubClientNames(); |
||
| 94 | $view->itemGroups = $this->getGroupItems(); |
||
| 95 | $view->itemData = $data; |
||
| 96 | $view->itemBody = ''; |
||
| 97 | |||
| 98 | foreach( $this->getSubClients() as $idx => $client ) |
||
| 99 | { |
||
| 100 | $view->tabindex = ++$idx + 1; |
||
| 101 | $view->itemBody .= $client->create(); |
||
| 102 | } |
||
| 103 | } |
||
| 104 | catch( \Aimeos\MShop\Exception $e ) |
||
| 105 | { |
||
| 106 | $error = array( 'customer-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 107 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 108 | $this->logException( $e ); |
||
| 109 | } |
||
| 110 | catch( \Exception $e ) |
||
| 111 | { |
||
| 112 | $error = array( 'customer-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 113 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 114 | $this->logException( $e ); |
||
| 115 | } |
||
| 116 | |||
| 117 | return $this->render( $view ); |
||
| 118 | } |
||
| 119 | |||
| 120 | |||
| 121 | /** |
||
| 122 | * Deletes a resource |
||
| 123 | * |
||
| 124 | * @return string|null HTML output |
||
| 125 | */ |
||
| 126 | public function delete() |
||
| 127 | { |
||
| 128 | $view = $this->getView(); |
||
| 129 | $context = $this->getContext(); |
||
| 130 | |||
| 131 | $manager = \Aimeos\MShop::create( $context, 'customer' ); |
||
| 132 | $manager->begin(); |
||
| 133 | |||
| 134 | try |
||
| 135 | { |
||
| 136 | if( ( $id = $view->param( 'id' ) ) === null ) { |
||
| 137 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) ); |
||
| 138 | } |
||
| 139 | |||
| 140 | $view->item = $manager->getItem( $id, $this->getDomains() ); |
||
| 141 | |||
| 142 | foreach( $this->getSubClients() as $client ) { |
||
| 143 | $client->delete(); |
||
| 144 | } |
||
| 145 | |||
| 146 | $manager->saveItem( $view->item ); |
||
| 147 | $manager->deleteItem( $id ); |
||
| 148 | $manager->commit(); |
||
| 149 | |||
| 150 | $this->nextAction( $view, 'search', 'customer', null, 'delete' ); |
||
| 151 | return; |
||
| 152 | } |
||
| 153 | catch( \Aimeos\MShop\Exception $e ) |
||
| 154 | { |
||
| 155 | $error = array( 'customer-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 156 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 157 | $this->logException( $e ); |
||
| 158 | } |
||
| 159 | catch( \Exception $e ) |
||
| 160 | { |
||
| 161 | $error = array( 'customer-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 162 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 163 | $this->logException( $e ); |
||
| 164 | } |
||
| 165 | |||
| 166 | $manager->rollback(); |
||
| 167 | |||
| 168 | return $this->search(); |
||
| 169 | } |
||
| 170 | |||
| 171 | |||
| 172 | /** |
||
| 173 | * Returns a single resource |
||
| 174 | * |
||
| 175 | * @return string HTML output |
||
| 176 | */ |
||
| 177 | public function get() |
||
| 178 | { |
||
| 179 | $view = $this->getView(); |
||
| 180 | $context = $this->getContext(); |
||
| 181 | |||
| 182 | try |
||
| 183 | { |
||
| 184 | if( ( $id = $view->param( 'id' ) ) === null ) { |
||
| 185 | throw new \Aimeos\Admin\JQAdm\Exception( sprintf( 'Required parameter "%1$s" is missing', 'id' ) ); |
||
| 186 | } |
||
| 187 | |||
| 188 | $manager = \Aimeos\MShop::create( $context, 'customer' ); |
||
| 189 | |||
| 190 | $view->item = $manager->getItem( $id, $this->getDomains() ); |
||
| 191 | $view->itemSubparts = $this->getSubClientNames(); |
||
| 192 | $view->itemData = $this->toArray( $view->item ); |
||
| 193 | $view->itemGroups = $this->getGroupItems(); |
||
| 194 | $view->itemBody = ''; |
||
| 195 | |||
| 196 | foreach( $this->getSubClients() as $idx => $client ) |
||
| 197 | { |
||
| 198 | $view->tabindex = ++$idx + 1; |
||
| 199 | $view->itemBody .= $client->get(); |
||
| 200 | } |
||
| 201 | } |
||
| 202 | catch( \Aimeos\MShop\Exception $e ) |
||
| 203 | { |
||
| 204 | $error = array( 'customer-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 205 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 206 | $this->logException( $e ); |
||
| 207 | } |
||
| 208 | catch( \Exception $e ) |
||
| 209 | { |
||
| 210 | $error = array( 'customer-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 211 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 212 | $this->logException( $e ); |
||
| 213 | } |
||
| 214 | |||
| 215 | return $this->render( $view ); |
||
| 216 | } |
||
| 217 | |||
| 218 | |||
| 219 | /** |
||
| 220 | * Saves the data |
||
| 221 | * |
||
| 222 | * @return string HTML output |
||
| 223 | */ |
||
| 224 | public function save() |
||
| 225 | { |
||
| 226 | $view = $this->getView(); |
||
| 227 | $context = $this->getContext(); |
||
| 228 | |||
| 229 | $manager = \Aimeos\MShop::create( $context, 'customer' ); |
||
| 230 | $manager->begin(); |
||
| 231 | |||
| 232 | try |
||
| 233 | { |
||
| 234 | $item = $this->fromArray( $view->param( 'item', [] ) ); |
||
| 235 | $view->item = $item->getId() ? $item : $manager->saveItem( $item ); |
||
| 236 | $view->itemBody = ''; |
||
| 237 | |||
| 238 | foreach( $this->getSubClients() as $client ) { |
||
| 239 | $view->itemBody .= $client->save(); |
||
| 240 | } |
||
| 241 | |||
| 242 | $manager->saveItem( clone $view->item ); |
||
| 243 | $manager->commit(); |
||
| 244 | |||
| 245 | $this->nextAction( $view, $view->param( 'next' ), 'customer', $view->item->getId(), 'save' ); |
||
| 246 | return; |
||
| 247 | } |
||
| 248 | catch( \Aimeos\Admin\JQAdm\Exception $e ) |
||
| 249 | { |
||
| 250 | // fall through to create |
||
| 251 | } |
||
| 252 | catch( \Aimeos\MShop\Exception $e ) |
||
| 253 | { |
||
| 254 | $error = array( 'customer-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 255 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 256 | $this->logException( $e ); |
||
| 257 | } |
||
| 258 | catch( \Exception $e ) |
||
| 259 | { |
||
| 260 | $error = array( 'customer-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 261 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 262 | $this->logException( $e ); |
||
| 263 | } |
||
| 264 | |||
| 265 | $manager->rollback(); |
||
| 266 | |||
| 267 | return $this->create(); |
||
| 268 | } |
||
| 269 | |||
| 270 | |||
| 271 | /** |
||
| 272 | * Returns a list of resource according to the conditions |
||
| 273 | * |
||
| 274 | * @return string HTML output |
||
| 275 | */ |
||
| 276 | public function search() |
||
| 277 | { |
||
| 278 | $view = $this->getView(); |
||
| 279 | $context = $this->getContext(); |
||
| 280 | |||
| 281 | try |
||
| 282 | { |
||
| 283 | $total = 0; |
||
| 284 | $params = $this->storeSearchParams( $view->param(), 'customer' ); |
||
| 285 | $manager = \Aimeos\MShop::create( $context, 'customer' ); |
||
| 286 | $search = $this->initCriteria( $manager->createSearch(), $params ); |
||
| 287 | |||
| 288 | $view->items = $manager->searchItems( $search, $this->getDomains(), $total ); |
||
| 289 | $view->filterAttributes = $manager->getSearchAttributes( true ); |
||
| 290 | $view->filterOperators = $search->getOperators(); |
||
| 291 | $view->total = $total; |
||
| 292 | $view->itemBody = ''; |
||
| 293 | |||
| 294 | foreach( $this->getSubClients() as $client ) { |
||
| 295 | $view->itemBody .= $client->search(); |
||
| 296 | } |
||
| 297 | } |
||
| 298 | catch( \Aimeos\MShop\Exception $e ) |
||
| 299 | { |
||
| 300 | $error = array( 'customer-item' => $context->getI18n()->dt( 'mshop', $e->getMessage() ) ); |
||
| 301 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 302 | $this->logException( $e ); |
||
| 303 | } |
||
| 304 | catch( \Exception $e ) |
||
| 305 | { |
||
| 306 | $error = array( 'customer-item' => $e->getMessage() . ', ' . $e->getFile() . ':' . $e->getLine() ); |
||
| 307 | $view->errors = $view->get( 'errors', [] ) + $error; |
||
| 308 | $this->logException( $e ); |
||
| 309 | } |
||
| 310 | |||
| 311 | /** admin/jqadm/customer/template-list |
||
| 312 | * Relative path to the HTML body template for the customer list. |
||
| 313 | * |
||
| 314 | * The template file contains the HTML code and processing instructions |
||
| 315 | * to generate the result shown in the body of the frontend. The |
||
| 316 | * configuration string is the path to the template file relative |
||
| 317 | * to the templates directory (usually in admin/jqadm/templates). |
||
| 318 | * |
||
| 319 | * You can overwrite the template file configuration in extensions and |
||
| 320 | * provide alternative templates. These alternative templates should be |
||
| 321 | * named like the default one but with the string "default" replaced by |
||
| 322 | * an unique name. You may use the name of your project for this. If |
||
| 323 | * you've implemented an alternative client class as well, "default" |
||
| 324 | * should be replaced by the name of the new class. |
||
| 325 | * |
||
| 326 | * @param string Relative path to the template creating the HTML code |
||
| 327 | * @since 2016.04 |
||
| 328 | * @category Developer |
||
| 329 | */ |
||
| 330 | $tplconf = 'admin/jqadm/customer/template-list'; |
||
| 331 | $default = 'customer/list-standard'; |
||
| 332 | |||
| 333 | return $view->render( $view->config( $tplconf, $default ) ); |
||
| 334 | } |
||
| 335 | |||
| 336 | |||
| 337 | /** |
||
| 338 | * Returns the sub-client given by its name. |
||
| 339 | * |
||
| 340 | * @param string $type Name of the client type |
||
| 341 | * @param string|null $name Name of the sub-client (Default if null) |
||
| 342 | * @return \Aimeos\Admin\JQAdm\Iface Sub-client object |
||
| 343 | */ |
||
| 344 | public function getSubClient( $type, $name = null ) |
||
| 345 | { |
||
| 346 | /** admin/jqadm/customer/decorators/excludes |
||
| 347 | * Excludes decorators added by the "common" option from the customer JQAdm client |
||
| 348 | * |
||
| 349 | * Decorators extend the functionality of a class by adding new aspects |
||
| 350 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 351 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 352 | * modify what is returned to the caller. |
||
| 353 | * |
||
| 354 | * This option allows you to remove a decorator added via |
||
| 355 | * "client/jqadm/common/decorators/default" before they are wrapped |
||
| 356 | * around the JQAdm client. |
||
| 357 | * |
||
| 358 | * admin/jqadm/customer/decorators/excludes = array( 'decorator1' ) |
||
| 359 | * |
||
| 360 | * This would remove the decorator named "decorator1" from the list of |
||
| 361 | * common decorators ("\Aimeos\Admin\JQAdm\Common\Decorator\*") added via |
||
| 362 | * "client/jqadm/common/decorators/default" to the JQAdm client. |
||
| 363 | * |
||
| 364 | * @param array List of decorator names |
||
| 365 | * @since 2017.07 |
||
| 366 | * @category Developer |
||
| 367 | * @see admin/jqadm/common/decorators/default |
||
| 368 | * @see admin/jqadm/customer/decorators/global |
||
| 369 | * @see admin/jqadm/customer/decorators/local |
||
| 370 | */ |
||
| 371 | |||
| 372 | /** admin/jqadm/customer/decorators/global |
||
| 373 | * Adds a list of globally available decorators only to the customer JQAdm client |
||
| 374 | * |
||
| 375 | * Decorators extend the functionality of a class by adding new aspects |
||
| 376 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 377 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 378 | * modify what is returned to the caller. |
||
| 379 | * |
||
| 380 | * This option allows you to wrap global decorators |
||
| 381 | * ("\Aimeos\Admin\JQAdm\Common\Decorator\*") around the JQAdm client. |
||
| 382 | * |
||
| 383 | * admin/jqadm/customer/decorators/global = array( 'decorator1' ) |
||
| 384 | * |
||
| 385 | * This would add the decorator named "decorator1" defined by |
||
| 386 | * "\Aimeos\Admin\JQAdm\Common\Decorator\Decorator1" only to the JQAdm client. |
||
| 387 | * |
||
| 388 | * @param array List of decorator names |
||
| 389 | * @since 2017.07 |
||
| 390 | * @category Developer |
||
| 391 | * @see admin/jqadm/common/decorators/default |
||
| 392 | * @see admin/jqadm/customer/decorators/excludes |
||
| 393 | * @see admin/jqadm/customer/decorators/local |
||
| 394 | */ |
||
| 395 | |||
| 396 | /** admin/jqadm/customer/decorators/local |
||
| 397 | * Adds a list of local decorators only to the customer JQAdm client |
||
| 398 | * |
||
| 399 | * Decorators extend the functionality of a class by adding new aspects |
||
| 400 | * (e.g. log what is currently done), executing the methods of the underlying |
||
| 401 | * class only in certain conditions (e.g. only for logged in users) or |
||
| 402 | * modify what is returned to the caller. |
||
| 403 | * |
||
| 404 | * This option allows you to wrap local decorators |
||
| 405 | * ("\Aimeos\Admin\JQAdm\Customer\Decorator\*") around the JQAdm client. |
||
| 406 | * |
||
| 407 | * admin/jqadm/customer/decorators/local = array( 'decorator2' ) |
||
| 408 | * |
||
| 409 | * This would add the decorator named "decorator2" defined by |
||
| 410 | * "\Aimeos\Admin\JQAdm\Customer\Decorator\Decorator2" only to the JQAdm client. |
||
| 411 | * |
||
| 412 | * @param array List of decorator names |
||
| 413 | * @since 2017.07 |
||
| 414 | * @category Developer |
||
| 415 | * @see admin/jqadm/common/decorators/default |
||
| 416 | * @see admin/jqadm/customer/decorators/excludes |
||
| 417 | * @see admin/jqadm/customer/decorators/global |
||
| 418 | */ |
||
| 419 | return $this->createSubClient( 'customer/' . $type, $name ); |
||
| 420 | } |
||
| 421 | |||
| 422 | |||
| 423 | /** |
||
| 424 | * Returns the domain names whose items should be fetched too |
||
| 425 | * |
||
| 426 | * @return string[] List of domain names |
||
| 427 | */ |
||
| 428 | protected function getDomains() |
||
| 429 | { |
||
| 430 | /** admin/jqadm/customer/domains |
||
| 431 | * List of domain items that should be fetched along with the customer |
||
| 432 | * |
||
| 433 | * If you need to display additional content, you can configure your own |
||
| 434 | * list of domains (attribute, media, price, customer, text, etc. are |
||
| 435 | * domains) whose items are fetched from the storage. |
||
| 436 | * |
||
| 437 | * @param array List of domain names |
||
| 438 | * @since 2017.07 |
||
| 439 | * @category Developer |
||
| 440 | */ |
||
| 441 | $domains = ['customer/address', 'customer/group', 'customer/property']; |
||
| 442 | |||
| 443 | return $this->getContext()->getConfig()->get( 'admin/jqadm/customer/domains', $domains ); |
||
| 444 | } |
||
| 445 | |||
| 446 | |||
| 447 | /** |
||
| 448 | * Returns the available group items |
||
| 449 | * |
||
| 450 | * @return \Aimeos\MShop\Customer\Item\Group\Iface[] Associative list of group IDs as keys and group items as values |
||
| 451 | */ |
||
| 452 | protected function getGroupItems() |
||
| 453 | { |
||
| 454 | $list = []; |
||
| 455 | $isSuper = $this->getView()->access( ['super'] ); |
||
| 456 | $isAdmin = $this->getView()->access( ['admin'] ); |
||
| 457 | |||
| 458 | $manager = \Aimeos\MShop::create( $this->getContext(), 'customer/group' ); |
||
| 459 | $search = $manager->createSearch(); |
||
| 460 | $search->setSortations( [$search->sort( '+', 'customer.group.label' )] ); |
||
| 461 | |||
| 462 | foreach( $manager->searchItems( $search ) as $groupId => $groupItem ) |
||
| 463 | { |
||
| 464 | if( !$isSuper && in_array( $groupItem->getCode(), ['super'] ) ) { |
||
|
|
|||
| 465 | continue; |
||
| 466 | } |
||
| 467 | |||
| 468 | if( !$isSuper && !$isAdmin && in_array( $groupItem->getCode(), ['super', 'admin', 'editor'] ) ) { |
||
| 469 | continue; |
||
| 470 | } |
||
| 471 | |||
| 472 | $list[$groupId] = $groupItem; |
||
| 473 | } |
||
| 474 | |||
| 475 | return $list; |
||
| 476 | } |
||
| 477 | |||
| 478 | |||
| 479 | /** |
||
| 480 | * Returns the list of sub-client names configured for the client. |
||
| 481 | * |
||
| 482 | * @return array List of JQAdm client names |
||
| 483 | */ |
||
| 484 | protected function getSubClientNames() |
||
| 485 | { |
||
| 486 | /** admin/jqadm/customer/standard/subparts |
||
| 487 | * List of JQAdm sub-clients rendered within the customer section |
||
| 488 | * |
||
| 489 | * The output of the frontend is composed of the code generated by the JQAdm |
||
| 490 | * clients. Each JQAdm client can consist of serveral (or none) sub-clients |
||
| 491 | * that are responsible for rendering certain sub-parts of the output. The |
||
| 492 | * sub-clients can contain JQAdm clients themselves and therefore a |
||
| 493 | * hierarchical tree of JQAdm clients is composed. Each JQAdm client creates |
||
| 494 | * the output that is placed inside the container of its parent. |
||
| 495 | * |
||
| 496 | * At first, always the JQAdm code generated by the parent is printed, then |
||
| 497 | * the JQAdm code of its sub-clients. The order of the JQAdm sub-clients |
||
| 498 | * determines the order of the output of these sub-clients inside the parent |
||
| 499 | * container. If the configured list of clients is |
||
| 500 | * |
||
| 501 | * array( "subclient1", "subclient2" ) |
||
| 502 | * |
||
| 503 | * you can easily change the order of the output by reordering the subparts: |
||
| 504 | * |
||
| 505 | * admin/jqadm/<clients>/subparts = array( "subclient1", "subclient2" ) |
||
| 506 | * |
||
| 507 | * You can also remove one or more parts if they shouldn't be rendered: |
||
| 508 | * |
||
| 509 | * admin/jqadm/<clients>/subparts = array( "subclient1" ) |
||
| 510 | * |
||
| 511 | * As the clients only generates structural JQAdm, the layout defined via CSS |
||
| 512 | * should support adding, removing or reordering content by a fluid like |
||
| 513 | * design. |
||
| 514 | * |
||
| 515 | * @param array List of sub-client names |
||
| 516 | * @since 2017.07 |
||
| 517 | * @category Developer |
||
| 518 | */ |
||
| 519 | return $this->getContext()->getConfig()->get( 'admin/jqadm/customer/standard/subparts', [] ); |
||
| 520 | } |
||
| 521 | |||
| 522 | |||
| 523 | |||
| 524 | /** |
||
| 525 | * Creates new and updates existing items using the data array |
||
| 526 | * |
||
| 527 | * @param string[] Data array |
||
| 528 | * @return \Aimeos\MShop\Customer\Item\Iface New customer item object |
||
| 529 | */ |
||
| 530 | protected function fromArray( array $data ) |
||
| 531 | { |
||
| 532 | $data['customer.label'] = $data['customer.firstname'] . ' ' . $data['customer.lastname']; |
||
| 533 | $data['customer.code'] = $data['customer.email']; |
||
| 534 | |||
| 535 | $manager = \Aimeos\MShop::create( $this->getContext(), 'customer' ); |
||
| 536 | |||
| 537 | if( isset( $data['customer.id'] ) && $data['customer.id'] != '' ) { |
||
| 538 | $item = $manager->getItem( $data['customer.id'], $this->getDomains() ); |
||
| 539 | } else { |
||
| 540 | $item = $manager->createItem(); |
||
| 541 | } |
||
| 542 | |||
| 543 | $item->fromArray( $data ); |
||
| 544 | $item->setGroups( array_intersect( array_keys( $this->getGroupItems() ), $item->getGroups() ) ); |
||
| 545 | |||
| 546 | return $item; |
||
| 547 | } |
||
| 548 | |||
| 549 | |||
| 550 | /** |
||
| 551 | * Constructs the data array for the view from the given item |
||
| 552 | * |
||
| 553 | * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object |
||
| 554 | * @return string[] Multi-dimensional associative list of item data |
||
| 555 | */ |
||
| 556 | protected function toArray( \Aimeos\MShop\Customer\Item\Iface $item, $copy = false ) |
||
| 568 | } |
||
| 569 | |||
| 570 | |||
| 571 | /** |
||
| 572 | * Returns the rendered template including the view data |
||
| 573 | * |
||
| 574 | * @param \Aimeos\MW\View\Iface $view View object with data assigned |
||
| 575 | * @return string HTML output |
||
| 576 | */ |
||
| 577 | protected function render( \Aimeos\MW\View\Iface $view ) |
||
| 602 | } |
||
| 603 | } |
||
| 604 |