当前位置: 首页>>代码示例>>PHP>>正文


PHP Album::exchangeArray方法代码示例

本文整理汇总了PHP中Album\Model\Album::exchangeArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Album::exchangeArray方法的具体用法?PHP Album::exchangeArray怎么用?PHP Album::exchangeArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Album\Model\Album的用法示例。


在下文中一共展示了Album::exchangeArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例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: 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

示例4: 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

示例5: testGetArrayCopyReturnsAnArrayWithPropertyValues

 public function testGetArrayCopyReturnsAnArrayWithPropertyValues()
 {
     $album = new Album();
     $data = array('artist' => 'some artist', 'id' => 123, 'title' => 'some title');
     $album->exchangeArray($data);
     $copyArray = $album->getArrayCopy();
     $this->assertSame($data['artist'], $copyArray['artist'], '"artist" was not set correctly');
     $this->assertSame($data['id'], $copyArray['id'], '"id" was not set correctly');
     $this->assertSame($data['title'], $copyArray['title'], '"title" was not set correctly');
 }
开发者ID:obsidianstorms,项目名称:zendtraining,代码行数:10,代码来源:AlbumTest.php

示例6: 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

示例7: 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

示例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: 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

示例10: 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

示例11: 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

示例12: 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

示例13: 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

示例14: create

 public function create($data)
 {
     //     	 $response = $this->getResponseWithHeader()
     //     	    	           ->setContent( __METHOD__.'  POST DATA');
     //     	 return $response;
     //         $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);
     //         }
     $idsave = '';
     if (!$data['id']) {
         //     		return new JsonModel(array(
         //     		    	'data' => 'Update data',
         //     		   ));
         // Update data
         $album = new Album();
         $album->exchangeArray($data);
         $idsave = $this->getAlbumTable()->saveAlbum($album);
     } else {
         // Insert data
         $album = new Album();
         $album->exchangeArray($data);
         $idsave = $this->getAlbumTable()->saveAlbum($album);
     }
     if ($idsave != 0) {
         $status = 'Success!';
     } else {
         $status = 'Error!';
     }
     $data_resphone = array('id' => $idsave, 'status' => $status);
     return new JsonModel(array('data' => $data_resphone));
 }
开发者ID:gstearmit,项目名称:EshopVegeTable,代码行数:36,代码来源:RestAlbumController.php

示例15: addAction

 public function addAction()
 {
     $auth = new AuthenticationService();
     $acl = $this->getAcl();
     if (!$auth->hasIdentity()) {
         return $this->redirect()->toRoute('album', array('action' => 'login'));
     }
     if (!$acl->isAllowed($this->getRole(), null, 'add')) {
         return $this->redirect()->toRoute('album', array('action' => 'index'));
     }
     $form = new AlbumForm();
     $form->get('submit')->setValue('Add');
     $request = $this->getRequest();
     // If form submitted
     if ($request->isPost()) {
         // If back button clicked
         if ($request->getPost('submit2')) {
             return $this->redirect()->toRoute('album');
         }
         // Add new album
         $album = new Album();
         $form->setInputFilter($album->getInputFilter());
         $form->setData($request->getPost());
         if ($form->isValid()) {
             $album->exchangeArray($form->getData());
             $this->getAlbumTable()->saveAlbum($album);
             $notification = $form->getData();
             $form->get('title')->setValue('');
             $form->get('artist')->setValue('');
         }
     }
     return array('form' => $form, 'notification' => $notification);
 }
开发者ID:anshp,项目名称:new,代码行数:33,代码来源:AlbumController.php


注:本文中的Album\Model\Album::exchangeArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。