run(array( 'mailing' => $mailing, 'attachments' => \CRM_Core_BAO_File::getEntityFile('civicrm_mailing', $mailing->id), )); } /** * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface */ private $dispatcher; /** * FlexMailer constructor. * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher */ public function __construct(EventDispatcherInterface $dispatcher = NULL) { $this->dispatcher = $dispatcher ? $dispatcher : \Civi::service('dispatcher'); } /** * @param array $context * An array which must define options: * - mailing: \CRM_Mailing_BAO_Mailing * - attachments: array * @return array * List of error messages. * Ex: array('subject' => 'The Subject field is blank'). * Example keys: 'subject', 'name', 'from_name', 'from_email', 'body', 'body_html:unsubscribeUrl'. */ public function run($context) { $checkSendable = new CheckSendableEvent($context); $this->dispatcher->dispatch(static::EVENT_CHECK_SENDABLE, $checkSendable); return $checkSendable->getErrors(); } }