Completed
Push — master ( f97bb5...a4e8a9 )
by Aimeos
02:10
created

Base::aggregateIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Catalog\Decorator;
12
13
14
/**
15
 * Base for catalog frontend controller decorators
16
 *
17
 * @package Controller
18
 * @subpackage Frontend
19
 */
20
abstract class Base
21
	implements \Aimeos\Controller\Frontend\Common\Decorator\Iface
1 ignored issue
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
22
{
23
	private $context;
24
	private $controller;
25
26
27
	/**
28
	 * Initializes the controller decorator.
29
	 *
30
	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
31
	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
32
	 */
33
	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
34
	{
35
		$iface = '\Aimeos\Controller\Frontend\Catalog\Iface';
36
		if( !( $controller instanceof $iface ) )
37
		{
38
			$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface );
39
			throw new \Aimeos\Controller\Frontend\Exception( $msg );
40
		}
41
42
		$this->context = $context;
43
		$this->controller = $controller;
44
	}
45
46
47
	/**
48
	 * Passes unknown methods to wrapped objects.
49
	 *
50
	 * @param string $name Name of the method
51
	 * @param array $param List of method parameter
52
	 * @return mixed Returns the value of the called method
53
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
54
	 */
55
	public function __call( $name, array $param )
56
	{
57
		return @call_user_func_array( array( $this->controller, $name ), $param );
58
	}
59
60
61
	/**
62
	 * Returns the manager for the given name
63
	 *
64
	 * @param string $name Name of the manager
65
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager object
66
	 */
67
	public function createManager( $name )
68
	{
69
		return $this->getController()->createManager( $name );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createManager() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
70
	}
71
72
73
	/**
74
	 * Returns the default catalog filter
75
	 *
76
	 * @param boolean True to add default criteria, e.g. status > 0
77
	 * @return \Aimeos\MW\Criteria\Iface Criteria object for filtering
78
	 * @since 2017.03
79
	 */
80
	public function createFilter()
81
	{
82
		return $this->getController()->createFilter();
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard, Aimeos\Controller\Frontend\Product\Decorator\Base, Aimeos\Controller\Frontend\Product\Standard, Aimeos\Controller\Frontend\Stock\Decorator\Base, Aimeos\Controller\Frontend\Stock\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
83
	}
84
85
86
87
	/**
88
	 * Returns the list of categries that are in the path to the root node including the one specified by its ID.
89
	 *
90
	 * @param integer $id Category ID to start from, null for root node
91
	 * @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too
92
	 * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys
93
	 * @since 2017.03
94
	 */
95
	public function getPath( $id, array $domains = array( 'text', 'media' ) )
96
	{
97
		return $this->getController()->getPath( $id, $domains );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getPath() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
98
	}
99
100
101
	/**
102
	 * Returns the hierarchical catalog tree starting from the given ID.
103
	 *
104
	 * @param integer|null $id Category ID to start from, null for root node
105
	 * @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too
106
	 * @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base for the depth of the returned tree, LEVEL_ONE for
107
	 * 	specific node only, LEVEL_LIST for node and all direct child nodes, LEVEL_TREE for the whole tree
108
	 * @param \Aimeos\MW\Criteria\Iface|null $search Optional criteria object with conditions
109
	 * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant
110
	 * @since 2017.03
111
	 */
112
	public function getTree( $id = null, array $domains = array( 'text', 'media' ),
113
		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null )
114
	{
115
		return $this->getController()->getTree( $id, $domains, $level, $search );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getTree() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
116
	}
117
118
119
	/**
120
	 * Returns the default catalog filter
121
	 *
122
	 * @param boolean True to add default criteria, e.g. status > 0
123
	 * @return \Aimeos\MW\Criteria\Iface Criteria object for filtering
124
	 * @since 2015.08
125
	 * @deprecated Use createFilter() instead
126
	 */
127
	public function createCatalogFilter( $default = true )
128
	{
129
		return $this->getController()->createCatalogFilter( $default );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createCatalogFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
130
	}
