admin/jqadm/src/Admin/JQAdm/Attribute/Media/Standard.php
protected function deleteMediaItems( \Aimeos\MShop\Attribute\Item\Iface $item, array $listItems )
	{
		$context = $this->getContext();
		$cntl = \Aimeos\Controller\Common\Media\Factory::create( $context );
		$manager = \Aimeos\MShop::create( $context, 'attribute' );
		$search = $manager->createSearch();

		foreach( $listItems as $listItem )
		{
			$func = $search->createFunction( 'attribute:has', ['media', $listItem->getType(), $listItem->getRefId()] );
			$search->setConditions( $search->compare( '!=', $func, null ) );
			$items = $manager->searchItems( $search );
			$refItem = null;

			if( count( $items ) === 1 && ( $refItem = $listItem->getRefItem() ) !== null ) {
				$cntl->delete( $refItem );
			}

			$item->deleteListItem( 'media', $listItem, $refItem );
		}

		return $item;
	}
protected function deleteMediaItems( \Aimeos\MShop\Attribute\Item\Iface $item, array $listItems )
	{
		$context = $this->getContext();
		$cntl = \Aimeos\Controller\Common\Media\Factory::create( $context );
		$manager = \Aimeos\MShop::create( $context, 'attribute' );
		$search = $manager->createSearch();

		foreach( $listItems as $listItem )
		{
			$func = $search->createFunction( 'attribute:has', ['media', $listItem->getType(), $listItem->getRefId()] );
			$search->setConditions( $search->compare( '!=', $func, null ) );
			$items = $manager->searchItems( $search );
			$refItem = null;

			if( count( $items ) === 1 && ( $refItem = $listItem->getRefItem() ) !== null ) {
				$cntl->delete( $refItem );
			}

			$item->deleteListItem( 'media', $listItem, $refItem );
		}

		return $item;
	}
protected function deleteMediaItems ( \ Aimeos \ MShop \ Attribute \ Item \ Iface $ item , array $ listItems ) { $ context = $ this -> getContext ( ) ; $ cntl = \ Aimeos \ Controller \ Common \ Media \ Factory :: create ( $ context ) ; $ manager = \ Aimeos \ MShop :: create ( $ context , 'attribute' ) ; $ search = $ manager -> createSearch ( ) ; foreach ( $ listItems as $ listItem ) { $ func = $ search -> createFunction ( 'attribute:has' , [ 'media' , $ listItem -> getType ( ) , $ listItem -> getRefId ( ) ] ) ; $ search -> setConditions ( $ search -> compare ( '!=' , $ func , null ) ) ; $ items = $ manager -> searchItems ( $ search ) ; $ refItem = null ; if ( count ( $ items ) === 1 && ( $ refItem = $ listItem -> getRefItem ( ) ) !== null ) { $ cntl -> delete ( $ refItem ) ; } $ item -> deleteListItem ( 'media' , $ listItem , $ refItem ) ; } return $ item ; }
Removes the media reference and the media item if not shared

@param \Aimeos\MShop\Attribute\Item\Iface $item Attribute item including media reference
@param array $listItems Media list items to be removed
@return \Aimeos\MShop\Attribute\Item\Iface Modified attribute item
Removes the media reference and the media item if not shared