| Total Complexity | 53 | 
| Total Lines | 733 | 
| Duplicated Lines | 0 % | 
| Changes | 25 | ||
| Bugs | 0 | Features | 0 | 
Complex classes like Typo3 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 Typo3, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 21 | class Typo3  | 
            ||
| 22 | extends \Aimeos\MShop\Customer\Manager\Standard  | 
            ||
| 23 | { | 
            ||
| 24 | private $searchConfig = array(  | 
            ||
| 25 | // customer.siteid is only for informational purpuse, not for filtering  | 
            ||
| 26 | 'customer.id' => array(  | 
            ||
| 27 | 'label' => 'Customer ID',  | 
            ||
| 28 | 'code' => 'customer.id',  | 
            ||
| 29 | 'internalcode' => 't3feu."uid"',  | 
            ||
| 30 | 'type' => 'integer',  | 
            ||
| 31 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,  | 
            ||
| 32 | 'public' => false,  | 
            ||
| 33 | ),  | 
            ||
| 34 | 'customer.code' => array(  | 
            ||
| 35 | 'label' => 'Customer username',  | 
            ||
| 36 | 'code' => 'customer.code',  | 
            ||
| 37 | 'internalcode' => 't3feu."username"',  | 
            ||
| 38 | 'type' => 'string',  | 
            ||
| 39 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR  | 
            ||
| 40 | ),  | 
            ||
| 41 | 'customer.label' => array(  | 
            ||
| 42 | 'label' => 'Customer name',  | 
            ||
| 43 | 'code' => 'customer.label',  | 
            ||
| 44 | 'internalcode' => 't3feu."name"',  | 
            ||
| 45 | 'type' => 'string',  | 
            ||
| 46 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR  | 
            ||
| 47 | ),  | 
            ||
| 48 | 'customer.salutation' => array(  | 
            ||
| 49 | 'label' => 'Customer salutation',  | 
            ||
| 50 | 'code' => 'customer.salutation',  | 
            ||
| 51 | 'internalcode' => 't3feu."gender"',  | 
            ||
| 52 | 'type' => 'string',  | 
            ||
| 53 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 54 | ),  | 
            ||
| 55 | 'customer.company'=> array(  | 
            ||
| 56 | 'label' => 'Customer company',  | 
            ||
| 57 | 'code' => 'customer.company',  | 
            ||
| 58 | 'internalcode' => 't3feu."company"',  | 
            ||
| 59 | 'type' => 'string',  | 
            ||
| 60 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 61 | ),  | 
            ||
| 62 | 'customer.vatid'=> array(  | 
            ||
| 63 | 'label' => 'Customer VAT ID',  | 
            ||
| 64 | 'code' => 'customer.vatid',  | 
            ||
| 65 | 'internalcode' => 't3feu."vatid"',  | 
            ||
| 66 | 'type' => 'string',  | 
            ||
| 67 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 68 | ),  | 
            ||
| 69 | 'customer.title' => array(  | 
            ||
| 70 | 'label' => 'Customer title',  | 
            ||
| 71 | 'code' => 'customer.title',  | 
            ||
| 72 | 'internalcode' => 't3feu."title"',  | 
            ||
| 73 | 'type' => 'string',  | 
            ||
| 74 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 75 | ),  | 
            ||
| 76 | 'customer.firstname' => array(  | 
            ||
| 77 | 'label' => 'Customer firstname',  | 
            ||
| 78 | 'code' => 'customer.firstname',  | 
            ||
| 79 | 'internalcode' => 't3feu."first_name"',  | 
            ||
| 80 | 'type' => 'string',  | 
            ||
| 81 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 82 | ),  | 
            ||
| 83 | 'customer.lastname' => array(  | 
            ||
| 84 | 'label' => 'Customer lastname',  | 
            ||
| 85 | 'code' => 'customer.lastname',  | 
            ||
| 86 | 'internalcode' => 't3feu."last_name"',  | 
            ||
| 87 | 'type' => 'string',  | 
            ||
| 88 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 89 | ),  | 
            ||
| 90 | 'customer.address1' => array(  | 
            ||
| 91 | 'label' => 'Customer address part one',  | 
            ||
| 92 | 'code' => 'customer.address1',  | 
            ||
| 93 | 'internalcode' => 't3feu."address"',  | 
            ||
| 94 | 'type' => 'string',  | 
            ||
| 95 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 96 | ),  | 
            ||
| 97 | 'customer.address2' => array(  | 
            ||
| 98 | 'label' => 'Customer address part two',  | 
            ||
| 99 | 'code' => 'customer.address2',  | 
            ||
| 100 | 'internalcode' => 't3feu."address"',  | 
            ||
| 101 | 'type' => 'string',  | 
            ||
| 102 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 103 | ),  | 
            ||
| 104 | 'customer.address3' => array(  | 
            ||
| 105 | 'label' => 'Customer address part three',  | 
            ||
| 106 | 'code' => 'customer.address3',  | 
            ||
| 107 | 'internalcode' => 't3feu."address"',  | 
            ||
| 108 | 'type' => 'string',  | 
            ||
| 109 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 110 | ),  | 
            ||
| 111 | 'customer.postal' => array(  | 
            ||
| 112 | 'label' => 'Customer postal',  | 
            ||
| 113 | 'code' => 'customer.postal',  | 
            ||
| 114 | 'internalcode' => 't3feu."zip"',  | 
            ||
| 115 | 'type' => 'string',  | 
            ||
| 116 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 117 | ),  | 
            ||
| 118 | 'customer.city' => array(  | 
            ||
| 119 | 'label' => 'Customer city',  | 
            ||
| 120 | 'code' => 'customer.city',  | 
            ||
| 121 | 'internalcode' => 't3feu."city"',  | 
            ||
| 122 | 'type' => 'string',  | 
            ||
| 123 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 124 | ),  | 
            ||
| 125 | 'customer.state' => array(  | 
            ||
| 126 | 'label' => 'Customer state',  | 
            ||
| 127 | 'code' => 'customer.state',  | 
            ||
| 128 | 'internalcode' => 't3feu."zone"',  | 
            ||
| 129 | 'type' => 'string',  | 
            ||
| 130 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 131 | ),  | 
            ||
| 132 | 'customer.languageid' => array(  | 
            ||
| 133 | 'label' => 'Customer language',  | 
            ||
| 134 | 'code' => 'customer.languageid',  | 
            ||
| 135 | 'internalcode' => 't3feu."language"',  | 
            ||
| 136 | 'type' => 'string',  | 
            ||
| 137 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 138 | ),  | 
            ||
| 139 | 'customer.countryid' => array(  | 
            ||
| 140 | 'label' => 'Customer country',  | 
            ||
| 141 | 'code' => 'customer.countryid',  | 
            ||
| 142 | 'internalcode' => 'tsc."cn_iso_2"',  | 
            ||
| 143 | 'type' => 'string',  | 
            ||
| 144 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 145 | ),  | 
            ||
| 146 | 'customer.telephone' => array(  | 
            ||
| 147 | 'label' => 'Customer telephone',  | 
            ||
| 148 | 'code' => 'customer.telephone',  | 
            ||
| 149 | 'internalcode' => 't3feu."telephone"',  | 
            ||
| 150 | 'type' => 'string',  | 
            ||
| 151 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 152 | ),  | 
            ||
| 153 | 'customer.email' => array(  | 
            ||
| 154 | 'label' => 'Customer email',  | 
            ||
| 155 | 'code' => 'customer.email',  | 
            ||
| 156 | 'internalcode' => 't3feu."email"',  | 
            ||
| 157 | 'type' => 'string',  | 
            ||
| 158 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 159 | ),  | 
            ||
| 160 | 'customer.telefax' => array(  | 
            ||
| 161 | 'label' => 'Customer telefax',  | 
            ||
| 162 | 'code' => 'customer.telefax',  | 
            ||
| 163 | 'internalcode' => 't3feu."fax"',  | 
            ||
| 164 | 'type' => 'string',  | 
            ||
| 165 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 166 | ),  | 
            ||
| 167 | 'customer.website' => array(  | 
            ||
| 168 | 'label' => 'Customer website',  | 
            ||
| 169 | 'code' => 'customer.website',  | 
            ||
| 170 | 'internalcode' => 't3feu."www"',  | 
            ||
| 171 | 'type' => 'string',  | 
            ||
| 172 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 173 | ),  | 
            ||
| 174 | 'customer.longitude' => array(  | 
            ||
| 175 | 'label' => 'Customer longitude',  | 
            ||
| 176 | 'code' => 'customer.longitude',  | 
            ||
| 177 | 'internalcode' => 't3feu."longitude"',  | 
            ||
| 178 | 'type' => 'float',  | 
            ||
| 179 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT,  | 
            ||
| 180 | ),  | 
            ||
| 181 | 'customer.latitude' => array(  | 
            ||
| 182 | 'label' => 'Customer latitude',  | 
            ||
| 183 | 'code' => 'customer.latitude',  | 
            ||
| 184 | 'internalcode' => 't3feu."latitude"',  | 
            ||
| 185 | 'type' => 'float',  | 
            ||
| 186 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT,  | 
            ||
| 187 | ),  | 
            ||
| 188 | 'customer.birthday' => array(  | 
            ||
| 189 | 'label' => 'Customer birthday',  | 
            ||
| 190 | 'code' => 'customer.birthday',  | 
            ||
| 191 | 'internalcode' => 't3feu."date_of_birth"',  | 
            ||
| 192 | 'type' => 'string',  | 
            ||
| 193 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 194 | ),  | 
            ||
| 195 | 'customer.password'=> array(  | 
            ||
| 196 | 'label' => 'Customer password',  | 
            ||
| 197 | 'code' => 'customer.password',  | 
            ||
| 198 | 'internalcode' => 't3feu."password"',  | 
            ||
| 199 | 'type' => 'string',  | 
            ||
| 200 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 201 | ),  | 
            ||
| 202 | 'customer.status'=> array(  | 
            ||
| 203 | 'label' => 'Customer status',  | 
            ||
| 204 | 'code' => 'customer.status',  | 
            ||
| 205 | 'internalcode' => 't3feu."disable"',  | 
            ||
| 206 | 'type' => 'integer',  | 
            ||
| 207 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT  | 
            ||
| 208 | ),  | 
            ||
| 209 | 'customer.dateverified'=> array(  | 
            ||
| 210 | 'label' => 'Customer verification date',  | 
            ||
| 211 | 'code' => 'customer.dateverified',  | 
            ||
| 212 | 'internalcode' => 't3feu."vdate"',  | 
            ||
| 213 | 'type' => 'date',  | 
            ||
| 214 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 215 | ),  | 
            ||
| 216 | 'customer.ctime'=> array(  | 
            ||
| 217 | 'label' => 'Customer creation time',  | 
            ||
| 218 | 'code' => 'customer.ctime',  | 
            ||
| 219 | 'internalcode' => 't3feu."crdate"',  | 
            ||
| 220 | 'type' => 'datetime',  | 
            ||
| 221 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 222 | ),  | 
            ||
| 223 | 'customer.mtime'=> array(  | 
            ||
| 224 | 'label' => 'Customer modification time',  | 
            ||
| 225 | 'code' => 'customer.mtime',  | 
            ||
| 226 | 'internalcode' => 't3feu."tstamp"',  | 
            ||
| 227 | 'type' => 'datetime',  | 
            ||
| 228 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 229 | ),  | 
            ||
| 230 | // not available  | 
            ||
| 231 | 'customer.editor'=> array(  | 
            ||
| 232 | 'label' => 'Customer editor',  | 
            ||
| 233 | 'code' => 'customer.editor',  | 
            ||
| 234 | 'internalcode' => null,  | 
            ||
| 235 | 'type' => 'string',  | 
            ||
| 236 | 'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,  | 
            ||
| 237 | ),  | 
            ||
| 238 | 'customer:has' => array(  | 
            ||
| 239 | 'code' => 'customer:has()',  | 
            ||
| 240 | 'internalcode' => ':site :key AND t3feuli."id"',  | 
            ||
| 241 | 'internaldeps' => ['LEFT JOIN "fe_users_list" AS t3feuli ON ( t3feuli."parentid" = t3feu."uid" )'],  | 
            ||
| 242 | 'label' => 'Customer has list item, parameter(<domain>[,<list type>[,<reference ID>)]]',  | 
            ||
| 243 | 'type' => 'null',  | 
            ||
| 244 | 'internaltype' => 'null',  | 
            ||
| 245 | 'public' => false,  | 
            ||
| 246 | ),  | 
            ||
| 247 | 'customer:prop' => array(  | 
            ||
| 248 | 'code' => 'customer:prop()',  | 
            ||
| 249 | 'internalcode' => ':site :key AND t3feupr."id"',  | 
            ||
| 250 | 'internaldeps' => ['LEFT JOIN "fe_users_property" AS t3feupr ON ( t3feupr."parentid" = t3feu."uid" )'],  | 
            ||
| 251 | 'label' => 'Customer has property item, parameter(<property type>[,<language code>[,<property value>]])',  | 
            ||
| 252 | 'type' => 'null',  | 
            ||
| 253 | 'internaltype' => 'null',  | 
            ||
| 254 | 'public' => false,  | 
            ||
| 255 | ),  | 
            ||
| 256 | );  | 
            ||
| 257 | |||
| 258 | |||
| 259 | private $plugins = [];  | 
            ||
| 260 | private $reverse = [];  | 
            ||
| 261 | private $helper;  | 
            ||
| 262 | private $pid;  | 
            ||
| 263 | |||
| 264 | |||
| 265 | |||
| 266 | /**  | 
            ||
| 267 | * Initializes a new customer manager object using the given context object.  | 
            ||
| 268 | *  | 
            ||
| 269 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects  | 
            ||
| 270 | */  | 
            ||
| 271 | public function __construct( \Aimeos\MShop\Context\Item\Iface $context )  | 
            ||
| 272 | 	{ | 
            ||
| 273 | parent::__construct( $context );  | 
            ||
| 274 | |||
| 275 | $plugin = new \Aimeos\MW\Criteria\Plugin\T3Salutation();  | 
            ||
| 276 | $this->plugins['customer.salutation'] = $this->reverse['gender'] = $plugin;  | 
            ||
| 277 | |||
| 278 | $plugin = new \Aimeos\MW\Criteria\Plugin\T3Status();  | 
            ||
| 279 | $this->plugins['customer.status'] = $this->reverse['disable'] = $plugin;  | 
            ||
| 280 | |||
| 281 | $plugin = new \Aimeos\MW\Criteria\Plugin\T3Date();  | 
            ||
| 282 | $this->plugins['customer.birthday'] = $this->reverse['date_of_birth'] = $plugin;  | 
            ||
| 283 | |||
| 284 | $plugin = new \Aimeos\MW\Criteria\Plugin\T3Datetime();  | 
            ||
| 285 | $this->plugins['customer.ctime'] = $this->reverse['crdate'] = $plugin;  | 
            ||
| 286 | $this->plugins['customer.mtime'] = $this->reverse['tstamp'] = $plugin;  | 
            ||
| 287 | |||
| 288 | $this->pid = $context->getConfig()->get( 'mshop/customer/manager/typo3/pid-default', 0 );  | 
            ||
| 289 | |||
| 290 | |||
| 291 | $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;  | 
            ||
| 292 | $level = $context->getConfig()->get( 'mshop/customer/manager/sitemode', $level );  | 
            ||
| 293 | |||
| 294 | $siteIds = $this->getSiteIds( $level );  | 
            ||
| 295 | $self = $this;  | 
            ||
| 296 | |||
| 297 | |||
| 298 | 		$this->searchConfig['customer:has']['function'] = function( &$source, array $params ) use ( $self, $siteIds ) { | 
            ||
| 299 | |||
| 300 | 			array_walk_recursive( $params, function( &$v ) { | 
            ||
| 301 | $v = trim( $v, '\'' );  | 
            ||
| 302 | } );  | 
            ||
| 303 | |||
| 304 | $keys = [];  | 
            ||
| 305 | $params[1] = isset( $params[1] ) ? $params[1] : '';  | 
            ||
| 306 | $params[2] = isset( $params[2] ) ? $params[2] : '';  | 
            ||
| 307 | |||
| 308 | 			foreach( (array) $params[1] as $type ) { | 
            ||
| 309 | 				foreach( (array) $params[2] as $id ) { | 
            ||
| 310 | $keys[] = $params[0] . '|' . ( $type ? $type . '|' : '' ) . $id;  | 
            ||
| 311 | }  | 
            ||
| 312 | }  | 
            ||
| 313 | |||
| 314 | $sitestr = $siteIds ? $self->toExpression( 't3feuli."siteid"', $siteIds ) . ' AND' : '';  | 
            ||
| 315 | $keystr = $self->toExpression( 't3feuli."key"', $keys, $params[2] !== '' ? '==' : '=~' );  | 
            ||
| 316 | $source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );  | 
            ||
| 317 | |||
| 318 | return $params;  | 
            ||
| 319 | };  | 
            ||
| 320 | |||
| 321 | |||
| 322 | 		$this->searchConfig['customer:prop']['function'] = function( &$source, array $params ) use ( $self, $siteIds ) { | 
            ||
| 323 | |||
| 324 | 			array_walk_recursive( $params, function( &$v ) { | 
            ||
| 325 | $v = trim( $v, '\'' );  | 
            ||
| 326 | } );  | 
            ||
| 327 | |||
| 328 | $keys = [];  | 
            ||
| 329 | $params[1] = array_key_exists( 1, $params ) ? $params[1] : '';  | 
            ||
| 330 | $params[2] = isset( $params[2] ) ? $params[2] : '';  | 
            ||
| 331 | |||
| 332 | 			foreach( (array) $params[1] as $lang ) { | 
            ||
| 333 | 				foreach( (array) $params[2] as $id ) { | 
            ||
| 334 | $keys[] = $params[0] . '|' . ( $lang ? $lang . '|' : '' ) . ( $id !== '' ? md5( $id ) : '' );  | 
            ||
| 335 | }  | 
            ||
| 336 | }  | 
            ||
| 337 | |||
| 338 | $sitestr = $siteIds ? $self->toExpression( 't3feupr."siteid"', $siteIds ) . ' AND' : '';  | 
            ||
| 339 | $keystr = $self->toExpression( 't3feupr."key"', $keys, $params[2] !== '' ? '==' : '=~' );  | 
            ||
| 340 | $source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );  | 
            ||
| 341 | |||
| 342 | return $params;  | 
            ||
| 343 | };  | 
            ||
| 344 | }  | 
            ||
| 345 | |||
| 346 | |||
| 347 | /**  | 
            ||
| 348 | * Removes old entries from the storage.  | 
            ||
| 349 | *  | 
            ||
| 350 | * @param array $siteids List of IDs for sites whose entries should be deleted  | 
            ||
| 351 | */  | 
            ||
| 352 | public function clear( array $siteids )  | 
            ||
| 353 | 	{ | 
            ||
| 354 | $path = 'mshop/customer/manager/submanagers';  | 
            ||
| 355 | $default = ['address', 'group', 'lists', 'property'];  | 
            ||
| 356 | |||
| 357 | 		foreach( $this->getContext()->getConfig()->get( $path, $default ) as $domain ) { | 
            ||
| 358 | $this->getObject()->getSubManager( $domain )->clear( $siteids );  | 
            ||
| 359 | }  | 
            ||
| 360 | }  | 
            ||
| 361 | |||
| 362 | |||
| 363 | /**  | 
            ||
| 364 | * Creates a new empty item instance  | 
            ||
| 365 | *  | 
            ||
| 366 | * @param array $values Values the item should be initialized with  | 
            ||
| 367 | * @return \Aimeos\MShop\Customer\Item\Iface New site item object  | 
            ||
| 368 | */  | 
            ||
| 369 | public function createItem( array $values = [] )  | 
            ||
| 373 | }  | 
            ||
| 374 | |||
| 375 | |||
| 376 | /**  | 
            ||
| 377 | * Removes multiple items.  | 
            ||
| 378 | *  | 
            ||
| 379 | * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items  | 
            ||
| 380 | * @return \Aimeos\MShop\Common\Manager\Iface Manager object for chaining method calls  | 
            ||
| 381 | */  | 
            ||
| 382 | public function deleteItems( array $itemIds )  | 
            ||
| 383 | 	{ | 
            ||
| 384 | $path = 'mshop/customer/manager/typo3/delete';  | 
            ||
| 385 | $this->deleteItemsBase( $itemIds, $path, false, 'uid' );  | 
            ||
| 386 | |||
| 387 | $manager = $this->getObject()->getSubManager( 'address' );  | 
            ||
| 388 | $search = $manager->createSearch()->setSlice( 0, 0x7fffffff );  | 
            ||
| 389 | $search->setConditions( $search->compare( '==', 'customer.address.parentid', $itemIds ) );  | 
            ||
| 390 | $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) );  | 
            ||
| 391 | |||
| 392 | $manager = $this->getObject()->getSubManager( 'lists' );  | 
            ||
| 393 | $search = $manager->createSearch()->setSlice( 0, 0x7fffffff );  | 
            ||
