Source of file CreateListOfTasks.php
Size: 3,454 Bytes - Last Modified: 2020-07-03T12:08:09+00:00
/var/www/docs.ssmods.com/process/src/src/Api/CreateListOfTasks.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 | <?php namespace Sunnysideup\UpgradeToSilverstripe4\Api; use Sunnysideup\UpgradeToSilverstripe4\ModuleUpgrader; class CreateListOfTasks { public function run() { $this->myMu = ModuleUpgrader::create(); $html = ''; foreach (array_keys($this->mu()->getAvailableRecipes()) as $recipeKey) { $this->mu()->applyRecipe($recipeKey); $html .= '<h1>List of Tasks in run order for recipe: ' . $recipeKey . '</h1>'; $count = 0; $totalCount = count($this->mu()->getListOfTasks()); $previousStep = ''; foreach ($this->mu()->getListOfTasks() as $class => $params) { $properClass = current(explode('-', $class)); $nameSpacesArray = explode('\\', $class); $shortClassCode = end($nameSpacesArray); if (! class_exists($properClass)) { $properClass = $this->mu()->getDefaultNamespaceForTasks() . '\\' . $properClass; } if (class_exists($properClass)) { $count++; // $runItNow = $this->mu()->shouldWeRunIt((string) $shortClassCode); $params['taskName'] = $shortClassCode; $obj = $properClass::create($this, $params); if ($obj->getTaskName()) { $params['taskName'] = $obj->getTaskName(); } $reflectionClass = new \ReflectionClass($properClass); $path = 'https://github.com/sunnysideup/silverstripe-upgrade_to_silverstripe_4/tree/master/src/'; $path .= str_replace('\\', '/', $reflectionClass->getName()) . '.php'; $path = str_replace('Sunnysideup/UpgradeToSilverstripe4/', '', $path); $currentStepCode = $obj->getTaskStepCode(); $currentStep = $obj->getTaskStep($currentStepCode); if ($currentStepCode === 's00') { //do nothing when it is an anytime step } else { if ($previousStep !== $currentStep) { $html .= '<h2>' . $currentStep . '</h2>'; } $previousStep = $currentStep; } $html .= '<h4>' . $count . '/' . $totalCount . ': ' . $obj->getTitle() . '</h4>'; $html .= '<p>' . $obj->getDescription() . '<br />'; $html .= '<strong>Class Code: </strong>' . $class; $html .= '<br /><strong>Class Name: </strong>'; $html .= '<a href="' . $path . '">' . $reflectionClass->getShortName() . '</a>'; $html .= '</p>'; $obj = $properClass::deleteTask($params); } else { user_error($properClass . ' could not be found as class', E_USER_ERROR); } } } $dir = $this->mu()->checkIfPathExistsAndCleanItUp(__DIR__ . '/../../docs/en/'); if ($dir) { $html = str_replace(' _', ' \_', $html); file_put_contents( rtrim($dir, '/') . '/AvailableTasks.md', $html ); } else { user_error('Coult not find ' . $dir . ' directory'); } } protected function mu() { return $this->myMu; } } |