Skip to content

Commit

Permalink
Replaced deleteItems() by delete() method
Browse files Browse the repository at this point in the history
  • Loading branch information
aimeos committed Nov 11, 2020
1 parent 93fe313 commit 2e8c1ee
Show file tree
Hide file tree
Showing 93 changed files with 133 additions and 164 deletions.
8 changes: 4 additions & 4 deletions lib/mshoplib/setup/MShopAddDataAbstract.php
Expand Up @@ -471,7 +471,7 @@ protected function removeItems( $parentid, $name, $domain, $refdomain )
$search->setConditions( $search->combine( '&&', $expr ) );

$ids = $manager->search( $search )->keys()->toArray();
$manager->deleteItems( $ids );
$manager->delete( $ids );


$search = $listManager->filter();
Expand All @@ -482,7 +482,7 @@ protected function removeItems( $parentid, $name, $domain, $refdomain )
);
$search->setConditions( $search->combine( '&&', $expr ) );

$listManager->deleteItems( $listManager->search( $search )->toArray() );
$listManager->delete( $listManager->search( $search )->toArray() );
}


Expand Down Expand Up @@ -530,7 +530,7 @@ protected function removeListItems( $parentid, $name, $refdomain )
$listIds = array_merge( $listIds, $map[$refId] );
}

$listManager->deleteItems( $listIds );
$listManager->delete( $listIds );


$count = count( $result );
Expand All @@ -552,7 +552,7 @@ protected function removeListItems( $parentid, $name, $refdomain )
);
$search->setConditions( $search->combine( '&&', $expr ) );

$listManager->deleteItems( $listManager->search( $search )->toArray() );
$listManager->delete( $listManager->search( $search )->toArray() );
}


Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/default/DemoAddCatalogData.php
Expand Up @@ -70,7 +70,7 @@ public function migrate()

$search = $manager->filter();
$search->setConditions( $search->compare( '=~', 'catalog.code', 'demo-' ) );
$manager->deleteItems( $manager->search( $search )->getId()->toArray() );
$manager->delete( $manager->search( $search )->getId()->toArray() );


if( $value === '1' )
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/default/DemoAddCouponData.php
Expand Up @@ -48,7 +48,7 @@ public function migrate()
$search->setConditions( $search->compare( '=~', 'coupon.label', 'demo-' ) );
$services = $manager->search( $search );

$manager->deleteItems( $services->toArray() );
$manager->delete( $services->toArray() );


if( $value === '1' )
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/default/DemoAddCustomerData.php
Expand Up @@ -49,7 +49,7 @@ public function migrate()
$search->setConditions( $search->compare( '==', 'customer.code', 'demo@example.com' ) );
$services = $manager->search( $search );

$manager->deleteItems( $services->toArray() );
$manager->delete( $services->toArray() );


if( $value === '1' )
Expand Down
8 changes: 4 additions & 4 deletions lib/mshoplib/setup/default/DemoAddProductData.php
Expand Up @@ -69,10 +69,10 @@ public function migrate()
$rmIds = $rmIds->merge( $item->getRefItems( $domain, null, null, false )->keys() );
}

\Aimeos\MShop::create( $context, $domain )->deleteItems( $rmIds->toArray() );
\Aimeos\MShop::create( $context, $domain )->delete( $rmIds->toArray() );
}

$manager->deleteItems( $products->toArray() );
$manager->delete( $products->toArray() );
$this->removeAttributeItems();
$this->removeStockItems();

Expand Down Expand Up @@ -257,7 +257,7 @@ protected function removeAttributeItems()
$search = $manager->filter();
$search->setConditions( $search->compare( '=~', 'attribute.label', 'Demo:' ) );

$manager->deleteItems( $manager->search( $search )->toArray() );
$manager->delete( $manager->search( $search )->toArray() );
}


Expand All @@ -271,6 +271,6 @@ protected function removeStockItems()
$search = $manager->filter();
$search->setConditions( $search->compare( '=~', 'stock.productcode', 'demo-' ) );

$manager->deleteItems( $manager->search( $search )->toArray() );
$manager->delete( $manager->search( $search )->toArray() );
}
}
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/default/DemoAddServiceData.php
Expand Up @@ -56,7 +56,7 @@ public function migrate()
$this->removeItems( $item->getId(), 'service/lists', 'service', 'text' );
}

$manager->deleteItems( $services->toArray() );
$manager->delete( $services->toArray() );


if( $value === '1' )
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/default/DemoAddSupplierData.php
Expand Up @@ -59,7 +59,7 @@ public function migrate()
$search->setConditions( $search->compare( '=~', 'supplier.code', 'demo-' ) );
$services = $manager->search( $search );

$manager->deleteItems( $services->toArray() );
$manager->delete( $services->toArray() );


if( $value === '1' )
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MAdmin/Cache/Manager/None.php
Expand Up @@ -76,7 +76,7 @@ public function saveItem( \Aimeos\MAdmin\Cache\Item\Iface $item, bool $fetch = t
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MAdmin\Cache\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
return $this;
}
Expand Down
10 changes: 7 additions & 3 deletions lib/mshoplib/src/MAdmin/Cache/Manager/Standard.php
Expand Up @@ -372,12 +372,16 @@ public function saveItem( \Aimeos\MAdmin\Cache\Item\Iface $item, bool $fetch = t
/**
* Removes multiple items.
*
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @param \Aimeos\MShop\Common\Item\Iface|array|string $items List of item objects or IDs of the items
* @return \Aimeos\MAdmin\Cache\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface
{
$this->getCache()->deleteMultiple( $itemIds );
if( is_map( $items ) ) { $items = $items->toArray(); }
if( !is_array( $items ) ) { $items = [$items]; }
if( empty( $items ) ) { return $this; }

$this->getCache()->deleteMultiple( $items );
return $this;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MAdmin/Job/Manager/Standard.php
Expand Up @@ -344,7 +344,7 @@ public function saveItem( \Aimeos\MAdmin\Job\Item\Iface $item, bool $fetch = tru
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MAdmin\Job\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** madmin/job/manager/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MAdmin/Log/Manager/Standard.php
Expand Up @@ -356,7 +356,7 @@ public function saveItem( \Aimeos\MAdmin\Log\Item\Iface $item, bool $fetch = tru
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MAdmin\Log\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** madmin/log/manager/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Attribute/Manager/Standard.php
Expand Up @@ -512,7 +512,7 @@ public function saveItem( \Aimeos\MShop\Attribute\Item\Iface $item, bool $fetch
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Attribute\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** mshop/attribute/manager/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
36 changes: 14 additions & 22 deletions lib/mshoplib/src/MShop/Catalog/Manager/Standard.php
Expand Up @@ -296,20 +296,28 @@ public function filter( bool $default = false, bool $site = false ) : \Aimeos\MW


/**
* Deletes the item.
* Removes multiple items.
*
* @param \Aimeos\MShop\Common\Item\Iface|string $itemId Item object or ID of the item object
* @param \Aimeos\MShop\Common\Item\Iface|array|string $items List of item objects or IDs of the items
* @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls
*/
public function delete( $id ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface
{
if( is_map( $items ) ) { $items = $items->toArray(); }
if( !is_array( $items ) ) { $items = [$items]; }
if( empty( $items ) ) { return $this; }

$this->begin();
$this->lock();

try
{
$siteid = $this->getContext()->getLocale()->getSiteId();
$this->createTreeManager( $siteid )->deleteNode( $id );

foreach( $items as $item ) {
$this->createTreeManager( $siteid )->deleteNode( (string) $item );
}

$this->unlock();
$this->commit();
}
Expand All @@ -320,23 +328,7 @@ public function delete( $id ) : \Aimeos\MShop\Common\Manager\Iface
throw $e;
}

return $this;
}


/**
* Removes multiple items.
*
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
foreach( $itemIds as $itemId ) {
$this->getObject()->delete( $itemId );
}

return $this->deleteRefItems( $itemIds );
return $this->deleteRefItems( $items );
}


Expand Down Expand Up @@ -845,7 +837,7 @@ protected function saveChildren( \Aimeos\MShop\Catalog\Item\Iface $item ) : \Aim
$rmIds[] = $child->getId();
}

$this->deleteItems( $rmIds );
$this->delete( $rmIds );

foreach( $item->getChildren() as $child )
{
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Common/Manager/Address/Base.php
Expand Up @@ -71,7 +71,7 @@ public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Common\Manager\Address\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
return $this->deleteItemsBase( $itemIds, $this->getConfigPath() . 'delete' );
}
Expand Down
Expand Up @@ -91,7 +91,7 @@ protected function saveAddressItems( \Aimeos\MShop\Common\Item\AddressRef\Iface
{
$pos = 0;
$manager = $this->getObject()->getSubManager( 'address' );
$manager->deleteItems( $item->getAddressItemsDeleted()->keys()->toArray() );
$manager->delete( $item->getAddressItemsDeleted()->keys()->toArray() );

foreach( $item->getAddressItems() as $idx => $addrItem )
{
Expand Down
16 changes: 0 additions & 16 deletions lib/mshoplib/src/MShop/Common/Manager/Base.php
Expand Up @@ -101,22 +101,6 @@ public function filter( bool $default = false, bool $site = false ) : \Aimeos\MW
}


/**
* Deletes one or more items.
*
* @param \Aimeos\MShop\Common\Item\Iface|array|string $items Item object, ID of the item or a list of them
* @return \Aimeos\MShop\Common\Manager\Iface Manager object for chaining method calls
*/
public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface
{
if( !is_array( $items ) ) {
$items = [$items];
}

return $this->getObject()->deleteItems( $items );
}


/**
* Adds or updates an item object or a list of them.
*
Expand Down
13 changes: 0 additions & 13 deletions lib/mshoplib/src/MShop/Common/Manager/Decorator/Base.php
Expand Up @@ -102,19 +102,6 @@ public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface
}


/**
* Removes multiple items.
*
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Common\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
$this->manager->deleteItems( $itemIds );
return $this;
}


/**
* Creates a filter object.
*
Expand Down
6 changes: 3 additions & 3 deletions lib/mshoplib/src/MShop/Common/Manager/ListRef/Traits.php
Expand Up @@ -145,7 +145,7 @@ protected function deleteRefItems( $items ) : \Aimeos\MShop\Common\Manager\ListR
}

foreach( $map as $domain => $ids ) {
\Aimeos\MShop::create( $this->getContext(), $domain )->begin()->deleteItems( $ids )->commit();
\Aimeos\MShop::create( $this->getContext(), $domain )->begin()->delete( $ids )->commit();
}

return $this;
Expand Down Expand Up @@ -268,10 +268,10 @@ protected function saveListItems( \Aimeos\MShop\Common\Item\ListRef\Iface $item,
$refManager[$refDomain] = \Aimeos\MShop::create( $context, $refDomain );
$refManager[$refDomain]->begin();

$refManager[$refDomain]->deleteItems( $ids );
$refManager[$refDomain]->delete( $ids );
}

$listManager->deleteItems( $rmListIds );
$listManager->delete( $rmListIds );


foreach( $item->getListItems( null, null, null, false ) as $listItem )
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Common/Manager/Lists/Base.php
Expand Up @@ -169,7 +169,7 @@ public function saveItem( \Aimeos\MShop\Common\Item\Lists\Iface $item, bool $fet
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Common\Manager\Lists\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
return $this->deleteItemsBase( $itemIds, $this->getConfigPath() . 'delete' );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Common/Manager/Property/Base.php
Expand Up @@ -170,7 +170,7 @@ public function saveItem( \Aimeos\MShop\Common\Item\Property\Iface $item, bool $
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Common\Manager\Property\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
return $this->deleteItemsBase( $itemIds, $this->getConfigPath() . 'delete' );
}
Expand Down
Expand Up @@ -98,7 +98,7 @@ protected function savePropertyItems( \Aimeos\MShop\Common\Item\PropertyRef\Ifac
bool $fetch = true ) : \Aimeos\MShop\Common\Item\PropertyRef\Iface
{
$propManager = $this->getObject()->getSubManager( 'property' );
$propManager->deleteItems( $item->getPropertyItemsDeleted()->keys()->toArray() );
$propManager->delete( $item->getPropertyItemsDeleted()->keys()->toArray() );

foreach( $item->getPropertyItems( null, false ) as $propItem )
{
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Common/Manager/Type/Base.php
Expand Up @@ -161,7 +161,7 @@ public function saveItem( \Aimeos\MShop\Common\Item\Type\Iface $item, bool $fetc
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Common\Manager\Type\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
return $this->deleteItemsBase( $itemIds, $this->getConfigPath() . 'delete' );
}
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Coupon/Manager/Code/Standard.php
Expand Up @@ -549,7 +549,7 @@ public function saveItem( \Aimeos\MShop\Coupon\Item\Code\Iface $item, bool $fetc
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Coupon\Manager\Code\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** mshop/coupon/manager/code/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Coupon/Manager/Standard.php
Expand Up @@ -405,7 +405,7 @@ public function saveItem( \Aimeos\MShop\Coupon\Item\Iface $item, bool $fetch = t
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Coupon\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** mshop/coupon/manager/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Customer/Manager/Group/Standard.php
Expand Up @@ -171,7 +171,7 @@ public function getSearchAttributes( bool $withsub = true ) : array
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Customer\Manager\Group\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** mshop/customer/manager/group/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Customer/Manager/Standard.php
Expand Up @@ -416,7 +416,7 @@ public function getSearchAttributes( bool $withsub = true ) : array
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Customer\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** mshop/customer/manager/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down
Expand Up @@ -170,7 +170,7 @@ public function cleanup( string $timestamp ) : \Aimeos\MShop\Index\Manager\Iface
* @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
* @return \Aimeos\MShop\Index\Manager\Iface Manager object for chaining method calls
*/
public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
{
/** mshop/index/manager/attribute/standard/delete/mysql
* Deletes the items matched by the given IDs from the database
Expand Down

0 comments on commit 2e8c1ee

Please sign in to comment.