| 394 | $search->setConditions( $search->compare( '==', 'customer.lists.parentid', $itemIds ) );  | 
            ||
| 395 | $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) );  | 
            ||
| 396 | |||
| 397 | $manager = $this->getObject()->getSubManager( 'property' );  | 
            ||
| 398 | $search = $manager->createSearch()->setSlice( 0, 0x7fffffff );  | 
            ||
| 399 | $search->setConditions( $search->compare( '==', 'customer.property.parentid', $itemIds ) );  | 
            ||
| 400 | $manager->deleteItems( array_keys( $manager->searchItems( $search ) ) );  | 
            ||
| 401 | |||
| 402 | return $this->deleteRefItems( $itemIds );  | 
            ||
| 403 | }  | 
            ||
| 404 | |||
| 405 | |||
| 406 | /**  | 
            ||
| 407 | * Returns the list attributes that can be used for searching.  | 
            ||
| 408 | *  | 
            ||
| 409 | * @param boolean $withsub Return also attributes of sub-managers if true  | 
            ||
| 410 | * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface  | 
            ||
| 411 | */  | 
            ||
| 412 | public function getSearchAttributes( $withsub = true )  | 
            ||
| 413 | 	{ | 
            ||
| 414 | $path = 'mshop/customer/manager/submanagers';  | 
            ||
| 415 | return $this->getSearchAttributesBase( $this->searchConfig, $path, ['address'], $withsub );  | 
            ||
| 416 | }  | 
            ||
