mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-05-06 14:35:34 +02:00
[EAV] Value::setAttribute add return this
This commit is contained in:
parent
3bf84ae0f6
commit
115dd3bdb3
@ -40,7 +40,6 @@ class ValueTest extends \PHPUnit_Framework_TestCase
|
|||||||
$value->setName('Silver');
|
$value->setName('Silver');
|
||||||
$this->assertSame($attribute, $value->getAttribute());
|
$this->assertSame($attribute, $value->getAttribute());
|
||||||
|
|
||||||
$value->setAttribute($attribute);
|
$this->assertSame($attribute, $value->setAttribute($attribute)->getAttribute());
|
||||||
$this->assertSame($attribute, $value->getAttribute());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,15 @@ class Value implements ValueInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Attribute $attribute
|
* @param Attribute $attribute
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setAttribute(Attribute $attribute)
|
public function setAttribute(Attribute $attribute)
|
||||||
{
|
{
|
||||||
$this->attribute->removeValue($this); // Remove value from current attribute
|
$this->attribute->removeValue($this); // Remove value from current attribute
|
||||||
$attribute->addValue($this); // Add value to new attribute
|
$attribute->addValue($this); // Add value to new attribute
|
||||||
$this->attribute = $attribute;
|
$this->attribute = $attribute;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user