Exemple #1
0
 /**
  * Main method
  *
  * @param string $basePath
  * @return void
  */
 public static function main($basePath)
 {
     $startup = new StartupService();
     $app = AppContainer::getInstance();
     $startup->init($app, $basePath);
     $startup->run($app);
 }
Exemple #2
0
 /**
  * Constructor
  *
  * @param Capsule $db
  * @param Application $app
  */
 public function __construct(Capsule $db = null, ServiceContainer $app = null)
 {
     if ($app === null) {
         $app = AppContainer::getInstance();
     }
     $this->app = $app;
     if ($db === null) {
         $this->db = $this->app->db;
     }
 }
 public static function boot()
 {
     parent::boot();
     // Do the event listener here
     $callbacks = ['saved' => function ($user) {
         $app = \App\Container\AppContainer::getInstance();
         $logger = $app->getContainer()->logger;
         $logger->info('user saved event FIRED!');
         $logger->info($user);
     }, 'updated' => function ($user) {
         $app = \App\Container\AppContainer::getInstance();
         $logger = $app->getContainer()->logger;
         $logger->info('user updated event FIRED!');
         $logger->info($user);
     }];
     foreach ($callbacks as $key => $value) {
         User::$key($value);
     }
 }
Exemple #4
0
/**
 * Text translation (I18n)
 *
 * @param string $message
 * @param array $context
 * @return string
 *
 * <code>
 * echo __('Hello');
 * echo __('There are {number} persons logged', array('number' => 7));
 * </code>
 */
function __($message, array $context = array())
{
    $translator = \App\Container\AppContainer::getInstance()->translator;
    $message = $translator->trans($message);
    if (!empty($context)) {
        $message = interpolate($message, $context);
    }
    return $message;
}