當前位置: 首頁>>代碼示例>>PHP>>正文


PHP content::setContentType方法代碼示例

本文整理匯總了PHP中content::setContentType方法的典型用法代碼示例。如果您正苦於以下問題:PHP content::setContentType方法的具體用法?PHP content::setContentType怎麽用?PHP content::setContentType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在content的用法示例。


在下文中一共展示了content::setContentType方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: submitAction

 /**
  * @param Request $request
  * @param Request $securekey
  * @param Request $redirect
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function submitAction(Request $request, $securekey, $redirect)
 {
     $locale = $request->getLocale();
     $mode = "module-submission";
     $em = $this->getDoctrine()->getManager();
     $cs = $this->get('ssone.cms.content');
     $fieldsRepository = $this->getFieldsRepository();
     $blockService = $this->get('ssone.cms.block');
     $contentType = $this->getDoctrine()->getRepository('SSoneCMSBundle:ContentType')->findBySecurekey($securekey);
     $content = new content();
     $content->setContentType($contentType);
     $blockService->contentBlockManager($content);
     $form = $this->createForm(new ContentTYPE($mode, $fieldsRepository, $cs, $locale), $content);
     $form->handleRequest($request);
     print $contentType->getName();
     print $form->isValid();
     if ($form->isValid()) {
         $auditor = $this->get('ssone.cms.recordauditor');
         $auditor->auditRecord($content);
         //Audit blocks and fields
         foreach ($content->getBlocks() as $block) {
             $auditor->auditRecord($block);
             foreach ($block->getBlockFields() as $blockField) {
                 $auditor->auditRecord($blockField);
             }
         }
         //handle file uploads
         $uploader = $this->get('ssone.cms.fileuploader');
         foreach ($form['blocks'] as $block) {
             foreach ($block['blockFields'] as $blockField) {
                 foreach ($blockField['fieldContent'] as $input) {
                     if (strpos($input->getName(), '_fileupload') !== false) {
                         $params = explode("_", $input->getName());
                         $fieldSettings = $fieldsRepository->findBySecurekey($params[2])->getFieldTypeSettings();
                         if ($fp = $uploader->contentFileUpload($input->getData(), $fieldSettings['fileupload']['fileuploadfolder'])) {
                             //Get current field content
                             $blockFieldObj = $blockField->getData();
                             $blockFieldContents = $blockFieldObj->getFieldContent();
                             $blockFieldContents[$params[0]] = $fp;
                             unset($blockFieldContents[$input->getName()]);
                             $blockFieldObj->setFieldContent($blockFieldContents);
                         }
                     }
                 }
             }
         }
         $em->persist($content);
         $em->flush();
         $storedContent = $cs->findSecureKeyById($content->getId());
         $this->cacheContent($content->getId(), $cs, $em);
         return $this->redirect($this->generateUrl('ssone_cms_frontend', array('uri' => $redirect)));
     }
     return $this->render('SSoneCMSBundle:Content:crud.html.twig', array('form' => $form->createView(), 'contentTitle' => $content->getName(), 'mode' => $mode, 'locale' => $locale));
 }
開發者ID:ssone,項目名稱:cms-bundle,代碼行數:60,代碼來源:ModuleContentSubmissionController.php


注:本文中的content::setContentType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。