简体   繁体   中英

return values of components in Yii

Yii framework:) Suppose that we have two files, one controller:

    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. But that is not always the choice of the developer... Then use the braintree extension inside of protected/extensions/BraintreeApi/

If not then use the Egopay SCI package and put it inside say:

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

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.

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 :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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