Пример #1
0
 public function addMediaType(MediaTypeInterface $mediaType)
 {
     $this->mediaTypes[$mediaType->getAlias()] = $mediaType;
 }
Пример #2
0
 private function getDefaultEntity(Request $request, $type, MediaTypeInterface $mediaType, $init, $collection)
 {
     if (!$init) {
         $entity = $mediaType->getEntityClass();
         $entity = new $entity();
         return $entity;
     }
     switch ($type) {
         case 'web':
             try {
                 /* @var MediaTypeInterface|WebMediaTypeInterface $mediaType */
                 $entity = $mediaType->getEntityFromWeb($request);
             } catch (\Exception $e) {
                 throw new NotFoundHttpException();
             }
             break;
         case 'paste':
             $pastedText = $request->request->get('pastedText', false);
             if (empty($pastedText)) {
                 throw new NotFoundHttpException();
             }
             /* @var MediaTypeInterface|PasteMediaTypeInterface $mediaType */
             $entity = $mediaType->getEntityFromPaste($pastedText);
             break;
         default:
             throw new \LogicException();
     }
     if ($collection !== null) {
         $entity->setCollection($this->getDoctrine()->getManager()->find('CmfcmfMediaModule:Collection\\CollectionEntity', $collection));
     }
     return $entity;
 }