• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-core / 69437571-b082-4b11-ac5a-25c958bba87a

06 Aug 2024 10:26AM UTC coverage: 91.754%. Remained the same
69437571-b082-4b11-ac5a-25c958bba87a

push

circleci

aimeos
Removed @category tags from config documentation

11005 of 11994 relevant lines covered (91.75%)

55.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

40.0
/src/MAdmin/Common/Manager/Base.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2024
7
 * @package MAdmin
8
 * @subpackage Common
9
 */
10

11

12
namespace Aimeos\MAdmin\Common\Manager;
13

14

15
/**
16
 * Provides common methods required by most of the manager classes.
17
 *
18
 * @package MAdmin
19
 * @subpackage Common
20
 */
21
abstract class Base extends \Aimeos\MShop\Common\Manager\Base
22
{
23
        /**
24
         * Adds the configured decorators to the given manager object.
25
         *
26
         * @param \Aimeos\MShop\Common\Manager\Iface $manager Manager object
27
         * @param string $managerpath Manager sub-names separated by slashes, e.g. "lists/type"
28
         * @param string $domain Domain name in lower case, e.g. "product"
29
         * @return \Aimeos\MShop\Common\Manager\Iface Manager with decorators added
30
         */
31
        protected function addManagerDecorators( \Aimeos\MShop\Common\Manager\Iface $manager, string $managerpath, string $domain ) : \Aimeos\MShop\Common\Manager\Iface
32
        {
33
                $context = $this->context();
×
34
                $config = $context->config();
×
35

36
                /** madmin/common/manager/decorators/default
37
                 * Configures the list of decorators applied to all admin managers
38
                 *
39
                 * Decorators extend the functionality of a class by adding new aspects
40
                 * (e.g. log what is currently done), executing the methods of the underlying
41
                 * class only in certain conditions (e.g. only for logged in users) or
42
                 * modify what is returned to the caller.
43
                 *
44
                 * This option allows you to configure a list of decorator names that should
45
                 * be wrapped around the original instances of all created managers:
46
                 *
47
                 *  madmin/common/manager/decorators/default = array( 'decorator1', 'decorator2' )
48
                 *
49
                 * This would wrap the decorators named "decorator1" and "decorator2" around
50
                 * all controller instances in that order. The decorator classes would be
51
                 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" and
52
                 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator2".
53
                 *
54
                 * @param array List of decorator names
55
                 * @since 2014.03
56
                 */
57
                $decorators = $config->get( 'madmin/common/manager/decorators/default', [] );
×
58
                $excludes = $config->get( 'madmin/' . $domain . '/manager/' . $managerpath . '/decorators/excludes', [] );
×
59

60
                foreach( $decorators as $key => $name )
×
61
                {
62
                        if( in_array( $name, $excludes ) ) {
×
63
                                unset( $decorators[$key] );
×
64
                        }
65
                }
66

67
                $classprefix = '\Aimeos\MShop\Common\Manager\Decorator\\';
×
68
                $manager = $this->addDecorators( $context, $manager, $decorators, $classprefix );
×
69

70
                $classprefix = '\Aimeos\MShop\Common\Manager\Decorator\\';
×
71
                $decorators = $config->get( 'madmin/' . $domain . '/manager/' . $managerpath . '/decorators/global', [] );
×
72
                $manager = $this->addDecorators( $context, $manager, $decorators, $classprefix );
×
73

74
                $subpath = $this->createSubNames( $managerpath );
×
75
                $classprefix = 'MShop_' . ucfirst( $domain ) . '_Manager_' . $subpath . '_Decorator_';
×
76
                $decorators = $config->get( 'madmin/' . $domain . '/manager/' . $managerpath . '/decorators/local', [] );
×
77

78
                return $this->addDecorators( $context, $manager, $decorators, $classprefix );
×
79
        }
80

81

82
        /**
83
         * Returns a new manager the given extension name
84
         *
85
         * @param string $domain Name of the domain (product, text, media, etc.)
86
         * @param string $manager Name of the sub manager type in lower case (can contain a path like base/product)
87
         * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
88
         * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions
89
         * @throws \LogicException If class isn't found
90
         */
91
        protected function getSubManagerBase( string $domain, string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
92
        {
93
                $context = $this->context();
4✔
94
                $domain = strtolower( $domain );
4✔
95
                $manager = strtolower( $manager );
4✔
96

97

98
                if( empty( $domain ) || ctype_alnum( $domain ) === false ) {
4✔
99
                        throw new \LogicException( sprintf( 'Invalid characters in domain name "%1$s"', $domain ), 400 );
×
100
                }
101

102
                if( $name === null ) {
4✔
103
                        $name = $context->config()->get( 'mshop/' . $domain . '/manager/' . $manager . '/name', 'Standard' );
4✔
104
                }
105

106
                if( empty( $name ) || ctype_alnum( $name ) === false ) {
4✔
107
                        throw new \LogicException( sprintf( 'Invalid characters in manager name "%1$s"', $name ), 400 );
×
108
                }
109

110
                $domainname = ucfirst( $domain );
4✔
111
                $subnames = $this->createSubNames( $manager );
4✔
112

113
                $classname = '\Aimeos\MAdmin\\' . $domainname . '\Manager\\' . $subnames . '\\' . $name;
4✔
114
                $interface = '\Aimeos\MAdmin\\' . $domainname . '\Manager\\' . $subnames . '\Iface';
4✔
115

116
                return \Aimeos\Utils::create( $classname, [$context], $interface );
4✔
117
        }
118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc