| 1 | <?php |
||
| 3 | namespace Dynamic\FlexSlider; |
||
| 4 | |||
| 5 | use SilverStripe\CMS\Model\SiteTree; |
||
| 6 | use SilverStripe\Core\ClassInfo; |
||
| 7 | use SilverStripe\Dev\BuildTask; |
||
| 8 | |||
| 9 | class SlideThumbnailNavMigrationTask extends BuildTask |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var string |
||
| 13 | */ |
||
| 14 | protected $title = 'FlexSlider Default Values'; |
||
| 15 | /** |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | protected $description = 'Set default values for slider after the thumbnail nav update'; |
||
| 19 | /** |
||
| 20 | * @var bool |
||
| 21 | */ |
||
| 22 | protected $enabled = true; |
||
| 23 | /** |
||
| 24 | * @param $request |
||
| 25 | */ |
||
| 26 | public function run($request) |
||
| 30 | /** |
||
| 31 | * |
||
| 32 | */ |
||
| 33 | public function defaultSliderSettings() |
||
| 34 | { |
||
| 35 | $ct = 0; |
||
| 36 | |||
| 37 | $objects = ClassInfo::subclassesFor('DataObject'); |
||
| 38 | if ($objects) { |
||
|
|
|||
| 39 | unset($objects['DataObject']); |
||
| 40 | foreach ($objects as $object) { |
||
| 41 | if (singleton($object)->hasExtension('FlexSlider')) { |
||
| 42 | foreach ($object::get() as $result) { |
||
| 43 | $result->Loop = 1; |
||
| 44 | $result->Animate = 1; |
||
| 45 | $result->SliderControlNav = 1; |
||
| 46 | $result->SliderDirectionNav = 1; |
||
| 47 | $result->CarouselControlNav = 0; |
||
| 48 | $result->CarouselDirectionNav = 1; |
||
| 49 | $result->CarouselThumbnailCt = 6; |
||
| 50 | if ($result InstanceOf SiteTree || singleton($object)->hasExtension('VersionedDataobject')) { |
||
| 51 | $result->writeToStage('Stage'); |
||
| 52 | if ($result->isPublished()) { |
||
| 53 | $result->publish('Stage', 'Live'); |
||
| 54 | } |
||
| 55 | } else { |
||
| 56 | $result->write(); |
||
| 57 | } |
||
| 58 | $ct++; |
||
| 59 | } |
||
| 60 | } |
||
| 65 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.