1 | <?php |
||
2 | |||
3 | namespace DNADesign\Elemental\Tasks; |
||
4 | |||
5 | use DNADesign\Elemental\Models\ElementalArea; |
||
6 | use DNADesign\Elemental\Models\ElementContent; |
||
7 | |||
8 | use SilverStripe\Dev\BuildTask; |
||
9 | |||
10 | class MigrateContentToElement extends BuildTask |
||
11 | { |
||
12 | |||
13 | protected $title = 'MigrateContentToElement'; |
||
14 | |||
15 | protected $description = 'When installing Elemental this task converts content in the $Content field to an ElementContent'; |
||
16 | |||
17 | public function run($request) |
||
18 | { |
||
19 | // TODO: needs rewriting for multiple elemental areas |
||
20 | $pageTypes = ElementalArea::elemental_page_types(); |
||
0 ignored issues
–
show
|
|||
21 | $count = 0; |
||
22 | foreach ($pageTypes as $pageType) { |
||
23 | $pages = $pageType::get()->filter('ElementalAreaID', 0); |
||
24 | foreach ($pages as $page) { |
||
25 | $content = $page->Content; |
||
26 | $page->Content = ''; |
||
27 | // trigger area relations to be setup |
||
28 | $page->write(); |
||
29 | $area = $page->ElementalArea(); |
||
30 | $element = new ElementContent(); |
||
31 | $element->Title = 'Auto migrated content'; |
||
32 | $element->HTML = $content; |
||
33 | $element->ParentID = $area->ID; |
||
34 | $element->write(); |
||
35 | } |
||
36 | $count += $pages->Count(); |
||
37 | echo 'Migrated ' . $pages->Count() . ' ' . $pageType . ' pages\' content<br>'; |
||
38 | } |
||
39 | echo 'Finished migrating ' . $count . ' pages\' content<br>'; |
||
40 | } |
||
41 | } |
||
42 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.