Factory.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\core;
12 
13 /**
14  * Interface for Factory implementations. A Factory is used to instantiate
15  * services to be used by clients.
16  *
17  * @author ingo herwig <ingo@wemove.com>
18  */
19 interface Factory {
20 
21  /**
22  * Get an instance from the configuration. Instances created with this method
23  * might be shared (depending on the __shared configuration property).
24  * @note Instance names are treated case insensitive
25  * @param $name The name of the instance (section, where the instance is defined)
26  * @param $dynamicConfiguration Associative array with key value pairs for
27  * dynamic instance properties (optional)
28  * @return Object
29  */
30  public function getInstance($name, $dynamicConfiguration=[]);
31 
32  /**
33  * Get a new instance from the configuration. Instances created with this method are not shared.
34  * @note Instance names are treated case insensitive
35  * @param $name The name of the instance (section, where the instance is defined)
36  * @param $dynamicConfiguration Associative array with key value pairs for
37  * dynamic instance properties (optional)
38  * @return Object
39  */
40  public function getNewInstance($name, $dynamicConfiguration=[]);
41 
42  /**
43  * Create an instance of a class. Instances created with this method are not shared.
44  * @param $class The name of the class
45  * @param $dynamicConfiguration Associative array with key value pairs for
46  * dynamic instance properties (optional)
47  * @return Object
48  */
49  public function getInstanceOf($class, $dynamicConfiguration=[]);
50 
51  /**
52  * Register a shared instance with a given name.
53  * @note Instance names are treated case insensitive
54  * @param $name The name of the instance.
55  * @param $instance The instance
56  */
57  public function registerInstance($name, $instance);
58 
59  /**
60  * Add interfaces that instances must implement.
61  * @param $interfaces Associative array with instance names as keys and interface names as values.
62  */
63  public function addInterfaces(array $interfaces);
64 
65  /**
66  * Delete all created instances.
67  */
68  public function clear();
69 }
70 ?>
registerInstance($name, $instance)
Register a shared instance with a given name.
clear()
Delete all created instances.
Interface for Factory implementations.
Definition: Factory.php:19
addInterfaces(array $interfaces)
Add interfaces that instances must implement.
Core classes.
Definition: namespaces.php:11
getInstanceOf($class, $dynamicConfiguration=[])
Create an instance of a class.
getNewInstance($name, $dynamicConfiguration=[])
Get a new instance from the configuration.
getInstance($name, $dynamicConfiguration=[])
Get an instance from the configuration.