简体   繁体   English

返回Yii中组件的值

[英]return values of components in Yii

Yii framework:) Suppose that we have two files, one controller: Yii框架:)假设我们有两个文件,一个控制器:

    Yii::app()->egopay->testf('testtext_testtext_testtext');
echo $test;

and second component: 第二部分:

public function testf($t){
    $test = $t;
return $test;
}

I have a very long code whose value does not copy the but works on the same principle, therefore, must be paying a variable from the component to the controller. 我有一个很长的代码,其值不会复制,而是按相同的原理工作,因此,必须从组件向控制器支付变量。 Why can not I display the returned value component? 为什么我不能显示返回值部分?

I would first see if braintree could be used instead of egopay. 我先看看是否可以使用Braintree代替egopay。 But that is not always the choice of the developer... Then use the braintree extension inside of protected/extensions/BraintreeApi/ 但这并不总是开发人员的选择...然后在protected / extensions / BraintreeApi /中使用braintree扩展

If not then use the Egopay SCI package and put it inside say: 如果没有,请使用Egopay SCI软件包并将其放入其中,然后说:

protected/extensions/EgopayApi/

Then in the Controller for Payments? 然后在付款管理器中? Cart? 大车? make a new action for the payment link: 对付款链接进行新的操作:

public function actionPayment() {
  $model = ; # maybe find by primary key for user?
  # example: $model = User::model()->findByPk(Yii::app()->user->id);
  Yii::import('ext.EgoPaySci.models.EgopayCCForm');  # Brings in the EgoPaySci.php and form if any
  $payment = new EgopayCCForm(array('store_id' => 8888, 'store_password' => 'JkkYhs7ft'));

The values from EgoPaySci.php will be available via: $payment 来自EgoPaySci.php的值可通过以下方式获得:$ payment

Sorry for being vague but I am assuming you are doing a payment gateway. 抱歉,我含糊不清,但我假设您正在使用付款网关。 And there is a lot of details to explain. 并且有很多细节需要解释。 But setting this up in the Controller will make it available to the model and therefor the views also. 但是在Controller中对其进行设置将使其可用于模型,因此也可用于视图。

not quite what I meant. 不完全是我的意思。 And here is ready to like someone needed a :) 并且这里准备好喜欢某人需要:)

controller:
$test = Yii::app()->egopay->testf('testtext_testtext_testtext');
echo 'variable a:'.$test['a'];
echo $test['b'];
echo $test['c'];

components:
public function testf($t){
    $var['a'] = $t;
    $var['b'] = 'variable b: '.$t;
    $var['c'] = 'variable c: '.$t;
return $var;
}

but anyway thanks for the reply :) 但无论如何,感谢您的回复:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM