Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add decorateWith() method to Yadif_Builder

  • Loading branch information...
commit 42cc9a11f42aae57b10a25d6d86c24bdf75ad51f 1 parent ae655f1
@beberlei authored
Showing with 31 additions and 0 deletions.
  1. +14 −0 Builder.php
  2. +3 −0  README.markdown
  3. +14 −0 Tests/BuilderTest.php
View
14 Builder.php
@@ -151,4 +151,18 @@ public function scope($scope)
$this->_config[$this->_lastComponentName]['scope'] = $scope;
return $this;
}
+
+ /**
+ *
+ * @param string $decoratorComponentName
+ * @return Yadif_Builder
+ */
+ public function decorateWith($decoratorComponentName)
+ {
+ if (!isset($this->_config[$this->_lastComponentName]['decorateWith'])) {
+ $this->_config[$this->_lastComponentName]['decorateWith'] = array();
+ }
+ $this->_config[$this->_lastComponentName]['decorateWith'][] = $decoratorComponentName;
+ return $this;
+ }
}
View
3  README.markdown
@@ -519,6 +519,9 @@ Set the scope of the component to "singleton" or "prototype"
Set a factory PHP callback variable, which is used instead of a new operation via reflection
to create the object.
+- decorateWith($decoratorComponentName)
+Set a decorator component name for the current component.
+
14. Modules
=============
View
14 Tests/BuilderTest.php
@@ -235,6 +235,20 @@ public function testChainBindMethodArgs()
);
}
+ public function testDecorateWith()
+ {
+ $this->builder->bind('stdClass')->decorateWith('foo');
+
+ $this->assertBuilder(
+ array(
+ 'stdClass' => array(
+ 'class' => 'stdClass',
+ 'decorateWith' => array('foo'),
+ ),
+ )
+ );
+ }
+
public function assertBuilder($expectedConfig)
{
$this->assertEquals($expectedConfig, $this->builder->finalize());
Please sign in to comment.
Something went wrong with that request. Please try again.