Ejemplo n.º 1
0
function array_object_smart(array $array)
{
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            $array[$key] = array_object_smart($value);
        }
    }
    return \Coast\is_array_assoc($array) ? (object) $array : $array;
}
Ejemplo n.º 2
0
 public function __invoke($file, $transforms, array $params = array())
 {
     if (\Coast\is_array_assoc($transforms)) {
         $params = $transforms;
         $transforms = ['default'];
     }
     $file = !$file instanceof File ? new File("{$file}") : $file;
     $file = $file->isRelative() ? new File("{$this->_baseDir}/{$file}") : $file;
     $file = $file->toReal();
     if (!$file->isWithin($this->_baseDir)) {
         throw new Image\Exception("File '{$file}' is not within base directory '{$this->_baseDir}'");
     } else {
         if (!$file->isReadable()) {
             return $this->_urlResolver->file($file);
         }
     }
     $transforms = (array) $transforms;
     foreach ($transforms as $i => $name) {
         if (!isset($this->_transforms[$name])) {
             throw new Image\Exception("Transform '{$name}' is not defined");
         }
         $transforms[$i] = (string) $name;
     }
     foreach ($params as $name => $value) {
         $params[(string) $name] = (string) $value;
     }
     $path = $file->toRelative($this->_baseDir);
     $output = $this->_generateOutput($file, $transforms, $params);
     return $output->exists() ? isset($this->_outputUrlResolver) ? $this->_outputUrlResolver->file($output) : $this->_urlResolver->file($output) : $this->_urlResolver->string('image')->queryParams(['file' => $path->name(), 'transforms' => $transforms, 'params' => $params]);
 }