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


PHP Model\Album類代碼示例

本文整理匯總了PHP中Album\Model\Album的典型用法代碼示例。如果您正苦於以下問題:PHP Album類的具體用法?PHP Album怎麽用?PHP Album使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: create

 /**
  * Test With 
  * curl -i -H "Accept: application/json" -X POST -d "artist=Some Name&title=Some Title" http://zf2.local/album-rest
  * (non-PHPdoc)
  * @see \Zend\Mvc\Controller\AbstractRestfulController::create()
  */
 function create($data)
 {
     $album = new Album();
     $album->exchangeArray($data);
     $this->getAlbumTable()->saveAlbum($album);
     return new JsonModel(array("status" => "ok"));
 }
開發者ID:omusico,項目名稱:cursoZf2,代碼行數:13,代碼來源:AlbumRestController.php

示例2: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     // 56
     $form->get('submit')->setValue('Add');
     // 57
     $request = $this->getRequest();
     if ($request->isPost()) {
         // 58
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         // 59
         $form->setData($request->getPost());
         // 60
         if ($form->isValid()) {
             // 61
             $album->exchangeArray($form->getData());
             // 62
             $this->getAlbumTable()->saveAlbum($album);
             // 63
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
             // 64
         }
     }
     return array('form' => $form);
     // 65
 }
開發者ID:Rud5G,項目名稱:zf2-tutorial,代碼行數:28,代碼來源:AlbumController.php

示例3: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             // Perform album validation
             if ($form->isValidAlbum($album)) {
                 // If the album passes validation then save it
                 $this->getAlbumTable()->saveAlbum($album);
             } else {
                 // Album did not pass validation!
                 // Post message to user, album not allowed!
                 // TODO: Add message to user did not pass validation.
             }
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
開發者ID:justintime4tea,項目名稱:ZendFramework2_AlbumModule,代碼行數:26,代碼來源:AlbumController.php

示例4: testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent

 public function testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent()
 {
     $album = new Album();
     $album->exchangeArray(array('artist' => 'some artist', 'id' => 123, 'title' => 'some title'));
     $album->exchangeArray(array());
     $this->assertNull($album->artist, '"artist" should have defaulted to null');
     $this->assertNull($album->id, '"title" should have defaulted to null');
     $this->assertNull($album->title, '"title" should have defaulted to null');
 }
開發者ID:rwellens,項目名稱:zf2_quickstart,代碼行數:9,代碼來源:AlbumTest.php

示例5: testInputFiltersAreSetCorrectly

 public function testInputFiltersAreSetCorrectly()
 {
     $album = new Album();
     $inputFilter = $album->getInputFilter();
     $this->assertSame(3, $inputFilter->count());
     $this->assertTrue($inputFilter->has('artist'));
     $this->assertTrue($inputFilter->has('id'));
     $this->assertTrue($inputFilter->has('title'));
 }
開發者ID:obsidianstorms,項目名稱:zendtraining,代碼行數:9,代碼來源:AlbumTest.php

示例6: create

 public function create($data)
 {
     $em = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
     $album = new Album();
     $album->setArtist($data['artist']);
     $album->setTitle($data['title']);
     $em->persist($album);
     $em->flush();
     return new JsonModel(array('data' => $album->getId()));
 }
開發者ID:blattmann,項目名稱:angularjs-zf2-sample,代碼行數:10,代碼來源:AlbumController.php

示例7: create

 public function create($data)
 {
     $form = new AlbumForm();
     $album = new Album();
     $form->setInputFilter($album->getInputFilter());
     $form->setData($data);
     if ($form->isValid()) {
         $album->exchangeArray($form->getData());
         $id = $this->getAlbumTable()->saveAlbum($album);
     }
     return $this->get($id);
 }
開發者ID:gstearmit,項目名稱:EshopVegeTable,代碼行數:12,代碼來源:AlbumRestController-bk.php

示例8: create

 public function create($data)
 {
     $form = new AlbumForm();
     $album = new Album();
     $form->setInputFilter($album->getInputFilter());
     $form->setData($data);
     if ($form->isValid()) {
         $album->exchangeArray($form->getData());
         $id = $this->getAlbumTable()->saveAlbum($album);
         return new JsonModel(array('code' => 0, 'ret' => $this->get($id)));
     } else {
         return new JsonModel(array('code' => -1, 'ret' => 'invalid'));
     }
 }
