Give this a look.
Jan 8, 2015
65
Level 1
L5 Maximum function nesting level of '100' reached, aborting!
Hello guys ! I have an EmailNotifierInterface, and a class EmailNotifier that implements that interface, and it depends on Mailer Contract from 'Illuminate\Contracts\Mail\Mailer'
and this EmailNotifierInterface injected an Event Handler.
but it gives me this error
Maximum function nesting level of '100' reached, aborting!
Code
<?php
namespace App\Services;
interface EmailNotifierInterface
{
/**
* Sends a confirmation email to user just registred
*
* @param $email
* @param $confirmationKey
*/
public function sendRegistrationConfirmation($email, $confirmationKey);
}
<?php
namespace App\Services;
use Illuminate\Contracts\Mail\Mailer;
class EmailNotifier implements EmailNotifierInterface
{
/**
* @var Mailer
*/
private $mailer;
function __construct(Mailer $mailer)
{
$this->mailer = $mailer;
}
/**
* Sends a confirmation email to user just registred
*
* @param $email
* @param $confirmationKey
*/
public function sendRegistrationConfirmation($email, $confirmationKey){
$data = ['email' => $email,'confirmationKey' => $confirmationKey];
$this->mailer->send('email.confirmation', $data, function($message) use($email){
$message->to($email)->subject(trans("emails.title_confirmation_email"));
});
}
}
<?php namespace App\Handlers\Events;
use App\Events\UserWasRegistred;
use App\Services\EmailNotifier;
use App\Services\EmailNotifierInterface;
use Illuminate\Mail\Mailer;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldBeQueued;
class SendConfirmationEmail {
/**
* @var EmailNotifierInterface
*/
private $emailNotifier;
/**
* Create the event handler.
*
* @return void
*/
public function __construct(EmailNotifierInterface $mailer)
{
$this->emailNotifier = $mailer;
}
/**
* Handle the event.
*
* @param UserWasRegistred $event
* @return void
*/
public function handle(UserWasRegistred $event)
{
$confirmationKey = $this->generateConfirmationKey();
$this->emailNotifier->sendRegistrationConfirmation($event->getUser()->email, $confirmationKey);
}
// In AppServiceProvider
$this->app->bind(
'App\Services\EmailNotifierInterface',
'App\Services\EmailNotifier');
// and this is the Error !
Whoops, looks like something went wrong.
1/1
FatalErrorException in ClassLoader.php line 321:
Maximum function nesting level of '100' reached, aborting!
in ClassLoader.php line 321
at HandleExceptions->fatalExceptionFromError(array('type' => '1', 'message' => 'Maximum function nesting level of '100' reached, aborting!', 'file' => '/Applications/MAMP/htdocs/chhiwty/vendor/composer/ClassLoader.php', 'line' => '321')) in HandleExceptions.php line 116
at HandleExceptions->handleShutdown()
Please or to participate in this conversation.