cleaning up code.
This commit is contained in:
parent
ba3f62f79a
commit
bf6313e50b
|
@ -161,8 +161,7 @@ public static function is($extensions, $path)
|
||||||
|
|
||||||
// The MIME configuration file contains an array of file extensions and
|
// The MIME configuration file contains an array of file extensions and
|
||||||
// their associated MIME types. We will spin through each extension the
|
// their associated MIME types. We will spin through each extension the
|
||||||
// developer wants to check to determine if the file's MIME type is in
|
// developer wants to check and look for the MIME type.
|
||||||
// the list of MIMEs we have for that extension.
|
|
||||||
foreach ((array) $extensions as $extension)
|
foreach ((array) $extensions as $extension)
|
||||||
{
|
{
|
||||||
if (isset($mimes[$extension]) and in_array($mime, (array) $mimes[$extension]))
|
if (isset($mimes[$extension]) and in_array($mime, (array) $mimes[$extension]))
|
||||||
|
|
|
@ -177,18 +177,6 @@ function array_first($array, $callback, $default = null)
|
||||||
return value($default);
|
return value($default);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Spin through the array, executing a callback with each key and element.
|
|
||||||
*
|
|
||||||
* @param array $array
|
|
||||||
* @param mixed $callback
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function array_spin($array, $callback)
|
|
||||||
{
|
|
||||||
return array_map($callback, array_keys($array), array_values($array));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Recursively remove slashes from array keys and values.
|
* Recursively remove slashes from array keys and values.
|
||||||
*
|
*
|
||||||
|
|
|
@ -129,11 +129,7 @@ public static function resolve($name, $parameters = array())
|
||||||
|
|
||||||
// If the resolver is registering as a singleton resolver, we will cache
|
// If the resolver is registering as a singleton resolver, we will cache
|
||||||
// the instance of the object in the container so we can resolve it next
|
// the instance of the object in the container so we can resolve it next
|
||||||
// time without having to instantiate a new instance of the object.
|
// time without having to instantiate a brand new instance.
|
||||||
//
|
|
||||||
// This allows the developer to reuse objects that do not need to be
|
|
||||||
// instantiated each time they are needed, such as a SwiftMailer or
|
|
||||||
// Twig object that can be shared.
|
|
||||||
if (isset(static::$registry[$name]['singleton']))
|
if (isset(static::$registry[$name]['singleton']))
|
||||||
{
|
{
|
||||||
return static::$singletons[$name] = $object;
|
return static::$singletons[$name] = $object;
|
||||||
|
|
|
@ -53,9 +53,10 @@
|
||||||
ini_set('display_errors', Config::get('error.display'));
|
ini_set('display_errors', Config::get('error.display'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine if we need to set the application key to a random
|
* Determine if we need to set the application key to a very random
|
||||||
* string for the developer. This provides the developer with
|
* string so we can provide a zero configuration installation but
|
||||||
* a zero configuration install process.
|
* still ensure that the key is set to something random. It is
|
||||||
|
* possible to disable this feature.
|
||||||
*/
|
*/
|
||||||
$auto_key = Config::get('application.auto_key');
|
$auto_key = Config::get('application.auto_key');
|
||||||
|
|
||||||
|
|
|
@ -697,14 +697,15 @@ protected function message($attribute, $rule)
|
||||||
protected function size_message($bundle, $attribute, $rule)
|
protected function size_message($bundle, $attribute, $rule)
|
||||||
{
|
{
|
||||||
// There are three different types of size validations. The attribute
|
// There are three different types of size validations. The attribute
|
||||||
// may be either a number, file, or a string. If the attribute has a
|
// may be either a number, file, or a string, so we'll check a few
|
||||||
// numeric rule attached to it, we can assume it is a number. If the
|
// things to figure out which one it is.
|
||||||
// attribute is in the file array, it is a file, otherwise we can
|
|
||||||
// assume the attribute is simply a string.
|
|
||||||
if ($this->has_rule($attribute, $this->numeric_rules))
|
if ($this->has_rule($attribute, $this->numeric_rules))
|
||||||
{
|
{
|
||||||
$line = 'numeric';
|
$line = 'numeric';
|
||||||
}
|
}
|
||||||
|
// We assume that attributes present in the $_FILES array are files,
|
||||||
|
// which makes sense. If the attribute doesn't have numeric rules
|
||||||
|
// and isn't as file, it's a string.
|
||||||
elseif (array_key_exists($attribute, Input::file()))
|
elseif (array_key_exists($attribute, Input::file()))
|
||||||
{
|
{
|
||||||
$line = 'file';
|
$line = 'file';
|
||||||
|
@ -877,15 +878,19 @@ protected function attribute($attribute)
|
||||||
// More reader friendly versions of the attribute names may be stored
|
// More reader friendly versions of the attribute names may be stored
|
||||||
// in the validation language file, allowing a more readable version
|
// in the validation language file, allowing a more readable version
|
||||||
// of the attribute name to be used in the message.
|
// of the attribute name to be used in the message.
|
||||||
//
|
|
||||||
// If no language line has been specified for the attribute, all of
|
|
||||||
// the underscores will be removed from the attribute name and that
|
|
||||||
// will be used as the attribtue name.
|
|
||||||
$line = "{$bundle}validation.attributes.{$attribute}";
|
$line = "{$bundle}validation.attributes.{$attribute}";
|
||||||
|
|
||||||
$display = Lang::line($line)->get($this->language);
|
$display = Lang::line($line)->get($this->language);
|
||||||
|
|
||||||
return (is_null($display)) ? str_replace('_', ' ', $attribute) : $display;
|
// If no language line has been specified for the attribute, all of
|
||||||
|
// the underscores are removed from the attribute name and that
|
||||||
|
// will be used as the attribtue name.
|
||||||
|
if (is_null($display))
|
||||||
|
{
|
||||||
|
return str_replace('_', ' ', $attribute);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $display;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue