php
  • zend-framework
  • 2013-01-18 1 views 2 likes 
    2

    안녕을 호출하면 내 코드입니다 :은 젠드 프레임 워크 내가 여기 여기서, 메일을 보낼 다른 컨트롤러 액션을 호출의 문제가 다른 컨트롤러 조치

    user.php

    public function followAction() 
    { 
        $follow_id = $this->_getParam('id'); 
    $response = "<a href='javascript: void(0)' class='i-wrap ig-wrap-user_social i-follow_small-user_social-wrap'><i class='i i-follow_small-user_social ig-user_social'></i>Stop Following</a>"; 
    
    notifyEmail() ------> need to call Notity Controller with notifyEmail() Action along with   
             params 
    $this->_helper->json($response); ----> return json response 
    
    } 
    

    NotifyController.php

    <?php 
    
    class NotifyController extends Zend_Controller_Action 
    { 
    
        public function init() 
        { 
         /* Initialize action controller here */ 
    
        } 
    
        public function index() 
        { 
    
        } 
    
        public function notifyEmailAction() 
        { 
          // rest of email code goes here 
        } 
    
    } 
    

    도움 주셔서 감사합니다.

    +0

    마음 낭비 자원에 계속 최선의 해결책이 아닙니다. [Zend Action Helper] (http://framework.zend.com/manual/1.12/en/zend.controller.actionhelpers.html) –

    답변

    7

    당신은, 다른 곳으로 를 메일 기능을 보낼 이동하고 두 가지 방법으로 호출해야합니다.

    확인 Calling member function of other controller in zend framework?

    내가 새로운 클래스의 새 폴더 '내'경로/도서관에서 그 안에 새 파일 Utilities.php 해당 파일에 작성하는 것이 좋습니다이 스레드 모든 당신의 도움을 넣을 수있는 곳 방법

    class My_Utilities { 
        // put here your custom help methods 
    } 
    

    당신은 당신이 우리를 할 수있는 그런

    autoloaderNamespaces.my = "My_" 
    

    를 넣어 application.ini/auto-load that namespace .IN의 CONFIGS 필요 e 네임 스페이스 My_ 및 My_Utilities 클래스.

    include 'NotifyController.php'; 
    $a = new NotifyController($this->_request, $this->_response); 
    $a->notifyEmailAction(); 
    
    +0

    글로벌 유틸리티 클래스 대신 서비스 개체. – blockhead

    -1

    도우미을 FrontController를 통해 걸어보고 다시 모든 플러그인을 파견이 코드 $this->action("action","controller","module")

    0
    $this->action('action', 'controller', 'module', 'params') 
    

    을 시도하십시오 : 어떤 경우에


    , 당신은 방법이 다른 컨트롤러를 형성 호출 할 수 있습니다 . 내가 생각

    당신은 작업 도우미를 작성하고 거기에 이메일 보내는 코드를 넣을 수 있습니다

    관련 문제