We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Url getStatic does not accept an array

I want to create an url for a predefined route, but for a static source. When I provide an array with parameters to the $url->get() method it's working fine but giving me the default base url. When using the ->setStatic() it's ginging me the following warning:

Notice: Array to string conversion in

Also the result isnt't correct (as expected). See:

https://cdn.example.dev/Array

My code:

$url = DI::getDefault()->get('url');
return $url->getStatic(array(
    'for' => 'get-user-image',
    'uid' => $userUid,
    'file' => $file
));

And the documentation says:

/**
* Generates a URL for a static resource
*
* @param string|array $uri
* @return string
*/
public function getStatic($uri=null){ }

Try using get:

$url = DI::getDefault()->get('url');
return $url->get(array(
    'for' => 'get-user-image',
    'uid' => $userUid,
    'file' => $file
));


514

As I described I've used the get-method, but this is giving me an url with the normale base-uri instead of the static (cdn-url). As of the description it should accept an array. So I guess the implementation of handling an array is missing/wrong in the GetStatic method.

This is probably a bug, could you please post it on Github?