/** * @param Exception $e * * @return array|null */ public static function exception(Exception $e = NULL) { if ($e instanceof Exception) { $data = ['message' => Helpers_Text::trimAsNULL($e->getMessage()), 'code' => $e->getCode()]; if (!Kohana_Helpers_Core::isProduction()) { $data = Kohana_Helpers_Arr::merge($data, ['file' => $e->getFile(), 'line' => $e->getLine(), 'trace' => $e->getTrace(), 'previous' => Helpers_Arr::exception($e->getPrevious())]); } } else { $data = NULL; } return $data; }
public static function data($pathKey = NULL, $pathDefault = NULL, $order = NULL, $forced = FALSE) { $order = Helpers_Text::trimAsNULL(NULL === $order ? $order = static::config('request.data.order') : $order); $data = []; if (NULL !== $order) { isset(static::$cachedData) or static::$cachedData = []; if ($forced || !isset(static::$cachedData[$order])) { for ($idx = 0; $idx < strlen($order); $idx++) { switch (strtoupper($order[$idx])) { case 'G': $data = Kohana_Helpers_Arr::merge($data, static::current()->query()); break; case 'P': $data = Kohana_Helpers_Arr::merge($data, static::getBodyData()); break; case 'H': $data = Kohana_Helpers_Arr::merge($data, static::current()->headers()); break; } } static::$cachedData[$order] = $data; } } if (is_array($pathKey)) { $result = []; foreach ($pathKey as $key) { $result[$key] = Kohana_Helpers_Arr::path($data, $pathKey, $pathDefault); } } elseif (is_scalar($pathKey)) { $result = Kohana_Helpers_Arr::path($data, $pathKey, $pathDefault); } else { $result = $data; } return $result; }