yii2 invoke使用示例

<?php
class TestController
{
    public function actionIndex()
    {
        $order = Yii::$container->invoke([$this, 'createOrder'],[$this->view()]);
        print_r($order);
        exit();
    }

    public function createOrder($orderForm = [])
    {
        return $orderForm;
    }

    public function view(){
        return [1,2,3];
    }
}

返回结果【执行/test/index】:

原文地址:https://www.cnblogs.com/-mrl/p/14000586.html