本文整理汇总了PHP中Repository::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::save方法的具体用法?PHP Repository::save怎么用?PHP Repository::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository::save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
function edit($id = null)
{
if (empty($this->data)) {
if (is_null($id)) {
$this->redirect('index');
}
$repo = $this->Repository->read(null, $id);
if (empty($repo)) {
$this->e404();
}
$this->data = $repo;
$current = 'repositories';
$menu = 'menu_admin';
$this->set(compact('current', 'menu'));
} else {
$this->Repository->set($this->data);
if (!$this->Repository->validates()) {
$this->Session->setFlash($this->Repository->validationErrors, 'flash_errors');
} elseif (!$this->Repository->save()) {
$this->Session->setFlash('An error ocurred saving the repository. Please, blame the developer', 'flash_errors');
} else {
$this->Session->setFlash('Repository saved');
CakeLog::write('activity', 'Repository [id=' . $id . '] edited');
$this->redirect('index');
}
}
}
示例2: executeAdd
public function executeAdd()
{
$name = mfwRequest::get('name');
$project = mfwRequest::get('project');
if (!$name || !$project) {
return $this->buildErrorPage("invalid argument (name={$name}, project={$project})", "/pulls/add", 'return');
}
$repo = new Repository(array('name' => $name, 'project' => $project));
$repo->save();
return $this->redirect("/pulls/index");
}
示例3: testUpdateNonExistingOption
/**
* @expectedException \Magento\Framework\Exception\NoSuchEntityException
*/
public function testUpdateNonExistingOption()
{
$convertedOption = ['title' => 'test_option_code_1', 'type' => 'field', 'sort_order' => 1, 'is_require' => 1, 'price' => 10, 'price_type' => 'fixed', 'sku' => 'sku1', 'max_characters' => 10, 'values' => []];
$optionId = 10;
$productSku = 'productSku';
$this->optionMock->expects($this->once())->method('getProductSku')->willReturn($productSku);
$this->productRepositoryMock->expects($this->once())->method('get')->with($productSku, true)->willReturn($this->productMock);
$this->converterMock->expects($this->once())->method('toArray')->with($this->optionMock)->will($this->returnValue($convertedOption));
$this->optionMock->expects($this->any())->method('getOptionId')->willReturn($optionId);
$this->productMock->expects($this->once())->method('getOptionById')->with($optionId);
$this->optionRepository->save($this->optionMock);
}
示例4: testSaveInputExceptionInvalidFieldValue
/**
* @expectedException \Magento\Framework\Exception\InputException
* @expectedExceptionMessage Invalid value of "" provided for the frontend_label field.
*/
public function testSaveInputExceptionInvalidFieldValue()
{
$attributeMock = $this->getMock('Magento\\Catalog\\Model\\Resource\\Eav\\Attribute', ['getFrontendLabels', 'getDefaultFrontendLabel', 'getAttributeId', '__wakeup'], [], '', false);
$this->attributeBuilderMock->expects($this->once())->method('populate')->with($attributeMock)->willReturn($this->attributeBuilderMock);
$attributeMock->expects($this->once())->method('getAttributeId')->willReturn(null);
$this->attributeBuilderMock->expects($this->once())->method('setAttributeId')->with(null)->willReturnSelf();
$labelMock = $this->getMock('Magento\\Eav\\Api\\Data\\AttributeFrontendLabelInterface', [], [], '', false);
$attributeMock->expects($this->exactly(4))->method('getFrontendLabels')->willReturn([$labelMock]);
$attributeMock->expects($this->exactly(2))->method('getDefaultFrontendLabel')->willReturn('test');
$labelMock->expects($this->once())->method('getStoreId')->willReturn(0);
$labelMock->expects($this->once())->method('getLabel')->willReturn(null);
$this->model->save($attributeMock);
}
示例5: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->asfGuardUser !== null) {
if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
$affectedRows += $this->asfGuardUser->save($con);
}
$this->setsfGuardUser($this->asfGuardUser);
}
if ($this->aRepository !== null) {
if ($this->aRepository->isModified() || $this->aRepository->isNew()) {
$affectedRows += $this->aRepository->save($con);
}
$this->setRepository($this->aRepository);
}
if ($this->aBranch !== null) {
if ($this->aBranch->isModified() || $this->aBranch->isNew()) {
$affectedRows += $this->aBranch->save($con);
}
$this->setBranch($this->aBranch);
}
if ($this->aFile !== null) {
if ($this->aFile->isModified() || $this->aFile->isNew()) {
$affectedRows += $this->aFile->save($con);
}
$this->setFile($this->aFile);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例6: create
public static function create($name, $url = null, $files = array()){
$id = self::getID($name);
// Handles old repositories as well
$repository = new Repository($id);
$repository->name = $name;
$repository->url = $url;
foreach($files as $file){
$repository->add($file);
}
$repository->save();
return $repository;
}
示例7: edit
/**
* Edit repository
*
* @param null
* @return void
*/
function edit()
{
if (!$this->active_repository->canEdit($this->logged_user)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
$repository_data = $this->request->post('repository');
if (!is_array($repository_data)) {
$repository_data = array('name' => $this->active_repository->getName(), 'url' => $this->active_repository->getUrl(), 'username' => $this->active_repository->getUsername(), 'password' => $this->active_repository->getPassword(), 'repositorytype' => $this->active_repository->getRepositoryType(), 'updatetype' => $this->active_repository->getUpdateType(), 'visibility' => $this->active_repository->getVisibility());
}
if ($this->request->isSubmitted()) {
db_begin_work();
$this->active_repository->setAttributes($repository_data);
$this->active_repository->loadEngine($this->active_repository->getRepositoryType());
$this->repository_engine = new RepositoryEngine($this->active_repository);
$this->repository_engine->triggerred_by_handler = true;
$result = $this->repository_engine->testRepositoryConnection();
if ($result === true) {
$save = $this->active_repository->save();
if ($save && !is_error($save)) {
db_commit();
flash_success(lang('Repository has been successfully updated'));
$this->redirectToUrl($this->active_repository->getHistoryUrl());
} else {
db_rollback();
$this->smarty->assign('errors', $save);
}
//if
} else {
db_rollback();
$errors = new ValidationErrors();
$errors->addError(lang('Failed to connect to repository: :message', array('message' => $result)));
$this->smarty->assign('errors', $errors);
}
// if
}
// if
js_assign('repository_test_connection_url', assemble_url('repository_test_connection', array('project_id' => $this->active_project->getId())));
$this->smarty->assign(array('types' => $this->active_repository->types, 'update_types' => $this->active_repository->update_types, 'repository_data' => $repository_data, 'active_repository' => $this->active_repository, 'disable_url_and_type' => instance_of($this->active_repository->getLastCommit(), 'Commit'), 'aid_url' => lang('The path to the existing repository cannot be changed'), 'aid_engine' => lang('Repository type cannot be changed')));
}
示例8: add
/**
* Add a Github repository
*
* @return void
* @return null
**/
function add()
{
if (!Repository::canAdd($this->logged_user, $this->active_project)) {
$this->httpError(HTTP_ERR_FORBIDDEN);
}
// if
$repository_data = $this->request->post('repository');
if (!is_array($repository_data)) {
$repository_data = array('visibility' => $this->active_project->getDefaultVisibility());
}
// if
if ($this->request->isSubmitted()) {
$repository_data['name'] = trim($repository_data['name']) == '' ? $repository_data['url'] : $repository_data['name'];
$this->active_repository->setAttributes($repository_data);
$this->active_repository->setBody(clean(array_var($repository_data, 'url', null)));
$this->active_repository->setProjectId($this->active_project->getId());
$this->active_repository->setCreatedBy($this->logged_user);
$this->active_repository->setState(STATE_VISIBLE);
$result = $this->active_repository->testRepositoryConnection();
if ($result === true) {
$save = $this->active_repository->save();
if ($save && !is_error($save)) {
flash_success(lang('Project repository ":name" has been added successfully'), array('name' => $this->active_repository->getName()));
$this->redirectToUrl(github_module_url($this->active_project));
} else {
$save->errors['-- any --'] = $save->errors['body'];
$this->smarty->assign('errors', $save);
}
//if
} else {
$errors = new ValidationErrors();
$errors->addError(lang('Failed to connect to repository: :message', array('message' => $result)));
$this->smarty->assign('errors', $errors);
}
// if
}
// if
$this->smarty->assign(array('repository_data' => $repository_data));
}
示例9: md5
require_once './sdk/Hpp.Protocol.php';
require_once './sdk/Hpp.PayService.php';
require_once './repository.php';
//订单号
$orderNumber = md5(uniqid(mt_rand(), true));
//请求参数
$payRequest = new PayRequest();
$payRequest->setAppId('CA_APP-ID-0001');
$payRequest->setPayInterface($_POST['pay_interface']);
$payRequest->setOrderNumber($orderNumber);
$payRequest->setOrderSubject('php-demo-1分钱支付体验');
//订单标题
$payRequest->setOrderDescribe($_POST['order_describe']);
$payRequest->setAmount($_POST['order_amount']);
$payRequest->setCustomerIp('127.0.0.1');
$payRequest->setReturnUrl('http://127.0.0.1/callback-return.php?orderNumber' . $orderNumber);
$payResponse = new PayResponse(PayService::startPay($payRequest));
//保存部分参数供后续用
//订单状态
$payRequest->setValue('status', Protocol::STATUS_ORDER_CREATED);
$payRequest->setValue(Protocol::KEY_TRADE_SN, $payResponse->getTradeSn());
//相应数据
$payRequest->setValue('responseData', ['rawHtml' => $payResponse->getRawHtml(), 'wXQRPayUrl' => $payResponse->getWXQRPayUrl()]);
//订单日期
$now = (new DateTime())->format('m-d H:i:s');
$payRequest->setValue('createOn', $now);
Repository::save($payRequest->getOrderNumber(), $payRequest->toJsonString());
//ajax api输出
header('Content-Type: application/json; charset=UTF-8"');
echo json_encode(['orderNumber' => $orderNumber]);
示例10: Repository
Doctrine_Core::loadData(dirname(__FILE__) . '/RepositoryFixture.yml');
$t = new lime_test(28);
// construct
$t->diag('__construct()');
$t->ok(new Repository() instanceof Repository, 'Repositoryインスタンス化');
// create
$t->diag('create');
$repository = new Repository();
$repository->setName('repository_name');
$repository->setRepository('repository_url');
$repository->setSubdirectory('subdirectory');
$repository->setBindPath('/bind_path');
$repository->setSettingsJson('settings_json');
$repository->setForceUpdate(true);
$repository->setForceClone(true);
$repository->save();
$repository = RepositoryTable::getInstance()->findOneByName('repository_name');
$t->ok($repository instanceof Repository, 'Repository保存');
$t->is($repository->getName(), 'repository_name', 'リポジトリ名の保存');
$t->is($repository->getRepository(), 'repository_url', 'リポジトリURLの保存');
$t->is($repository->getSubdirectory(), 'subdirectory', 'サブディレクトリの保存');
$t->is($repository->getBindPath(), '/bind_path', '結合パスの保存');
$t->is($repository->getSettingsJson(), 'settings_json', '設定値の保存');
$t->is($repository->getForceUpdate(), true, '強制更新値の保存');
$t->is($repository->getForceClone(), true, '強制clone値の保存');
// setter bind_path
$t->diag('setter bind_path');
$repository->setBindPath('/');
$t->is($repository->getBindPath(), '', '/のみは空白に');
$repository->setBindPath('/test');
$t->is($repository->getBindPath(), '/test', '先頭スラッシュ付き、末尾スラッシュなし');
示例11: doSave
/**
* Performs the work of inserting or updating the row in the database.
*
* If the object is new, it inserts it; otherwise an update is performed.
* All related objects are also updated in this method.
*
* @param PropelPDO $con
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
* @throws PropelException
* @see save()
*/
protected function doSave(PropelPDO $con)
{
$affectedRows = 0;
// initialize var to track total num of affected rows
if (!$this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this->aRepository !== null) {
if ($this->aRepository->isModified() || $this->aRepository->isNew()) {
$affectedRows += $this->aRepository->save($con);
}
$this->setRepository($this->aRepository);
}
if ($this->asfGuardUser !== null) {
if ($this->asfGuardUser->isModified() || $this->asfGuardUser->isNew()) {
$affectedRows += $this->asfGuardUser->save($con);
}
$this->setsfGuardUser($this->asfGuardUser);
}
if ($this->isNew() || $this->isModified()) {
// persist changes
if ($this->isNew()) {
$this->doInsert($con);
} else {
$this->doUpdate($con);
}
$affectedRows += 1;
$this->resetModified();
}
if ($this->commentsScheduledForDeletion !== null) {
if (!$this->commentsScheduledForDeletion->isEmpty()) {
CommentQuery::create()->filterByPrimaryKeys($this->commentsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->commentsScheduledForDeletion = null;
}
}
if ($this->collComments !== null) {
foreach ($this->collComments as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->filesScheduledForDeletion !== null) {
if (!$this->filesScheduledForDeletion->isEmpty()) {
FileQuery::create()->filterByPrimaryKeys($this->filesScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->filesScheduledForDeletion = null;
}
}
if ($this->collFiles !== null) {
foreach ($this->collFiles as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
if ($this->statusActionsScheduledForDeletion !== null) {
if (!$this->statusActionsScheduledForDeletion->isEmpty()) {
StatusActionQuery::create()->filterByPrimaryKeys($this->statusActionsScheduledForDeletion->getPrimaryKeys(false))->delete($con);
$this->statusActionsScheduledForDeletion = null;
}
}
if ($this->collStatusActions !== null) {
foreach ($this->collStatusActions as $referrerFK) {
if (!$referrerFK->isDeleted()) {
$affectedRows += $referrerFK->save($con);
}
}
}
$this->alreadyInSave = false;
}
return $affectedRows;
}
示例12: file_get_contents
<?php
require_once './sdk/Hpp.PayService.php';
require_once './sdk/Hpp.Protocol.php';
/**
* 处理入账响应
*/
//直接读取整个req过来的请求
$rawEventBody = file_get_contents('php://input');
$tradeEvent = new TradeSuccessEvent(PayService::reciveTradeSuccessEvent($rawEventBody));
if ($tradeEvent->isTradeSuccess()) {
//TODO: 订单已完成,在这里完成发货逻辑...
//存储模拟的订单信息
$order = Repository::find($tradeEvent->getOrderNumber());
$order['status'] = $tradeEvent->getStatus();
Repository::save($tradeEvent->getOrderNumber(), json_encode($order));
}
示例13: header
<?php
require_once './sdk/Hpp.PayService.php';
require_once './sdk/Hpp.Protocol.php';
require_once './repository.php';
/**
* 订单状态查询
*/
$orderNumber = $_REQUEST['orderNumber'];
//不区分GET/POST
$order = Repository::find($orderNumber);
if ($order['status'] == 'NOTIFY_CONFIRM') {
header('location: ./order-list.php');
exit;
}
//订单并未完成,向hpp提交订单状态查询请求
$queryRequest = new OrderQueryRequest($order[Protocol::KEY_TRADE_SN]);
$queryResponse = new OrderQueryResponse(PayService::startOrderQuery($queryRequest));
//刷新请求状态
$order['status'] = $queryResponse->getStatus();
Repository::save($orderNumber, json_encode($order));
header('location: ./order-list.php');