/** * Allows magic methods such as Icon::home([attributes]) or Icon::close_white() * * Sample Usage: * <code> * <?php * Icon::plus(); * // <i class="icon-plus"></i> * Icon::folder_open(array('class'=>'widget','data-foo'=>'bar')); * // <i class="widget icon-folder-open" data-foo="bar"></i> * Icon::circle_arrow_right_white(); * // <i class="icon-circle-arrow-right icon-white"></i> * ?> * </code> * * @param string $method Name of missing method * @param array $parameters array of parameters passed to missing method * * @return string */ public static function __callStatic($method, $parameters) { // Explode method name $method_bits = explode('_', strtolower($method)); // White icon variant? (when using glyphicons sprite version) $white = in_array('white', $method_bits); // Remove white from array $method_bits = array_filter($method_bits, function ($val) { return $val != 'white'; }); // Get icon name $icon_classes = array(implode('-', $method_bits)); if ($white) { $icon_classes[] = 'white'; } // If the parameters weren't put into an array, do it if (!isset($parameters[0])) { $parameters = array(0 => $parameters); } // Prepend icon- to classes $parameters = Helpers::set_multi_class_attributes(null, $icon_classes, $parameters, 0, Config::get('icons_prefix')); return '<i' . HTML::attributes($parameters[0]) . '></i>'; }
/** * Outputs the current body in memory * * @return string A <tbody> with content */ public function __toString() { if (!$this->tbody) { return false; } // Fetch ignored columns if (!$this->ignore) { $this->ignore = Config::get('table.ignore'); } // Fetch variables $content = $this->tbody; // Open table body $html = '<tbody>'; // Iterate through the data foreach ($content as $row) { $html .= '<tr>'; $columnCount = 0; $data = is_object($row) ? $row->attributes : $row; // Reorder columns if necessary if ($this->order) { $data = array_merge(array_flip($this->order), $data); } // Read the data row with ignored keys foreach ($data as $column => $value) { if (in_array($column, (array) $this->ignore)) { continue; } // Check for replacing columns $replace = array_get($this->columns, $column); if ($replace) { $value = is_callable($replace) ? $replace($row) : $replace; $value = static::replace_keywords($value, $data); } $columnCount++; $html .= static::appendColumn($column, $value); } // Add supplementary columns if ($this->columns) { foreach ($this->columns as $class => $column) { // Check for replacing columns if (array_key_exists($class, $data)) { continue; } // Calculate closures if (is_callable($column)) { $column = $column($row); } // Parse and decode content $column = static::replace_keywords($column, $data); $column = HTML::decode($column); // Wrap content in a <td> tag if necessary $columnCount++; $html .= static::appendColumn($class, $column); } } $html .= '</tr>'; // Save new number of columns if ($columnCount > $this->numberColumns) { $this->numberColumns = $columnCount; } } $html .= '</tbody>'; // Empty data from this body $this->ignore = array(); $this->columns = array(); $this->tbody = null; return $html; }
public function testUserCanSetEmptyConfigKeys() { LaravelConfig::set('bootstrapper.foo', ''); $config = Config::get('foo'); $this->assertEquals('', $config); }
/** * Get the value of an option * * @param string $key The option to get * @param string $fallback A fallback if undefined * @return string The option value */ public static function get($key, $fallback = null) { $user = LaravelConfig::get('bootstrapper.' . $key, null); $vendor = LaravelConfig::get('bootstrapper::bootstrapper.' . $key, $fallback); return is_null($user) ? $vendor : $user; }