summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
813df40)
Replace package usage with route
Cleanup
namespace Rapsys\PackBundle\Util;
namespace Rapsys\PackBundle\Util;
-use Symfony\Component\Asset\PackageInterface;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Filesystem\Exception\IOExceptionInterface;
use Symfony\Component\Filesystem\Filesystem;
+use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
+use Symfony\Component\Routing\RouterInterface;
/**
* Helps manage facebook images
/**
* Helps manage facebook images
- * The package instance
- *
- * @var PackageInterface
+ * The RouterInterface instance
- protected $package;
-
- /**
- * The prefix
- *
- * @var string
- */
- protected $prefix;
+ protected RouterInterface $router;
- * Creates a new osm util
+ * Creates a new facebook util
- * @param PackageInterface $package The package instance
+ * @param RouterInterface $router The RouterInterface instance
* @param string $cache The cache directory
* @param string $path The public path
* @param string $cache The cache directory
* @param string $path The public path
- * @param string $url The public url
* @param string $prefix The prefix
*/
* @param string $prefix The prefix
*/
- function __construct(PackageInterface $package, string $cache, string $path, string $url, string $prefix = 'facebook', string $source = 'png/facebook.png', array $fonts = [ 'default' => 'ttf/default.ttf' ]) {
+ function __construct(RouterInterface $router, string $cache = '../var/cache', string $path = './bundles/rapsyspack', string $prefix = 'facebook', string $source = 'png/facebook.png', array $fonts = [ 'default' => 'ttf/default.ttf' ]) {
//Set cache
$this->cache = $cache.'/'.$prefix;
//Set cache
$this->cache = $cache.'/'.$prefix;
//Set path
$this->path = $path.'/'.$prefix;
//Set path
$this->path = $path.'/'.$prefix;
- //Set url
- $this->url = $url.'/'.$prefix;
-
- //Set package instance
- $this->package = $package;
+ //Set router
+ $this->router = $router;
//Set prefix key
$this->prefix = $prefix;
//Set prefix key
$this->prefix = $prefix;
//Return image data
return [
//Return image data
return [
- #'og:image' => $this->package->getAbsoluteUrl('@RapsysAir/facebook/'.$mtime.$pathInfo.'.jpeg'),
- 'og:image' => $this->package->getAbsoluteUrl($this->url.'/'.$mtime.$pathInfo.'.jpeg'),
+ 'og:image' => $this->router->generate('rapsys_pack_facebook', ['mtime' => $mtime, 'path' => $pathInfo], UrlGeneratorInterface::ABSOLUTE_URL),
'og:image:alt' => str_replace("\n", ' ', implode(' - ', array_keys($texts))),
'og:image:height' => $height,
'og:image:width' => $width
'og:image:alt' => str_replace("\n", ' ', implode(' - ', array_keys($texts))),
'og:image:height' => $height,
'og:image:width' => $width
//Return image data
return [
//Return image data
return [
- 'og:image' => $this->package->getAbsoluteUrl($this->url.'/'.stat($path)['mtime'].$pathInfo.'.jpeg'),
+ 'og:image' => $this->router->generate('rapsys_pack_facebook', ['mtime' => stat($path)['mtime'], 'path' => $pathInfo], UrlGeneratorInterface::ABSOLUTE_URL),
'og:image:alt' => str_replace("\n", ' ', implode(' - ', array_keys($texts))),
'og:image:height' => $height,
'og:image:width' => $width
'og:image:alt' => str_replace("\n", ' ', implode(' - ', array_keys($texts))),
'og:image:height' => $height,
'og:image:width' => $width