| 417 | |||
| 418 | |||
| 419 | /**  | 
            ||
| 420 | * Saves a customer item object.  | 
            ||
| 421 | *  | 
            ||
| 422 | * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object  | 
            ||
| 423 | * @param boolean $fetch True if the new ID should be returned in the item  | 
            ||
| 424 | * @return \Aimeos\MShop\Customer\Item\Iface $item Updated item including the generated ID  | 
            ||
| 425 | */  | 
            ||
| 426 | public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item, $fetch = true )  | 
            ||
| 427 | 	{ | 
            ||
| 428 | if( !$item->isModified() )  | 
            ||
| 429 | 		{ | 
            ||
| 430 | $item = $this->savePropertyItems( $item, 'customer' );  | 
            ||
| 431 | $item = $this->saveAddressItems( $item, 'customer' );  | 
            ||
| 432 | return $this->saveListItems( $item, 'customer' );  | 
            ||
| 433 | }  | 
            ||
| 434 | |||
| 435 | $context = $this->getContext();  | 
            ||
| 436 | $dbm = $context->getDatabaseManager();  | 
            ||
| 437 | $dbname = $this->getResourceName();  | 
            ||
| 438 | $conn = $dbm->acquire( $dbname );  | 
            ||
| 439 | |||
| 440 | try  | 
            ||
| 441 | 		{ | 
            ||
| 442 | $id = $item->getId();  | 
            ||
| 443 | $billingAddress = $item->getPaymentAddress();  | 
            ||
| 444 | $columns = $this->getObject()->getSaveAttributes();  | 
            ||
| 445 | |||
| 446 | if( $id === null )  | 
            ||
| 447 | 			{ | 
            ||
| 448 | /** mshop/customer/manager/typo3/insert  | 
            ||
| 449 | * Inserts a new customer record into the database table  | 
            ||
| 450 | *  | 
            ||
| 451 | * Items with no ID yet (i.e. the ID is NULL) will be created in  | 
            ||
| 452 | * the database and the newly created ID retrieved afterwards  | 
            ||
| 453 | * using the "newid" SQL statement.  | 
            ||
| 454 | *  | 
            ||
| 455 | * The SQL statement must be a string suitable for being used as  | 
            ||
| 456 | * prepared statement. It must include question marks for binding  | 
            ||
| 457 | * the values from the customer item to the statement before they are  | 
            ||
| 458 | * sent to the database server. The number of question marks must  | 
            ||
| 459 | * be the same as the number of columns listed in the INSERT  | 
            ||
| 460 | * statement. The order of the columns must correspond to the  | 
            ||
| 461 | * order in the saveItems() method, so the correct values are  | 
            ||
| 462 | * bound to the columns.  | 
            ||
| 463 | *  | 
            ||
| 464 | * The SQL statement should conform to the ANSI standard to be  | 
            ||
| 465 | * compatible with most relational database systems. This also  | 
            ||
| 466 | * includes using double quotes for table and column names.  | 
            ||
| 467 | *  | 
            ||
| 468 | * @param string SQL statement for inserting records  | 
            ||
| 469 | * @since 2014.03  | 
            ||
| 470 | * @category Developer  | 
            ||
| 471 | * @see mshop/customer/manager/typo3/update  | 
            ||
| 472 | * @see mshop/customer/manager/typo3/newid  | 
            ||
| 473 | * @see mshop/customer/manager/typo3/delete  | 
            ||
| 474 | * @see mshop/customer/manager/typo3/search  | 
            ||
| 475 | * @see mshop/customer/manager/typo3/count  | 
            ||
| 476 | */  | 
            ||
| 477 | $path = 'mshop/customer/manager/typo3/insert';  | 
            ||
| 478 | $sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ) );  | 
            ||
| 479 | }  | 
            ||
| 480 | else  | 
            ||
| 481 | 			{ | 
            ||
| 482 | /** mshop/customer/manager/typo3/update  | 
            ||
| 483 | * Updates an existing customer record in the database  | 
            ||
| 484 | *  | 
            ||
| 485 | * Items which already have an ID (i.e. the ID is not NULL) will  | 
            ||
| 486 | * be updated in the database.  | 
            ||
| 487 | *  | 
            ||
| 488 | * The SQL statement must be a string suitable for being used as  | 
            ||
| 489 | * prepared statement. It must include question marks for binding  | 
            ||
| 490 | * the values from the customer item to the statement before they are  | 
            ||
| 491 | * sent to the database server. The order of the columns must  | 
            ||
| 492 | * correspond to the order in the saveItems() method, so the  | 
            ||
| 493 | * correct values are bound to the columns.  | 
            ||
| 494 | *  | 
            ||
| 495 | * The SQL statement should conform to the ANSI standard to be  | 
            ||
| 496 | * compatible with most relational database systems. This also  | 
            ||
| 497 | * includes using double quotes for table and column names.  | 
            ||
| 498 | *  | 
            ||
| 499 | * @param string SQL statement for updating records  | 
            ||
| 500 | * @since 2014.03  | 
            ||
| 501 | * @category Developer  | 
            ||
| 502 | * @see mshop/customer/manager/typo3/insert  | 
            ||
| 503 | * @see mshop/customer/manager/typo3/newid  | 
            ||
| 504 | * @see mshop/customer/manager/typo3/delete  | 
            ||
| 505 | * @see mshop/customer/manager/typo3/search  | 
            ||
| 506 | * @see mshop/customer/manager/typo3/count  | 
            ||
| 507 | */  | 
            ||
| 508 | $path = 'mshop/customer/manager/typo3/update';  | 
            ||
| 509 | $sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ), false );  | 
            ||
| 510 | }  | 
            ||
| 511 | |||
| 512 | $address = $billingAddress->getAddress1();  | 
            ||
| 513 | |||
| 514 | 			if( ( $part = $billingAddress->getAddress2() ) != '' ) { | 
            ||
| 515 | $address .= ' ' . $part;  | 
            ||
| 516 | }  | 
            ||
| 517 | |||
| 518 | 			if( ( $part = $billingAddress->getAddress3() ) != '' ) { | 
            ||
| 519 | $address .= ' ' . $part;  | 
            ||
| 520 | }  | 
            ||
| 521 | |||
| 522 | $idx = 1;  | 
            ||
| 523 | $stmt = $this->getCachedStatement( $conn, $path, $sql );  | 
            ||
| 524 | |||
| 525 | 			foreach( $columns as $name => $entry ) { | 
            ||
| 526 | $stmt->bind( $idx++, $item->get( $name ), $entry->getInternalType() );  | 
            ||
| 527 | }  | 
            ||
| 528 | |||
| 529 | // TYPO3 fe_users.static_info_country is a three letter ISO code instead a two letter one  | 
            ||
| 530 | $stmt->bind( $idx++, $context->getLocale()->getSiteId(), \Aimeos\MW\DB\Statement\Base::PARAM_INT );  | 
            ||
| 531 | $stmt->bind( $idx++, $item->getLabel() );  | 
            ||
| 532 | $stmt->bind( $idx++, $item->getCode() );  | 
            ||
| 533 | $stmt->bind( $idx++, $this->plugins['customer.salutation']->translate( $billingAddress->getSalutation() ), \Aimeos\MW\DB\Statement\Base::PARAM_INT );  | 
            ||
| 534 | $stmt->bind( $idx++, $billingAddress->getCompany() );  | 
            ||
| 535 | $stmt->bind( $idx++, $billingAddress->getVatID() );  | 
            ||
| 536 | $stmt->bind( $idx++, $billingAddress->getTitle() );  | 
            ||
| 537 | $stmt->bind( $idx++, $billingAddress->getFirstname() );  | 
            ||
| 538 | $stmt->bind( $idx++, $billingAddress->getLastname() );  | 
            ||
| 539 | $stmt->bind( $idx++, $address );  | 
            ||
| 540 | $stmt->bind( $idx++, $billingAddress->getPostal() );  | 
            ||
| 541 | $stmt->bind( $idx++, $billingAddress->getCity() );  | 
            ||
| 542 | $stmt->bind( $idx++, $billingAddress->getState() );  | 
            ||
| 543 | $stmt->bind( $idx++, $billingAddress->getLanguageId() );  | 
            ||
| 544 | $stmt->bind( $idx++, $billingAddress->getTelephone() );  | 
            ||
| 545 | $stmt->bind( $idx++, $billingAddress->getEmail() );  | 
            ||
| 546 | $stmt->bind( $idx++, $billingAddress->getTelefax() );  | 
            ||
| 547 | $stmt->bind( $idx++, $billingAddress->getWebsite() );  | 
            ||
| 548 | $stmt->bind( $idx++, $billingAddress->getLongitude(), \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT );  | 
            ||
| 549 | $stmt->bind( $idx++, $billingAddress->getLatitude(), \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT );  | 
            ||
| 550 | $stmt->bind( $idx++, $this->plugins['customer.birthday']->translate( $item->getBirthday() ), \Aimeos\MW\DB\Statement\Base::PARAM_INT );  | 
            ||
| 551 | $stmt->bind( $idx++, $this->plugins['customer.status']->translate( $item->getStatus() ), \Aimeos\MW\DB\Statement\Base::PARAM_INT );  | 
            ||
| 552 | $stmt->bind( $idx++, $item->getPassword() );  | 
            ||
| 553 | $stmt->bind( $idx++, time(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); // Modification time  | 
            ||
| 554 | $stmt->bind( $idx++, $billingAddress->getCountryId() );  | 
            ||
| 555 | $stmt->bind( $idx++, implode( ',', $item->getGroups() ) );  | 
            ||
| 556 | $stmt->bind( $idx++, $this->pid, \Aimeos\MW\DB\Statement\Base::PARAM_INT ); // TYPO3 PID value  | 
            ||
| 557 | |||
| 558 | 			if( $id !== null ) { | 
            ||
| 559 | $stmt->bind( $idx, $id, \Aimeos\MW\DB\Statement\Base::PARAM_INT );  | 
            ||
| 560 | $item->setId( $id );  | 
            ||
| 561 | 			} else { | 
            ||
| 562 | $stmt->bind( $idx, time(), \Aimeos\MW\DB\Statement\Base::PARAM_INT ); // Creation time  | 
            ||
| 563 | }  | 
            ||
| 564 | |||
| 565 | $stmt->execute()->finish();  | 
            ||
| 566 | |||
| 567 | if( $id === null && $fetch === true )  | 
            ||
| 568 | 			{ | 
            ||
| 569 | /** mshop/customer/manager/typo3/newid  | 
            ||
| 570 | * Retrieves the ID generated by the database when inserting a new record  | 
            ||
| 571 | *  | 
            ||
| 572 | * As soon as a new record is inserted into the database table,  | 
            ||
| 573 | * the database server generates a new and unique identifier for  | 
            ||
| 574 | * that record. This ID can be used for retrieving, updating and  | 
            ||
| 575 | * deleting that specific record from the table again.  | 
            ||
| 576 | *  | 
            ||
| 577 | * For MySQL:  | 
            ||
| 578 | * SELECT LAST_INSERT_ID()  | 
            ||
| 579 | * For PostgreSQL:  | 
            ||
| 580 | 				 *  SELECT currval('seq_mcus_id') | 
            ||
| 581 | * For SQL Server:  | 
            ||
| 582 | * SELECT SCOPE_IDENTITY()  | 
            ||
| 583 | * For Oracle:  | 
            ||
| 584 | * SELECT "seq_mcus_id".CURRVAL FROM DUAL  | 
            ||
| 585 | *  | 
            ||
| 586 | * There's no way to retrive the new ID by a SQL statements that  | 
            ||
| 587 | * fits for most database servers as they implement their own  | 
            ||
| 588 | * specific way.  | 
            ||
| 589 | *  | 
            ||
| 590 | * @param string SQL statement for retrieving the last inserted record ID  | 
            ||
| 591 | * @since 2014.03  | 
            ||
| 592 | * @category Developer  | 
            ||
| 593 | * @see mshop/customer/manager/typo3/insert  | 
            ||
| 594 | * @see mshop/customer/manager/typo3/update  | 
            ||
| 595 | * @see mshop/customer/manager/typo3/delete  | 
            ||
| 596 | * @see mshop/customer/manager/typo3/search  | 
            ||
| 597 | * @see mshop/customer/manager/typo3/count  | 
            ||
| 598 | */  | 
            ||
| 599 | $path = 'mshop/customer/manager/typo3/newid';  | 
            ||
| 600 | $item->setId( $this->newId( $conn, $path ) );  | 
            ||
| 601 | }  | 
            ||
| 602 | |||
| 603 | $dbm->release( $conn, $dbname );  | 
            ||
| 604 | }  | 
            ||
| 605 | catch( \Exception $e )  | 
            ||
| 606 | 		{ | 
            ||
| 607 | $dbm->release( $conn, $dbname );  | 
            ||
| 608 | throw $e;  | 
            ||
| 609 | }  | 
            ||
| 610 | |||
| 611 | $item = $this->savePropertyItems( $item, 'customer' );  | 
            ||
| 612 | $item = $this->saveAddressItems( $item, 'customer' );  | 
            ||
| 613 | return $this->saveListItems( $item, 'customer' );  | 
            ||
| 614 | }  | 
            ||
| 615 | |||
| 616 | |||
| 617 | /**  | 
            ||
| 618 | * Returns the item objects matched by the given search criteria.  | 
            ||
| 619 | *  | 
            ||
| 620 | * @param \Aimeos\MW\Criteria\Iface $search Search criteria object  | 
            ||
| 621 | * @param integer &$total Number of items that are available in total  | 
            ||
| 622 | * @return array List of items implementing \Aimeos\MShop\Customer\Item\Iface  | 
            ||
| 623 | * @throws \Aimeos\MShop\Customer\Exception If creating items failed  | 
            ||
| 624 | */  | 
            ||
| 625 | public function searchItems( \Aimeos\MW\Criteria\Iface $search, array $ref = [], &$total = null )  | 
            ||
| 626 | 	{ | 
            ||
| 627 | $dbm = $this->getContext()->getDatabaseManager();  | 
            ||
| 628 | $dbname = $this->getResourceName();  | 
            ||
| 629 | $conn = $dbm->acquire( $dbname );  | 
            ||
| 630 | $map = [];  | 
            ||
| 631 | |||
| 632 | try  | 
            ||
| 633 | 		{ | 
            ||
| 634 | $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;  | 
            ||
| 635 | $cfgPathSearch = 'mshop/customer/manager/typo3/search';  | 
            ||
| 636 | $cfgPathCount = 'mshop/customer/manager/typo3/count';  | 
            ||
| 637 | $required = array( 'customer' );  | 
            ||
| 638 | |||
| 639 | $results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level, $this->plugins );  | 
            ||
| 640 | 			while( ( $row = $results->fetch() ) !== false ) { | 
            ||
| 641 | $map[(string) $row['customer.id']] = $row;  | 
            ||
| 642 | }  | 
            ||
| 643 | |||
| 644 | $dbm->release( $conn, $dbname );  | 
            ||
| 645 | }  | 
            ||
| 646 | catch( \Exception $e )  | 
            ||
| 647 | 		{ | 
            ||
| 648 | $dbm->release( $conn, $dbname );  | 
            ||
| 649 | throw $e;  | 
            ||
| 650 | }  | 
            ||
| 651 | |||
| 652 | $addrItems = [];  | 
            ||
| 653 | 		if( in_array( 'customer/address', $ref, true ) ) { | 
            ||
| 654 | $addrItems = $this->getAddressItems( array_keys( $map ), 'customer' );  | 
            ||
| 655 | }  | 
            ||
| 656 | |||
| 657 | $propItems = []; $name = 'customer/property';  | 
            ||
| 658 | if( isset( $ref[$name] ) || in_array( $name, $ref, true ) )  | 
            ||
| 659 | 		{ | 
            ||
| 660 | $propTypes = isset( $ref[$name] ) && is_array( $ref[$name] ) ? $ref[$name] : null;  | 
            ||
| 661 | $propItems = $this->getPropertyItems( array_keys( $map ), 'customer', $propTypes );  | 
            ||
| 662 | }  | 
            ||
| 663 | |||
| 664 | return $this->buildItems( $map, $ref, 'customer', $addrItems, $propItems );  | 
            ||
| 665 | }  | 
            ||
| 666 | |||
| 667 | |||
| 668 | /**  | 
            ||
| 669 | * Returns a new manager for customer extensions  | 
            ||
| 670 | *  | 
            ||
| 671 | * @param string $manager Name of the sub manager type in lower case  | 
            ||
| 672 | * @param string|null $name Name of the implementation, will be from configuration (or Default) if null  | 
            ||
| 673 | * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.  | 
            ||
| 674 | */  | 
            ||
| 675 | public function getSubManager( $manager, $name = null )  | 
            ||
| 678 | }  | 
            ||
| 679 | |||
| 680 | |||
| 681 | /**  | 
            ||
| 682 | * Creates a new customer item.  | 
            ||
| 683 | *  | 
            ||
| 684 | * @param array $values List of attributes for customer item  | 
            ||
| 685 | * @param \Aimeos\MShop\Common\Lists\Item\Iface[] $listItems List of list items  | 
            ||
| 686 | * @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items  | 
            ||
| 687 | * @param \Aimeos\MShop\Common\Item\Address\Iface[] $addrItems List of referenced address items  | 
            ||
| 688 | * @param \Aimeos\MShop\Common\Item\Property\Iface[] $propItems List of property items  | 
            ||
| 689 | * @return \Aimeos\MShop\Customer\Item\Iface New customer item  | 
            ||
| 690 | */  | 
            ||
| 691 | protected function createItemBase( array $values = [], array $listItems = [], array $refItems = [],  | 
            ||
| 692 | array $addrItems = [], array $propItems = [] )  | 
            ||
| 693 | 	{ | 
            ||
| 694 | $helper = $this->getPasswordHelper();  | 
            ||
| 695 | $values['customer.siteid'] = $this->getContext()->getLocale()->getSiteId();  | 
            ||
| 696 | |||
| 697 | 		if( array_key_exists( 'date_of_birth', $values ) ) { | 
            ||
| 698 | $values['customer.birthday'] = $this->reverse['date_of_birth']->reverse( $values['date_of_birth'] );  | 
            ||
| 699 | }  | 
            ||
| 700 | |||
| 701 | 		if( array_key_exists( 'gender', $values ) ) { | 
            ||
| 702 | $values['customer.salutation'] = $this->reverse['gender']->reverse( $values['gender'] );  | 
            ||
| 703 | }  | 
            ||
| 704 | |||
| 705 | 		if( array_key_exists( 'disable', $values ) ) { | 
            ||
| 706 | $values['customer.status'] = $this->reverse['disable']->reverse( $values['disable'] );  | 
            ||
| 707 | }  | 
            ||
| 708 | |||
| 709 | 		if( array_key_exists( 'tstamp', $values ) ) { | 
            ||
| 710 | $values['customer.mtime'] = $this->reverse['tstamp']->reverse( $values['tstamp'] );  | 
            ||
| 711 | }  | 
            ||
| 712 | |||
| 713 | 		if( array_key_exists( 'crdate', $values ) ) { | 
            ||
| 714 | $values['customer.ctime'] = $this->reverse['crdate']->reverse( $values['crdate'] );  | 
            ||
| 715 | }  | 
            ||
| 716 | |||
| 717 | 		if( array_key_exists( 'groups', $values ) && $values['groups'] !== '' ) { | 
            ||
| 718 | $values['customer.groups'] = explode( ',', $values['groups'] );  | 
            ||
| 719 | }  | 
            ||
| 720 | |||
| 721 | |||
| 722 | $address = new \Aimeos\MShop\Common\Item\Address\Simple( 'customer.', $values );  | 
            ||
| 723 | |||
| 724 | return new \Aimeos\MShop\Customer\Item\Standard(  | 
            ||
| 725 | $address, $values, $listItems, $refItems, $addrItems, $propItems, $helper  | 
            ||
| 726 | );  | 
            ||
| 727 | }  | 
            ||
| 728 | |||
| 729 | |||
| 730 | /**  | 
            ||
| 731 | * Returns a password helper object based on the configuration.  | 
            ||
| 732 | *  | 
            ||
| 733 | * @return \Aimeos\MShop\Common\Helper\Password\Iface Password helper object  | 
            ||
| 734 | * @throws \Aimeos\MShop\Exception If the name is invalid or the class isn't found  | 
            ||
| 735 | */  | 
            ||
| 736 | protected function getPasswordHelper()  | 
            ||
| 754 | }  | 
            ||
| 755 | }  | 
            ||
| 756 |