Commit 7a202403 authored by Taylor Otwell's avatar Taylor Otwell

added some comments to the view class.

parent 5d67672d
......@@ -12,7 +12,7 @@ class Str {
{
if (function_exists('mb_strtolower'))
{
return mb_strtolower($value, static::encoding());
return mb_strtolower($value, Config::get('application.encoding'));
}
return strtolower($value);
......@@ -44,7 +44,7 @@ class Str {
{
if (function_exists('mb_convert_case'))
{
return mb_convert_case($value, MB_CASE_TITLE, static::encoding());
return mb_convert_case($value, MB_CASE_TITLE, Config::get('application.encoding'));
}
return ucwords(strtolower($value));
......@@ -60,7 +60,7 @@ class Str {
{
if (function_exists('mb_strlen'))
{
return mb_strlen($value, static::encoding());
return mb_strlen($value, Config::get('application.encoding'));
}
return strlen($value);
......@@ -99,14 +99,4 @@ class Str {
return implode('', array_map(function() use ($pool) { return $pool[mt_rand(0, strlen($pool) - 1)]; }, range(0, $length - 1)));
}
/**
* Get the application encoding from the configuration class.
*
* @return string
*/
protected static function encoding()
{
return Config::get('application.encoding');
}
}
\ No newline at end of file
......@@ -56,6 +56,14 @@ class URI {
/**
* Get a given URI segment from the URI for the current request.
*
* <code>
* // Get the first URI segment for the request
* $first = URI::segment(1);
*
* // Return a default value if the URI segment doesn't exist
* $segment = URI::segment(3, 'Default');
* </code>
*
* @param int $segment
* @param mixed $default
* @return string
......
......@@ -7,6 +7,11 @@ class URL {
*
* If the given URL is already well-formed, it will be returned unchanged.
*
* <code>
* // Create a URL to a location within the application
* $url = URL::to('user/profile');
* </code>
*
* @param string $url
* @param bool $https
* @return string
......@@ -57,6 +62,14 @@ class URL {
* parameter to the method. The values of this array will be used to fill the
* wildcard segments of the route URI.
*
* <code>
* // Create a URL to the "profile" named route
* $url = URL::to_route('profile');
*
* // Create a URL to the "profile" named route with wildcard parameters
* $url = URL::to_route('profile', array($username));
* </code>
*
* @param string $name
* @param array $parameters
* @param bool $https
......@@ -70,9 +83,9 @@ class URL {
$uri = substr($uris[0], strpos($uris[0], '/'));
// Spin through each route parameter and replace the route wildcard segment
// with the corresponding parameter passed to the method.
foreach ($parameters as $parameter)
// Spin through each route parameter and replace the route wildcard
// segment with the corresponding parameter passed to the method.
foreach ((array) $parameters as $parameter)
{
$uri = preg_replace('/\(.+?\)/', $parameter, $uri, 1);
}
......@@ -100,6 +113,14 @@ class URL {
/**
* Generate a URL friendly "slug".
*
* <code>
* // Returns "this-is-my-blog-post"
* $slug = URL::slug('This is my blog post!');
*
* // Returns "this_is_my_blog_post"
* $slug = URL::slug('This is my blog post!', '_');
* </code>
*
* @param string $title
* @param string $separator
* @return string
......@@ -119,6 +140,17 @@ class URL {
/**
* Magic Method for dynamically creating URLs to named routes.
*
* <code>
* // Create a URL to the "profile" named route
* $url = URL::to_profile();
*
* // Create a URL to the "profile" named route with wildcard segments
* $url = URL::to_profile(array($username));
*
* // Create a URL to the "profile" named route using HTTPS
* $url = URL::to_secure_profile();
* </code>
*/
public static function __callStatic($method, $parameters)
{
......
......@@ -54,7 +54,7 @@ class View_Factory {
* @param array $data
* @return View
*/
protected function of($name, $data = array())
public function of($name, $data = array())
{
if ( ! is_null($view = $this->composer->name($name)))
{
......@@ -74,13 +74,9 @@ class View_Factory {
{
$view = str_replace('.', '/', $view);
if (file_exists($path = $this->path.$view.BLADE_EXT))
foreach (array(BLADE_EXT, EXT) as $extension)
{
return $path;
}
elseif (file_exists($path = $this->path.$view.EXT))
{
return $path;
if (file_exists($path = $this->path.$view.$extension)) return $path;
}
throw new \Exception('View ['.$view.'] does not exist.');
......@@ -219,6 +215,14 @@ class View {
* within your application views directory. Dots or slashes may used to
* reference views within sub-directories.
*
* <code>
* // Create a new view instance
* $view = View::make('home.index');
*
* // Create a new view instance with bound data
* $view = View::make('home.index', array('name' => 'Taylor'));
* </code>
*
* @param string $view
* @param array $data
* @return View
......@@ -233,11 +237,19 @@ class View {
*
* View names are defined in the application composers file.
*
* <code>
* // Create an instance of the "layout" named view
* $view = View::of('layout');
*
* // Create an instance of the "layout" view with bound data
* $view = View::of('layout', array('name' => 'Taylor'));
* </code>
*
* @param string $name
* @param array $data
* @return View
*/
protected function of($name, $data = array())
public static function of($name, $data = array())
{
return IoC::container()->resolve('laravel.view')->of($name, $data);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment