Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Renamed findItem() to find()
  • Loading branch information
aimeos committed Nov 2, 2020
1 parent cae5a77 commit 1697791
Show file tree
Hide file tree
Showing 62 changed files with 140 additions and 170 deletions.
Expand Up @@ -119,7 +119,7 @@ public function testAddStatusItem()
public function testGetBundleMap()
{
$context = \TestHelperCntl::getContext();
$prodId = \Aimeos\MShop::create( $context, 'product' )->findItem( 'CNC' )->getId();
$prodId = \Aimeos\MShop::create( $context, 'product' )->find( 'CNC' )->getId();

$class = new \ReflectionClass( \Aimeos\Controller\Common\Order\Standard::class );
$method = $class->getMethod( 'getBundleMap' );
Expand Down Expand Up @@ -567,7 +567,7 @@ public function testUpdateStockBundle()
public function testUpdateStockSelection()
{
$context = \TestHelperCntl::getContext();
$prodId = \Aimeos\MShop::create( $context, 'product' )->findItem( 'U:TEST' )->getId();
$prodId = \Aimeos\MShop::create( $context, 'product' )->find( 'U:TEST' )->getId();


$stockStub = $this->getMockBuilder( \Aimeos\MShop\Stock\Manager\Standard::class )
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/MShopAddCodeData.php
Expand Up @@ -52,7 +52,7 @@ protected function process( array $data )

try
{
$item = $domainManager->findItem( $dataset['code'] );
$item = $domainManager->find( $dataset['code'] );
}
catch( \Exception $e )
{
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/setup/MShopAddLocaleData.php
Expand Up @@ -67,7 +67,7 @@ public function migrate()
}
catch( \Aimeos\MW\DB\Exception $e ) // already in the database
{
$siteItem = $siteManager->findItem( $code );
$siteItem = $siteManager->find( $code );
}

try
Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/setup/default/DemoAddProductData.php
Expand Up @@ -171,7 +171,7 @@ protected function addRefItems( \Aimeos\MShop\Common\Item\ListRef\Iface $item, a
try
{
$manager = \Aimeos\MShop::create( $context, 'attribute' );
$refItem = $manager->findItem( $refItem->getCode(), [], $domain, $refItem->getType() );
$refItem = $manager->find( $refItem->getCode(), [], $domain, $refItem->getType() );
}
catch( \Aimeos\MShop\Exception $e ) { ; } // attribute doesn't exist yet

Expand Down Expand Up @@ -212,7 +212,7 @@ protected function addRefItems( \Aimeos\MShop\Common\Item\ListRef\Iface $item, a
foreach( $entry['product'] as $data )
{
$listItem = $listManager->createItem()->fromArray( $data );
$listItem->setRefId( $manager->findItem( $data['product.code'] )->getId() );
$listItem->setRefId( $manager->find( $data['product.code'] )->getId() );

$item->addListItem( 'product', $listItem );
}
Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/setup/unittest/ReviewAddTestData.php
Expand Up @@ -67,8 +67,8 @@ protected function addData( array $testdata )

foreach( $list as $dataset )
{
$refId = $domainManager->findItem( $dataset['refid'] )->getId();
$custId = $custManager->findItem( $dataset['customerid'] )->getId();
$refId = $domainManager->find( $dataset['refid'] )->getId();
$custId = $custManager->find( $dataset['customerid'] )->getId();

$ordProdItem = $this->getOrderProductItem( $dataset['ordprodid'] );

Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Attribute/Manager/Standard.php
Expand Up @@ -291,15 +291,15 @@ public function createItem( array $values = [] ) : \Aimeos\MShop\Common\Item\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Attribute\Item\Iface Attribute item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
$find = array(
'attribute.code' => $code,
'attribute.domain' => $domain,
'attribute.type' => $type,
);
return $this->findItemBase( $find, $ref, $default );
return $this->findBase( $find, $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Catalog/Manager/Standard.php
Expand Up @@ -350,10 +350,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'catalog.code' => $code ), $ref, $default );
return $this->findBase( array( 'catalog.code' => $code ), $ref, $default );
}


Expand Down
19 changes: 1 addition & 18 deletions lib/mshoplib/src/MShop/Common/Manager/Base.php
Expand Up @@ -141,23 +141,6 @@ public function deleteItem( $itemId ) : \Aimeos\MShop\Common\Manager\Iface
}


/**
* Returns the item specified by its code and domain/type if necessary
*
* @param string $code Code of the item
* @param string[] $ref List of domains to fetch list items and referenced items for
* @param string|null $domain Domain of the item if necessary to identify the item uniquely
* @param string|null $type Type code of the item if necessary to identify the item uniquely
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function find( string $code, array $ref = [], string $domain = 'product', string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->getObject()->findItem( $code, $ref, $domain, $type, $default );
}


/**
* Adds or updates an item object or a list of them.
*
Expand Down Expand Up @@ -578,7 +561,7 @@ protected function getSqlConfig( string $path )
* @return \Aimeos\MShop\Common\Item\Iface Requested item
* @throws \Aimeos\MShop\Exception if no item with the given ID found
*/
protected function findItemBase( array $pairs, array $ref, bool $default ) : \Aimeos\MShop\Common\Item\Iface
protected function findBase( array $pairs, array $ref, bool $default ) : \Aimeos\MShop\Common\Item\Iface
{
$expr = [];
$criteria = $this->getObject()->filter( $default )->setSlice( 0, 1 );
Expand Down
15 changes: 1 addition & 14 deletions lib/mshoplib/src/MShop/Common/Manager/Find/Iface.php
Expand Up @@ -12,7 +12,7 @@


/**
* Common interface for managers implementing findItem()
* Common interface for managers implementing find()
*
* @package MShop
* @subpackage Common
Expand All @@ -31,17 +31,4 @@ interface Iface
*/
public function find( string $code, array $ref = [], string $domain = 'product', string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface;

/**
* Returns the item specified by its code and domain/type if necessary
*
* @param string $code Code of the item
* @param string[] $ref List of domains to fetch list items and referenced items for
* @param string|null $domain Domain of the item if necessary to identify the item uniquely
* @param string|null $type Type code of the item if necessary to identify the item uniquely
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = 'product', string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface;
}
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Common/Manager/Type/Base.php
Expand Up @@ -177,14 +177,14 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = 'product', string $type = null,
public function find( string $code, array $ref = [], string $domain = 'product', string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
$find = array(
$this->prefix . 'code' => $code,
$this->prefix . 'domain' => $domain,
);
return $this->findItemBase( $find, $ref, $default );
return $this->findBase( $find, $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Coupon/Manager/Code/Standard.php
Expand Up @@ -334,10 +334,10 @@ public function getSearchAttributes( bool $withsub = true ) : array
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'coupon.code.code' => $code ), $ref, $default );
return $this->findBase( array( 'coupon.code.code' => $code ), $ref, $default );
}


Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Coupon/Provider/Base.php
Expand Up @@ -219,7 +219,7 @@ protected function createProduct( string $prodcode, float $quantity = 1,
string $stocktype = 'default' ) : \Aimeos\MShop\Order\Item\Base\Product\Iface
{
$productManager = \Aimeos\MShop::create( $this->context, 'product' );
$product = $productManager->findItem( $prodcode, ['text', 'media', 'price'] );
$product = $productManager->find( $prodcode, ['text', 'media', 'price'] );

$priceManager = \Aimeos\MShop::create( $this->context, 'price' );
$prices = $product->getRefItems( 'price', 'default', 'default' );
Expand Down
Expand Up @@ -66,7 +66,7 @@ public function calcPrice( \Aimeos\MShop\Order\Item\Base\Iface $base ) : \Aimeos
$listManager = \Aimeos\MShop::create( $this->getContext(), 'catalog/lists' );

$price = \Aimeos\MShop::create( $this->getContext(), 'price' )->createItem();
$catItem = $manager->findItem( $this->getConfigValue( 'category.code' ) );
$catItem = $manager->find( $this->getConfigValue( 'category.code' ) );

$search = $listManager->filter( true )->setSlice( 0, count( $prodIds ) );
$search->setConditions( $search->combine( '&&', [
Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Coupon/Provider/Voucher.php
Expand Up @@ -77,7 +77,7 @@ public function update( \Aimeos\MShop\Order\Item\Base\Iface $base ) : \Aimeos\MS
}

$manager = \Aimeos\MShop::create( $this->getContext(), 'coupon/code' );
$orderProductId = $manager->findItem( $this->getCode() )->getRef();
$orderProductId = $manager->find( $this->getCode() )->getRef();

$status = [\Aimeos\MShop\Order\Item\Base::PAY_AUTHORIZED, \Aimeos\MShop\Order\Item\Base::PAY_RECEIVED];
$this->checkVoucher( $orderProductId, $status );
Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Customer/Manager/Base.php
Expand Up @@ -86,10 +86,10 @@ public function filter( bool $default = false, bool $site = false ) : \Aimeos\MW
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Customer\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'customer.code' => $code ), $ref, $default );
return $this->findBase( array( 'customer.code' => $code ), $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Customer/Manager/Group/Standard.php
Expand Up @@ -219,10 +219,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'customer.group.code' => $code ), $ref, $default );
return $this->findBase( array( 'customer.group.code' => $code ), $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Index/Manager/DBBase.php
Expand Up @@ -107,10 +107,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = 'product', string $type = null,
public function find( string $code, array $ref = [], string $domain = 'product', string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->manager->findItem( $code, $ref, $domain, $type, $default );
return $this->manager->find( $code, $ref, $domain, $type, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Locale/Manager/Currency/Standard.php
Expand Up @@ -620,10 +620,10 @@ public function getSubManager( string $manager, string $name = null ) : \Aimeos\
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'locale.currency.id' => $code ), $ref, $default );
return $this->findBase( array( 'locale.currency.id' => $code ), $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Locale/Manager/Language/Standard.php
Expand Up @@ -488,10 +488,10 @@ public function getSubManager( string $manager, string $name = null ) : \Aimeos\
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'locale.language.id' => $code ), $ref, $default );
return $this->findBase( array( 'locale.language.id' => $code ), $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Locale/Manager/Site/Standard.php
Expand Up @@ -361,10 +361,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'locale.site.code' => $code ), $ref, $default );
return $this->findBase( array( 'locale.site.code' => $code ), $ref, $default );
}


Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Locale/Manager/Standard.php
Expand Up @@ -122,7 +122,7 @@ public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
public function bootstrap( string $site, string $lang = '', string $currency = '', bool $active = true, int $level = null,
bool $bare = false ) : \Aimeos\MShop\Locale\Item\Iface
{
$siteItem = $this->getObject()->getSubManager( 'site' )->findItem( $site );
$siteItem = $this->getObject()->getSubManager( 'site' )->find( $site );

if( $siteItem->getStatus() < 1 ) {
throw new \Aimeos\MShop\Locale\Exception( 'Site not found' );
Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Product/Manager/Standard.php
Expand Up @@ -393,10 +393,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'product.code' => $code ), $ref, $default );
return $this->findBase( array( 'product.code' => $code ), $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Service/Manager/Standard.php
Expand Up @@ -310,10 +310,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( ['service.code' => $code], $ref, $default );
return $this->findBase( ['service.code' => $code], $ref, $default );
}


Expand Down
2 changes: 1 addition & 1 deletion lib/mshoplib/src/MShop/Stock/Manager/Nolimit.php
Expand Up @@ -43,7 +43,7 @@ public function clear( array $siteids ) : \Aimeos\MShop\Common\Manager\Iface
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Stock\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
$values = ['stock.productcode' => $code, 'stock.type' => $type];
Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Stock/Manager/Standard.php
Expand Up @@ -153,11 +153,11 @@ public function createItem( array $values = [] ) : \Aimeos\MShop\Common\Item\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Common\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
$list = array( 'stock.productcode' => $code, 'stock.type' => $type );
return $this->findItemBase( $list, $ref, $default );
return $this->findBase( $list, $ref, $default );
}


Expand Down
4 changes: 2 additions & 2 deletions lib/mshoplib/src/MShop/Supplier/Manager/Standard.php
Expand Up @@ -267,10 +267,10 @@ public function deleteItems( array $itemIds ) : \Aimeos\MShop\Common\Manager\Ifa
* @param bool $default True to add default criteria
* @return \Aimeos\MShop\Supplier\Item\Iface Item object
*/
public function findItem( string $code, array $ref = [], string $domain = null, string $type = null,
public function find( string $code, array $ref = [], string $domain = null, string $type = null,
bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
{
return $this->findItemBase( array( 'supplier.code' => $code ), $ref, $default );
return $this->findBase( array( 'supplier.code' => $code ), $ref, $default );
}


Expand Down

0 comments on commit 1697791

Please sign in to comment.