예제 #1
0
 public function register(Container $container)
 {
     $host = Config::get('mail.smtp.host');
     $port = Config::get('mail.smtp.port');
     $encryption = Config::get('mail.smtp.encryption');
     $username = Config::get('mail.smtp.username');
     $password = Config::get('mail.smtp.password');
     // The Swift SMTP transport instance will allow us to use any SMTP backend
     // for delivering mail such as Sendgrid, Amazon SMS, or a custom server
     // a developer has available. We will just pass the configured host.
     $transport = SmtpTransport::newInstance($host, $port);
     if (isset($encryption)) {
         $transport->setEncryption($encryption);
     }
     // Once we have the transport we will check for the presence of a username
     // and password. If we have it we will set the credentials on the Swift
     // transporter instance so that we'll properly authenticate delivery.
     if (isset($username)) {
         $transport->setUsername($username);
         $transport->setPassword($password);
     }
     $mailer = new Mailer(new Swift_Mailer($transport));
     $mailer->alwaysFrom(Config::get('mail.from.email'), Config::get('mail.from.name'));
     $container->mail = $mailer;
 }
예제 #2
0
 public function __construct($compress = true)
 {
     $this->compiler = new scssc();
     if (!Config::get('debug')) {
         $this->compiler->setFormatter('scss_formatter_compressed');
     }
 }
예제 #3
0
 public function register(Container $c)
 {
     $c['twig.filesystem'] = function ($c) {
         return new TwigFilesystem(APP_ROOT . DS . 'app' . DS . 'views');
     };
     $c['twig.env'] = function ($c) {
         return new Twig_Environment($c['twig.filesystem'], array('cache' => APP_ROOT . 'tmp/', 'auto_reload' => Config::get('debug') ? true : false, 'debug' => Config::get('debug') ? true : false));
     };
     $this->registerFunctions($c);
     $this->registerGlobals($c);
 }
예제 #4
0
 private function useCache($assetFilename)
 {
     if (Config::get('app.debug')) {
         return false;
     }
     $location = $this->assetLocation($assetFilename);
     $assetStat = stat($location) ?: array();
     $cacheModificationTime = $this->cache->time($assetFilename);
     if ($assetStat['mtime'] != null && $cacheModificationTime != null && $assetStat['mtime'] < $cacheModificationTime) {
         return true;
     } else {
         if ($this->cache->has($assetFilename)) {
             return true;
         }
     }
     return false;
 }
예제 #5
0
 public function register(Container $container)
 {
     $driver = Config::get('cache.driver', 'array');
     if ($driver === 'array') {
         $container->cache = new ArrayCache();
     } else {
         if ($driver === 'file') {
             $container->cache = new FileCache();
         } else {
             if ($driver === 'redis') {
                 throw new Exception('Redis cache driver not yet implemented!');
             } else {
                 throw new Exception('CacheProvider couln\'t find the implementation for the specified driver');
             }
         }
     }
 }
예제 #6
0
 public function handle($content)
 {
     if (Config::get('debug')) {
         return $content;
     }
     // Create a temporary file for the compiler & write content
     $tmpFilePath = tempnam(realpath(sys_get_temp_dir()), "phpcc_");
     $handle = fopen($tmpFilePath, "w");
     fwrite($handle, $content['body']);
     fclose($handle);
     // Compile js
     $compilerFile = dirname(__FILE__) . '/closure-compiler.jar';
     $compiledContent = shell_exec("java -jar {$compilerFile} --js {$tmpFilePath} --language_in=ECMASCRIPT5");
     if ($compiledContent === '') {
         $compiledContent = '/** If this is empty and should not be, check if java is installed on your machine **/';
     }
     // Assign the output to the response
     $content['type'] = 'application/javascript';
     $content['body'] = $compiledContent;
     // Delete temporary file
     unlink($tmpFilePath);
     return $content;
 }
예제 #7
0
 public function setUpAliases()
 {
     $aliases = Config::group('aliases');
     foreach ($aliases as $alias => $realClass) {
         if (!class_exists($alias)) {
             class_alias($realClass, $alias);
         }
     }
 }