anchor stringlengths 10 14.3k | positive stringlengths 10 14.9k |
|---|---|
Create tmp file und return its FileInfo. | protected function getDeletableFileInfo()
{
$file = tempnam('.', '');
$spl = new \SplFileInfo($file);
return $spl;
} |
module should throw Exception in case of merge is not possible | protected function merge(User $target, User $source)
{
$event = new Am_Event(Am_Event::USER_BEFORE_MERGE, array(
'target' => $target,
'source' => $source
));
$this->getDi()->hook->call(Am_Event::USER_BEFORE_MERGE, $event);
$this->getDi()->db->query('UPDATE ?_... |
Creates a cms page | protected function createPage($name, $hierarchy, Page $parent = null): Page
{
$page = new Page();
$page->setParent($parent);
$page->setHierarchy($hierarchy);
$page->setPublish(1);
$page->setRedirectType(0);
$page->setSection('');
$page->addShop($this->shop);
... |
Form render function Construct and output the form we have gathered info about. | public function render($buffer=false)
{
//--------------------------------------------------------
// Inset Value Buffer
//--------------------------------------------------------
ob_start();
//--------------------------------------------------------
// Data Output Buffer
//-----------------------------... |
Commits all pending changes. | protected function commit() {
$this->get_search_client()->commit();
} |
Traverse an \StdClass object recursively in search of the needed property | private function traverseGet(\StdClass $json, array $chain, $index = 0)
{
$property = $chain[$index];
if (!property_exists($json, $property)) {
return false;
}
if (isset($chain[$index + 1])) {
return $this->traverseGet($json->{$property}, $chain, $index + 1);
... |
Returns the static model of the specified AR class. | public static function model($className = __CLASS__)
{
return parent::model($className);
} |
Checks whether the transaction info for the transaction linked to the order is already linked to another order. | protected function checkTransactionInfo(Mage_Sales_Model_Order $order)
{
/* @var PostFinanceCheckout_Payment_Model_Entity_TransactionInfo $info */
$info = Mage::getModel('postfinancecheckout_payment/entity_transactionInfo')->loadByTransaction(
$order->getPostfinancecheckoutSpaceId(), $or... |
Execute the console command. | public function fire()
{
$rows = Report::getReport();
$table = new Table($this->output);
$table->setHeaders(array_shift($rows));
array_walk($rows, function($row) use ($table) {
$table->addRow($row);
});
$table->render();
} |
Update the specified resource in storage. | public function update(Request $request, $id)
{
$film = Film::findOrFail($id);
$film->update($request->all());
return $film;
} |
Set the nom marital. | public function setNomMarital($nomMarital) {
$this->nomMarital = $nomMarital;
return $this;
} |
END VERIFIKASI REKENING PEMBIAYAAN BEGIN ASURANSI SETUP | public function datatable_insurance_setup()
{
/* Array of database columns which should be read and sent back to DataTables. Use a space where
* you want to insert a non-database field (for example a counter or static image)
*/
$aColumns = array( '','mfi_account_insurance.account_insurance_no', 'mfi_cif.nama... |
Display the specified resource. | public function show(Request $request)
{
$user_id = $request->user_id;
$validation = Validator::make(
$request->all(),
[
'status_id' => 'required|integer|numeric',
]
);
$errors = $validation->errors();
if($validation->fails... |
Determine which templates support layouts. | function layout_get_templates_options_object( )
{
$ret = new stdClass();
$template_option = $this->get_option('templates');
if ($template_option) {
foreach($template_option as $file => $layout) {
$layout_templates[] = $file;
}
}
$templates = wp_get... |
Show the form for creating a new resource. | public function create()
{
} |
Initializes context with parameters from behat.yml. | public function __construct(array $parameters)
{
$this->parameters = $parameters;
} |
Return xpath of dropdown button. | private function getButtonXpath() {
return sprintf(Dropdown::BUTTON_XPATH,$this::$keyWord);
} |
Returns the controller class name from provided route | public function inflect(Route $route): ControllerDispatch
{
$arguments = $this->extractAttributes($route);
return $this->createDispatch($arguments);
} |
Get Address type Type of the address. This is a code. You can find the possible values at Guidelines | public function getAddressType(): ?string
{
return $this->AddressType ?? null;
} |
Returns the mood for the current post. The mood is set by the 'mood' custom field. | function unique_entry_mood_shortcode( $attr ) {
$attr = shortcode_atts( array( 'before' => '', 'after' => '' ), $attr );
$mood = get_post_meta( get_the_ID(), 'mood', true );
if ( !empty( $mood ) )
$mood = $attr['before'] . convert_smilies( $mood ) . $attr['after'];
return $mood;
} |
Testing the user search | public function testSearchUser()
{
echo "\nTesting user search...";
//$url = TestServiceAsReadOnly::$elasticsearchHost . "/CIL_RS/index.php/rest/users?search=Vicky";
$url = TestServiceAsReadOnly::$elasticsearchHost . $this->context."/users?search=Vicky";
$response = $this->c... |
Gestion information de l'item | public function setData(Array $texts, Array $files){
$this->_data = array_merge($this->_structure,$this->_data);
$this->setTexts($texts);
$newFiles = $this->setImages($files);
$this->saveData();
// Information de la collection
$collectionData = $this->_collectionAdministr... |
End Score Operator Comment for problem operator | function get_CommentsByProb($probId) {
$query = "SELECT c.id,c.userID,u.name,u.nickname,u.photoPath,c.content,c.time FROM commentsforproblem AS c,user AS u where c.stat=0 and c.probID=$probId AND c.userID=u.id AND u.stat=0 order by c.time;";
return mydb_query_return_double_array($query);
} |
Create a new rule instance. | public function __construct(PriceList $price_list = null)
{
$this->price_list = $price_list;
} |
Save Categoriees to Reservation category database | function savecat(){
$data =[
'reservation_category' => $_POST['reservation_category'],
'category_description' => $_POST['category_description'],
'reservation_duration' => $_POST['reservation_duration']
];
insert( 'reservation_categories', $data );
redirect( route('dashboard/... |
Show Willow fancy Banner | public static function fancyBanner(CLImate $cli): void {
// Display Willow's fancy message
$cli->forceAnsiOn();
$cli->green()->border('*', 55);
$cli->addArt(__DIR__);
$cli->bold()->lightGreen()->animation('willow')->speed(200)->enterFrom('left');
$cli->backgroundGreen()... |
Get the validation rules that apply to the request. | public function rules(): array
{
return [
'total' => 'nullable|numeric',
'price' => 'nullable|numeric',
'note' => 'nullable|string',
//{{REQUEST_RULES_NOT_DELETE_THIS_LINE}}
];
} |
Initialises the search engine configuration. | public function __construct() {
parent::__construct();
$curlversion = curl_version();
if (isset($curlversion['version']) && stripos($curlversion['version'], '7.35.') === 0) {
// There is a flaw with curl 7.35.0 that causes problems with client reuse.
$this->cacheclient =... |
Load controller. Returns true on success and false otherwise | public function loadCtrl($ctrlName, $use_dir = null)
{
if ($use_dir === null) {
$use_dir = $this->app->conf['mvc']['use_subdirs']['controllers'];
}
$filename = $this->app->app_path.$this->app->conf['mvc']['dirs']['controllers'].($use_dir ? '/'.$ctrlName : '').'/'.$ctrlName.'.ctrl.php';
if ($this->app->mode... |
Show the form for editing the specified resource. | public function chooseRevision(Request $request, $doc)
{
$doc = Document::findBySlug($doc);
if (!$doc) {
return response(view('docs.404'), 404);
}
$this->authorize('manage', $doc);
$doc->load('updatedBy', 'createdBy');
$results = $doc->revisionHistory->sortByDesc('created_at');
$paginator = new L... |
Get the route key for the model. | public function getRouteKeyName()
{
return 'uuid';
} |
Set a given configuration value. | public function set($key, $value) {
} |
Read data from database. | public function read(){
$this->_getDAO(false);
if($array = $this->dao->read($this->user->getID(), $this->ident)){
$this->_setFromArray($array);
return true;
} else {
return false;
}
} |
Gets the page layout | public function getLayout(); |
/ Function: data returns content of files stored as gzipped base64 encoded strings. This function is replaced by the build command. See Also: | function data($name) {
switch ($name) {
//START_OF_DATA
case 'index': return '';
case 'system/languages/languages.json': return file_get_contents('system/languages/languages.json');
//END_OF_DATA
}
if ($zip) return gzdecode(base64_decode($zip));
} |
Returns table with associative array of row values. Example: [ [id => 1, name => Bonifac], [id => 2, name => Michael] ] | public function fetchAll(): array {
if($this->database === null) {
throw new \Exception('Database connection has not been set.');
}
$this->queryProperty->setFetchType($this->queryProperty::FETCH_ALL);
$cachedResult = $this->checkQueriesCache($this->queryProperty);
... |
Get paging view for a collection of events. | private function getView(Collection $collection) {
$view = [];
foreach (['first', 'previous', 'next', 'last'] as $key) {
$url = $collection->get($key);
if ($url) {
$info = parse_url($url);
if (!empty($info['query'])) {
parse_str($info['query'], $query);
$view[$ke... |
Checks if a given email is already in the database | public function usernameExists($email) {
$stmt = $this->db->prepare("SELECT count(email) FROM users where email=?");
$stmt->execute(array($username));
if ($stmt->fetchColumn() > 0) {
return true;
}
} |
Set pricing attributes for a service | public function actionAddPricing($id)
{
$model = $this->findModel($id);
$motherMatrix = new ServiceAttributeMatrix($model);
return $this->render('add-pricing', [
'model' => $model,
'motherMatrix' => $motherMatrix,
]);
} |
/start of login request | public function login(Request $request){
$rules = [
'email' => 'required|email',
'password'=> 'required'
];
$validator = Validator::make(request()->all(),$rules);
if($validator->fails()){
result( 401, $validator->messages(), null);
}
e... |
Get the value of DOCUMENT_PRODUCT_CFOP | public function getDocumentProductCfop()
{
return (string) $this->document_product_cfop;
} |
Run the database seeds. | public function run()
{
$title = Str::random(10);
DB::table('channels')->insert([
'title' => $title,
'slug' => Str::of($title)->slug(),
'description' => Str::random(100)
]);
} |
Display the specified resource. | public function show($id)
{
// dd($this->model->find($id)->bds->id_loaibds);
return view('admin.pages.hopdong.show', [
'auth' => \Auth::user(),
'route' => $this->model->route,
'data' => $this->model->find($id),
'customers' ... |
Test Case: Validate that the project has a description. | public function shouldHaveDescription()
{
// Arrange
$attributes = factory(Project::class)->raw([
'description' => ''
]);
// Action
$response = $this->post('/projects', $attributes);
// Assert
$response->assertSessionHasErrors('description');
... |
Should the system run the migration tool automatically | public function shouldRunMigration()
{
return $this->canRunMigration()
&& !Mage::getStoreConfigFlag(self::MIGRATION_COMPLETE)
&& !Mage::getStoreConfig('payment/gene_braintree/merchant_id')
&& !Mage::getStoreConfig('payment/gene_braintree/sandbox_merchant_id');
} |
Run the database seeds. | public function run()
{
Reply::truncate();
$tickets = Ticket::all();
$faker = Faker::create();
Reply::create([
'ticket_id' => $tickets[0]->id,
'user_id' => 1,
'name' => null,
'message' => $faker->paragraphs(3, true)
]);
... |
Get all records from table ordered by field | public function queryAllOrderBy($orderColumn); |
This returns the grandparent of the page specified by the GUID | public function getChildrenByParent($parent, $offline=false) {
global $db;
$query = "SELECT guid, title FROM pages WHERE parent = '$parent' ";
if (!$offline) $query.="AND offline=0";
//print "$query<br>\n";
return $db->get_results($query);
} |
Called when request iterated. | public function run() {
$this->header('Content-Type: text/html');
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>G... |
Run the database seeds. | public function run()
{
// DB::statement('SET FOREIGN_KEY_CHECKS=0;');
DB::table('image_products')->truncate();
$faker = Faker\Factory::create('vi_VN');
for ($i = 0; $i < 50; $i++) {
DB::table('image_products')->insert([
'products_id' => rand(1,10),
... |
Get index analysis list. | public function getIndexAnalysis()
{
foreach ($this->items as $item) {
if ('index' == $item->getName()) {
return $item;
}
}
} |
This GLA computes the page ranks of a graph given the edge set as inputs. The algorithm runs with O(V) space and O(I E) time, where V is the total number of vertices; E, the total number of edges; and I, the number of iterations. The input should be two integers specifying source and target vertices. The output is vert... | function Page_Rank($t_args, $inputs, $outputs)
{
// Class name is randomly generated.
$className = generate_name('PageRank');
// Initializiation of argument names.
$inputs_ = array_combine(['s', 't'], $inputs);
$vertex = $inputs_['s'];
// Processing of template arguments.
$adj = $t_args['a... |
Counts scalar values recursively in array. | private function countRecursiveScalars($array)
{
$count = 0;
if (!is_array($array)) {
return 1;
}
foreach ($array as $element) {
if (is_array($element)) {
$count += $this->countRecursiveScalars($element);
} else {
... |
Get a string including indispensable info: Use this function to add space into position str: | function addSpace($str){
$s = $str[0];
for($i=1;$i<strlen($str);$i++){
if(ctype_upper($str[$i]) == true){
$s.= ' '.$str[$i];
}
else{
$s.= $str[$i];
}
}
return $s;
} |
Test a successful command run. | public function testRunsOk()
{
$application = new Application();
$application->add($this->command);
$command = $application->find('dequeue');
$command_tester = new CommandTester($command);
$this->assertEquals(0, $this->dispatcher->getQueue()->count());
$this->dispat... |
Initializes context. Every scenario gets its own context instance. You can also pass arbitrary arguments to the context constructor through behat.yml. | public function __construct(UserRepository $userRepository)
{
$user = $userRepository->findOneBy(['name' => 'behatTestuser']);
$this->user = $user;
} |
Logs with an arbitrary level. | public function log($level, $message, array $context = array())
{
// Make sure the log level is valid
if (!array_key_exists($level, $this->priorityMap))
{
throw new \InvalidArgumentException('An invalid log level has been given.');
}
// Map the level to Joomla's priority
$priority = $this->priorityMap[... |
Test that we can read and parse the email | public function testMailParse()
{
// Parse a simple email
$email_message = new EmailParse();
$email_message->read_email(true, $this->_email);
// Basics
$this->assertEquals('"ElkArte Community" <elkarteforum@gmail.com>', $email_message->headers['reply-to']);
$this->assertEquals('[ElkArte Community] Test Me... |
The last name of the user. | public function setLastName(?string $lastName): self
{
$this->initialized['lastName'] = true;
$this->lastName = $lastName;
return $this;
} |
////////////////////////////////////////////////////////////////////////// GET DETAILS ON A PARTICULAR FIELD COLUMN IN THIS RESULT ////////////////////////////////////////////////////////////////////////// | public function getField($column) {
if (!$column) return ['QUERY'];
return false;
} |
/ accessor method for profile creation date return string value of creation date | public function getDateCreated() {
return($this->dateCreated);
} |
Remove the specified resource from storage. | public function destroy(Organization $organization)
{
//
} |
Show the form for creating a new resource. | public function create()
{
return view('trainer.create');
} |
FUNCIONES DEL NUEVO FORMULARIOS // | public function validateInformation(Request $request){
$data_input = $request->get('drivingLicence');
// echo '<pre> licencia';
// print_r($data_input);
// die;
$message_error_expi_date = 'La fecha de vencimiento no puede ser menor a la de expedición';
$validator... |
TO DO:delete all files | public function actionRestartqueue() {
if (!empty($_POST['id']))
{
CConvertQueue::model()->restartUserQueue($this->user_id, $_POST['id']);
}
} |
defineHandlers Un(Install) Install module | function install() {
/*
* do some stuff at install db table creation/modification, email template creation etc.
*
*
*/
return parent::install();
} |
Lists all Erform models. | public function actionIndex()
{
$searchModel = new ErformSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$erform = Erform::find()->where(['etype' => 1])->all();
$erform2 = Erform::find()->where(['etype' => 2])->all();
$erform3 = Erform::find()... |
Retrieve a single order from the database. | public function get_order_data_from_table( $order ) {
global $wpdb;
return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}woocommerce_orders WHERE order_id = %d;", $order->get_id() ) );
} |
Check for SHA 256 string validity | public static function isSha256($sha1)
{
return preg_match('/^[a-fA-F0-9]{64}$/', $sha1);
} |
Get historical currency exchange rates. | protected function query($date, $base, array $targets)
{
$url = self::URL . $date;
$query = [];
if ($base != 'EUR') {
$query['base'] = $base;
}
// add symbols to query string
if (!empty($targets)) {
$query['symbols'] = implode(',', $... |
Create User Profile for newly registered User with given columns With User Model. | public function create(array $columns, $type, UserModelInterface $user); |
Creates admin user id with status draft and redirects to update if success | public function create()
{
$data = ['user_role_id' => USER_ROLE_ADMINISTRATOR];
if ($id = $this->users_model->save($data)) {
//if user has not access to update
$this->session->set_userdata(['new_item' => ['module' => 'administrators', 'id' => $id]]);
redirect("/admin/users/update/$id");
}
else {
... |
Display a listing of the products. | public function index()
{
$products = $this->products->paginate(10);
return view('products.index', compact('products'));
} |
return a sanitize_callback for serialized data | public function sanitizeCallback($type, $k) {
switch($type) {
case 'boolean':
return function($v) use ($k) {
if (!is_array($v)) return (bool) $v;
if (isset($v[$k])) $v[$k] = (bool) $v[$k];
return $v;
... |
Set success message and redirect to successUrl page. | public function redirect(Event $event)
{
/** @var PluginController $controller */
$controller = $event->getSubject();
$controller->Flash->success(__d('users', 'Restore password confirmation was sent.'));
return $controller->redirect($this->getConfig('successUrl'));
} |
check this option with user access | private function check_access_to_option(array $_option, int $_user_id)
{
$user_access_code = $this->check_user_access((int) $_user_id);
if (!$user_access_code) {
return false;
}
return true;
} |
Return customers who made changes | private function getCourseEditors()
{
return $this->entityManager->createQueryBuilder()
->select('customer')
->from(Customer::class, 'customer')
->innerJoin(ActionLog::class, 'log', Expr\Join::WITH, 'customer.id = log.user')
->where('customer.id in (:ids)')
... |
Creates a client token signature When client from browser wants to connect to Centrifuge he must send his user ID and ID of project. To validate that data we use HMAC to build token. | public function get_client_token($user, $timestamp, $custom_data = false )
{
if($custom_data == true)
{
$token = hash_hmac($this->settings['encryption'], $this->settings['project_id'] . $user . $timestamp . $custom_data, $this->settings['secret_key'], false );
}
else
{
$token = hash_hmac($this->setting... |
Return an instance of DOMDocument constructed with the property of results | protected function getDom()
{
if (! isset($this->dom)) {
$dom = new DOMDocument();
if (is_null($this->getResults())) {
throw new \RuntimeException('There doesnt appear to be any results to load');
}
// suppress warning but throw Exception
... |
Display a listing of the resource. | public function index()
{
return view('codifications.index');
} |
Search in names of entities | public function search($query) {
$queryBuilder = $this->db->createQueryBuilder();
$queryBuilder
->select('c.*')
->from($this->table, 'c');
$queryBuilder->where("c.`name` LIKE :query");
$queryBuilder->setParameter(':query', "%$query%");
$queryBuilder->orde... |
Determine if the user is authorized to make this request. | public function authorize(): bool
{
return auth('api')->check();
} |
A user can have many posts. | public function posts()
{
return $this->hasMany(Post::class);
} |
Transform each stream element int a tuple (array of 2 elements) where the first element is the result of the callback applied to the element value and the second is the element value. | public function keyBy(callable $callback): Stream {
$generator = function (Stream $stream) use ($callback) {
foreach ($stream as $value) {
yield [$callback($value), $value];
}
};
return new Stream($generator($this));
} |
Handler to actual send replyrelated activity payload. | private function notify_forum_reply_payload( $activity, $reply_id ) {
if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) {
return;
}
if ( ! bbp_is_site_public() ) {
return;
}
if ( ! in_array( $activity, array( 'create-reply', 'remove-reply' ), true ) ) {
return;
}
if ( 'create-reply' === $activi... |
Adds additional entries to the specifed option field. | public function add($field, array $dependencies)
{
if (! file_exists($this->file)) {
throw new RuntimeException("Could not add dependencies, `package.json` file do not exists.");
}
$packages = json_decode(file_get_contents($this->file), true);
$packages[$field] = $depen... |
Execute a select query and return the first entity | public function selectOne(Query\Select $query): ?Entity
{
return $this->db->selectOne($this->klass, $query);
} |
Parses pattern based on ICU grammar. | private static function parseToken(array $token, array $values, $locale)
{
if (!isset($values[$param = trim($token[0])])) {
return '{'.$param.'}';
}
$arg = $values[$param];
$type = isset($token[1]) ? trim($token[1]) : 'none';
switch ($type) {
case 'da... |
Return the HTML for the Categories section. | public function get_sidebar_categories(){
$html = '<tr class="wm-widget-sub-title"><td>{{categories-title}}:</td></tr><tr class="wm-widget-info"><td>';
$categories = get_the_category();
$output = '';
foreach( $categories as $category ){
$id = get_cat_ID(... |
Filter the element input. | public function filterElementInputMmd($components, $args)
{
$db = get_db();
$element = $args['element'];
$record = $args['record'];
$elementName = $element->name;
$elementId = $element->id;
$recordId = $record->id;
$index = $args['index'];
$mmdManua... |
Deletes a particular model. If deletion is successful, the browser will be redirected to the 'admin' page. | public function actionDelete($id) {
$persona = Persona::model()->with(array('titularidad', 'cotitularidad'))->findByPk($id);
if (is_null($persona->titularidad) && is_null($persona->cotitularidad)) {
$persona->delete();
} else {
http_response_code(400);
header('Content-type: ... |
parrafo a lo que venga | function parrafo($text){
return "<p>$text</p>";
} |
Function to convert base64 image source to actual image (saved in folder "upload/image/") from textarea | public function convert_inline($str = '', $new_name = '', $mark = 'inline-')
{
$img = array();
$start = '<img';
$end = '>';
$pattern = sprintf('/%s(.+?)%s/ims', preg_quote($start, '/'), preg_quote($end, '/'));
$search = true;
$i = 1;
while($search)
{
if (preg_match($pattern, $str, $matches)... |
A list of inputs that should be accepted. Currently only `dtmf` is supported. All digits captured during a pay session are redacted from the logs. | public function setInput(string $input): self
{
$this->options['input'] = $input;
return $this;
} |
Store a newly created ipcontaip_10 in storage. | public function store(Createipcontaip_10Request $request)
{
$input = $request->all();
$ipcontaip10 = $this->ipcontaip10Repository->create($input);
Flash::success(__('messages.saved', ['model' => __('models/ipcontaip10s.singular')]));
return redirect(route('ipcontaip10s.index'));
... |
Return the type of the response as a string. | public function getType(): string; |
get SessionID Returns:A unique identifier for the session in the service that raised the event. | public function getSessionID()
{
return $this->getKey('SessionID');
} |
Gets the Relation if the embed is a valid relation to the main model. Also handles nested relationships | protected function getValidRelation($relation_models)
{
/**
* @var Relation $actual_relation
*/
$manager = $this->main_model_obj->getModelsManager();
$_model = $this->main_model;
$actual_relation = null;
foreach ($relation_models as $model){
$re... |
Update the specified resource in storage. | public function update(Request $request, $id)
{
$this->validate($request, [
'name'=>'required|max:120',
'short_name'=>'required|max:10|min:3',
]);
//\Auth::user()->activity;
$company = Company::findOrFail($id);
$company->name = $request['name'];
... |
check if multiple variables exists | public static function mx()
{
for ($i = 0; $i < func_num_args(); $i++) {
$arg = func_get_arg($i);
if (self::nx(@$arg)) {
return false;
}
}
return true;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.