本文整理汇总了PHP中patch函数的典型用法代码示例。如果您正苦于以下问题:PHP patch函数的具体用法?PHP patch怎么用?PHP patch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了patch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: patch
/**
* Patches array by xpath.
*
* Arguments:
* (Array): The array to patch.
* (Array): List of new xpath-value pairs.
*
* Returns:
* (Array): Returns patched array.
*
* @arrays @patch
*
** __::patch(['addr' => ['country' => 'US', 'zip' => 12345]], ['/addr/country' => 'CA', '/addr/zip' => 54321]);
** // → ['addr' => ['country' => 'CA', 'zip' => 54321]]
*/
function patch($arr, $patches, $parent = '')
{
foreach ($arr as $key => $value) {
$z = $parent . '/' . $key;
if (isset($patches[$z])) {
$arr[$key] = $patches[$z];
unset($patches[$z]);
if (!count($patches)) {
break;
}
}
if (is_array($value)) {
$arr[$key] = patch($value, $patches, $z);
}
}
return $arr;
}
示例2: use
return $a["Name"] == $iItem["conference_track"];
})->singleOrDefault();
$conferenceDay = $dbConferenceDays->where(function ($a) use($iItem) {
return $a["Name"] == $iItem["conference_day_name"];
})->singleOrDefault();
$conferenceRoom = $dbConferenceRooms->where(function ($a) use($iItem) {
return $a["Name"] == $iItem["conference_room"];
})->singleOrDefault();
$iItem["conference_track_id"] = isset($conferenceTrack) ? $conferenceTrack["Id"] : "";
$iItem["conference_day_id"] = isset($conferenceDay) ? $conferenceDay["Id"] : "";
$iItem["conference_room_id"] = isset($conferenceRoom) ? $conferenceRoom["Id"] : "";
$parts = explode("–", $iItem["title"]);
$iItem["title"] = $parts[0];
$iItem["subtitle"] = sizeof($parts) == 2 ? trim($parts[1]) : "";
$iItem["is_deviating_from_conbook"] = 0;
$patchedItem = patch($iItem, $dbItem, array("event_id" => "SourceEventId", "slug" => "Slug", "conference_track_id" => "ConferenceTrackId", "conference_day_id" => "ConferenceDayId", "conference_room_id" => "ConferenceRoomId", "title" => "Title", "subtitle" => "SubTitle", "abstract" => "Abstract", "description" => "Description", "start_time" => "StartTime", "end_time" => "EndTime", "duration" => "Duration", "pannel_hosts" => "PanelHosts", "is_deviating_from_conbook" => "IsDeviatingFromConBook"));
if ($patchedItem) {
if (!$dbItem) {
$database->insert("EventEntry", $patchedItem);
} else {
$database->update("EventEntry", $patchedItem, "Id=%s", $dbItem["Id"]);
}
}
});
Log::info("Commiting changes to database");
$database->commit();
} catch (Exception $e) {
var_dump($e->getMessage());
Log::error("Rolling back changes to database");
$database->rollback();
}
示例3: function
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
Route::get('/', function () {
return Redirect::to('/api-docs');
});
Route::group(['prefix' => 'api'], function () {
post('register', 'TokenAuthController@register');
post('authenticate', 'TokenAuthController@authenticate');
get('authenticate/user', 'TokenAuthController@getAuthenticatedUser');
Route::group(['middleware' => 'jwt.auth'], function () {
post('logout', 'TokenAuthController@logout');
resource('appointment_requests', 'AppointmentRequestController', ['except' => ['create', 'edit']]);
patch('appointment_requests/{id}/confirm', 'AppointmentRequestController@confirm');
patch('appointment_requests/{id}/cancel', 'AppointmentRequestController@cancel');
});
});
示例4: get
// OAuth Authentication Routes...
get('auth/github', 'Auth\\AuthController@redirectToProvider');
get('auth/github/callback', 'Auth\\AuthController@handleProviderCallback');
// Static Pages Routes...
get('/', ['as' => 'root_path', 'uses' => 'PagesController@home']);
get('about', ['as' => 'about_path', 'uses' => 'PagesController@about']);
get('contact', ['as' => 'contact_path', 'uses' => 'PagesController@contact']);
post('contact', ['as' => 'contact_path', 'uses' => 'PagesController@postContact']);
// User routes...
get('artisans', ['as' => 'artisans_path', 'uses' => 'UsersController@index']);
get('@{username}', ['as' => 'profile_path', 'uses' => 'UsersController@profile']);
Route::group(['prefix' => 'account', 'middleware' => 'auth'], function () {
get('/', ['as' => 'account_path', 'uses' => 'UsersController@account']);
get('/edit', ['as' => 'edit_account_path', 'uses' => 'UsersController@edit_account']);
patch('/', ['as' => 'account_path', 'uses' => 'UsersController@update_account']);
get('/set_password', ['as' => 'new_password_path', 'uses' => 'UsersController@new_password']);
patch('/set_password', ['as' => 'new_password_path', 'uses' => 'UsersController@update_password']);
});
// Authentication routes...
Route::get('auth/login', 'Auth\\AuthController@getLogin');
Route::post('auth/login', 'Auth\\AuthController@postLogin');
Route::get('auth/logout', 'Auth\\AuthController@getLogout');
// Registration routes...
Route::get('auth/register', ['as' => 'register_path', 'uses' => 'Auth\\AuthController@getRegister']);
Route::post('auth/register', 'Auth\\AuthController@postRegister');
// Password reset link request routes...
Route::get('password/email', 'Auth\\PasswordController@getEmail');
Route::post('password/email', 'Auth\\PasswordController@postEmail');
// Password reset routes...
Route::get('password/reset/{token}', 'Auth\\PasswordController@getReset');
Route::post('password/reset', 'Auth\\PasswordController@postReset');
示例5: post
post('register', ['as' => 'registrations.store', 'uses' => 'RegistrationsController@store']);
Route::group(['prefix' => 'admin', 'before' => 'auth'], function () {
# Static Pages
get('dashboard', ['as' => 'dashboard', 'uses' => 'PagesController@dashboard']);
get('help', ['as' => 'help', 'uses' => 'PagesController@help']);
# Domain Section
get('domains', ['as' => 'admin.domains.index', 'uses' => 'DomainsController@index']);
get('domains/create', ['as' => 'admin.domains.create', 'uses' => 'DomainsController@create']);
post('domains', ['as' => 'admin.domains.store', 'uses' => 'DomainsController@store']);
get('domains/{domain}', ['as' => 'admin.domains.show', 'uses' => 'DomainsController@show']);
get('domains/{domain}/edit', ['as' => 'admin.domains.edit', 'uses' => 'DomainsController@edit']);
put('domains/{domain}', ['as' => 'admin.domains.update', 'uses' => 'DomainsController@update']);
patch('domains/{domain}', 'DomainsController@update');
get('domains/{id}/delete', ['as' => 'admin.domains.destroy', 'uses' => 'DomainsController@destroy']);
get('domains/{id}/token', ['as' => 'admin.domains.new_token', 'uses' => 'DomainsController@generateToken']);
get('domains/{id}/nginx', ['as' => 'admin.domains.nginx', 'uses' => 'DomainsController@showNginx']);
patch('domains/{id}/nginx', ['as' => 'admin.domains.nginx.update', 'uses' => 'DomainsController@updateNginx']);
# App/Repository Section
post('domains/{id}/app', ['as' => 'admin.app.store', 'uses' => 'AppsController@store']);
patch('app/{id}', ['as' => 'admin.app.update', 'uses' => 'AppsController@update']);
delete('app/{id}', ['as' => 'admin.app.destroy', 'uses' => 'AppsController@destroy']);
# Environment Section
post('domains/{id}/environment', ['as' => 'admin.environment.store', 'uses' => 'EnvironmentsController@store']);
get('environment/{id}', ['as' => 'admin.environment.destroy', 'uses' => 'EnvironmentsController@destroy']);
# Workers Section
post('domains/{id}/worker', ['as' => 'admin.workers.store', 'uses' => 'WorkersController@store']);
get('worker/{id}', ['as' => 'admin.workers.destroy', 'uses' => 'WorkersController@destroy']);
# Settings Section
get('settings', ['as' => 'settings', 'uses' => 'ConfigurationsController@create']);
post('settings', ['as' => 'settings.save', 'uses' => 'ConfigurationsController@store']);
});
示例6: file_get_contents
return false;
}
if (!$fnamePatch || !file_exists($fnamePatch)) {
return false;
}
$cont_patch = file_get_contents($fnamePatch);
if (preg_match('/^<[?](?:php|)/', $cont_patch, $arr) && is_array($arr)) {
$cont_patch = substr($cont_patch, strlen($arr[0]));
}
$cont_obj = substr($cont_obj, 0, $k) . $cont_patch . substr($cont_obj, $k);
file_put_contents($fnameObj, $cont_obj);
return 1;
}
$fname = 'AdminImport.php';
if (isset($_REQUEST['filename']) && ($v = $_REQUEST['filename'])) {
$fname = $v;
}
if ($argc >= 2 && ($v = trim($argv[1]))) {
$fname = $v;
}
$ret = patch($fname, FILE_PATCH);
switch ($ret) {
case 1:
echo 'Installation completed: file "' . $fname . '" successfully patched';
break;
case 2:
echo 'Installation has already done';
break;
default:
echo 'Installation failed';
}
示例7: generatePluginFile
/**
* Generate plugin file from template
*
* NOTE: aborts entire script on error
*
* @param string $filename file name (relative path)
* @param array $plgdata plugin data
* @return void
*
*/
function generatePluginFile($filename, $plgdata)
{
$content = readTemplate($filename);
$content = patch($content, $plgdata);
$content = optionalSections($content, $plgdata);
writePluginFile($filename, $content, $plgdata);
}
示例8: function
});
$router->bind('cat', function ($cat) {
$kat_id = App\Kategori::where('nama_kategori', $cat)->firstOrFail()->id;
return $kat_id;
});
Route::controllers(['auth' => 'Auth\\AuthController', 'password' => 'Auth\\PasswordController']);
get('/search', ['as' => 'search', 'uses' => 'HomeController@search']);
get('/admin', ['as' => 'admin', 'uses' => 'AdminController@index']);
get('/admin/login', ['as' => 'admin_login', 'uses' => 'AdminController@login']);
get('/admin/posts', ['as' => 'admin_posts', 'uses' => 'AdminController@posts']);
get('/admin/posts/create', ['as' => 'admin_create', 'uses' => 'AdminController@create']);
get('/admin/posts/{news}/edit', ['as' => 'admin_edit', 'uses' => 'AdminController@edit']);
get('/admin/posts/{news}/delete', ['as' => 'admin_delete', 'uses' => 'AdminController@delete']);
get('/admin/posts/{news}/destroy', ['as' => 'admin_destroy', 'uses' => 'AdminController@destroy']);
post('/admin/post', ['as' => 'admin_store', 'uses' => 'AdminController@store']);
patch('/{news}', ['as' => 'admin_update', 'uses' => 'AdminController@update']);
get('/search', ['as' => 'search', 'uses' => 'HomeController@search']);
get('home', ['as' => 'home', 'uses' => 'HomeController@index']);
get('/category/{cat}', 'HomeController@category');
get('/', ['as' => 'root', 'uses' => 'HomeController@index']);
get('/{news}', ['as' => 'news_path', 'uses' => 'HomeController@show']);
post('/comment', ['as' => 'storeComment', 'uses' => 'HomeController@storeComment']);
//$router->bind('songs', function($slug)
//{
// return App\Song::where('slug' , $slug)->first();
//});
//$router->resource('songs','SongsController');
//get('songs',['as'=>'songs_path','uses'=>'SongsController@index']);
//get('songs/{song}' ,['as'=>'song_path','uses'=>'SongsController@show']);
//get('songs/{song}/edit', 'SongsController@edit');
//patch('songs/{song}', 'SongsController@update');
示例9: get
get('profile/edit', 'ProfileController@edit')->name('frontend.profile.edit');
patch('profile/update', 'ProfileController@update')->name('frontend.profile.update');
//Reports : Create New Report
get('report/new', 'UserController@newReport')->name('report.new');
post('report/new', 'UserController@postReport')->name('report.post_report');
//View all reports in list
get('reports', 'UserController@reports')->name('reports');
//View a single report
get('report/{id}', 'UserController@reportPage')->name('report.page');
//Save conversations
post('report/chat/new', 'UserController@saveConversations')->name('report.new_conversation');
Route::group(['middleware' => 'access.routeNeedsPermission:give_recommendations'], function () {
get('doctor/dashboard', 'DoctorController@dashboard')->name('doctor.dashboard');
get('doctor/report/{id}', 'DoctorController@report')->name('doctor.report');
get('doctor/reports', 'DoctorController@allReports')->name('doctor.reports');
post('doctor/report/post-recommendation/{id}', 'DoctorController@postRecommendation')->name('doctor.post.recommendation');
post('doctor/report/refer_patient/{id}', 'DoctorController@referPatient')->name('doctor.refer_patient');
//Patient Feedback / messages
get('doctor/feedback/{id}', 'DoctorController@feedback')->name('doctor.feedback');
//Save conversations
post('doctor/report/chat/new', 'DoctorController@saveConversations')->name('report.new_conversation');
});
Route::group(['middleware' => 'access.routeNeedsPermission:manage_hospital'], function () {
get('management/dashboard', 'ManagementController@dashboard')->name('management.dashboard');
get('management/new-doctor', 'ManagementController@newDoctor')->name('management.register_doctor');
get('management/profile/edit/{id}', 'ManagementController@edit')->name('frontend.management.profile.edit');
get('management/reports', 'ManagementController@reports')->name('frontend.management.reports');
patch('management/profile/update', 'ManagementController@update')->name('frontend.management.profile.update');
post('management/doctor/save', 'ManagementController@registerDoctor')->name('management.create.dashboard');
});
});
示例10: switch
switch ($row_get_sysid['property_type']) {
case 'Multifamily':
$property_type = 7;
break;
case 'Residential Detached':
$property_type = 1;
break;
case 'Residential Attached':
$property_type = 2;
break;
}
if (!empty($property_type)) {
$listing_array = get_data_array($property_type, $new_sysid);
if (!empty($listing_array)) {
update_database($property_type, $listing_array, $new_sysid);
patch($new_sysid);
}
}
}
} else {
echo '<br/>All listings are patched<br/>';
}
$selectSQL = "SELECT SQL_CALC_FOUND_ROWS DISTINCT listings.sysid, postal_code, house_number, street_name, street_type, city, province FROM listings\nLEFT JOIN listing_geoaddress ON listings.sysid=listing_geoaddress.sysid WHERE (ISNULL(lat) OR listing_geoaddress.updated='N') AND status='A' AND property_type!='Land Only' ORDER BY RAND() LIMIT 0, 10";
$get_sysid = mysql_query_or_die($selectSQL, $useradmin);
$row = mysql_fetch_row(mysql_query("SELECT FOUND_ROWS()", $useradmin));
if ($row[0] > 0) {
echo "<br/>There are " . $row[0] . " listings that don't have geo code address (or don't have accurate geo code).<br/><br/>";
//login and receive server response.
//$response=$rets->Login();
//var_dump($response);
while ($row_get_sysid = mysql_fetch_assoc($get_sysid)) {
示例11: function
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
//Route::get('/', 'HomeController@index');
/*
Route::get('/', function () {
return view('welcome');
});
*/
//Route::bind('song', function($slug)
//{
// return App\Song::whereSlug($slug)->first();
//});
get('/', ['as' => 'home.page', 'uses' => 'PageController@index']);
get('about', ['as' => 'about.page', 'uses' => 'PageController@about']);
get('demo', ['as' => 'demo.page', 'uses' => 'PageController@demo']);
get('music', ['as' => 'song.index', 'uses' => 'SongsController@index']);
get('music/{slug}/view', ['as' => 'song.show', 'uses' => 'SongsController@show']);
get('music/{slug}/edit', ['as' => 'song.edit', 'uses' => 'SongsController@edit']);
patch('music/{slug}', ['as' => 'song.patch', 'uses' => 'SongsController@update']);
get('music/create', ['as' => 'song.create', 'uses' => 'SongsController@create']);
post('music/store', ['as' => 'song.store', 'uses' => 'SongsController@store']);
delete('music/{slug}', ['as' => 'song.destroy', 'uses' => 'SongsController@destroy']);
//$router->resource('songs', 'SongsController');
$router->resource('people', 'PeopleController');
示例12: config
<?php
Route::group(['prefix' => config('laracrud.route_prefix')], function () {
get('/', ['as' => 'laracrud.dashboard', 'uses' => function () {
return 'crud dashboard';
}]);
// List
get('{model}', ['as' => 'laracrud.index', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@index']);
// Create
get('{model}/create', ['as' => 'laracrud.create', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@create']);
// Show
get('{model}/{item}', ['as' => 'laracrud.show', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@show']);
// Edit
get('{model}/{item}/edit', ['as' => 'laracrud.edit', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@edit']);
// Store
post('{model}', ['as' => 'laracrud.store', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@store']);
// Update
put('{model}/{id}', ['as' => 'laracrud.update', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@update']);
patch('{model}/{id}', ['as' => 'laracrud.update', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@update']);
// Destroy
delete('{model}/{item}', ['as' => 'laracrud.destroy', 'uses' => 'Laracrud\\Laracrud\\Controllers\\Controller@destroy']);
});
示例13: json_decode
}
$news = json_decode(file_get_contents('http://6al.de/efsched/getconnews'));
Log::info("Importing ConNews");
try {
$database->startTransaction();
foreach ($news as $entry) {
Log::info(sprintf("Id: %s, Type: %s -> %s", $entry->id, $entry->news->type, $entry->news->title));
$dbItem = @$database->query("SELECT * FROM Announcement WHERE ExternalId=%s", "connews:" . $entry->id)[0];
if ($dbItem) {
$dbItem["ValidFromDateTimeUtc"] = new DateTime($dbItem["ValidFromDateTimeUtc"]);
$dbItem["ValidUntilDateTimeUtc"] = new DateTime($dbItem["ValidUntilDateTimeUtc"]);
}
if ($entry->news->type == "new" || $entry->news->type == "reschedule") {
$entry->news->valid_until = $entry->date + 60 * 60 * 48;
}
$sourceItem = array("ExternalId" => "connews:" . $entry->id, "ValidFrom" => DateTime::createFromFormat('U', $entry->date), "ValidUntil" => DateTime::createFromFormat('U', $entry->news->valid_until), "Area" => ucwords($entry->news->type), "Author" => isset($entry->news->department) ? ucwords($entry->news->department) : "Eurofurence", "Title" => $entry->news->title, "Content" => strip_tags($parsedown->text($entry->news->message)));
$patchedItem = patch($sourceItem, $dbItem, array("ExternalId" => "ExternalId", "ValidFrom" => "ValidFromDateTimeUtc", "ValidUntil" => "ValidUntilDateTimeUtc", "Area" => "Area", "Author" => "Author", "Title" => "Title", "Content" => "Content"));
if ($patchedItem) {
if (!$dbItem) {
$database->insert("Announcement", $patchedItem);
} else {
$database->update("Announcement", $patchedItem, "Id=%s", $dbItem["Id"]);
}
}
}
$database->commit();
} catch (Exception $e) {
var_dump($e->getMessage());
Log::error("Rolling back changes to database");
$database->rollback();
}
示例14: function
Route::get('order', ['as' => 'order.index', 'uses' => 'CheckoutController@index']);
Route::get('order/create', ['as' => 'order.create', 'uses' => 'CheckoutController@create']);
Route::post('order/store', ['as' => 'order.store', 'uses' => 'CheckoutController@store']);
});
Route::group(['middleware' => 'cors'], function () {
Route::post('oauth/access_token', function () {
return Response::json(Authorizer::issueAccessToken());
});
Route::group(['prefix' => 'api', 'middleware' => 'oauth', 'as' => 'api.'], function () {
//admin
Route::group(['prefix' => 'admin', 'middleware' => 'oauth.checkrole:admin', 'as' => 'admin.'], function () {
Route::resource('products', 'Api\\Admin\\AdminProductController', ['except' => ['create', 'edit']]);
Route::resource('categories', 'Api\\Admin\\AdminCategoryController', ['except' => ['create', 'edit', 'destroy', 'store']]);
});
//client
Route::group(['prefix' => 'client', 'middleware' => 'oauth.checkrole:client', 'as' => 'client.'], function () {
Route::get('products', ['as' => 'api.products.index', 'uses' => 'Api\\Client\\ClientProductController@index']);
Route::post('order', ['as' => 'api.order.store', 'uses' => 'Api\\Client\\ClientCheckoutController@store']);
});
//deliveryman
Route::group(['prefix' => 'deliveryman', 'middleware' => 'oauth.checkrole:deliveryman', 'as' => 'deliveryman.'], function () {
Route::resource('order', 'Api\\Deliveryman\\DeliverymanCheckoutController', ['except' => ['create', 'edit', 'destroy', 'store']]);
Route:
patch('order/{id}/update-status', ['uses' => 'Api\\Deliveryman\\DeliverymanCheckoutController@updateStatus', 'as' => 'orders.update_status']);
});
//cupom
Route::get('cupom/{code}', ['as' => 'api.cupom.show', 'uses' => 'Api\\CupomController@show']);
//user
Route::get('user/authenticated', ['as' => 'api.user.authenticated', 'uses' => 'Api\\UserController@authenticated']);
});
});
示例15: get
// backend home page
get('/', ['as' => 'backend', 'uses' => 'Backend\\HomeController@index']);
// roles and permissions
Route::group(['prefix' => 'security'], function () {
// roles
resource('roles', 'Backend\\Security\\RolesController');
// permissions
resource('permissions', 'Backend\\Security\\PermissionsController');
// access control. defining permissions used by roles, and users assigned this roles
Route::group(['prefix' => 'access-control'], function () {
resource('roles', 'Backend\\Security\\UserRolesController');
});
});
// other user's accounts
Route::group(['prefix' => 'accounts'], function () {
patch('/resetPassword/{user_id}', ['as' => 'useraccount.password.edit', 'uses' => 'Shared\\AccountController@patchAnotherUsersPassword']);
});
// counties
resource('counties', 'Backend\\Shipping\\CountiesController');
// products
resource('products', 'Backend\\Inventory\\ProductsController');
// help articles
resource('articles', 'Backend\\Articles\\ArticlesController');
// brands
resource('brands', 'Backend\\Inventory\\BrandsController');
// categories
resource('categories', 'Backend\\Inventory\\CategoriesController');
// categories
resource('orders', 'Backend\\Orders\\OrdersController');
// subcategories
resource('subcategories', 'Backend\\Inventory\\SubCategoriesController');