1 | <?php |
||
2 | |||
3 | |||
4 | namespace carono\exchange1c\controllers; |
||
5 | |||
6 | |||
7 | use carono\exchange1c\models\TestingClass; |
||
8 | |||
9 | class TestingController extends Controller |
||
10 | { |
||
11 | /** |
||
12 | * @param null $class |
||
0 ignored issues
–
show
Documentation
Bug
introduced
by
![]() |
|||
13 | * @param null $result |
||
0 ignored issues
–
show
|
|||
14 | * @return string |
||
15 | * @throws \Exception |
||
16 | */ |
||
17 | public function actionIndex($class = null, $result = null) |
||
18 | { |
||
19 | /** |
||
20 | * @var TestingClass $testingClass |
||
21 | * @var TestingClass $resultClass |
||
22 | */ |
||
23 | $testingClass = null; |
||
24 | $resultClass = null; |
||
25 | if ($class) { |
||
0 ignored issues
–
show
|
|||
26 | $className = 'carono\exchange1c\models\\' . $class; |
||
27 | if (class_exists($className)) { |
||
28 | $testingClass = new $className(); |
||
29 | } else { |
||
30 | throw new \Exception("Class $className not found"); |
||
31 | } |
||
32 | |||
33 | if ($testingClass::testImplementsClass()->hasErrors()) { |
||
34 | throw new \Exception('Ошибки реализации интерфейсов.'); |
||
35 | } |
||
36 | |||
37 | if ($result) { |
||
38 | $resultClass = new $className(['method' => $result]); |
||
39 | } |
||
40 | } |
||
41 | return $this->render('index', ['testingClass' => $testingClass, 'resultClass' => $resultClass]); |
||
42 | } |
||
43 | } |