Merge pull request #58 from oddnoc/safe-sitetree

Make SiteTree reference conditional in InitProcessor
This commit is contained in:
Ingo Schommer 2014-08-02 17:54:20 +12:00
commit bf36edecad

View File

@ -197,12 +197,14 @@ class FeatureContext extends SilverStripeContext {
$factory->define('Member', $blueprint); $factory->define('Member', $blueprint);
// Auto-publish pages // Auto-publish pages
foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) { if (class_exists('SiteTree')) {
$blueprint = \Injector::inst()->create('FixtureBlueprint', $class); foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) {
$blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) { $blueprint = \Injector::inst()->create('FixtureBlueprint', $class);
$obj->publish('Stage', 'Live'); $blueprint->addCallback('afterCreate', function($obj, $identifier, &$data, &$fixtures) {
}); $obj->publish('Stage', 'Live');
$factory->define($class, $blueprint); });
$factory->define($class, $blueprint);
}
} }
} }