開發者ID:idwsdta,項目名稱:ZF2_resftFull_mobile_frameworks,代碼行數:14,代碼來源:AlbumRestApiController.php

示例9: testSaveAlbumWillUpdateExistingAlbumsIfTheyAlreadyHaveAnId

 public function testSaveAlbumWillUpdateExistingAlbumsIfTheyAlreadyHaveAnId()
 {
     $albumData = array('id' => 123, 'artist' => 'The Military Wives', 'title' => 'In My Dreams');
     $album = new Album();
     $album->exchangeArray($albumData);
     $resultSet = new ResultSet();
     $resultSet->setArrayObjectPrototype(new Album());
     $resultSet->initialize(array($album));
     $mockTableGateway = $this->getMock('Zend\\Db\\TableGateway\\TableGateway', array('select', 'update'), array(), '', false);
     $mockTableGateway->expects($this->once())->method('select')->with(array('id' => 123))->will($this->returnValue($resultSet));
     $mockTableGateway->expects($this->once())->method('update')->with(array('artist' => 'The Military Wives', 'title' => 'In My Dreams'), array('id' => 123));
     $albumTable = new AlbumTable($mockTableGateway);
     $albumTable->saveAlbum($album);
 }
開發者ID:rwellens,項目名稱:zf2_quickstart,代碼行數:14,代碼來源:AlbumTableTest.php

示例10: create

 public function create($data)
 {
     $form = new AlbumForm();
     $album = new Album();
     $form->setInputFilter($album->getInputFilter());
     $form->setData($data);
     // should set empty id value so form does not mark as invalid if id is not found
     if ($form->isValid()) {
         $album->exchangeArray($form->getData());
         $id = $this->getAlbumTable()->saveAlbum($album);
     }
     // should throw error if form is invalid for validation error, 400 with errors in Reason-Phase
     return new JsonModel(array('data' => $this->getAlbumTable()->getAlbum($id)));
 }
開發者ID:jingjangjung,項目名稱:zf2-example1,代碼行數:14,代碼來源:AlbumRestController.php

示例11: create

 public function create($data)
 {
     $form = new AlbumForm();
     $album = new Album();
     $form->setInputFilter($album->getInputFilter());
     $form->setData($data);
     $id = null;
     if ($form->isValid()) {
         $album->exchangeArray($form->getData());
         $id = $this->getAlbumTable()->saveAlbum($album);
         return $this->get($id);
     } else {
         var_dump($form->getData());
         die;
     }
     return new JsonModel(array());
 }
開發者ID:ptcampos,項目名稱:angular-zf2-rest,代碼行數:17,代碼來源:AlbumRestController.php

示例12: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('value', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->post());
         if ($form->isValid()) {
             $album->populate($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
開發者ID:robertbasic,項目名稱:zf2-tutorial,代碼行數:18,代碼來源:AlbumController.php

示例13: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album, $this->getUserId());
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     $this->layout()->setVariable('header_title', 'Ajouter un Album');
     return array('form' => $form);
 }
開發者ID:Embraser01,項目名稱:IUT-ProjetWeb-TP1,代碼行數:18,代碼來源:AlbumController.php

示例14: addAction

 public function addAction()
 {
     $viewModel = $this->getViewModel();
     $form = new AlbumForm();
     $form->get('submit')->setAttribute('value', 'Add');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album-front-album');
         }
     }
     return $viewModel->setVariables(array('form' => $form));
 }
開發者ID:ashimidashajia,項目名稱:zendstore,代碼行數:19,代碼來源:AlbumController.ZendDB.php

示例15: addAction

 public function addAction()
 {
     $form = new AlbumForm();
     $form->get('submit')->setValue('Add');
     $form->get('title')->setAttribute('class', 'form-control');
     $form->get('artist')->setAttribute('class', 'form-control');
     $request = $this->getRequest();
     if ($request->isPost()) {
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             // Redirect to list of albums
             return $this->redirect()->toRoute('album');
         }
     }
     return array('form' => $form);
 }
開發者ID:TensaZangetsu,項目名稱:Zend_MVC,代碼行數:20,代碼來源:AlbumController.php


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