コード例 #1
0
ファイル: Application.php プロジェクト: schpill/thin
 /**
  * Resolve an array of commands through the application.
  *
  * @param  array|dynamic  $commands
  * @return void
  */
 public function resolveCommands($commands)
 {
     $commands = Arrays::isArray($commands) ? $commands : func_get_args();
     foreach ($commands as $command) {
         $this->resolve($command);
     }
 }
コード例 #2
0
ファイル: Gravatar.php プロジェクト: schpill/thin
 /**
  * Render the gravatar image HTML
  *
  * @param array $options [optional] The email to be used to generate the URL
  * or a keyed array of option=>value pairs, for example:
  * <code>
  * echo $gravatar->render('*****@*****.**');
  * </code>
  * or
  * <code>
  * echo $gravatar->render([
  *     $gravatar::OPTION_EMAIL      => '*****@*****.**',
  *     $gravatar::OPTION_IMAGE_SIZE => 120
  * ]);
  * </code>
  *
  * @return string The img HTML tag containing the gravatar image
  *
  *
  */
 public function render($options = array())
 {
     // check if the input is an array, and if not, assume it's an email address
     if (!\Thin\Arrays::isArray($options)) {
         $options = [self::OPTION_EMAIL => strval($options)];
     }
     $options = $options + $this->options;
     // set HTML attributes
     $attributes = new \Thin\Html\Attributes();
     $attributes->set($this->attributes)->set('src', $this->getUrl($options))->set('width', $options[self::OPTION_IMAGE_SIZE])->set('height', $options[self::OPTION_IMAGE_SIZE]);
     // build the HTML output and return it
     return "<img {$attributes} />";
 }
コード例 #3
0
ファイル: Setting.php プロジェクト: schpill/thin
 /**
  * Set a value in the config.
  *
  * Only allow setting of a property if $allowModifications  was set to true
  * on construction. Otherwise, throw an exception.
  *
  * @param  string $name
  * @param  mixed  $value
  * @return void
  * @throws Exception\RuntimeException
  */
 public function __set($name, $value)
 {
     if ($this->allowModifications) {
         if (Arrays::isArray($value)) {
             $value = new static($value, true);
         }
         if (null === $name) {
             $this->data[] = $value;
         } else {
             $this->data[$name] = $value;
         }
         $this->count++;
     } else {
         throw new Exception\RuntimeException('Config is read only');
     }
 }