Sulu\Bundle\MediaBundle\Media\Manager\MediaManagerInterface::getById PHP Method

getById() public method

Returns a media with a given id.
public getById ( integer $id, string $locale ) : Media
$id integer the id of the category
$locale string the locale which the object will be returned
return Sulu\Bundle\MediaBundle\Api\Media
    public function getById($id, $locale);

Usage Example

Example #1
0
 /**
  * resolves media id or object.
  *
  * @param int|MediaEntity $media id to resolve
  * @param string $locale
  *
  * @return MediaApi
  */
 public function resolveMediaFunction($media, $locale)
 {
     if (is_object($media)) {
         return $this->resolveMediaObject($media, $locale);
     }
     return $this->mediaManager->getById($media, $locale);
 }