Using array_replace_recursive to merge arrays instead

parent 893a3270
...@@ -36,7 +36,7 @@ final class FileIsCreating implements EntityIsChanging ...@@ -36,7 +36,7 @@ final class FileIsCreating implements EntityIsChanging
*/ */
public function setAttributes(array $attributes) public function setAttributes(array $attributes)
{ {
$this->attributes += $attributes; $this->attributes = array_replace_recursive($this->attributes, $attributes);
} }
/** /**
......
...@@ -7,7 +7,6 @@ use Modules\Media\Entities\File; ...@@ -7,7 +7,6 @@ use Modules\Media\Entities\File;
final class FileIsUpdating implements EntityIsChanging final class FileIsUpdating implements EntityIsChanging
{ {
/** /**
* @var File * @var File
*/ */
...@@ -49,7 +48,7 @@ final class FileIsUpdating implements EntityIsChanging ...@@ -49,7 +48,7 @@ final class FileIsUpdating implements EntityIsChanging
*/ */
public function setAttributes(array $attributes) public function setAttributes(array $attributes)
{ {
$this->attributes += $attributes; $this->attributes = array_replace_recursive($this->attributes, $attributes);
} }
/** /**
......
...@@ -209,6 +209,7 @@ class EloquentFileRepositoryTest extends MediaTestCase ...@@ -209,6 +209,7 @@ class EloquentFileRepositoryTest extends MediaTestCase
]); ]);
$this->assertEquals('bettername.jpg', $file->filename); $this->assertEquals('bettername.jpg', $file->filename);
$this->assertEquals('Hello World', $file->translate('en')->description);
} }
private function createFile($fileName = 'random/name.jpg') private function createFile($fileName = 'random/name.jpg')
......
...@@ -36,7 +36,7 @@ class PageIsCreating implements EntityIsChanging ...@@ -36,7 +36,7 @@ class PageIsCreating implements EntityIsChanging
*/ */
public function setAttributes(array $attributes) public function setAttributes(array $attributes)
{ {
$this->attributes = array_merge($this->attributes, $attributes); $this->attributes = array_replace_recursive($this->attributes, $attributes);
} }
/** /**
......
...@@ -42,7 +42,7 @@ class PageIsUpdating implements EntityIsChanging ...@@ -42,7 +42,7 @@ class PageIsUpdating implements EntityIsChanging
*/ */
public function setAttributes(array $attributes) public function setAttributes(array $attributes)
{ {
$this->attributes = array_merge($this->attributes, $attributes); $this->attributes = array_replace_recursive($this->attributes, $attributes);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment