#5904: Cannot load EmailComponent from within MyComponent and send an email
---------------------------+------------------------------------------------
    Reporter:  patcoll     |         Owner:          
        Type:  Bug         |        Status:  reopened
    Priority:  Medium      |     Milestone:  1.2.x.x 
   Component:  Components  |       Version:  RC4     
    Severity:  Normal      |    Resolution:          
    Keywords:              |   Php_version:  PHP 5   
Cake_version:              |  
---------------------------+------------------------------------------------
Changes (by patcoll):

  * status:  closed => reopened
  * resolution:  invalid =>

Comment:

 I have read bugreport. I see no duplicates nor have I gotten any IRC
 response. Here's the situation:

 === what i did ===

 I put this in a custom Component of mine:

 {{{
   var $components = array('Email');
 }}}

 I then used the `EmailComponent::send()` method from within a method
 called `email()` in my custom Component.

 === what i expected ===

 What I expected to happen was for the email to be sent using the
 `EmailComponent`. This is not what happened.

 === what happened ===

 This error:

 {{{
 Undefined property: EmailComponent::$Controller
 [CORE/cake/libs/controller/components/email.php, line 352]
 }}}

 I did some digging and discovered that EmailComponent assigns a reference
 to the controller that loads it into a variable called
 `EmailComponent::$Controller`. This assignment would work fine if
 EmailComponent were being used directly by a controller, but instead it's
 being used via a custom component. I was able to fix this error by
 including this code in my custom component:

 {{{
 function startup(&$controller){
         $this->Email->startup($controller);
 }
 }}}

 As an apparent design decision made by the core team to allow recursive
 loading of components, it seems odd that EmailComponent, a core component
 itself, would break this design by not allowing developers to use its core
 functionality inside of a custom component without this overhead. I see no
 necessity in this overhead.

 To promote better code decoupling in Cake core, I'd suggest taking out
 this dependency, unless a reasonable use case is presented.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5904#comment:2>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to