public static function write($type, $message, $pretty_print = false) { $message = $pretty_print ? print_r($message, true) : $message; if (Event::listeners('laravel.log')) { Event::fire('laravel.log', array($type, $message)); } $message = static::format($type, $message); File::append(path('storage') . 'logs/' . date('Y-m-d') . '.log', $message); }
/** * Render the view. * * @return string * @throws \Exception */ public function render() { // Events Event::fire("laravel.composing: {$this->view}", array($this)); // Buffer the output ob_start(); try { // array of paths where to find the views $paths = Config::get('weed::weed.paths'); // build the Twig object $loader = new Twig\Weed\Loader\Filesystem($paths); // define the Twig environment $config = array('cache' => Config::get('weed::weed.cache'), 'debug' => Config::get('weed::weed.debug'), 'auto_reload' => Config::get('weed::weed.auto_reload')); $twig = new \Twig_Environment($loader, $config); // register the desired extensions foreach (Config::get('weed::weed.extensions') as $extension) { $twig->addExtension(new $extension()); } // output the rendered template :-) echo $twig->render($this->template, $this->data()); } catch (\Exception $e) { ob_get_clean(); throw $e; } return ob_get_clean(); }
/** * Sends email * * @param string $to Recipient email address * @param string $subject Subject of the email * @param string $htmlBody HTML body of the email * @param string $plainBody Plain text body of the email * @param string $connConfigName Connection configuration name to be used * * @throws InvalidConnectionConfigException * * @return bool * * @author Mert Hurturk <*****@*****.**> **/ public function sendEmail($to, $subject, $htmlBody, $plainBody, $connConfigName = null) { $config = $this->_getConfigurationArray($connConfigName); if (!is_array($config)) { throw new InvalidConnectionConfigException('Invalid Sendersuite connection configuration key: "' . $connConfigName . '"'); } $data = array('to' => $to, 'subject' => $subject, 'htmlbody' => $htmlBody, 'plainbody' => $plainBody); try { $this->_connection->send($data, $config); return true; } catch (Exception $e) { \Laravel\Event::fire('sendersuite.email.error', array($data, $config, $e)); return false; } }
/** * Load a bundle by running it's start-up script. * * If the bundle has already been started, no action will be taken. * * @param string $bundle * @return void */ public static function start($bundle) { if (static::started($bundle)) { return; } if (!static::exists($bundle)) { throw new \Exception("Bundle [{$bundle}] has not been installed."); } // Each bundle may have a "start" script which is responsible for preparing // the bundle for use by the application. The start script may register any // classes the bundle uses with the auto-loader, etc. if (file_exists($path = static::path($bundle) . 'start' . EXT)) { require $path; } // Each bundle may also have a "routes" file which is responsible for // registering the bundle's routes. This is kept separate from the // start script for reverse routing efficiency purposes. static::routes($bundle); Event::fire("started: {$bundle}"); static::$started[] = strtolower($bundle); }
/** * Fire a given event for the model. * * @param string $event * @return array */ protected function fire_event($event) { $events = array("eloquent.{$event}", "eloquent.{$event}: " . get_class($this)); Event::fire($events, array($this)); }
/** * Log the query and fire the core query event. * * @param string $sql * @param array $bindings * @param int $start * @return void */ protected function log($sql, $bindings, $start) { $time = number_format((microtime(true) - $start) * 1000, 2); Event::fire('laravel.query', array($sql, $bindings, $time)); static::$queries[] = compact('sql', 'bindings', 'time'); }
/** * Get the evaluated string content of the view. * * @return string */ public function render() { Event::fire("laravel.composing: {$this->view}", array($this)); // If there are listeners to the view engine event, we'll pass them // the view so they can render it according to their needs, which // allows easy attachment of other view parsers. if (Event::listeners(static::engine)) { $result = Event::until(static::engine, array($this)); if (!is_null($result)) { return $result; } } return $this->get(); }
public function send($data = array(), $config = array()) { \Laravel\Event::fire('sendersuite.email.debug', array($data, $config)); }
protected function log($command, $start, $arguments) { $time = number_format((microtime(true) - $start) * 1000, 2); \Laravel\Event::fire('laravel.mongoquery', array($this->_db, $command, $arguments, $time)); }
/** * Resolve a given type to an instance. * * <code> * // Get an instance of the "mailer" object registered in the container * $mailer = IoC::resolve('mailer'); * * // Get an instance of the "mailer" object and pass parameters to the resolver * $mailer = IoC::resolve('mailer', array('test')); * </code> * * @param string $type * @param array $parameters * @return mixed */ public static function resolve($type, $parameters = array()) { // If an instance of the type is currently being managed as a singleton, we will // just return the existing instance instead of instantiating a fresh instance // so the developer can keep re-using the exact same object instance from us. if (isset(static::$singletons[$type])) { return static::$singletons[$type]; } // If we don't have a registered resolver or concrete for the type, we'll just // assume the type is the concrete name and will attempt to resolve it as is // since the container should be able to resolve concretes automatically. if (!isset(static::$registry[$type])) { $concrete = $type; } else { $concrete = array_get(static::$registry[$type], 'resolver', $type); } // We're ready to instantiate an instance of the concrete type registered for // the binding. This will instantiate the type, as well as resolve any of // its nested dependencies recursively until they are each resolved. if ($concrete == $type or $concrete instanceof Closure) { $object = static::build($concrete, $parameters); } else { $object = static::resolve($concrete); } // If the requested type is registered as a singleton, we want to cache off // the instance in memory so we can return it later without creating an // entirely new instances of the object on each subsequent request. if (isset(static::$registry[$type]['singleton']) && static::$registry[$type]['singleton'] === true) { static::$singletons[$type] = $object; } Event::fire('laravel.resolving', array($type, $object)); return $object; }
/** * Log the user out of the driver's auth context. * * @return void */ public function logout() { $this->user = null; $this->cookie($this->recaller(), null, -2000); Session::forget($this->token()); Event::fire('laravel.auth: logout'); $this->token = null; }
/** * Log the query and fire the core query event. * * @param string $sql * @param array $bindings * @param int $time * @return void */ protected function log($sql, $bindings, $time) { Event::fire('laravel: query', array($sql, $bindings, $time)); static::$queries = compact('sql', 'bindings', 'time'); }
/** * Get the evaluated string content of the view. * * @return string */ public function render() { // To allow bundles or other pieces of the application to modify the // view before it is rendered, we will fire an event, passing in the // view instance so it can modified. Event::fire("laravel.composing: {$this->view}", array($this)); $data = $this->data(); ob_start() and extract($data, EXTR_SKIP); // If the view is Bladed, we need to check the view for changes and // get the path to the compiled view file. Otherwise, we'll just // use the regular path to the view. // // Also, if the Blade view has expired or doesn't exist it will be // re-compiled and placed in the view storage directory. The Blade // views are re-compiled the original view changes. if (strpos($this->path, BLADE_EXT) !== false) { $this->path = $this->compile(); } try { include $this->path; } catch (\Exception $e) { ob_get_clean(); throw $e; } return ob_get_clean(); }
/** * Get the evaluated string content of the view. * * @return string */ public function render() { // To allow bundles or other pieces of the application to modify the // view before it is rendered, we'll fire an event, passing in the // view instance so it can modified. $composer = "laravel.composing: {$this->view}"; Event::fire($composer, array($this)); // If there are listeners to the view engine event, we'll pass them // the view so they can render it according to their needs, which // allows easy attachment of other view parsers. if (Event::listeners(static::engine)) { $result = Event::first(static::engine, array($this)); if ($result !== false) { return $result; } } return $this->get(); }
/** * Get the evaluated string content of the view. * * @return string */ public function render() { static::$render_count++; Event::fire("laravel.composing: {$this->view}", array($this)); $contents = null; // If there are listeners to the view engine event, we'll pass them // the view so they can render it according to their needs, which // allows easy attachment of other view parsers. if (Event::listeners(static::engine)) { $result = Event::until(static::engine, array($this)); if (!is_null($result)) { $contents = $result; } } if (is_null($contents)) { $contents = $this->get(); } static::$render_count--; if (static::$render_count == 0) { //Section::$sections = array(); } return $contents; }
| | We'll send the response back to the browser here. This method will also | send all of the response headers to the browser as well as the string | content of the Response. This should make the view available to the | browser and show something pretty to the user. | */ $response->send(); /* |-------------------------------------------------------------------------- | And We're Done! |-------------------------------------------------------------------------- | | Raise the "done" event so extra output can be attached to the response. | This allows the adding of debug toolbars, etc. to the view, or may be | used to do some kind of logging by the application. | */ Event::fire('laravel.done', array($response)); /* |-------------------------------------------------------------------------- | Finish the request for PHP-FastCGI |-------------------------------------------------------------------------- | | Stopping the PHP process for PHP-FastCGI users to speed up some | PHP queries. Acceleration is possible when there are actions in the | process of script execution that do not affect server response. | For example, saving the session in memcached can occur after the page | has been formed and passed to a web server. */ $response->foundation->finish();