silverstripe-framework/Dev/BehatFixtureFactory.php
Damian Mooyman 8dd644d25d
API Namespace all classes
Namespace all templates
Move difflib and BBCodeParser2 to thirdparty
Remove deprecated API marked for removal in 4.0
2016-09-08 10:23:17 +12:00

23 lines
654 B
PHP

<?php
namespace SilverStripe\Dev;
class BehatFixtureFactory extends FixtureFactory {
public function createObject($name, $identifier, $data = null) {
if(!$data) $data = array();
// Copy identifier to some visible property unless its already defined.
// Exclude files, since they generate their own named based on the file path.
if (!is_a($name, 'SilverStripe\\Assets\\File', true)) {
foreach(array('Name', 'Title') as $fieldName) {
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
$data[$fieldName] = $identifier;
break;
}
}
}
return parent::createObject($name, $identifier, $data);
}
}