131
132
133
134
	/**
135
	 * Returns the list of categries that are in the path to the root node including the one specified by its ID.
136
	 *
137
	 * @param integer $id Category ID to start from, null for root node
138
	 * @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too
139
	 * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys
140
	 * @since 2015.08
141
	 * @deprecated Use getPath() instead
142
	 */
143
	public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) )
144
	{
145
		return $this->getController()->getCatalogPath( $id, $domains );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getCatalogPath() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
146
	}
147
148
149
	/**
150
	 * Returns the hierarchical catalog tree starting from the given ID.
151
	 *
152
	 * @param integer|null $id Category ID to start from, null for root node
153
	 * @param string[] $domains Domain names of items that are associated with the categories and that should be fetched too
154
	 * @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base for the depth of the returned tree, LEVEL_ONE for
155
	 * 	specific node only, LEVEL_LIST for node and all direct child nodes, LEVEL_TREE for the whole tree
156
	 * @param \Aimeos\MW\Criteria\Iface|null $search Optional criteria object with conditions
157
	 * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant
158
	 * @since 2015.08
159
	 * @deprecated Use getTree() instead
160
	 */
161
	public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ),
162
		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null )
163
	{
164
		return $this->getController()->getCatalogTree( $id, $domains, $level, $search );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getCatalogTree() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
165
	}
166
167
168
	/**
169
	 * Returns the aggregated count of products from the index for the given key.
170
	 *
171
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
172
	 * @param string $key Search key to aggregate for, e.g. "index.attribute.id"
173
	 * @return array Associative list of key values as key and the product count for this key as value
174
	 * @since 2015.08
175
	 * @deprecated Use product controller instead
176
	 */
177
	public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key )
178
	{
179
		return $this->getController()->aggregateIndex( $filter, $key );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method aggregateIndex() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
180
	}
181
182
183
	/**
184
	 * Returns the given search filter with the conditions attached for filtering by category.
185
	 *
186
	 * @param \Aimeos\MW\Criteria\Iface $search Criteria object used for product search
187
	 * @param string $catid Selected category by the user
188
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
189
	 * @since 2015.08
190
	 * @deprecated Use product controller instead
191
	 */
192
	public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid )
193
	{
194
		return $this->getController()->addIndexFilterCategory( $search, $catid );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method addIndexFilterCategory() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
195
	}
196
197
198
	/**
199
	 * Returns the given search filter with the conditions attached for filtering texts.
200
	 *
201
	 * @param \Aimeos\MW\Criteria\Iface $search Criteria object used for product search
202
	 * @param string $input Search string entered by the user
203
	 * @param string $listtype List type of the text associated to the product, usually "default"
204
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
205
	 * @since 2015.08
206
	 * @deprecated Use product controller instead
207
	 */
208
	public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' )
209
	{
210
		return $this->getController()->addIndexFilterText( $search, $input, $listtype );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method addIndexFilterText() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
211
	}
212
213
214
	/**
215
	 * Returns the default index filter.
216
	 *
217
	 * @param string|null $sort Sortation of the product list like "name", "code", "price" and "position", null for no sortation
218
	 * @param string $direction Sort direction of the product list ("+", "-")
219
	 * @param integer $start Position in the list of found products where to begin retrieving the items
220
	 * @param integer $size Number of products that should be returned
221
	 * @param string $listtype Type of the product list, e.g. default, promotion, etc.
222
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
223
	 * @since 2015.08
224
	 * @deprecated Use product controller instead
225
	 */
226
	public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
227
	{
228
		return $this->getController()->createIndexFilter( $sort, $direction, $start, $size, $listtype );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createIndexFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
229
	}
230
231
232
	/**
233
	 * Returns a index filter for the given category ID.
234
	 *
235
	 * @param integer $catid ID of the category to get the product list from
236
	 * @param string $sort Sortation of the product list like "name", "price" and "position"
237
	 * @param string $direction Sort direction of the product list ("+", "-")
238
	 * @param integer $start Position in the list of found products where to begin retrieving the items
239
	 * @param integer $size Number of products that should be returned
240
	 * @param string $listtype Type of the product list, e.g. default, promotion, etc.
241
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
242
	 * @since 2015.08
243
	 * @deprecated Use product controller instead
244
	 */
