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


PHP Application::getRepository方法代碼示例

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


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

示例1: blogIndexAction

 public function blogIndexAction(Application $app, Request $request)
 {
     $repo = $app->getRepository('blog');
     $entities = $repo->findAll();
     print_r($entities);
     exit;
     $data = array('name' => 'blog', 'entities' => $entities);
     return new Response($app['twig']->render('@Templates/blog/index.html.twig', $data));
 }
開發者ID:Radvance,項目名稱:BlogApp,代碼行數:9,代碼來源:AppController.php

示例2: eventPostSave

 /**
  * Post-save testing event.
  *
  * @param StorageEvent $event
  */
 public function eventPostSave(StorageEvent $event)
 {
     $contentType = $event->getContentType();
     if ($contentType === 'pages') {
         $repo = $this->entityManager->getRepository($contentType);
         /** @var Content $record */
         $record = $event->getContent();
         $values = $record->serialize();
         if ($event->isCreate()) {
             // Add a unique paragraph to the end of the body
             $record->setBody($values['body'] . '<p>Snuck in to body during POST_SAVE on create: ' . date('Y-m-d H:i:s') . '</p>');
         } else {
             // Add a unique paragraph to the end of the body
             $record->setBody($values['body'] . '<p>Added to body during POST_SAVE on save: ' . date('Y-m-d H:i:s') . '</p>');
         }
         // Save the changes to the database
         $repo->save($record, true);
     }
 }
開發者ID:robbert-vdh,項目名稱:bolt,代碼行數:24,代碼來源:StorageEventTests.php

示例3: delete

 public function delete(Application $app, Request $request, $id)
 {
     $repo = $app->getRepository($this->getModelName());
     try {
         $repo->remove($repo->find($id));
     } catch (PDOException $e) {
         $app->addFlash('error', $e->getMessage());
     }
     // @todo Check errors
     return $app->redirect($app['url_generator']->generate(sprintf('%s_index', $this->getModelName())));
 }
開發者ID:radvance,項目名稱:radvance,代碼行數:11,代碼來源:CrudControllerTrait.php


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