/**
  * @param string $name
  * @param int $level
  * @param bool $bubble
  */
 public function __construct($name, $level = Logger::DEBUG, $bubble = true)
 {
     parent::__construct($level, $bubble);
     $this->name = $name;
     $this->notifier = JoliNotif\NotifierFactory::create();
     $this->notification = new JoliNotif\Notification();
 }
 public function __construct()
 {
     $this->notifier = NotifierFactory::create();
     if (self::$is_darwin === null) {
         self::$is_darwin = OsHelper::isMacOS();
     }
 }
 public function after(PrintResultEvent $e)
 {
     $notifier = NotifierFactory::create();
     if ($notifier) {
         $notifier->send((new \Joli\JoliNotif\Notification())->setTitle("Codeception Test Result")->setBody($this->formatBody())->setIcon(basename(__DIR__) . '/' . $this->getIcon()));
     }
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->comment(PHP_EOL . 'Start pending hours validation' . PHP_EOL);
     $referenceDate = Carbon::now();
     $referenceDate->hour(13)->minute(0)->second(0);
     $configurationRepository = new ConfigurationRepository();
     $enableQueueProcess = $configurationRepository->getValue('enable_queue_process');
     $reportsService = new Reports();
     $now = Carbon::now();
     if ($referenceDate->diffInMinutes($now, false) > 0) {
         $date = $now;
     } else {
         $date = Carbon::now()->subDay(1);
     }
     $this->info(PHP_EOL . 'Checking ' . $date->format('d/m/Y') . PHP_EOL);
     $pendingAppointment = $reportsService->getDaysWithPendingAppointmentHours($date, $date);
     if (isset($pendingAppointment['hoursPending'][0]) && $pendingAppointment['hoursPending'][0] > 0) {
         $notifier = NotifierFactory::create();
         $message = sprintf('You have pending hours in the day %s. You need to send %s hours.', $pendingAppointment['date'][0], $pendingAppointment['hoursPending'][0]);
         $this->error(PHP_EOL . $message . PHP_EOL);
         if ($notifier) {
             // Create your notification
             $notification = (new Notification())->setTitle('Pending Hours')->setBody($message)->setIcon(__DIR__ . '/../../../public/img/clock.png');
             // Send it
             $notifier->send($notification);
         }
     }
     $this->comment(PHP_EOL . 'End pending hours validation' . PHP_EOL);
 }
Esempio n. 5
0
 /**
  * Send desktop notification
  *
  * @param $message
  */
 public static function send($message)
 {
     $notifier = NotifierFactory::create();
     $basePath = dirname(__FILE__) . '/../../../';
     $notification = (new Notify())->setTitle('Magestead')->setBody($message)->setIcon($basePath . 'assets/magentologo.png');
     $notifier->send($notification);
 }
Esempio n. 6
0
 public function __construct($format = "[%STATUS%]\n%message%\n%author%")
 {
     if (!class_exists('Joli\\JoliNotif\\NotifierFactory')) {
         throw new \RuntimeException('This notifier requires the package jolicode/jolinotif to be installed');
     }
     $this->format = $format;
     $this->notifier = NotifierFactory::create();
 }
Esempio n. 7
0
/**
 * Desktop Push Notification
 * 
 * Notifications that can be pushed at a delayed time.
 * 
 * @since 6.2.11
 * @param string $title Give title of notification.
 * @param string $message Message that should be displayed.
 */
function etsis_push_notify($title, $message)
{
    $app = \Liten\Liten::getInstance();
    // Create a Notifier
    $notifier = NotifierFactory::create();
    // Create your notification
    $notification = (new Notification())->setTitle($title)->setBody($message)->setIcon(BASE_PATH . 'static/assets/imgages/icon-success.png');
    // Send it
    return $app->hook->apply_filter('push_notify', $notifier->send($notification));
}
Esempio n. 8
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $container = new Container();
     $verbose = OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity();
     $strategy = $container->getChainStrategy();
     $executor = $container->getExecutor(!$input->getOption('no-cache'), $verbose, $input->getOption('timeout'));
     $serviceManager = $container->getServiceManager($verbose);
     $notifier = NotifierFactory::create();
     $output->writeln("<info>Creating builds...</info>");
     $jobs = $strategy->getJobs($input->getOption("project-path"));
     $output->writeln(sprintf("<info>%s builds created</info>", count($jobs)));
     $exitCode = 0;
     try {
         foreach ($jobs as $job) {
             $output->writeln(sprintf("\n<info>Running job %s</info>\n", $job->getDescription()));
             $serviceManager->start($job);
             $strategy->prepareJob($job);
             $success = $executor->test($job, $input->getArgument('cmd'));
             $exitCode += $success == 0 ? 0 : 1;
             if ($input->getOption('notify')) {
                 $notification = new Notification();
                 $notification->setBody(sprintf('Test results for %s on %s', $container->getNaming()->getProjectName($input->getOption('project-path')), $job->getDescription()));
                 $notification->setTitle($success == 0 ? 'Tests passed' : 'Tests failed');
                 $notifier->send($notification);
             }
             $serviceManager->stop($job);
         }
     } catch (\Exception $e) {
         // Try stop last builds
         if (isset($job)) {
             $serviceManager->stop($job);
         }
         // We do not deal with exception (Console Component do it well),
         // we just catch it to allow cleaner to be runned even if one of the build failed hard
         // Simulation of a finally for php < 5.6 :-°
     }
     $container->getVacuum()->clean($input->getOption("project-path"), $input->getOption("keep"));
     if (isset($e)) {
         throw $e;
     }
     return $exitCode;
 }
Esempio n. 9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $io = new SymfonyStyle($input, $output);
     $date = new \DateTime($input->getArgument('datetime'));
     // Get departure/arrival stops
     $departure = $this->getStop($input->getArgument('departure'), 'Which departure ?');
     $arrival = $this->getStop($input->getArgument('arrival'), 'Which arrival ?');
     $io->title(sprintf('%s -> %s (%s)', $departure['value'], $arrival['value'], $date->format('d.m.y H:i')));
     // Query
     $times = $this->cff->query($departure, $arrival, $date);
     // Compute delays
     $delays = array();
     $now = new \DateTime();
     foreach ($times as $time) {
         $diff = $now->diff(\DateTime::createFromFormat('d.m.y H:i', $time['date'] . ' ' . $time['departure']));
         $delays[] = (int) ($diff->format('%r') . ($diff->h * 60 + $diff->i));
     }
     // Show output table
     $formattedTimes = array_map(function ($v, $d) {
         unset($v['date']);
         $v = array('in' => $d . '´') + $v;
         $v['infos'] = '<error>' . $v['infos'] . '</error>';
         return $v;
     }, $times, $delays);
     $io->table(array('In', 'Dep.', 'Arr.', 'Dur.', 'Chg.', 'With', 'Infos'), $formattedTimes);
     // Show notification
     if ($input->getOption('notify')) {
         $notifier = NotifierFactory::create();
         $body = '';
         foreach ($times as $t => $time) {
             $body .= sprintf("%s - %s | %s | %s chg. | %s | in %s´ %s\r\n", $time['departure'], $time['arrival'], $time['duration'], $time['change'], $time['product'], $delays[$t], $time['infos']);
         }
         $notification = (new Notification())->setTitle(sprintf("%s -> %s", $departure['value'], $arrival['value']))->setBody($body);
         $notifier->send($notification);
     }
 }
Esempio n. 10
0
<?php

/*
 * This file is part of the JoliNotif project.
 *
 * (c) Loïck Piera <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
use Joli\JoliNotif\Notification;
use Joli\JoliNotif\NotifierFactory;
require __DIR__ . '/../vendor/autoload.php';
$notifier = NotifierFactory::create();
if ($notifier) {
    $notification = (new Notification())->setTitle('Notification example')->setBody('This is a notification example. Pretty cool isn\'t it?')->setIcon(__DIR__ . '/icon-success.png');
    $result = $notifier->send($notification);
    echo 'Notification ', $result ? 'successfully sent' : 'failed', ' with ', get_class($notifier), PHP_EOL;
} else {
    echo 'No supported notifier', PHP_EOL;
}
Esempio n. 11
0
 /**
  * {@inheritdoc}
  */
 public function activate(Composer $composer, IOInterface $io)
 {
     $this->notifier = NotifierFactory::create();
     $this->composer = $composer;
 }
Esempio n. 12
0
 /** @expectedException \Joli\JoliNotif\Exception\NoSupportedNotifierException */
 public function testCreateOrThrowExceptionWithNoSupportedNotifiersThrowsException()
 {
     NotifierFactory::createOrThrowException([new ConfigurableNotifier(false), new ConfigurableNotifier(false)]);
 }
Esempio n. 13
0
 public function testCreateUsesTheFirstOfTheBestSupportedNotifiers()
 {
     $notifier1 = new ConfigurableNotifier(false);
     $notifier2 = new ConfigurableNotifier(true, 5);
     $notifier3 = new ConfigurableNotifier(true, 8);
     $notifier4 = new ConfigurableNotifier(false);
     $notifier5 = new ConfigurableNotifier(true, 8);
     $notifier = NotifierFactory::create([$notifier1, $notifier2, $notifier3, $notifier4, $notifier5]);
     $this->assertSame($notifier3, $notifier);
 }
Esempio n. 14
0
 /**
  * @param string $message
  */
 private function sendDesktopNotification($message)
 {
     $notifier = NotifierFactory::create();
     if ($notifier) {
         // Create your notification
         $notification = (new Notification())->setTitle('Bldr')->setBody($message);
         // Send it
         $notifier->send($notification);
     }
 }
 /**
  * Notifier desktop user
  */
 private function notifyDesktopUser()
 {
     $icon = __DIR__ . '/../../resources/icons/';
     if ($this->phpUnitTestCounter->getNbFailure()) {
         $title = 'FAILURES!';
         $body = sprintf('Tests: %d, Assertions: %d, Failures: %d.', $this->phpUnitTestCounter->getNbStartedTest(), $this->phpUnitTestCounter->getNbAssert(), $this->phpUnitTestCounter->getNbFailure());
         $icon .= 'failure-64.png';
     } else {
         $title = 'Success!';
         $body = sprintf('%d tests, %d assertions', $this->phpUnitTestCounter->getNbStartedTest(), $this->phpUnitTestCounter->getNbAssert());
         $icon .= 'success-64.png';
     }
     $notifier = NotifierFactory::create();
     if ($notifier) {
         $notification = (new Notification())->setTitle($title)->setBody($body)->setIcon($icon);
         $notifier->send($notification);
     }
 }