private static final function sendItem(CommunicationItem $item)
 {
     if ($item->Sent) {
         Log::warning("Attempt blocked to send already sent email", "COMMS", ["CommunicationItemID" => $item->CommunicationItemID, "EmailProvider" => self::$emailProviderClassName]);
         return true;
     }
     $sendable = $item->getSendable();
     $providerClass = $sendable->getProviderClassName();
     $provider = self::getContainer()->getInstance($providerClass);
     if ($provider instanceof CaptureToCommunicationsProcessorInterface) {
         throw new InvalidProviderException();
     }
     try {
         $provider->send($sendable);
         $item->markSent();
     } catch (\Exception $exception) {
         $item->Status = CommunicationItem::STATUS_FAILED;
     }
     $item->markSent();
     $item->save();
     Log::debug("Sending communication by Email", "COMMS", ["CommunicationID" => $item->CommunicationID, "EmailProvider" => self::$emailProviderClassName]);
     return $item->Status == CommunicationItem::STATUS_SENT;
 }
Exemplo n.º 2
0
 * a resource for performance reasons, e.g. accessing static content like images
 * and CSS files.
 */
use Rhubarb\Crown\Application;
use Rhubarb\Crown\Logging\Log;
// Initiate our bootstrap script to boot all libraries required.
require_once __DIR__ . "/boot-application.php";
require_once __DIR__ . "/../src/Logging/Log.php";
require_once __DIR__ . "/../src/Module.php";
require_once __DIR__ . "/../src/PhpContext.php";
Log::performance("Rhubarb booted", "ROUTER");
/**
 * @var Application $application
 */
if (!isset($application)) {
    Log::warning("HTTP request made with no application loaded.", "ROUTER");
} else {
    try {
        // Pass control to the application and ask it to generate a response for the
        // incoming request.
        $response = $application->generateResponseForRequest($application->request());
        Log::performance("Response generated", "ROUTER");
        $response->send();
        Log::performance("Response sent", "ROUTER");
    } catch (\Exception $er) {
        if ($application->developerMode) {
            Log::error($er->getMessage(), "ERROR");
            print "<pre>Exception: " . get_class($er) . "\nMessage: " . $er->getMessage() . "\nStack Trace:\n" . $er->getTraceAsString();
        }
    }
}