-
Notifications
You must be signed in to change notification settings - Fork 2
copy() method
Rieks Visser edited this page Sep 5, 2017
·
1 revision
For copying data from one path to another, the copy()
method can be used.
<?php
/** @var Mediact\DataContainer\DataContainer $container */
$container->copy('categories.foo', 'categories.qux');
var_dump($container->get('categories.qux')); // ['name' => 'Foo']
The copy method supports wildcards. The replacement can contain variables like used in expand().
<?php
/** @var Mediact\DataContainer\DataContainer $container */
$container->copy('categories.*', 'copied_categories.$1');
var_dump($container->get('copied_categories.foo')); // ['name' => 'Foo']
var_dump($container->get('copied_categories.bar')); // ['name' => 'Bar']