本文整理汇总了PHP中Sonata\MediaBundle\Model\MediaInterface::getProviderReference方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaInterface::getProviderReference方法的具体用法?PHP MediaInterface::getProviderReference怎么用?PHP MediaInterface::getProviderReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sonata\MediaBundle\Model\MediaInterface
的用法示例。
在下文中一共展示了MediaInterface::getProviderReference方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate
/**
* {@inheritdoc}
*/
public function generate(MediaProviderInterface $provider, MediaInterface $media)
{
$backend = $this->backend;
$id = $this->id;
$publish = function () use($backend, $media, $id) {
$backend->createAndPublish('sonata.media.create_thumbnail', array('thumbnailId' => $id, 'mediaId' => $media->getId(), 'providerReference' => $media->getProviderReference()));
};
// BC compatibility for missing EventDispatcher
if (null === $this->dispatcher) {
trigger_error('Since version 2.3.3, passing an empty parameter in argument 4 for __construct() in ' . __CLASS__ . ' is deprecated and the workaround for it will be removed in 3.0.', E_USER_DEPRECATED);
$publish();
} else {
$this->dispatcher->addListener('kernel.finish_request', $publish);
}
}
示例2: updateMetadata
/**
* {@inheritdoc}
*/
public function updateMetadata(MediaInterface $media, $force = false)
{
$base = '//config.playwire.com/%d/videos/v2/%d/zeus.json';
$ids = explode('|', $media->getProviderReference());
$url = sprintf($base, $ids[0], $ids[1]);
try {
$metadata = $this->getMetadata($media, $url);
} catch (\RuntimeException $e) {
$media->setEnabled(false);
$media->setProviderStatus(MediaInterface::STATUS_ERROR);
return;
}
$media->setContentType($metadata['type']);
$metadata['thumbnail_url'] = $metadata['content']['poster'];
$imgsize = getimagesize($metadata['thumbnail_url']);
$media->setWidth($imgsize[0]);
$media->setHeight($imgsize[1]);
$media->setProviderMetadata($metadata);
if ($force) {
$media->setName($metadata['settings']['title']);
}
}
示例3: getDownloadResponse
/**
* {@inheritdoc}
*/
public function getDownloadResponse(MediaInterface $media, $format, $mode, array $headers = array())
{
return new RedirectResponse(sprintf('http://vimeo.com/%s', $media->getProviderReference()), 302, $headers);
}
示例4: generate
/**
* {@inheritdoc}
*/
public function generate(MediaProviderInterface $provider, MediaInterface $media)
{
$this->backend->createAndPublish('sonata.media.create_thumbnail', array('thumbnailId' => $this->id, 'mediaId' => $media->getId(), 'providerReference' => $media->getProviderReference()));
}
示例5: updateMetadata
/**
* {@inheritdoc}
*/
public function updateMetadata(MediaInterface $media, $force = false)
{
//http://api.soundcloud.com/resolve?url=http://soundcloud.com/matas/hobnotropic&client_id=656c5a7c166b49062f31fbf24eb13fcd
/* $url = sprintf('http://videos.sapo.pt/oembed?url=http://videos.sapo.pt/%s&format=json', $media->getProviderReference()); */
/* $url = sprintf('http://api.soundcloud.com/resolve?url=%s', $media->getProviderReference()); */
/* $url = sprintf('http://soundcloud.com/oembed?url=%s&format=json&client_id=%s', $media->getProviderReference(), '656c5a7c166b49062f31fbf24eb13fcd'); */
$url = sprintf('http://soundcloud.com/oembed?url=%s&format=json', $media->getProviderReference());
try {
$metadata = $this->getMetadata($media, $url);
/* d($metadata); */
/* $metadata_thumbnail = $this->getMetadataThumbnail($media); */
/* $metadata = array_merge($metadata, $metadata_thumbnail); */
} catch (\RuntimeException $e) {
$media->setEnabled(false);
$media->setProviderStatus(MediaInterface::STATUS_ERROR);
return;
}
$media->setProviderMetadata($metadata);
if ($force) {
$media->setName($metadata['title']);
$media->setAuthorName($metadata['author_name']);
}
$media->setHeight($metadata['height']);
$media->setWidth($metadata['width']);
}