245
	public function createIndexFilterCategory( $catid, $sort = 'position', $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
246
	{
247
		return $this->getController()->createIndexFilter( $catid, $sort, $direction, $start, $size, $listtype );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createIndexFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
248
	}
249
250
251
	/**
252
	 * Returns the index filter for the given search string.
253
	 *
254
	 * @param string $input Search string entered by the user
255
	 * @param string $sort Sortation of the product list like "name", "price" and "relevance"
256
	 * @param string $direction Sort direction of the product list ("+", "-", but not for relevance )
257
	 * @param integer $start Position in the list of found products where to begin retrieving the items
258
	 * @param integer $size Number of products that should be returned
259
	 * @param string $listtype List type of the text associated to the product, usually "default"
260
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
261
	 * @since 2015.08
262
	 * @deprecated Use product controller instead
263
	 */
264
	public function createIndexFilterText( $input, $sort = 'relevance', $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
265
	{
266
		return $this->getController()->createIndexFilter( $input, $sort, $direction, $start, $size, $listtype );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createIndexFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
267
	}
268
269
270
	/**
271
	 * Returns the products from the index filtered by the given criteria object.
272
	 *
273
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
274
	 * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too
275
	 * @param integer &$total Parameter where the total number of found products will be stored in
276
	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
277
	 * @since 2015.08
278
	 * @deprecated Use product controller instead
279
	 */
280
	public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
281
	{
282
		return $this->getController()->getIndexItems( $filter, $domains, $total );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getIndexItems() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
283
	}
284
285
286
	/**
287
	 * Returns the product item for the given ID if it's available
288
	 *
289
	 * @param array $ids List of product IDs
290
	 * @param array $domains Domain names of items that are associated with the products and that should be fetched too
291
	 * @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface
292
	 * @since 2015.08
293
	 * @deprecated Use product controller instead
294
	 */
295
	public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) )
296
	{
297
		return $this->getController()->getProductItems( $ids, $domains );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getProductItems() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
298
	}
299
300
301
	/**
302
	 * Returns text filter for the given search string.
303
	 *
304
	 * @param string $input Search string entered by the user
305
	 * @param string|null $sort Sortation of the product list like "name" and "relevance", null for no sortation
306
	 * @param string $direction Sort direction of the product list ("+", "-")
307
	 * @param integer $start Position in the list of found products where to begin retrieving the items
308
	 * @param integer $size Number of products that should be returned
309
	 * @param string $listtype List type of the text associated to the product, usually "default"
310
	 * @param string $type Type of the text like "name", "short", "long", etc.
311
	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
312
	 * @deprecated Use product controller instead
313
	 */
314
	public function createTextFilter( $input, $sort = null, $direction = '-', $start = 0, $size = 25, $listtype = 'default', $type = 'name' )
315
	{
316
		return $this->getController()->createTextFilter( $input, $sort, $direction, $start, $size, $listtype, $type );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method createTextFilter() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
317
	}
318
319
320
	/**
321
	 * Returns an list of product text strings matched by the filter.
322
	 *
323
	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
324
	 * @return array Associative list of the product ID as key and the product text as value
325
	 * @deprecated Use product controller instead
326
	 */
327
	public function getTextList( \Aimeos\MW\Criteria\Iface $filter )
328
	{
329
		return $this->getController()->getTextList( $filter );
1 ignored issue
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface Aimeos\Controller\Frontend\Iface as the method getTextList() does only exist in the following implementations of said interface: Aimeos\Controller\Frontend\Catalog\Decorator\Base, Aimeos\Controller\Frontend\Catalog\Standard.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
330
	}
331
332
333
	/**
334
	 * Returns the context item
335
	 *
336
	 * @return \Aimeos\MShop\Context\Item\Iface Context item object
337
	 */
338
	protected function getContext()
339
	{
340
		return $this->context;
341
	}
342
343
344
	/**
345
	 * Returns the frontend controller
346
	 *
347
	 * @return \Aimeos\Controller\Frontend\Catalog\Iface Frontend controller object
348
	 */
349
	protected function getController()
350
	{
351
		return $this->controller;
352
	}
353
}
354