2013-06-05 11:40:36 +02:00
|
|
|
<?php
|
2016-08-19 00:51:35 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\Dev;
|
|
|
|
|
|
|
|
class BehatFixtureFactory extends FixtureFactory {
|
2013-08-21 11:27:16 +02:00
|
|
|
public function createObject($name, $identifier, $data = null) {
|
|
|
|
if(!$data) $data = array();
|
2013-06-05 11:40:36 +02:00
|
|
|
|
2013-08-21 11:27:16 +02:00
|
|
|
// Copy identifier to some visible property unless its already defined.
|
|
|
|
// Exclude files, since they generate their own named based on the file path.
|
2016-08-19 00:51:35 +02:00
|
|
|
if (!is_a($name, 'SilverStripe\\Assets\\File', true)) {
|
2013-08-21 11:27:16 +02:00
|
|
|
foreach(array('Name', 'Title') as $fieldName) {
|
|
|
|
if(singleton($name)->hasField($fieldName) && !isset($data[$fieldName])) {
|
|
|
|
$data[$fieldName] = $identifier;
|
|
|
|
break;
|
|
|
|
}
|
2014-08-15 08:53:05 +02:00
|
|
|
}
|
2013-08-21 11:27:16 +02:00
|
|
|
}
|
2013-06-05 11:40:36 +02:00
|
|
|
|
2013-08-21 11:27:16 +02:00
|
|
|
return parent::createObject($name, $identifier, $data);
|
|
|
|
}
|
|
|
|
}
|