1 | <?php |
||
2 | |||
3 | |||
4 | namespace carono\exchange1c\controllers; |
||
5 | |||
6 | |||
7 | use carono\exchange1c\models\Article; |
||
8 | use Yii; |
||
9 | use yii\helpers\FileHelper; |
||
10 | use yii\helpers\Html; |
||
11 | |||
12 | /** |
||
13 | * Class ArticleController |
||
14 | * |
||
15 | * @package carono\exchange1c\controllers |
||
16 | */ |
||
17 | class ArticleController extends Controller |
||
18 | { |
||
19 | public function actionCreate($parent = null) |
||
20 | { |
||
21 | $article = new Article(); |
||
22 | $article->pos = Article::find()->andWhere(['[[parent_id]]' => $parent])->max('pos') + 10; |
||
23 | $article->parent_id = $parent; |
||
24 | if ($article->load(\Yii::$app->request->post())) { |
||
25 | if ($article->save()) { |
||
26 | return $this->redirect(['article/index']); |
||
27 | } |
||
28 | |||
29 | \Yii::$app->session->setFlash('error', Html::errorSummary($article)); |
||
0 ignored issues
–
show
|
|||
30 | } |
||
31 | return $this->render('update', ['article' => $article]); |
||
32 | } |
||
33 | |||
34 | public function actionUpdate($id) |
||
35 | { |
||
36 | $article = Article::findOne($id, true); |
||
37 | if ($article->load(\Yii::$app->request->post())) { |
||
38 | if ($article->save()) { |
||
39 | return $this->redirect(['article/view', 'id' => $article->id]); |
||
40 | } |
||
41 | |||
42 | \Yii::$app->session->setFlash('error', Html::errorSummary($article)); |
||
43 | } |
||
44 | return $this->render('update', ['article' => $article]); |
||
45 | } |
||
46 | |||
47 | public function actionView($id) |
||
48 | { |
||
49 | Yii::$app->getView()->registerJs("$('pre').each(function(i, block) { hljs.highlightBlock(block); });"); |
||
50 | $article = Article::findOne($id, true); |
||
51 | return $this->render('view', ['article' => $article]); |
||
52 | } |
||
53 | |||
54 | public function actionDelete($id) |
||
55 | { |
||
56 | Article::findOne($id, true)->delete(); |
||
57 | return $this->redirect(['article/index']); |
||
58 | } |
||
59 | |||
60 | public function actionIndex() |
||
61 | { |
||
62 | $dataProvider = Article::find()->orderBy(['{{%article}}.[[pos]]' => SORT_ASC])->search(); |
||
63 | return $this->render('index', ['dataProvider' => $dataProvider]); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * Удаляем все реальные файлы, которые не используются в статьях |
||
68 | */ |
||
69 | public function actionDeleteUnusedImages() |
||
70 | { |
||
71 | $content = Article::find()->select(['content' => 'group_concat([[content]])'])->scalar(); |
||
72 | $dir = Yii::getAlias(Yii::$app->controller->module->redactor->uploadDir); |
||
73 | $files = Article::extractFilesFromString($content); |
||
74 | $realFiles = FileHelper::findFiles($dir); |
||
75 | array_walk($realFiles, function (&$item) use ($dir) { |
||
76 | $item = str_replace('\\', '/', substr($item, strlen($dir))); |
||
77 | }); |
||
78 | foreach (array_diff($realFiles, $files) as $file) { |
||
79 | unlink($dir . '/' . $file); |
||
80 | }; |
||
81 | return $this->redirect(['article/index']); |
||
82 | } |
||
83 | |||
84 | public function actionCreateReadme() |
||
85 | { |
||
86 | $badges = []; |
||
87 | $lines = []; |
||
88 | $titles = Article::formTitleItems(); |
||
89 | |||
90 | $badges[] = '[](https://scrutinizer-ci.com/g/carono/yii2-1c-exchange/?branch=master)'; |
||
91 | $badges[] = '[](https://packagist.org/packages/carono/yii2-1c-exchange)'; |
||
92 | $badges[] = '[](https://packagist.org/packages/carono/yii2-1c-exchange)'; |
||
93 | $badges[] = '[](https://packagist.org/packages/carono/yii2-1c-exchange)'; |
||
94 | $badges[] = "\n"; |
||
95 | $titles[] = "\n"; |
||
96 | foreach (Article::formContentItems() as $item) { |
||
97 | $titles[] = $item; |
||
98 | } |
||
99 | $titles[] = "\n"; |
||
100 | $content = implode("\n", array_merge($badges, $titles, $lines)); |
||
101 | file_put_contents(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'README.md', trim($content)); |
||
102 | } |
||
103 | } |
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.