Sulu\Bundle\MediaBundle\Media\Manager\MediaManager::get PHP Method

get() public method

public get ( $locale, $filter = [], $limit = null, $offset = null )
    public function get($locale, $filter = [], $limit = null, $offset = null)
    {
        $media = [];
        $mediaEntities = $this->mediaRepository->findMedia($filter, $limit, $offset, $this->getCurrentUser(), $this->permissions[PermissionTypes::VIEW]);
        $this->count = $this->mediaRepository->count($filter);
        foreach ($mediaEntities as $mediaEntity) {
            $media[] = $this->addFormatsAndUrl(new Media($mediaEntity, $locale, null));
        }
        return $media;
    }

Usage Example

示例#1
0
 public function testGetWithoutToken()
 {
     $this->tokenStorage->getToken()->willReturn(null);
     $this->mediaRepository->findMedia(Argument::cetera())->willReturn([])->shouldBeCalled();
     $this->mediaRepository->count(Argument::cetera())->shouldBeCalled();
     $this->mediaManager->get(1);
 }