There was an error while loading. Please reload this page.
The DataFromPathHelper.php provides function to replace strings (or array of strings) with data extracted from a cakephp's utility Hash path
buildStringFromDataPath
$url = $this->DataFromPath->buildStringFromDataPath( 'https://localhost/{{0}}/{{1}}.{{2}}', ['User' => ['id' => 42]], [ ['raw' => 'users/view'], ['datapath' => 'User.id'], ['function' => function($data, $dataPath) { return 'json'; }] ] ); // 'https://localhost/users/view/42.json'
buildStringsInArray
$myArray = $this->DataFromPath->buildStringsInArray( [ 'string1' => __('Is this the {{0}} life?'), 'string2' => __('Is this {{0}} {{1}}?'), ], ['Queen' => ['text1' => 'real']], [ 'string1' => ['Queen.text1'], 'string2' => [ ['raw' => 'just'], [ 'text' => 'fantasy', 'function' => function($data, $dataPath) { return $dataPath['text']; } ] ], ] ); // [ // 'string1' => 'Is this the real life?', // 'string2' => 'Is this just fantasy?', // ]