Passed
Push — master ( 8bf46b...192bc3 )
by Aimeos
06:59
created

SQLSrv   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 42
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubManager() 0 3 2
A getSubManagers() 0 17 4
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2020
6
 * @package MShop
7
 * @subpackage Index
8
 */
9
10
11
namespace Aimeos\MShop\Index\Manager;
12
13
14
/**
15
 * MySQL index index manager for searching in product tables.
16
 *
17
 * @package MShop
18
 * @subpackage Index
19
 */
20
class SQLSrv
21
	extends \Aimeos\MShop\Index\Manager\Standard
22
	implements \Aimeos\MShop\Index\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
23
{
24
	private $subManagers;
25
26
27
	/**
28
	 * Returns a new manager for product extensions.
29
	 *
30
	 * @param string $manager Name of the sub manager type in lower case
31
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
32
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc.
33
	 */
34
	public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
35
	{
36
		return $this->getSubManagerBase( 'index', $manager, $name ?: 'SQLSrv' );
37
	}
38
39
40
	/**
41
	 * Returns the list of sub-managers available for the index attribute manager.
42
	 *
43
	 * @return \Aimeos\MShop\Index\Manager\Iface[] Associative list of the sub-domain as key and the manager object as value
44
	 */
45
	protected function getSubManagers() : array
46
	{
47
		if( $this->subManagers === null )
48
		{
49
			$this->subManagers = [];
50
			$config = $this->getContext()->getConfig();
51
52
			foreach( $config->get( 'mshop/index/manager/submanagers', [] ) as $domain )
53
			{
54
				$name = $config->get( 'mshop/index/manager/' . $domain . '/name' );
55
				$this->subManagers[$domain] = $this->getObject()->getSubManager( $domain, $name ?: 'SQLSrv' );
56
			}
57
58
			return $this->subManagers;
59
		}
60
61
		return $this->subManagers;
62
	}
63
}
64