Skip to content

Commit

Permalink
BUGFIX tasks not compatible with SS4 (#135)
Browse files Browse the repository at this point in the history
fixes #134
  • Loading branch information
muskie9 authored and jsirish committed Sep 24, 2018
1 parent 4934513 commit 7491577
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
14 changes: 12 additions & 2 deletions tasks/SlidePublishTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,31 @@ public function run($request)
$this->publishSlides();
}

/**
* @return \Generator
*/
protected function getSlides()
{
foreach (SlideImage::get() as $slide) {
yield $slide;
}
}

/**
* mark all ProductDetail records as ShowInMenus = 0.
*/
public function publishSlides()
{
$slides = SlideImage::get();
$ct = 0;
foreach ($slides as $slide) {
foreach ($this->getSlides() as $slide) {
if ($slide->ShowSlide == 1) {
if (!$slide->Name) {
$slide->Name = "No Name";
}
$title = $slide->Name;
$slide->writeToStage('Stage');
$slide->publish('Stage', 'Live');
$slide->publishRecursive();
static::write_message($slide->Name . " updated");
++$ct;
}
Expand Down
27 changes: 21 additions & 6 deletions tasks/SlideThumbnailNavMigrationTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace Dynamic\flexslider\tasks;

use Dynamic\FlexSlider\ORM\FlexSlider;
use SilverStripe\CMS\Model\SiteTree;
use SilverStripe\Core\ClassInfo;
use SilverStripe\Dev\BuildTask;
use SilverStripe\ORM\DataObject;
use SilverStripe\Versioned\Versioned;

/**
* Class SlideThumbnailNavMigrationTask
Expand Down Expand Up @@ -35,30 +38,42 @@ public function run($request)
$this->defaultSliderSettings();
}

/**
* @param $class
* @return \Generator
*/
protected function getObjectSet($class)
{
foreach ($class::get() as $object) {
yield $object;
}
}

/**
*
*/
public function defaultSliderSettings()
{
$ct = 0;

$objects = ClassInfo::subclassesFor('DataObject');
$objects = ClassInfo::subclassesFor(DataObject::class);

if ($objects) {
unset($objects['DataObject']);
unset($objects[DataObject::class]);
foreach ($objects as $object) {
if (singleton($object)->hasExtension('FlexSlider')) {
foreach ($object::get() as $result) {
if ($object::singleton()->hasExtension(FlexSlider::class)) {
foreach ($this->getObjectSet($object) as $result) {
$result->Loop = 1;
$result->Animate = 1;
$result->SliderControlNav = 1;
$result->SliderDirectionNav = 1;
$result->CarouselControlNav = 0;
$result->CarouselDirectionNav = 1;
$result->CarouselThumbnailCt = 6;
if ($result instanceof SiteTree || singleton($object)->hasExtension('VersionedDataobject')) {
if ($result instanceof SiteTree || $object::singleton()->hasExtension(Versioned::class)) {
$result->writeToStage('Stage');
if ($result->isPublished()) {
$result->publish('Stage', 'Live');
$result->publishRecursive();
}
} else {
$result->write();
Expand Down

0 comments on commit 7491577

Please sign in to comment.