Skip to content

Commit

Permalink
remove initialize method from extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
dennis84 committed Sep 5, 2014
1 parent 02094ce commit 7e62918
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 40 deletions.
10 changes: 1 addition & 9 deletions src/Mapped/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
/**
* Extension.
*/
abstract class Extension
interface Extension
{
/**
* This method is called when a new mapping is created.
*
* @param Mapping $mapping The mapping object
*/
public function initialize(Mapping $mapping)
{
}
}
2 changes: 1 addition & 1 deletion src/Mapped/Extension/Constraints.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Enriches mapping objects with validation and transformation methods.
*/
class Constraints extends Extension
class Constraints implements Extension
{
/**
* Checks if the value is not empty.
Expand Down
2 changes: 1 addition & 1 deletion src/Mapped/Extension/Multiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Multiple extension.
*/
class Multiple extends Extension
class Multiple implements Extension
{
/**
* Makes this mapping to a multiple.
Expand Down
2 changes: 1 addition & 1 deletion src/Mapped/Extension/SymfonyValidation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
/**
* This extension allows you to use Symfony's validation constraints.
*/
class SymfonyValidation extends Extension
class SymfonyValidation implements Extension
{
protected $validator;

Expand Down
2 changes: 1 addition & 1 deletion src/Mapped/Extension/Verifying.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* This extension provides a simpler API to add custom constraints.
*/
class Verifying extends Extension
class Verifying implements Extension
{
/**
* Adds a callback constraint to the mapping.
Expand Down
7 changes: 0 additions & 7 deletions src/Mapped/Mapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public function __construct(EventDispatcherInterface $dispatcher, array $extensi
{
$this->dispatcher = $dispatcher;
$this->extensions = $extensions;
foreach ($extensions as $extension) {
$extension->initialize($this);
}
}

/**
Expand Down Expand Up @@ -82,10 +79,6 @@ public function getTransformers()
*/
public function __call($method, $arguments)
{
if ('initialize' === $method) {
return;
}

foreach ($this->extensions as $extension) {
if (false === method_exists($extension, $method)) {
continue;
Expand Down
2 changes: 1 addition & 1 deletion tests/Mapped/Tests/Fixtures/FooExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Mapped\Mapping;
use Mapped\Extension;

class FooExtension extends Extension
class FooExtension implements Extension
{
public function initialize(Mapping $mapping)
{
Expand Down
19 changes: 0 additions & 19 deletions tests/Mapped/Tests/MappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,6 @@

class MappingTest extends MappedTestCase
{
public function testInitialize()
{
$ext = $this->getMock('Mapped\Extension');
$ext->expects($this->once())
->method('initialize');

$mapping = $this->createMapping([$ext]);
}

public function testInitializeMethodMustNotBeCallable()
{
$ext = $this->getMock('Mapped\Extension');
$ext->expects($this->once())
->method('initialize');

$mapping = $this->createMapping([$ext]);
$mapping->initialize($mapping);
}

public function testValidExtensionMethod()
{
$mapping = $this->createMapping([
Expand Down

0 comments on commit 7e62918

Please sign in to comment.