Commit 934b4111 authored by Keven's avatar Keven
Browse files

Implemented #12 Resource `with-token`

parent da98f0ea
......@@ -2,6 +2,8 @@
namespace Libcast\Client\Command;
use Symfony\Component\OptionsResolver\OptionsResolver;
class Resource extends ResourceCommand
{
/**
......@@ -11,15 +13,50 @@ class Resource extends ResourceCommand
protected $path = '/resource/{slug}';
/**
*
*
* @var array Command options
*/
private $options;
/**
*
* @param string $name
* @param array $options
*/
public function __construct($name)
public function __construct($name, $options = [])
{
$this->resolveOptions($options);
if ($this->options['with-token']) {
$this->setQuery('with-token', 1);
}
if ('http' == substr($name, 0, 4)) {
$this->fullPath = $name;
} else {
$this->setVar('slug', $name);
}
}
}
\ No newline at end of file
/**
*
* @param array $options
*/
private function resolveOptions(array $options)
{
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$this->options = $resolver->resolve($options);
}
/**
*
* @param OptionsResolver $resolver
*/
private function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'with-token' => false, // Requires a token in the assets URLs?
]);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment