Added DependencyInjection UML
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 11 KiB |
@@ -4,12 +4,12 @@ class Assemble {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Car {
|
class Car {
|
||||||
+__construct()
|
+__construct(Workshop $workShop1, Workshop $workShop2)
|
||||||
+manufacture()
|
+manufacture()
|
||||||
}
|
}
|
||||||
|
|
||||||
class Motorcycle {
|
class Motorcycle {
|
||||||
+__construct()
|
+__construct(Workshop $workShop1, Workshop $workShop2)
|
||||||
+manufacture()
|
+manufacture()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -18,9 +18,9 @@ class Produce {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Vehicle {
|
abstract class Vehicle {
|
||||||
protected workShop1
|
#workShop1
|
||||||
protected workShop2
|
#workShop2
|
||||||
+__construct()
|
#__construct()
|
||||||
+manufacture()
|
+manufacture()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.3 KiB |
@@ -1,20 +1,20 @@
|
|||||||
@startuml
|
@startuml
|
||||||
class Form {
|
class Form {
|
||||||
protected elements
|
#elements : array|FormElement[]
|
||||||
+render($indent = 0)
|
+render($indent = 0 : int)
|
||||||
+addElement(FormElement $element)
|
+addElement(FormElement $element)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class FormElement {
|
abstract class FormElement {
|
||||||
+render($indent = 0)
|
+render($indent = 0 : int)
|
||||||
}
|
}
|
||||||
|
|
||||||
class InputElement {
|
class InputElement {
|
||||||
+render($indent = 0)
|
+render($indent = 0 : int)
|
||||||
}
|
}
|
||||||
|
|
||||||
class TextElement {
|
class TextElement {
|
||||||
+render($indent = 0)
|
+render($indent = 0 : int)
|
||||||
}
|
}
|
||||||
|
|
||||||
FormElement <|.. TextElement
|
FormElement <|.. TextElement
|
||||||
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 6.8 KiB After Width: | Height: | Size: 7.1 KiB |
@@ -1,25 +1,24 @@
|
|||||||
@startuml
|
@startuml
|
||||||
class User {
|
class User {
|
||||||
protected $userId
|
#$userId : int
|
||||||
protected $username
|
#$username : string
|
||||||
protected $email
|
#$email : string
|
||||||
+__construct($id = null, $username = null, $email = null)
|
+__construct($id = null : int, $username = null : string, $email = null : string)
|
||||||
+getUserId()
|
+getUserId()
|
||||||
+setUserID($userId)
|
+setUserID($userId : int)
|
||||||
+getUsername()
|
+getUsername()
|
||||||
+setUsername($username)
|
+setUsername($username : string)
|
||||||
+getEmail()
|
+getEmail()
|
||||||
+setEmail($email)
|
+setEmail($email : string)
|
||||||
}
|
}
|
||||||
|
|
||||||
class UserMapper {
|
class UserMapper {
|
||||||
# $user : User
|
#$adapter : DBAL
|
||||||
protected $adapter
|
|
||||||
+__construct(DBAL $dbLayer)
|
+__construct(DBAL $dbLayer)
|
||||||
+save(User $user)
|
+save(User $user)
|
||||||
+findById($id)
|
+findById($id : int)
|
||||||
+findAll()
|
+findAll()
|
||||||
+mapObject(array $row)
|
#mapObject(array $row)
|
||||||
}
|
}
|
||||||
|
|
||||||
@enduml
|
@enduml
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 8.9 KiB After Width: | Height: | Size: 9.0 KiB |
@@ -4,7 +4,7 @@ interface RendererInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract class Decorator {
|
abstract class Decorator {
|
||||||
# protected $wrapped : RendererInterface
|
#$wrapped : RendererInterface
|
||||||
+__construct(RendererInterface $wrappable)
|
+__construct(RendererInterface $wrappable)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -17,7 +17,7 @@ class RenderInXml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class Webservice {
|
class Webservice {
|
||||||
protected $data
|
#$data : mixed
|
||||||
+__construct($data)
|
+__construct($data)
|
||||||
+renderData()
|
+renderData()
|
||||||
}
|
}
|
||||||
|
@@ -14,3 +14,7 @@ Notice we are following Inversion of control principle in `Connection` by asking
|
|||||||
|
|
||||||
* The Doctrine2 ORM uses dependency injection e.g. for configuration that is injected into a `Connection` object. For testing purposes, one can easily create a mock object of the configuration and inject that into the `Connection` object
|
* The Doctrine2 ORM uses dependency injection e.g. for configuration that is injected into a `Connection` object. For testing purposes, one can easily create a mock object of the configuration and inject that into the `Connection` object
|
||||||
* Symfony and Zend Framework 2 already have containers for DI that create objects via a configuration array and inject them where needed (i.e. in Controllers)
|
* Symfony and Zend Framework 2 already have containers for DI that create objects via a configuration array and inject them where needed (i.e. in Controllers)
|
||||||
|
|
||||||
|
## UML Diagram
|
||||||
|
|
||||||
|

|
BIN
Structural/DependencyInjection/uml/uml.png
Normal file
After Width: | Height: | Size: 18 KiB |
1
Structural/DependencyInjection/uml/uml.svg
Normal file
After Width: | Height: | Size: 7.9 KiB |
28
Structural/DependencyInjection/uml/uml.txt
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
@startuml
|
||||||
|
abstract class AbstractConfig {
|
||||||
|
#$storage
|
||||||
|
+__construct($storage)
|
||||||
|
}
|
||||||
|
|
||||||
|
class ArrayConfig {
|
||||||
|
+get($key : string|int, $default = null)
|
||||||
|
+set($key : string|int, $value : mixed)
|
||||||
|
}
|
||||||
|
|
||||||
|
class Connection {
|
||||||
|
#$configuration : Parameters
|
||||||
|
#$host
|
||||||
|
+__construct(Parameters $config)
|
||||||
|
+connect()
|
||||||
|
+getHost()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Parameters {
|
||||||
|
+get($key : string|int)
|
||||||
|
+set($key, $value : mixed)
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractConfig <|.. ArrayConfig
|
||||||
|
Parameters <|.. ArrayConfig
|
||||||
|
|
||||||
|
@enduml
|