/** * Write a message to the log file. * * <code> * // Write an "error" message to the log file * Log::write('error', 'Something went horribly wrong!'); * * // Write an "error" message using the class' magic method * Log::error('Something went horribly wrong!'); * * // Log an arrays data * Log::write('info', array('name' => 'Sawny', 'passwd' => '1234', array(1337, 21, 0)), true); * //Result: Array ( [name] => Sawny [passwd] => 1234 [0] => Array ( [0] => 1337 [1] => 21 [2] => 0 ) ) * //If we had omit the third parameter the result had been: Array * </code> * * @param string $type * @param string $message * @return void */ public static function write($type, $message, $pretty_print = false) { $message = $pretty_print ? print_r($message, true) : $message; // If there is a listener for the log event, we'll delegate the logging // to the event and not write to the log files. This allows for quick // swapping of log implementations for debugging. if (Event::listeners('laravel.log')) { Event::fire('laravel.log', array($type, $message)); } $trace = debug_backtrace(); foreach ($trace as $item) { if (isset($item['class']) and $item['class'] == __CLASS__) { continue; } $caller = $item; break; } $function = $caller['function']; if (isset($caller['class'])) { $class = $caller['class'] . '::'; } else { $class = ''; } $message = static::format($type, $class . $function . ' - ' . $message); File::append(path('storage') . 'logs/' . date('Y-m-d') . '.log', $message); }
/** * Write a message to the log file. * * <code> * // Write an "error" message to the log file * Log::write('error', 'Something went horribly wrong!'); * * // Write an "error" message using the class' magic method * Log::error('Something went horribly wrong!'); * </code> * * @param string $type * @param string $message * @return void */ public static function write($type, $message) { // If there is a listener for the log event, we'll delegate the logging // to the event and not write to the log files. This allows for quick // swapping of log implementations for debugging. 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); }
public function get_nav($menu = '', $partial_path = null) { if (\Event::listeners("menu.render.navigation: {$menu}")) { $result = \Event::until("menu.render.navigation: {$menu}"); if (!is_null($result)) { if ($result instanceof \DOMDocument) { return $result->saveHTML(); } elseif (is_string($result)) { return $result; } elseif (is_array($result)) { return Dom::arrayToDOMDocument($result)->saveHTML(); } else { throw new \Exception("Menu event response is invalid. Supported responses are: [DOMDocument], [String], [Array]"); } } } $navigation_group = \Navigation\Model\Group::with(array('links' => function ($query) { $query->order_by('order', 'asc'); }))->where('slug', '=', $menu)->first(); // This navigation group is available? if (isset($navigation_group) and !empty($navigation_group)) { $items = $navigation_group->get_links(); if (\Event::listeners("menu.merge.navigation: {$menu}", array($items))) { $result = \Event::until("menu.merge.navigation: {$menu}", array($items)); $items = array_merge_recursive($items, $result); sort($items); } if (\Event::listeners("menu.make.navigation: {$menu}", array($items))) { $items = \Event::until("menu.make.navigation: {$menu}", array($items)); } if (\Event::listeners("menu.make.navigation", array($items))) { $items = \Event::until("menu.make.navigation", array($items)); } return $this->make($items, '', $partial_path); } else { return 'ERROR: The navigation group [' . $menu . '] does not exist.'; } }
/** * Return partial view rendered * * @param string $partial * @param array $data */ public function render_partial($partial, $data = array()) { if (\Event::listeners("themes.render.partial: {$partial}")) { $result = \Event::until("themes.render.partial: {$partial}", array($view)); if (!is_null($result)) { if ($result instanceof \DOMDocument) { $view = $result->saveHTML(); } elseif (is_string($result)) { $view = $result; } elseif (is_array($result)) { // array to dom $view = '<!DOCTYPE html>'; $view .= Dom::arrayToDOMDocument($result, 'html')->saveHTML(); } else { // trow exception } } } $data = $this->_share_data($data); $bundle_parts = \Bundle::parse($partial); $bundle_name = $bundle_parts['0'] == 'application' ? '' : $bundle_parts['0'] . DS; $partial_path = str_replace('.', DS, $bundle_parts['1']); $theme_view_folder = $this->_theme_absolute_path . DS . 'views' . DS; // Check for a custom path $has_partial = $this->_view_exists(str_replace('.', DS, $partial)); if ($has_partial) { return View::make($has_partial, $data); } // Check on the themes views folder $has_partial = $this->_view_exists($theme_view_folder . $bundle_name . 'partials' . DS . $partial_path); if ($has_partial) { return View::make($has_partial, $data); } // Check on custom folder (fallback for all themes) $has_partial = $this->_view_exists(path('public') . 'custom' . DS . 'views' . DS . $bundle_name . 'partials' . DS . $partial_path); if ($has_partial) { return View::make($has_partial, $data); } // bundles folder $has_partial = $this->_view_exists($partial); if ($has_partial) { return View::make($has_partial, $data); } // try to load from application views folder $has_partial = $this->_view_exists('partials' . DS . $partial_path); if ($has_partial) { return View::make($has_partial, $data); } Log::error('Failed to render partial from ' . $partial); throw new \Exception("Failed to render partial. Partial [{$partial}] doesn't exist. "); }