Get collection by content.

@param   string      $contentUid
@param   MediaFolder $mediaFolder
@return  mixed
484533
private function getCollectionByContent($contentUid, MediaFolder $mediaFolder)
    {
        $content = $this->getEntityManager()->find('BackBee\ClassContent\AbstractClassContent', $contentUid);

        if (null === $content) {
            throw new NotFoundHttpException("No content find with uid '{$contentUid}'");
        }

        return $this->getMediaRepository()->getMediasByContent($content, $mediaFolder);
    }
811131
private function getRecords($contentTypeKey, $limit)
    {
        $repo = $this->em->getRepository($contentTypeKey);
        $qb = $repo
            ->createQueryBuilder()
            ->setMaxResults($limit)
            ->orderBy('datechanged', 'DESC')
        ;

        return $repo->findWith($qb);
    }
979900
public function getFieldById(ContentTypeInterface $contentType, $fieldId)
    {
        $field = $this->om->getRepository($this->configurationManager->getEntityClass('field'))->find($fieldId);


        if (!$field instanceof FieldInterface) {
            return null;
        }
        if ($field->getContentType() && $field->getContentType()->getId() == $contentType->getId()) {
            return $field;
        }

        $parent = $field;
        while ($parent && $parentLayout = $parent->getLayout()) {
            if ($parent = $parentLayout->getParent()) {
                if ($parent->getContentType() !== null && $parent->getContentType()->getId() == $contentType->getId()) {
                    return $field;
                }
            }
        }

        return null;
    }
233116
public function countByFolderId($folderId)
    {
        $qb = $this->createQueryBuilder();

        $qb->field('mediaFolder.id')->equals($folderId);

        return $qb->getQuery()->count();
    }
32789
public function get($mediaId)
    {
        $response = $this->getHttp()->json(self::API_GET, ['media_id' => $mediaId]);

        foreach ($response->getHeader('Content-Type') as $mime) {
            if (preg_match('/(image|video|audio)/i', $mime)) {
                return $response->getBody();
            }
        }

        $json = $this->getHttp()->parseJSON($response);

        // XXX: 微信开发这帮混蛋，尼玛文件二进制输出不带header，简直日了!!!
        if (!$json) {
            return $response->getBody();
        }

        $this->checkAndThrow($json);

        return $json;
    }
813461
private function getMedia($mediaId)
    {
        $page = $this->getDoctrine()
                ->getRepository('FulgurioLightCMSBundle:Media')
                ->findOneBy(array('id' => $mediaId));
        if ($page)
        {
            return $page;
        }
        throw new NotFoundHttpException(
            $this->get('translator')->trans('fulgurio.lightcms.medias.not_found', array(), 'admin')
        );
    }
161245
public function getMediaToken($mediaContentKey, $clientUserId = null, array $optParams = [])
    {
        if (!isset($optParams['security_key'])) {
            $optParams['security_key'] = $this->serviceAccount->getKey();
        }

        if (!isset($optParams['media_content_key'])) {
            $optParams['media_content_key'] = $mediaContentKey;
        }

        if (!empty($clientUserId)) {
            $optParams['client_user_id'] = $clientUserId;
        }

        if (!isset($optParams['expire_time'])) {
            $optParams['expire_time'] = 7200;
        }

        $response = $this->getResponseJSON(
            'POST',
            'media_auth/media_token/get_media_link_by_userid.json',
            [],
            $optParams
        );

        if (!isset($response->result->media_token)) {
            throw new ClientException('Response is invalid.');
        }

        return $response->result->media_token;
    }
101819
public function download($mediaId, $directory, $filename = '')
    {
        if (!is_dir($directory) || !is_writable($directory)) {
            throw new InvalidArgumentException("Directory does not exist or is not writable: '$directory'.");
        }

        $filename = $filename ?: $mediaId;

        $stream = $this->getStream($mediaId);

        $filename .= File::getStreamExt($stream);

        file_put_contents($directory.'/'.$filename, $stream);

        return $filename;
    }
70150
public function getContentKey($contentKey)
    {
        $contentKeyId = Utilities::getEntityId(
            $contentKey,
            'WindowsAzure\MediaServices\Models\ContentKey'
        );

        return ContentKey::createFromOptions(
            $this->_getEntity("ContentKeys('{$contentKeyId}')")
        );
    }
887806
private function getCachedContent()
    {
        $item = null;

        if (null !== $this->cache) {
            $item = $this->cache->getItem($this->cacheKey);
            $cacheContent = $item->get();

            if ($item->isHit() && null !== $cacheContent) {
                $this->contentCache = $cacheContent;
            }
        }

        return $item;
    }
909197
public function getCollectionAction(Request $request, $start, $count)
    {
        $mediafolder = null;
        $folderUid = $request->get('mediaFolder_uid', null);

        if (null === $folderUid) {
            $mediafolder = $this->getMediaFolderRepository()->getRoot();
        } else {
            $mediafolder = $this->getMediaFolderRepository()->find($folderUid);
        }

        if (null === $mediafolder) {
            throw new NotFoundHttpException('Cannot find a media folder');
        }

        $paginator = null;

        if ($request->query->has('content_uid')) {
            $paginator = $this->getCollectionByContent($request->query->get('content_uid'), $mediafolder);
        } else {
            $paginator = $this->getClassicCollection($request, $mediafolder, $start, $count);
        }

        $iterator = $paginator->getIterator();
        $results = [];
        while ($iterator->valid()) {

            if($this->isGranted('VIEW', $iterator->current()->getMediaFolder())){

                $results[] = $iterator->current();
            }

            $iterator->next();
        }

        $pager = $request->query->has('usePagination') ? $paginator : null;

        return $this->addRangeToContent(
            $this->createJsonResponse($this->mediaToJson($results)),
            $pager,
            $start,
            count($results)
        );
    }
538000
public function getInfoCollectorFields($contentId)
    {
        $fields = [];

        $content = $this->contentService->loadContent($contentId);

        $contentType = $this->contentTypeService
            ->loadContentType($content->contentInfo->contentTypeId);

        foreach ($contentType->getFieldDefinitions() as $fieldDefinition) {

            if ($fieldDefinition->isInfoCollector) {
                $fields[$fieldDefinition->id] = $fieldDefinition->getName();
            }
        }

        return $fields;
    }
143001
def get_folder_contents_iter(self, uri):
        
        resource = self.get_resource_by_uri(uri)

        if not isinstance(resource, Folder):
            raise NotAFolderError(uri)

        folder_key = resource['folderkey']

        for item in self._folder_get_content_iter(folder_key):
            if 'filename' in item:
                # Work around https://mediafire.mantishub.com/view.php?id=5
                # TODO: remove in 1.0
                if ".patch." in item['filename']:
                    continue
                yield File(item)
            elif 'name' in item:
                yield Folder(item)
697931
public function get($url, $access_token = null, $parameters = [], $contentType = 'text/xml')
    {
        return $this->doApiCall($url, 'GET', $access_token, $parameters, $contentType);
    }
477268
protected function getAllMultiViewRecords($contentTypeName = null, DataDimensions $dataDimensions)
    {

        $folder = $this->getConfiguration()->getFolderNameRecords($contentTypeName, $dataDimensions);

        if (file_exists($folder))
        {
            $finder = new Finder();
            $finder->in($folder)->depth(0);

            $data = [ ];

            /** @var SplFileInfo $file */
            foreach ($finder->files()->name('*.json') as $file)
            {
                $data[] = json_decode($file->getContents(), true);

            }

            $definition = $this->getContentTypeDefinition($contentTypeName);

            $records = $this->getRecordFactory()
                            ->createRecordsFromJSONRecordsArray($definition, $data);

            return $records;

        }

        return [ ];

    }
720893
public function getAvailableRelatedContentAction($productId, $folderId)
    {
        $result = array();

        $folders = FolderQuery::create()->filterById($folderId)->find();

        if ($folders !== null) {
            $list = ContentQuery::create()
                ->joinWithI18n($this->getCurrentEditionLocale())
                ->filterByFolder($folders, Criteria::IN)
                ->filterById(ProductAssociatedContentQuery::create()->filterByProductId($productId)->select('content_id')->find(), Criteria::NOT_IN)
                ->find();
            ;

            if ($list !== null) {
                /** @var Content $item */
                foreach ($list as $item) {
                    $result[] = array('id' => $item->getId(), 'title' => $item->getTitle());
                }
            }
        }

        return $this->jsonResponse(json_encode($result));
    }
246618
public function getContentIdsByContentTypeId($contentTypeId)
    {
        $query = $this->dbHandler->createSelectQuery();
        $query
            ->select($this->dbHandler->quoteColumn('id'))
            ->from($this->dbHandler->quoteTable('ezcontentobject'))
            ->where(
                $query->expr->eq(
                    $this->dbHandler->quoteColumn('contentclass_id'),
                    $query->bindValue($contentTypeId, null, PDO::PARAM_INT)
                )
            );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(PDO::FETCH_COLUMN);
    }