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