Skip to content

Commit

Permalink
Merge branch 'master' of github.com:PUGX/godfather into fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
liuggio committed Jan 14, 2014
2 parents c3f00ed + ee46514 commit 6da14c2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
8 changes: 6 additions & 2 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,23 @@ godfather:
### Set your strategies:
```yml
parameters:
mug.class: Mug
tshirt.class: Tshirt

services:
manager_standard:
class: StandardProductManager

manager_mug:
class: MugManager
tags:
- { name: godfather.strategy, context_name: 'manager', context_key: Mug }
- { name: godfather.strategy, context_name: 'manager', context_key: %mug.class% }

manager_tshirt:
class: TshirtManager
tags:
- { name: godfather.strategy, context_name: 'manager', context_key: Tshirt }
- { name: godfather.strategy, context_name: 'manager', context_key: %tshirt.class% }
```
### Using in the controller:
Expand Down
3 changes: 1 addition & 2 deletions lib/PUGX/Godfather/Context/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ public function getFallbackStrategy()
private function getClassOrType($object)
{
if (is_object($object)) {
$function = new \ReflectionClass(get_class($object));

return $function->getShortName();
return get_class($object);
}
try {
$object = (string) $object;
Expand Down
2 changes: 1 addition & 1 deletion tests/PUGX/Godfather/Test/Context/ContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testGetStrategy()
{
$context = new Context(new \stdClass());

$this->assertEquals('ticket', $context->getStrategyName(new Ticket()));
$this->assertEquals('pugx.godfather.test.context.ticket', $context->getStrategyName(new Ticket()));
}

}
Expand Down
8 changes: 4 additions & 4 deletions tests/PUGX/Godfather/Test/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public function testStrategyUsage($godfather, $contextName, $contextKey, $produc
public function provider()
{
return array(
'SymfonyContainer with the Mug' => array($this->createSymfonyGodfather(), 'manager', 'mug_product', new MugProduct(), 'mug_manager' , 'echo-mug'),
'SymfonyContainer with the Tshirt' => array($this->createSymfonyGodfather(), 'manager', 'tshirt_product', new TshirtProduct(), 'tshirt_manager', 'echo-tshirt'),
'ArrayContainer with the Mug' => array($this->createArrayGodfather(), 'manager', 'mug_product', new MugProduct(), 'mug_manager' , 'echo-mug'),
'ArrayContainer with the Tshirt' => array($this->createArrayGodfather(), 'manager', 'tshirt_product', new TshirtProduct(), 'tshirt_manager', 'echo-tshirt'),
'SymfonyContainer with the Mug' => array($this->createSymfonyGodfather(), 'manager', 'pugx.godfather.test.fixture.mug_product', new MugProduct(), 'mug_manager' , 'echo-mug'),
'SymfonyContainer with the Tshirt' => array($this->createSymfonyGodfather(), 'manager', 'pugx.godfather.test.fixture.tshirt_product', new TshirtProduct(), 'tshirt_manager', 'echo-tshirt'),
'ArrayContainer with the Mug' => array($this->createArrayGodfather(), 'manager', 'pugx.godfather.test.fixture.mug_product', new MugProduct(), 'mug_manager' , 'echo-mug'),
'ArrayContainer with the Tshirt' => array($this->createArrayGodfather(), 'manager', 'pugx.godfather.test.fixture.tshirt_product', new TshirtProduct(), 'tshirt_manager', 'echo-tshirt'),
);
}

Expand Down

0 comments on commit 6da14c2

Please sign in to comment.