id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
223,300
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getWorkspaceTags
|
public function getWorkspaceTags($workspaceId = null)
{
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("workspaces/{$workspaceId}/tags");
}
|
php
|
public function getWorkspaceTags($workspaceId = null)
{
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("workspaces/{$workspaceId}/tags");
}
|
[
"public",
"function",
"getWorkspaceTags",
"(",
"$",
"workspaceId",
"=",
"null",
")",
"{",
"$",
"workspaceId",
"=",
"$",
"workspaceId",
"?",
":",
"$",
"this",
"->",
"defaultWorkspaceId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"workspaces/{$workspaceId}/tags\"",
")",
";",
"}"
] |
Returns tags of all workspace.
@param string $workspaceId The id of the workspace
@return string|null
|
[
"Returns",
"tags",
"of",
"all",
"workspace",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L604-L609
|
223,301
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getWorkspaceUsers
|
public function getWorkspaceUsers($workspaceId = null)
{
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("workspaces/{$workspaceId}/users");
}
|
php
|
public function getWorkspaceUsers($workspaceId = null)
{
$workspaceId = $workspaceId ?: $this->defaultWorkspaceId;
return $this->curl->get("workspaces/{$workspaceId}/users");
}
|
[
"public",
"function",
"getWorkspaceUsers",
"(",
"$",
"workspaceId",
"=",
"null",
")",
"{",
"$",
"workspaceId",
"=",
"$",
"workspaceId",
"?",
":",
"$",
"this",
"->",
"defaultWorkspaceId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"workspaces/{$workspaceId}/users\"",
")",
";",
"}"
] |
Returns users of all workspace.
@param string $workspaceId The id of the workspace
@return string|null
|
[
"Returns",
"users",
"of",
"all",
"workspace",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L618-L623
|
223,302
|
Torann/laravel-asana
|
src/Asana.php
|
Asana.getProjectEvents
|
public function getProjectEvents($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("projects/{$projectId}/events");
}
|
php
|
public function getProjectEvents($projectId = null)
{
$projectId = $projectId ?: $this->defaultProjectId;
return $this->curl->get("projects/{$projectId}/events");
}
|
[
"public",
"function",
"getProjectEvents",
"(",
"$",
"projectId",
"=",
"null",
")",
"{",
"$",
"projectId",
"=",
"$",
"projectId",
"?",
":",
"$",
"this",
"->",
"defaultProjectId",
";",
"return",
"$",
"this",
"->",
"curl",
"->",
"get",
"(",
"\"projects/{$projectId}/events\"",
")",
";",
"}"
] |
Returns events of a given project
@param string $projectId The id of the project
@return string|null
|
[
"Returns",
"events",
"of",
"a",
"given",
"project"
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/Asana.php#L632-L637
|
223,303
|
stuttter/wp-event-calendar
|
wp-event-calendar/includes/common/list-table-day.php
|
WP_Event_Calendar_Day_Table.setup_item
|
protected function setup_item( $post = false, $max = 10 ) {
// Calculate start day
if ( ! empty( $this->item_start ) ) {
$start_day = date_i18n( 'j', $this->item_start );
$start_hour = date_i18n( 'G', $this->item_start );
} else {
$start_day = 0;
$start_hour = 0;
}
// Calculate end day
if ( ! empty( $this->item_end ) ) {
$end_day = date_i18n( 'j', $this->item_end );
$end_hour = date_i18n( 'G', $this->item_end );
} else {
$end_day = $start_day;
$end_hour = $start_hour;
}
// All day events (and days that overlap multiple days)
if ( ( true === $this->item_all_day ) || ( $this->item_days > 1 ) || ( $start_day !== $end_day ) ) {
// What type of item is this?
$type = ( true === $this->item_all_day )
? 'all_day_items'
: 'multi_day_items';
// Math the heck out of this
$interval = 1;
$offset = 0;
$cell = $offset;
$end_cell = ( $end_day * $start_day ) + $offset;
// Regular single-day events
} else {
$type = 'items';
$interval = 1;
// Calculate the cell offset
$offset = intval( ( $this->item_start - $this->day_start ) / DAY_IN_SECONDS );
$cell = ( $start_hour * $interval ) + $offset;
$end_cell = ( $end_hour * $interval ) + $offset;
}
// Loop through days
while ( $cell <= $end_cell ) {
// Setup the pointer for each day
$this->setup_pointer( $post, $cell );
// Add post to items for each day in it's duration
if ( empty( $this->{$type}[ $cell ] ) || ( $max > count( $this->{$type}[ $cell ] ) ) ) {
$this->{$type}[ $cell ][ $post->ID ] = $post;
}
// Bump the hour
$cell = intval( $cell + $interval );
}
}
|
php
|
protected function setup_item( $post = false, $max = 10 ) {
// Calculate start day
if ( ! empty( $this->item_start ) ) {
$start_day = date_i18n( 'j', $this->item_start );
$start_hour = date_i18n( 'G', $this->item_start );
} else {
$start_day = 0;
$start_hour = 0;
}
// Calculate end day
if ( ! empty( $this->item_end ) ) {
$end_day = date_i18n( 'j', $this->item_end );
$end_hour = date_i18n( 'G', $this->item_end );
} else {
$end_day = $start_day;
$end_hour = $start_hour;
}
// All day events (and days that overlap multiple days)
if ( ( true === $this->item_all_day ) || ( $this->item_days > 1 ) || ( $start_day !== $end_day ) ) {
// What type of item is this?
$type = ( true === $this->item_all_day )
? 'all_day_items'
: 'multi_day_items';
// Math the heck out of this
$interval = 1;
$offset = 0;
$cell = $offset;
$end_cell = ( $end_day * $start_day ) + $offset;
// Regular single-day events
} else {
$type = 'items';
$interval = 1;
// Calculate the cell offset
$offset = intval( ( $this->item_start - $this->day_start ) / DAY_IN_SECONDS );
$cell = ( $start_hour * $interval ) + $offset;
$end_cell = ( $end_hour * $interval ) + $offset;
}
// Loop through days
while ( $cell <= $end_cell ) {
// Setup the pointer for each day
$this->setup_pointer( $post, $cell );
// Add post to items for each day in it's duration
if ( empty( $this->{$type}[ $cell ] ) || ( $max > count( $this->{$type}[ $cell ] ) ) ) {
$this->{$type}[ $cell ][ $post->ID ] = $post;
}
// Bump the hour
$cell = intval( $cell + $interval );
}
}
|
[
"protected",
"function",
"setup_item",
"(",
"$",
"post",
"=",
"false",
",",
"$",
"max",
"=",
"10",
")",
"{",
"// Calculate start day",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"item_start",
")",
")",
"{",
"$",
"start_day",
"=",
"date_i18n",
"(",
"'j'",
",",
"$",
"this",
"->",
"item_start",
")",
";",
"$",
"start_hour",
"=",
"date_i18n",
"(",
"'G'",
",",
"$",
"this",
"->",
"item_start",
")",
";",
"}",
"else",
"{",
"$",
"start_day",
"=",
"0",
";",
"$",
"start_hour",
"=",
"0",
";",
"}",
"// Calculate end day",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"item_end",
")",
")",
"{",
"$",
"end_day",
"=",
"date_i18n",
"(",
"'j'",
",",
"$",
"this",
"->",
"item_end",
")",
";",
"$",
"end_hour",
"=",
"date_i18n",
"(",
"'G'",
",",
"$",
"this",
"->",
"item_end",
")",
";",
"}",
"else",
"{",
"$",
"end_day",
"=",
"$",
"start_day",
";",
"$",
"end_hour",
"=",
"$",
"start_hour",
";",
"}",
"// All day events (and days that overlap multiple days)",
"if",
"(",
"(",
"true",
"===",
"$",
"this",
"->",
"item_all_day",
")",
"||",
"(",
"$",
"this",
"->",
"item_days",
">",
"1",
")",
"||",
"(",
"$",
"start_day",
"!==",
"$",
"end_day",
")",
")",
"{",
"// What type of item is this?",
"$",
"type",
"=",
"(",
"true",
"===",
"$",
"this",
"->",
"item_all_day",
")",
"?",
"'all_day_items'",
":",
"'multi_day_items'",
";",
"// Math the heck out of this",
"$",
"interval",
"=",
"1",
";",
"$",
"offset",
"=",
"0",
";",
"$",
"cell",
"=",
"$",
"offset",
";",
"$",
"end_cell",
"=",
"(",
"$",
"end_day",
"*",
"$",
"start_day",
")",
"+",
"$",
"offset",
";",
"// Regular single-day events",
"}",
"else",
"{",
"$",
"type",
"=",
"'items'",
";",
"$",
"interval",
"=",
"1",
";",
"// Calculate the cell offset",
"$",
"offset",
"=",
"intval",
"(",
"(",
"$",
"this",
"->",
"item_start",
"-",
"$",
"this",
"->",
"day_start",
")",
"/",
"DAY_IN_SECONDS",
")",
";",
"$",
"cell",
"=",
"(",
"$",
"start_hour",
"*",
"$",
"interval",
")",
"+",
"$",
"offset",
";",
"$",
"end_cell",
"=",
"(",
"$",
"end_hour",
"*",
"$",
"interval",
")",
"+",
"$",
"offset",
";",
"}",
"// Loop through days",
"while",
"(",
"$",
"cell",
"<=",
"$",
"end_cell",
")",
"{",
"// Setup the pointer for each day",
"$",
"this",
"->",
"setup_pointer",
"(",
"$",
"post",
",",
"$",
"cell",
")",
";",
"// Add post to items for each day in it's duration",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"[",
"$",
"cell",
"]",
")",
"||",
"(",
"$",
"max",
">",
"count",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"[",
"$",
"cell",
"]",
")",
")",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"[",
"$",
"cell",
"]",
"[",
"$",
"post",
"->",
"ID",
"]",
"=",
"$",
"post",
";",
"}",
"// Bump the hour",
"$",
"cell",
"=",
"intval",
"(",
"$",
"cell",
"+",
"$",
"interval",
")",
";",
"}",
"}"
] |
Add a post to the items array, keyed by day
@todo Repeat & expire
@since 0.1.8
@param object $post
@param int $max
|
[
"Add",
"a",
"post",
"to",
"the",
"items",
"array",
"keyed",
"by",
"day"
] |
e2221b52f0683c105c64fca056daa63763ea8665
|
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/list-table-day.php#L109-L168
|
223,304
|
stuttter/wp-event-calendar
|
wp-event-calendar/includes/common/list-table-day.php
|
WP_Event_Calendar_Day_Table.pagination
|
protected function pagination( $args = array() ) {
// Parse args
$r = wp_parse_args( $args, array(
'small' => '1 day',
'large' => '1 week',
'labels' => array(
'next_small' => esc_html__( 'Tomorrow', 'wp-event-calendar' ),
'next_large' => esc_html__( 'Next Week', 'wp-event-calendar' ),
'prev_small' => esc_html__( 'Yerterday', 'wp-event-calendar' ),
'prev_large' => esc_html__( 'Previous Week', 'wp-event-calendar' )
)
) );
// Return pagination
return parent::pagination( $r );
}
|
php
|
protected function pagination( $args = array() ) {
// Parse args
$r = wp_parse_args( $args, array(
'small' => '1 day',
'large' => '1 week',
'labels' => array(
'next_small' => esc_html__( 'Tomorrow', 'wp-event-calendar' ),
'next_large' => esc_html__( 'Next Week', 'wp-event-calendar' ),
'prev_small' => esc_html__( 'Yerterday', 'wp-event-calendar' ),
'prev_large' => esc_html__( 'Previous Week', 'wp-event-calendar' )
)
) );
// Return pagination
return parent::pagination( $r );
}
|
[
"protected",
"function",
"pagination",
"(",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"// Parse args",
"$",
"r",
"=",
"wp_parse_args",
"(",
"$",
"args",
",",
"array",
"(",
"'small'",
"=>",
"'1 day'",
",",
"'large'",
"=>",
"'1 week'",
",",
"'labels'",
"=>",
"array",
"(",
"'next_small'",
"=>",
"esc_html__",
"(",
"'Tomorrow'",
",",
"'wp-event-calendar'",
")",
",",
"'next_large'",
"=>",
"esc_html__",
"(",
"'Next Week'",
",",
"'wp-event-calendar'",
")",
",",
"'prev_small'",
"=>",
"esc_html__",
"(",
"'Yerterday'",
",",
"'wp-event-calendar'",
")",
",",
"'prev_large'",
"=>",
"esc_html__",
"(",
"'Previous Week'",
",",
"'wp-event-calendar'",
")",
")",
")",
")",
";",
"// Return pagination",
"return",
"parent",
"::",
"pagination",
"(",
"$",
"r",
")",
";",
"}"
] |
Paginate through days & weeks
@since 0.1.8
@param array $args
|
[
"Paginate",
"through",
"days",
"&",
"weeks"
] |
e2221b52f0683c105c64fca056daa63763ea8665
|
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/list-table-day.php#L177-L193
|
223,305
|
stuttter/wp-event-calendar
|
wp-event-calendar/includes/common/list-table-day.php
|
WP_Event_Calendar_Day_Table.display_mode
|
protected function display_mode() {
// Get timestamp
$timestamp = mktime( 0, 0, 0, $this->month, $this->day, $this->year );
$this_month = getdate( $timestamp );
$start_day = $this_month['wday'];
// All day events
echo $this->get_all_day_row();
// Multi day events
echo $this->get_multi_day_row();
// Loop through days of the month
for ( $i = 0; $i <= ( 24 - 1 ); $i++ ) {
// Get timestamp & hour
$timestamp = mktime( $i, 0, 0, $this->month, $this->day, $this->year );
// New row
echo $this->get_row_start( $timestamp );
// Get this table cell
echo $this->get_row_cell( $i, $start_day );
// Close row
echo $this->get_row_end();
}
}
|
php
|
protected function display_mode() {
// Get timestamp
$timestamp = mktime( 0, 0, 0, $this->month, $this->day, $this->year );
$this_month = getdate( $timestamp );
$start_day = $this_month['wday'];
// All day events
echo $this->get_all_day_row();
// Multi day events
echo $this->get_multi_day_row();
// Loop through days of the month
for ( $i = 0; $i <= ( 24 - 1 ); $i++ ) {
// Get timestamp & hour
$timestamp = mktime( $i, 0, 0, $this->month, $this->day, $this->year );
// New row
echo $this->get_row_start( $timestamp );
// Get this table cell
echo $this->get_row_cell( $i, $start_day );
// Close row
echo $this->get_row_end();
}
}
|
[
"protected",
"function",
"display_mode",
"(",
")",
"{",
"// Get timestamp",
"$",
"timestamp",
"=",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"month",
",",
"$",
"this",
"->",
"day",
",",
"$",
"this",
"->",
"year",
")",
";",
"$",
"this_month",
"=",
"getdate",
"(",
"$",
"timestamp",
")",
";",
"$",
"start_day",
"=",
"$",
"this_month",
"[",
"'wday'",
"]",
";",
"// All day events",
"echo",
"$",
"this",
"->",
"get_all_day_row",
"(",
")",
";",
"// Multi day events",
"echo",
"$",
"this",
"->",
"get_multi_day_row",
"(",
")",
";",
"// Loop through days of the month",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<=",
"(",
"24",
"-",
"1",
")",
";",
"$",
"i",
"++",
")",
"{",
"// Get timestamp & hour",
"$",
"timestamp",
"=",
"mktime",
"(",
"$",
"i",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"month",
",",
"$",
"this",
"->",
"day",
",",
"$",
"this",
"->",
"year",
")",
";",
"// New row",
"echo",
"$",
"this",
"->",
"get_row_start",
"(",
"$",
"timestamp",
")",
";",
"// Get this table cell",
"echo",
"$",
"this",
"->",
"get_row_cell",
"(",
"$",
"i",
",",
"$",
"start_day",
")",
";",
"// Close row",
"echo",
"$",
"this",
"->",
"get_row_end",
"(",
")",
";",
"}",
"}"
] |
Display a calendar by mode & range
@since 0.1.8
|
[
"Display",
"a",
"calendar",
"by",
"mode",
"&",
"range"
] |
e2221b52f0683c105c64fca056daa63763ea8665
|
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/list-table-day.php#L333-L361
|
223,306
|
mjanser/php-systemctl
|
Service.php
|
Service.isRunning
|
public function isRunning()
{
$process = $this->getProcess([
'--lines=0',
'status',
$this->name,
]);
$process->run();
if ($process->isSuccessful()) {
return true;
}
if (self::STATUS_STOPPED === $process->getExitCode()) {
return false;
}
throw new CommandFailedException($process);
}
|
php
|
public function isRunning()
{
$process = $this->getProcess([
'--lines=0',
'status',
$this->name,
]);
$process->run();
if ($process->isSuccessful()) {
return true;
}
if (self::STATUS_STOPPED === $process->getExitCode()) {
return false;
}
throw new CommandFailedException($process);
}
|
[
"public",
"function",
"isRunning",
"(",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"getProcess",
"(",
"[",
"'--lines=0'",
",",
"'status'",
",",
"$",
"this",
"->",
"name",
",",
"]",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"if",
"(",
"$",
"process",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"self",
"::",
"STATUS_STOPPED",
"===",
"$",
"process",
"->",
"getExitCode",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"throw",
"new",
"CommandFailedException",
"(",
"$",
"process",
")",
";",
"}"
] |
Checks whether or not the service is running.
@throws CommandFailedException If the command failed
@return bool
|
[
"Checks",
"whether",
"or",
"not",
"the",
"service",
"is",
"running",
"."
] |
d3e11f6451260bfbb935830d444e16b0dfc7de31
|
https://github.com/mjanser/php-systemctl/blob/d3e11f6451260bfbb935830d444e16b0dfc7de31/Service.php#L87-L105
|
223,307
|
mjanser/php-systemctl
|
Service.php
|
Service.stop
|
public function stop()
{
if (!$this->isRunning()) {
return;
}
$process = $this->getProcess([
'stop',
$this->name,
]);
$process->run();
if (!$process->isSuccessful()) {
throw new CommandFailedException($process);
}
}
|
php
|
public function stop()
{
if (!$this->isRunning()) {
return;
}
$process = $this->getProcess([
'stop',
$this->name,
]);
$process->run();
if (!$process->isSuccessful()) {
throw new CommandFailedException($process);
}
}
|
[
"public",
"function",
"stop",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRunning",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"process",
"=",
"$",
"this",
"->",
"getProcess",
"(",
"[",
"'stop'",
",",
"$",
"this",
"->",
"name",
",",
"]",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"process",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"throw",
"new",
"CommandFailedException",
"(",
"$",
"process",
")",
";",
"}",
"}"
] |
Stops the service.
@throws CommandFailedException If the command failed
|
[
"Stops",
"the",
"service",
"."
] |
d3e11f6451260bfbb935830d444e16b0dfc7de31
|
https://github.com/mjanser/php-systemctl/blob/d3e11f6451260bfbb935830d444e16b0dfc7de31/Service.php#L135-L151
|
223,308
|
mjanser/php-systemctl
|
Service.php
|
Service.restart
|
public function restart()
{
$process = $this->getProcess([
'restart',
$this->name,
]);
$process->run();
if (!$process->isSuccessful()) {
throw new CommandFailedException($process);
}
}
|
php
|
public function restart()
{
$process = $this->getProcess([
'restart',
$this->name,
]);
$process->run();
if (!$process->isSuccessful()) {
throw new CommandFailedException($process);
}
}
|
[
"public",
"function",
"restart",
"(",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"getProcess",
"(",
"[",
"'restart'",
",",
"$",
"this",
"->",
"name",
",",
"]",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"process",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"throw",
"new",
"CommandFailedException",
"(",
"$",
"process",
")",
";",
"}",
"}"
] |
Restarts the service.
@throws CommandFailedException If the command failed
|
[
"Restarts",
"the",
"service",
"."
] |
d3e11f6451260bfbb935830d444e16b0dfc7de31
|
https://github.com/mjanser/php-systemctl/blob/d3e11f6451260bfbb935830d444e16b0dfc7de31/Service.php#L158-L170
|
223,309
|
mjanser/php-systemctl
|
Service.php
|
Service.getProcess
|
private function getProcess(array $arguments)
{
$command = explode(' ', self::$command);
if (self::$sudo) {
array_unshift($command, 'sudo');
}
$command = array_merge($command, $arguments);
$process = new Process($command);
$process->setTimeout(self::$timeout);
return $process;
}
|
php
|
private function getProcess(array $arguments)
{
$command = explode(' ', self::$command);
if (self::$sudo) {
array_unshift($command, 'sudo');
}
$command = array_merge($command, $arguments);
$process = new Process($command);
$process->setTimeout(self::$timeout);
return $process;
}
|
[
"private",
"function",
"getProcess",
"(",
"array",
"$",
"arguments",
")",
"{",
"$",
"command",
"=",
"explode",
"(",
"' '",
",",
"self",
"::",
"$",
"command",
")",
";",
"if",
"(",
"self",
"::",
"$",
"sudo",
")",
"{",
"array_unshift",
"(",
"$",
"command",
",",
"'sudo'",
")",
";",
"}",
"$",
"command",
"=",
"array_merge",
"(",
"$",
"command",
",",
"$",
"arguments",
")",
";",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"command",
")",
";",
"$",
"process",
"->",
"setTimeout",
"(",
"self",
"::",
"$",
"timeout",
")",
";",
"return",
"$",
"process",
";",
"}"
] |
Creates and prepares a process.
@param string[] $arguments
@return Process
|
[
"Creates",
"and",
"prepares",
"a",
"process",
"."
] |
d3e11f6451260bfbb935830d444e16b0dfc7de31
|
https://github.com/mjanser/php-systemctl/blob/d3e11f6451260bfbb935830d444e16b0dfc7de31/Service.php#L187-L199
|
223,310
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getSingleIdReflectionProperty
|
public function getSingleIdReflectionProperty()
{
if ($this->isIdentifierComposite) {
throw new BadMethodCallException("Class " . $this->name . " has a composite identifier.");
}
return $this->reflFields[$this->identifier[0]];
}
|
php
|
public function getSingleIdReflectionProperty()
{
if ($this->isIdentifierComposite) {
throw new BadMethodCallException("Class " . $this->name . " has a composite identifier.");
}
return $this->reflFields[$this->identifier[0]];
}
|
[
"public",
"function",
"getSingleIdReflectionProperty",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isIdentifierComposite",
")",
"{",
"throw",
"new",
"BadMethodCallException",
"(",
"\"Class \"",
".",
"$",
"this",
"->",
"name",
".",
"\" has a composite identifier.\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"reflFields",
"[",
"$",
"this",
"->",
"identifier",
"[",
"0",
"]",
"]",
";",
"}"
] |
Gets the ReflectionProperty for the single identifier field.
@return \ReflectionProperty
@throws BadMethodCallException If the class has a composite identifier.
|
[
"Gets",
"the",
"ReflectionProperty",
"for",
"the",
"single",
"identifier",
"field",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L697-L703
|
223,311
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getIdentifierValues
|
public function getIdentifierValues($entity)
{
if ($this->isIdentifierComposite) {
$id = array();
foreach ($this->identifier as $idField) {
$value = $this->reflFields[$idField]->getValue($entity);
if ($value !== null) {
$id[$idField] = $value;
}
}
return $id;
}
$id = $this->identifier[0];
$value = $this->reflFields[$id]->getValue($entity);
if (null === $value) {
return array();
}
return array($id => $value);
}
|
php
|
public function getIdentifierValues($entity)
{
if ($this->isIdentifierComposite) {
$id = array();
foreach ($this->identifier as $idField) {
$value = $this->reflFields[$idField]->getValue($entity);
if ($value !== null) {
$id[$idField] = $value;
}
}
return $id;
}
$id = $this->identifier[0];
$value = $this->reflFields[$id]->getValue($entity);
if (null === $value) {
return array();
}
return array($id => $value);
}
|
[
"public",
"function",
"getIdentifierValues",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isIdentifierComposite",
")",
"{",
"$",
"id",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"identifier",
"as",
"$",
"idField",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"reflFields",
"[",
"$",
"idField",
"]",
"->",
"getValue",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"$",
"id",
"[",
"$",
"idField",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"id",
";",
"}",
"$",
"id",
"=",
"$",
"this",
"->",
"identifier",
"[",
"0",
"]",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"reflFields",
"[",
"$",
"id",
"]",
"->",
"getValue",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"array",
"(",
"$",
"id",
"=>",
"$",
"value",
")",
";",
"}"
] |
Extracts the identifier values of an entity of this class.
For composite identifiers, the identifier values are returned as an array
with the same order as the field order in {@link identifier}.
@param object $entity
@return array
|
[
"Extracts",
"the",
"identifier",
"values",
"of",
"an",
"entity",
"of",
"this",
"class",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L715-L739
|
223,312
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.isNullable
|
public function isNullable($fieldName)
{
$mapping = $this->getFieldMapping($fieldName);
if ($mapping !== false) {
return isset($mapping['nullable']) && $mapping['nullable'] == true;
}
return false;
}
|
php
|
public function isNullable($fieldName)
{
$mapping = $this->getFieldMapping($fieldName);
if ($mapping !== false) {
return isset($mapping['nullable']) && $mapping['nullable'] == true;
}
return false;
}
|
[
"public",
"function",
"isNullable",
"(",
"$",
"fieldName",
")",
"{",
"$",
"mapping",
"=",
"$",
"this",
"->",
"getFieldMapping",
"(",
"$",
"fieldName",
")",
";",
"if",
"(",
"$",
"mapping",
"!==",
"false",
")",
"{",
"return",
"isset",
"(",
"$",
"mapping",
"[",
"'nullable'",
"]",
")",
"&&",
"$",
"mapping",
"[",
"'nullable'",
"]",
"==",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Checks if the field is not null.
@param string $fieldName The field name.
@return boolean TRUE if the field is not null, FALSE otherwise.
|
[
"Checks",
"if",
"the",
"field",
"is",
"not",
"null",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1193-L1200
|
223,313
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getColumnName
|
public function getColumnName($fieldName)
{
return isset($this->columnNames[$fieldName]) ?
$this->columnNames[$fieldName] : $fieldName;
}
|
php
|
public function getColumnName($fieldName)
{
return isset($this->columnNames[$fieldName]) ?
$this->columnNames[$fieldName] : $fieldName;
}
|
[
"public",
"function",
"getColumnName",
"(",
"$",
"fieldName",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"columnNames",
"[",
"$",
"fieldName",
"]",
")",
"?",
"$",
"this",
"->",
"columnNames",
"[",
"$",
"fieldName",
"]",
":",
"$",
"fieldName",
";",
"}"
] |
Gets a column name for a field name.
If the column name for the field cannot be found, the given field name
is returned.
@param string $fieldName The field name.
@return string The column name.
|
[
"Gets",
"a",
"column",
"name",
"for",
"a",
"field",
"name",
".",
"If",
"the",
"column",
"name",
"for",
"the",
"field",
"cannot",
"be",
"found",
"the",
"given",
"field",
"name",
"is",
"returned",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1211-L1215
|
223,314
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getAssociationMapping
|
public function getAssociationMapping($fieldName)
{
if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::mappingNotFound($this->name, $fieldName);
}
return $this->associationMappings[$fieldName];
}
|
php
|
public function getAssociationMapping($fieldName)
{
if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::mappingNotFound($this->name, $fieldName);
}
return $this->associationMappings[$fieldName];
}
|
[
"public",
"function",
"getAssociationMapping",
"(",
"$",
"fieldName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"mappingNotFound",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"fieldName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
";",
"}"
] |
Gets the mapping of an association.
@see ClassMetadataInfo::$associationMappings
@param string $fieldName The field name that represents the association in
the object model.
@return array The mapping.
@throws MappingException
|
[
"Gets",
"the",
"mapping",
"of",
"an",
"association",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1247-L1253
|
223,315
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getFieldName
|
public function getFieldName($columnName)
{
return isset($this->fieldNames[$columnName]) ?
$this->fieldNames[$columnName] : $columnName;
}
|
php
|
public function getFieldName($columnName)
{
return isset($this->fieldNames[$columnName]) ?
$this->fieldNames[$columnName] : $columnName;
}
|
[
"public",
"function",
"getFieldName",
"(",
"$",
"columnName",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"columnName",
"]",
")",
"?",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"columnName",
"]",
":",
"$",
"columnName",
";",
"}"
] |
Gets the field name for a column name.
If no field name can be found the column name is returned.
@param string $columnName The column name.
@return string The column alias.
|
[
"Gets",
"the",
"field",
"name",
"for",
"a",
"column",
"name",
".",
"If",
"no",
"field",
"name",
"can",
"be",
"found",
"the",
"column",
"name",
"is",
"returned",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1273-L1277
|
223,316
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getNamedQuery
|
public function getNamedQuery($queryName)
{
if ( ! isset($this->namedQueries[$queryName])) {
throw MappingException::queryNotFound($this->name, $queryName);
}
return $this->namedQueries[$queryName]['dql'];
}
|
php
|
public function getNamedQuery($queryName)
{
if ( ! isset($this->namedQueries[$queryName])) {
throw MappingException::queryNotFound($this->name, $queryName);
}
return $this->namedQueries[$queryName]['dql'];
}
|
[
"public",
"function",
"getNamedQuery",
"(",
"$",
"queryName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"namedQueries",
"[",
"$",
"queryName",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"queryNotFound",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"queryName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"namedQueries",
"[",
"$",
"queryName",
"]",
"[",
"'dql'",
"]",
";",
"}"
] |
Gets the named query.
@see ClassMetadataInfo::$namedQueries
@param string $queryName The query name.
@return string
@throws MappingException
|
[
"Gets",
"the",
"named",
"query",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1290-L1296
|
223,317
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getNamedNativeQuery
|
public function getNamedNativeQuery($queryName)
{
if ( ! isset($this->namedNativeQueries[$queryName])) {
throw MappingException::queryNotFound($this->name, $queryName);
}
return $this->namedNativeQueries[$queryName];
}
|
php
|
public function getNamedNativeQuery($queryName)
{
if ( ! isset($this->namedNativeQueries[$queryName])) {
throw MappingException::queryNotFound($this->name, $queryName);
}
return $this->namedNativeQueries[$queryName];
}
|
[
"public",
"function",
"getNamedNativeQuery",
"(",
"$",
"queryName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"namedNativeQueries",
"[",
"$",
"queryName",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"queryNotFound",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"queryName",
")",
";",
"}",
"return",
"$",
"this",
"->",
"namedNativeQueries",
"[",
"$",
"queryName",
"]",
";",
"}"
] |
Gets the named native query.
@see ClassMetadataInfo::$namedNativeQueries
@param string $queryName The query name.
@return array
@throws MappingException
|
[
"Gets",
"the",
"named",
"native",
"query",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1319-L1326
|
223,318
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getSqlResultSetMapping
|
public function getSqlResultSetMapping($name)
{
if ( ! isset($this->sqlResultSetMappings[$name])) {
throw MappingException::resultMappingNotFound($this->name, $name);
}
return $this->sqlResultSetMappings[$name];
}
|
php
|
public function getSqlResultSetMapping($name)
{
if ( ! isset($this->sqlResultSetMappings[$name])) {
throw MappingException::resultMappingNotFound($this->name, $name);
}
return $this->sqlResultSetMappings[$name];
}
|
[
"public",
"function",
"getSqlResultSetMapping",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"sqlResultSetMappings",
"[",
"$",
"name",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"resultMappingNotFound",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"sqlResultSetMappings",
"[",
"$",
"name",
"]",
";",
"}"
] |
Gets the result set mapping.
@see ClassMetadataInfo::$sqlResultSetMappings
@param string $name The result set mapping name.
@return array
@throws MappingException
|
[
"Gets",
"the",
"result",
"set",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1349-L1356
|
223,319
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo._validateAndCompleteFieldMapping
|
protected function _validateAndCompleteFieldMapping(array &$mapping)
{
// Check mandatory fields
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
throw MappingException::missingFieldName($this->name);
}
if ( ! isset($mapping['type'])) {
// Default to string
$mapping['type'] = 'string';
}
// Complete fieldName and columnName mapping
if ( ! isset($mapping['columnName'])) {
$mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name);
}
if ($mapping['columnName'][0] === '`') {
$mapping['columnName'] = trim($mapping['columnName'], '`');
$mapping['quoted'] = true;
}
$this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) {
throw MappingException::duplicateColumnName($this->name, $mapping['columnName']);
}
$this->fieldNames[$mapping['columnName']] = $mapping['fieldName'];
// Complete id mapping
if (isset($mapping['id']) && $mapping['id'] === true) {
if ($this->versionField == $mapping['fieldName']) {
throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']);
}
if ( ! in_array($mapping['fieldName'], $this->identifier)) {
$this->identifier[] = $mapping['fieldName'];
}
// Check for composite key
if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) {
$this->isIdentifierComposite = true;
}
}
if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) {
if (isset($mapping['id']) && $mapping['id'] === true) {
throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']);
}
$mapping['requireSQLConversion'] = true;
}
}
|
php
|
protected function _validateAndCompleteFieldMapping(array &$mapping)
{
// Check mandatory fields
if ( ! isset($mapping['fieldName']) || strlen($mapping['fieldName']) == 0) {
throw MappingException::missingFieldName($this->name);
}
if ( ! isset($mapping['type'])) {
// Default to string
$mapping['type'] = 'string';
}
// Complete fieldName and columnName mapping
if ( ! isset($mapping['columnName'])) {
$mapping['columnName'] = $this->namingStrategy->propertyToColumnName($mapping['fieldName'], $this->name);
}
if ($mapping['columnName'][0] === '`') {
$mapping['columnName'] = trim($mapping['columnName'], '`');
$mapping['quoted'] = true;
}
$this->columnNames[$mapping['fieldName']] = $mapping['columnName'];
if (isset($this->fieldNames[$mapping['columnName']]) || ($this->discriminatorColumn != null && $this->discriminatorColumn['name'] == $mapping['columnName'])) {
throw MappingException::duplicateColumnName($this->name, $mapping['columnName']);
}
$this->fieldNames[$mapping['columnName']] = $mapping['fieldName'];
// Complete id mapping
if (isset($mapping['id']) && $mapping['id'] === true) {
if ($this->versionField == $mapping['fieldName']) {
throw MappingException::cannotVersionIdField($this->name, $mapping['fieldName']);
}
if ( ! in_array($mapping['fieldName'], $this->identifier)) {
$this->identifier[] = $mapping['fieldName'];
}
// Check for composite key
if ( ! $this->isIdentifierComposite && count($this->identifier) > 1) {
$this->isIdentifierComposite = true;
}
}
if (Type::hasType($mapping['type']) && Type::getType($mapping['type'])->canRequireSQLConversion()) {
if (isset($mapping['id']) && $mapping['id'] === true) {
throw MappingException::sqlConversionNotAllowedForIdentifiers($this->name, $mapping['fieldName'], $mapping['type']);
}
$mapping['requireSQLConversion'] = true;
}
}
|
[
"protected",
"function",
"_validateAndCompleteFieldMapping",
"(",
"array",
"&",
"$",
"mapping",
")",
"{",
"// Check mandatory fields",
"if",
"(",
"!",
"isset",
"(",
"$",
"mapping",
"[",
"'fieldName'",
"]",
")",
"||",
"strlen",
"(",
"$",
"mapping",
"[",
"'fieldName'",
"]",
")",
"==",
"0",
")",
"{",
"throw",
"MappingException",
"::",
"missingFieldName",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"mapping",
"[",
"'type'",
"]",
")",
")",
"{",
"// Default to string",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"'string'",
";",
"}",
"// Complete fieldName and columnName mapping",
"if",
"(",
"!",
"isset",
"(",
"$",
"mapping",
"[",
"'columnName'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'columnName'",
"]",
"=",
"$",
"this",
"->",
"namingStrategy",
"->",
"propertyToColumnName",
"(",
"$",
"mapping",
"[",
"'fieldName'",
"]",
",",
"$",
"this",
"->",
"name",
")",
";",
"}",
"if",
"(",
"$",
"mapping",
"[",
"'columnName'",
"]",
"[",
"0",
"]",
"===",
"'`'",
")",
"{",
"$",
"mapping",
"[",
"'columnName'",
"]",
"=",
"trim",
"(",
"$",
"mapping",
"[",
"'columnName'",
"]",
",",
"'`'",
")",
";",
"$",
"mapping",
"[",
"'quoted'",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"columnNames",
"[",
"$",
"mapping",
"[",
"'fieldName'",
"]",
"]",
"=",
"$",
"mapping",
"[",
"'columnName'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"mapping",
"[",
"'columnName'",
"]",
"]",
")",
"||",
"(",
"$",
"this",
"->",
"discriminatorColumn",
"!=",
"null",
"&&",
"$",
"this",
"->",
"discriminatorColumn",
"[",
"'name'",
"]",
"==",
"$",
"mapping",
"[",
"'columnName'",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"duplicateColumnName",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"mapping",
"[",
"'columnName'",
"]",
")",
";",
"}",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"mapping",
"[",
"'columnName'",
"]",
"]",
"=",
"$",
"mapping",
"[",
"'fieldName'",
"]",
";",
"// Complete id mapping",
"if",
"(",
"isset",
"(",
"$",
"mapping",
"[",
"'id'",
"]",
")",
"&&",
"$",
"mapping",
"[",
"'id'",
"]",
"===",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"versionField",
"==",
"$",
"mapping",
"[",
"'fieldName'",
"]",
")",
"{",
"throw",
"MappingException",
"::",
"cannotVersionIdField",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"mapping",
"[",
"'fieldName'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"in_array",
"(",
"$",
"mapping",
"[",
"'fieldName'",
"]",
",",
"$",
"this",
"->",
"identifier",
")",
")",
"{",
"$",
"this",
"->",
"identifier",
"[",
"]",
"=",
"$",
"mapping",
"[",
"'fieldName'",
"]",
";",
"}",
"// Check for composite key",
"if",
"(",
"!",
"$",
"this",
"->",
"isIdentifierComposite",
"&&",
"count",
"(",
"$",
"this",
"->",
"identifier",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"isIdentifierComposite",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"Type",
"::",
"hasType",
"(",
"$",
"mapping",
"[",
"'type'",
"]",
")",
"&&",
"Type",
"::",
"getType",
"(",
"$",
"mapping",
"[",
"'type'",
"]",
")",
"->",
"canRequireSQLConversion",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"mapping",
"[",
"'id'",
"]",
")",
"&&",
"$",
"mapping",
"[",
"'id'",
"]",
"===",
"true",
")",
"{",
"throw",
"MappingException",
"::",
"sqlConversionNotAllowedForIdentifiers",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"mapping",
"[",
"'fieldName'",
"]",
",",
"$",
"mapping",
"[",
"'type'",
"]",
")",
";",
"}",
"$",
"mapping",
"[",
"'requireSQLConversion'",
"]",
"=",
"true",
";",
"}",
"}"
] |
Validates & completes the given field mapping.
@param array $mapping The field mapping to validate & complete.
@return array The validated and completed field mapping.
@throws MappingException
|
[
"Validates",
"&",
"completes",
"the",
"given",
"field",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1377-L1427
|
223,320
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getColumnNames
|
public function getColumnNames(array $fieldNames = null)
{
if ($fieldNames === null) {
return array_keys($this->fieldNames);
} else {
$columnNames = array();
foreach ($fieldNames as $fieldName) {
$columnNames[] = $this->getColumnName($fieldName);
}
return $columnNames;
}
}
|
php
|
public function getColumnNames(array $fieldNames = null)
{
if ($fieldNames === null) {
return array_keys($this->fieldNames);
} else {
$columnNames = array();
foreach ($fieldNames as $fieldName) {
$columnNames[] = $this->getColumnName($fieldName);
}
return $columnNames;
}
}
|
[
"public",
"function",
"getColumnNames",
"(",
"array",
"$",
"fieldNames",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"fieldNames",
"===",
"null",
")",
"{",
"return",
"array_keys",
"(",
"$",
"this",
"->",
"fieldNames",
")",
";",
"}",
"else",
"{",
"$",
"columnNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fieldNames",
"as",
"$",
"fieldName",
")",
"{",
"$",
"columnNames",
"[",
"]",
"=",
"$",
"this",
"->",
"getColumnName",
"(",
"$",
"fieldName",
")",
";",
"}",
"return",
"$",
"columnNames",
";",
"}",
"}"
] |
Gets an array containing all the column names.
@param array|null $fieldNames
@return array
|
[
"Gets",
"an",
"array",
"containing",
"all",
"the",
"column",
"names",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1847-L1858
|
223,321
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getIdentifierColumnNames
|
public function getIdentifierColumnNames()
{
$columnNames = array();
foreach ($this->identifier as $idProperty) {
if (isset($this->fieldMappings[$idProperty])) {
$columnNames[] = $this->fieldMappings[$idProperty]['columnName'];
continue;
}
// Association defined as Id field
$joinColumns = $this->associationMappings[$idProperty]['joinColumns'];
$assocColumnNames = array_map(function ($joinColumn) { return $joinColumn['name']; }, $joinColumns);
$columnNames = array_merge($columnNames, $assocColumnNames);
}
return $columnNames;
}
|
php
|
public function getIdentifierColumnNames()
{
$columnNames = array();
foreach ($this->identifier as $idProperty) {
if (isset($this->fieldMappings[$idProperty])) {
$columnNames[] = $this->fieldMappings[$idProperty]['columnName'];
continue;
}
// Association defined as Id field
$joinColumns = $this->associationMappings[$idProperty]['joinColumns'];
$assocColumnNames = array_map(function ($joinColumn) { return $joinColumn['name']; }, $joinColumns);
$columnNames = array_merge($columnNames, $assocColumnNames);
}
return $columnNames;
}
|
[
"public",
"function",
"getIdentifierColumnNames",
"(",
")",
"{",
"$",
"columnNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"identifier",
"as",
"$",
"idProperty",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"idProperty",
"]",
")",
")",
"{",
"$",
"columnNames",
"[",
"]",
"=",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"idProperty",
"]",
"[",
"'columnName'",
"]",
";",
"continue",
";",
"}",
"// Association defined as Id field",
"$",
"joinColumns",
"=",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"idProperty",
"]",
"[",
"'joinColumns'",
"]",
";",
"$",
"assocColumnNames",
"=",
"array_map",
"(",
"function",
"(",
"$",
"joinColumn",
")",
"{",
"return",
"$",
"joinColumn",
"[",
"'name'",
"]",
";",
"}",
",",
"$",
"joinColumns",
")",
";",
"$",
"columnNames",
"=",
"array_merge",
"(",
"$",
"columnNames",
",",
"$",
"assocColumnNames",
")",
";",
"}",
"return",
"$",
"columnNames",
";",
"}"
] |
Returns an array with all the identifier column names.
@return array
|
[
"Returns",
"an",
"array",
"with",
"all",
"the",
"identifier",
"column",
"names",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L1865-L1884
|
223,322
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.setAssociationOverride
|
public function setAssociationOverride($fieldName, array $overrideMapping)
{
if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::invalidOverrideFieldName($this->name, $fieldName);
}
$mapping = $this->associationMappings[$fieldName];
if (isset($overrideMapping['joinColumns'])) {
$mapping['joinColumns'] = $overrideMapping['joinColumns'];
}
if (isset($overrideMapping['joinTable'])) {
$mapping['joinTable'] = $overrideMapping['joinTable'];
}
$mapping['joinColumnFieldNames'] = null;
$mapping['joinTableColumns'] = null;
$mapping['sourceToTargetKeyColumns'] = null;
$mapping['relationToSourceKeyColumns'] = null;
$mapping['relationToTargetKeyColumns'] = null;
switch ($mapping['type']) {
case self::ONE_TO_ONE:
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
break;
case self::ONE_TO_MANY:
$mapping = $this->_validateAndCompleteOneToManyMapping($mapping);
break;
case self::MANY_TO_ONE:
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
break;
case self::MANY_TO_MANY:
$mapping = $this->_validateAndCompleteManyToManyMapping($mapping);
break;
}
$this->associationMappings[$fieldName] = $mapping;
}
|
php
|
public function setAssociationOverride($fieldName, array $overrideMapping)
{
if ( ! isset($this->associationMappings[$fieldName])) {
throw MappingException::invalidOverrideFieldName($this->name, $fieldName);
}
$mapping = $this->associationMappings[$fieldName];
if (isset($overrideMapping['joinColumns'])) {
$mapping['joinColumns'] = $overrideMapping['joinColumns'];
}
if (isset($overrideMapping['joinTable'])) {
$mapping['joinTable'] = $overrideMapping['joinTable'];
}
$mapping['joinColumnFieldNames'] = null;
$mapping['joinTableColumns'] = null;
$mapping['sourceToTargetKeyColumns'] = null;
$mapping['relationToSourceKeyColumns'] = null;
$mapping['relationToTargetKeyColumns'] = null;
switch ($mapping['type']) {
case self::ONE_TO_ONE:
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
break;
case self::ONE_TO_MANY:
$mapping = $this->_validateAndCompleteOneToManyMapping($mapping);
break;
case self::MANY_TO_ONE:
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
break;
case self::MANY_TO_MANY:
$mapping = $this->_validateAndCompleteManyToManyMapping($mapping);
break;
}
$this->associationMappings[$fieldName] = $mapping;
}
|
[
"public",
"function",
"setAssociationOverride",
"(",
"$",
"fieldName",
",",
"array",
"$",
"overrideMapping",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidOverrideFieldName",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"fieldName",
")",
";",
"}",
"$",
"mapping",
"=",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"overrideMapping",
"[",
"'joinColumns'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'joinColumns'",
"]",
"=",
"$",
"overrideMapping",
"[",
"'joinColumns'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"overrideMapping",
"[",
"'joinTable'",
"]",
")",
")",
"{",
"$",
"mapping",
"[",
"'joinTable'",
"]",
"=",
"$",
"overrideMapping",
"[",
"'joinTable'",
"]",
";",
"}",
"$",
"mapping",
"[",
"'joinColumnFieldNames'",
"]",
"=",
"null",
";",
"$",
"mapping",
"[",
"'joinTableColumns'",
"]",
"=",
"null",
";",
"$",
"mapping",
"[",
"'sourceToTargetKeyColumns'",
"]",
"=",
"null",
";",
"$",
"mapping",
"[",
"'relationToSourceKeyColumns'",
"]",
"=",
"null",
";",
"$",
"mapping",
"[",
"'relationToTargetKeyColumns'",
"]",
"=",
"null",
";",
"switch",
"(",
"$",
"mapping",
"[",
"'type'",
"]",
")",
"{",
"case",
"self",
"::",
"ONE_TO_ONE",
":",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteOneToOneMapping",
"(",
"$",
"mapping",
")",
";",
"break",
";",
"case",
"self",
"::",
"ONE_TO_MANY",
":",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteOneToManyMapping",
"(",
"$",
"mapping",
")",
";",
"break",
";",
"case",
"self",
"::",
"MANY_TO_ONE",
":",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteOneToOneMapping",
"(",
"$",
"mapping",
")",
";",
"break",
";",
"case",
"self",
"::",
"MANY_TO_MANY",
":",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteManyToManyMapping",
"(",
"$",
"mapping",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"mapping",
";",
"}"
] |
Sets the association to override association mapping of property for an entity relationship.
@param string $fieldName
@param array $overrideMapping
@return void
@throws MappingException
|
[
"Sets",
"the",
"association",
"to",
"override",
"association",
"mapping",
"of",
"property",
"for",
"an",
"entity",
"relationship",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2117-L2155
|
223,323
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.setAttributeOverride
|
public function setAttributeOverride($fieldName, array $overrideMapping)
{
if ( ! isset($this->fieldMappings[$fieldName])) {
throw MappingException::invalidOverrideFieldName($this->name, $fieldName);
}
$mapping = $this->fieldMappings[$fieldName];
if (isset($mapping['id'])) {
$overrideMapping['id'] = $mapping['id'];
}
if ( ! isset($overrideMapping['type']) || $overrideMapping['type'] === null) {
$overrideMapping['type'] = $mapping['type'];
}
if ( ! isset($overrideMapping['fieldName']) || $overrideMapping['fieldName'] === null) {
$overrideMapping['fieldName'] = $mapping['fieldName'];
}
if ($overrideMapping['type'] !== $mapping['type']) {
throw MappingException::invalidOverrideFieldType($this->name, $fieldName);
}
unset($this->fieldMappings[$fieldName]);
unset($this->fieldNames[$mapping['columnName']]);
unset($this->columnNames[$mapping['fieldName']]);
$this->_validateAndCompleteFieldMapping($overrideMapping);
$this->fieldMappings[$fieldName] = $overrideMapping;
}
|
php
|
public function setAttributeOverride($fieldName, array $overrideMapping)
{
if ( ! isset($this->fieldMappings[$fieldName])) {
throw MappingException::invalidOverrideFieldName($this->name, $fieldName);
}
$mapping = $this->fieldMappings[$fieldName];
if (isset($mapping['id'])) {
$overrideMapping['id'] = $mapping['id'];
}
if ( ! isset($overrideMapping['type']) || $overrideMapping['type'] === null) {
$overrideMapping['type'] = $mapping['type'];
}
if ( ! isset($overrideMapping['fieldName']) || $overrideMapping['fieldName'] === null) {
$overrideMapping['fieldName'] = $mapping['fieldName'];
}
if ($overrideMapping['type'] !== $mapping['type']) {
throw MappingException::invalidOverrideFieldType($this->name, $fieldName);
}
unset($this->fieldMappings[$fieldName]);
unset($this->fieldNames[$mapping['columnName']]);
unset($this->columnNames[$mapping['fieldName']]);
$this->_validateAndCompleteFieldMapping($overrideMapping);
$this->fieldMappings[$fieldName] = $overrideMapping;
}
|
[
"public",
"function",
"setAttributeOverride",
"(",
"$",
"fieldName",
",",
"array",
"$",
"overrideMapping",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"invalidOverrideFieldName",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"fieldName",
")",
";",
"}",
"$",
"mapping",
"=",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"mapping",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"overrideMapping",
"[",
"'id'",
"]",
"=",
"$",
"mapping",
"[",
"'id'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"overrideMapping",
"[",
"'type'",
"]",
")",
"||",
"$",
"overrideMapping",
"[",
"'type'",
"]",
"===",
"null",
")",
"{",
"$",
"overrideMapping",
"[",
"'type'",
"]",
"=",
"$",
"mapping",
"[",
"'type'",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"overrideMapping",
"[",
"'fieldName'",
"]",
")",
"||",
"$",
"overrideMapping",
"[",
"'fieldName'",
"]",
"===",
"null",
")",
"{",
"$",
"overrideMapping",
"[",
"'fieldName'",
"]",
"=",
"$",
"mapping",
"[",
"'fieldName'",
"]",
";",
"}",
"if",
"(",
"$",
"overrideMapping",
"[",
"'type'",
"]",
"!==",
"$",
"mapping",
"[",
"'type'",
"]",
")",
"{",
"throw",
"MappingException",
"::",
"invalidOverrideFieldType",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"fieldName",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"mapping",
"[",
"'columnName'",
"]",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"columnNames",
"[",
"$",
"mapping",
"[",
"'fieldName'",
"]",
"]",
")",
";",
"$",
"this",
"->",
"_validateAndCompleteFieldMapping",
"(",
"$",
"overrideMapping",
")",
";",
"$",
"this",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
"=",
"$",
"overrideMapping",
";",
"}"
] |
Sets the override for a mapped field.
@param string $fieldName
@param array $overrideMapping
@return void
@throws MappingException
|
[
"Sets",
"the",
"override",
"for",
"a",
"mapped",
"field",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2167-L2197
|
223,324
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.mapOneToOne
|
public function mapOneToOne(array $mapping)
{
$mapping['type'] = self::ONE_TO_ONE;
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
php
|
public function mapOneToOne(array $mapping)
{
$mapping['type'] = self::ONE_TO_ONE;
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
[
"public",
"function",
"mapOneToOne",
"(",
"array",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"self",
"::",
"ONE_TO_ONE",
";",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteOneToOneMapping",
"(",
"$",
"mapping",
")",
";",
"$",
"this",
"->",
"_storeAssociationMapping",
"(",
"$",
"mapping",
")",
";",
"}"
] |
Adds a one-to-one mapping.
@param array $mapping The mapping.
@return void
|
[
"Adds",
"a",
"one",
"-",
"to",
"-",
"one",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2512-L2517
|
223,325
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.mapOneToMany
|
public function mapOneToMany(array $mapping)
{
$mapping['type'] = self::ONE_TO_MANY;
$mapping = $this->_validateAndCompleteOneToManyMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
php
|
public function mapOneToMany(array $mapping)
{
$mapping['type'] = self::ONE_TO_MANY;
$mapping = $this->_validateAndCompleteOneToManyMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
[
"public",
"function",
"mapOneToMany",
"(",
"array",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"self",
"::",
"ONE_TO_MANY",
";",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteOneToManyMapping",
"(",
"$",
"mapping",
")",
";",
"$",
"this",
"->",
"_storeAssociationMapping",
"(",
"$",
"mapping",
")",
";",
"}"
] |
Adds a one-to-many mapping.
@param array $mapping The mapping.
@return void
|
[
"Adds",
"a",
"one",
"-",
"to",
"-",
"many",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2526-L2531
|
223,326
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.mapManyToOne
|
public function mapManyToOne(array $mapping)
{
$mapping['type'] = self::MANY_TO_ONE;
// A many-to-one mapping is essentially a one-one backreference
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
php
|
public function mapManyToOne(array $mapping)
{
$mapping['type'] = self::MANY_TO_ONE;
// A many-to-one mapping is essentially a one-one backreference
$mapping = $this->_validateAndCompleteOneToOneMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
[
"public",
"function",
"mapManyToOne",
"(",
"array",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"self",
"::",
"MANY_TO_ONE",
";",
"// A many-to-one mapping is essentially a one-one backreference",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteOneToOneMapping",
"(",
"$",
"mapping",
")",
";",
"$",
"this",
"->",
"_storeAssociationMapping",
"(",
"$",
"mapping",
")",
";",
"}"
] |
Adds a many-to-one mapping.
@param array $mapping The mapping.
@return void
|
[
"Adds",
"a",
"many",
"-",
"to",
"-",
"one",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2540-L2546
|
223,327
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.mapManyToMany
|
public function mapManyToMany(array $mapping)
{
$mapping['type'] = self::MANY_TO_MANY;
$mapping = $this->_validateAndCompleteManyToManyMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
php
|
public function mapManyToMany(array $mapping)
{
$mapping['type'] = self::MANY_TO_MANY;
$mapping = $this->_validateAndCompleteManyToManyMapping($mapping);
$this->_storeAssociationMapping($mapping);
}
|
[
"public",
"function",
"mapManyToMany",
"(",
"array",
"$",
"mapping",
")",
"{",
"$",
"mapping",
"[",
"'type'",
"]",
"=",
"self",
"::",
"MANY_TO_MANY",
";",
"$",
"mapping",
"=",
"$",
"this",
"->",
"_validateAndCompleteManyToManyMapping",
"(",
"$",
"mapping",
")",
";",
"$",
"this",
"->",
"_storeAssociationMapping",
"(",
"$",
"mapping",
")",
";",
"}"
] |
Adds a many-to-many mapping.
@param array $mapping The mapping.
@return void
|
[
"Adds",
"a",
"many",
"-",
"to",
"-",
"many",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2555-L2560
|
223,328
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo._storeAssociationMapping
|
protected function _storeAssociationMapping(array $assocMapping)
{
$sourceFieldName = $assocMapping['fieldName'];
$this->assertFieldNotMapped($sourceFieldName);
$this->associationMappings[$sourceFieldName] = $assocMapping;
}
|
php
|
protected function _storeAssociationMapping(array $assocMapping)
{
$sourceFieldName = $assocMapping['fieldName'];
$this->assertFieldNotMapped($sourceFieldName);
$this->associationMappings[$sourceFieldName] = $assocMapping;
}
|
[
"protected",
"function",
"_storeAssociationMapping",
"(",
"array",
"$",
"assocMapping",
")",
"{",
"$",
"sourceFieldName",
"=",
"$",
"assocMapping",
"[",
"'fieldName'",
"]",
";",
"$",
"this",
"->",
"assertFieldNotMapped",
"(",
"$",
"sourceFieldName",
")",
";",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"sourceFieldName",
"]",
"=",
"$",
"assocMapping",
";",
"}"
] |
Stores the association mapping.
@param array $assocMapping
@return void
@throws MappingException
|
[
"Stores",
"the",
"association",
"mapping",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2571-L2578
|
223,329
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.invokeLifecycleCallbacks
|
public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
{
foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) {
$entity->$callback();
}
}
|
php
|
public function invokeLifecycleCallbacks($lifecycleEvent, $entity)
{
foreach ($this->lifecycleCallbacks[$lifecycleEvent] as $callback) {
$entity->$callback();
}
}
|
[
"public",
"function",
"invokeLifecycleCallbacks",
"(",
"$",
"lifecycleEvent",
",",
"$",
"entity",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"lifecycleCallbacks",
"[",
"$",
"lifecycleEvent",
"]",
"as",
"$",
"callback",
")",
"{",
"$",
"entity",
"->",
"$",
"callback",
"(",
")",
";",
"}",
"}"
] |
Dispatches the lifecycle event of the given entity to the registered
lifecycle callbacks and lifecycle listeners.
@deprecated Deprecated since version 2.4 in favor of \Doctrine\ORM\Event\ListenersInvoker
@param string $lifecycleEvent The lifecycle event.
@param object $entity The Entity on which the event occurred.
@return void
|
[
"Dispatches",
"the",
"lifecycle",
"event",
"of",
"the",
"given",
"entity",
"to",
"the",
"registered",
"lifecycle",
"callbacks",
"and",
"lifecycle",
"listeners",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2603-L2608
|
223,330
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.isAssociationWithSingleJoinColumn
|
public function isAssociationWithSingleJoinColumn($fieldName)
{
return (
isset($this->associationMappings[$fieldName]) &&
isset($this->associationMappings[$fieldName]['joinColumns'][0]) &&
!isset($this->associationMappings[$fieldName]['joinColumns'][1])
);
}
|
php
|
public function isAssociationWithSingleJoinColumn($fieldName)
{
return (
isset($this->associationMappings[$fieldName]) &&
isset($this->associationMappings[$fieldName]['joinColumns'][0]) &&
!isset($this->associationMappings[$fieldName]['joinColumns'][1])
);
}
|
[
"public",
"function",
"isAssociationWithSingleJoinColumn",
"(",
"$",
"fieldName",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
")",
"&&",
"isset",
"(",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'joinColumns'",
"]",
"[",
"0",
"]",
")",
"&&",
"!",
"isset",
"(",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'joinColumns'",
"]",
"[",
"1",
"]",
")",
")",
";",
"}"
] |
Is this an association that only has a single join column?
@param string $fieldName
@return bool
|
[
"Is",
"this",
"an",
"association",
"that",
"only",
"has",
"a",
"single",
"join",
"column?"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2849-L2856
|
223,331
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getFieldForColumn
|
public function getFieldForColumn($columnName)
{
if (isset($this->fieldNames[$columnName])) {
return $this->fieldNames[$columnName];
} else {
foreach ($this->associationMappings as $assocName => $mapping) {
if ($this->isAssociationWithSingleJoinColumn($assocName) &&
$this->associationMappings[$assocName]['joinColumns'][0]['name'] == $columnName) {
return $assocName;
}
}
throw MappingException::noFieldNameFoundForColumn($this->name, $columnName);
}
}
|
php
|
public function getFieldForColumn($columnName)
{
if (isset($this->fieldNames[$columnName])) {
return $this->fieldNames[$columnName];
} else {
foreach ($this->associationMappings as $assocName => $mapping) {
if ($this->isAssociationWithSingleJoinColumn($assocName) &&
$this->associationMappings[$assocName]['joinColumns'][0]['name'] == $columnName) {
return $assocName;
}
}
throw MappingException::noFieldNameFoundForColumn($this->name, $columnName);
}
}
|
[
"public",
"function",
"getFieldForColumn",
"(",
"$",
"columnName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"columnName",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fieldNames",
"[",
"$",
"columnName",
"]",
";",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"associationMappings",
"as",
"$",
"assocName",
"=>",
"$",
"mapping",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAssociationWithSingleJoinColumn",
"(",
"$",
"assocName",
")",
"&&",
"$",
"this",
"->",
"associationMappings",
"[",
"$",
"assocName",
"]",
"[",
"'joinColumns'",
"]",
"[",
"0",
"]",
"[",
"'name'",
"]",
"==",
"$",
"columnName",
")",
"{",
"return",
"$",
"assocName",
";",
"}",
"}",
"throw",
"MappingException",
"::",
"noFieldNameFoundForColumn",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"columnName",
")",
";",
"}",
"}"
] |
Used to retrieve a fieldname for either field or association from a given column.
This method is used in foreign-key as primary-key contexts.
@param string $columnName
@return string
@throws MappingException
|
[
"Used",
"to",
"retrieve",
"a",
"fieldname",
"for",
"either",
"field",
"or",
"association",
"from",
"a",
"given",
"column",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2903-L2918
|
223,332
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.setSequenceGeneratorDefinition
|
public function setSequenceGeneratorDefinition(array $definition)
{
if ( ! isset($definition['sequenceName'])) {
throw MappingException::missingSequenceName($this->name);
}
if ($definition['sequenceName'][0] == '`') {
$definition['sequenceName'] = trim($definition['sequenceName'], '`');
$definition['quoted'] = true;
}
$this->sequenceGeneratorDefinition = $definition;
}
|
php
|
public function setSequenceGeneratorDefinition(array $definition)
{
if ( ! isset($definition['sequenceName'])) {
throw MappingException::missingSequenceName($this->name);
}
if ($definition['sequenceName'][0] == '`') {
$definition['sequenceName'] = trim($definition['sequenceName'], '`');
$definition['quoted'] = true;
}
$this->sequenceGeneratorDefinition = $definition;
}
|
[
"public",
"function",
"setSequenceGeneratorDefinition",
"(",
"array",
"$",
"definition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"definition",
"[",
"'sequenceName'",
"]",
")",
")",
"{",
"throw",
"MappingException",
"::",
"missingSequenceName",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"if",
"(",
"$",
"definition",
"[",
"'sequenceName'",
"]",
"[",
"0",
"]",
"==",
"'`'",
")",
"{",
"$",
"definition",
"[",
"'sequenceName'",
"]",
"=",
"trim",
"(",
"$",
"definition",
"[",
"'sequenceName'",
"]",
",",
"'`'",
")",
";",
"$",
"definition",
"[",
"'quoted'",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"sequenceGeneratorDefinition",
"=",
"$",
"definition",
";",
"}"
] |
Sets the definition of the sequence ID generator for this class.
The definition must have the following structure:
<code>
array(
'sequenceName' => 'name',
'allocationSize' => 20,
'initialValue' => 1
'quoted' => 1
)
</code>
@param array $definition
@return void
|
[
"Sets",
"the",
"definition",
"of",
"the",
"sequence",
"ID",
"generator",
"for",
"this",
"class",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L2961-L2973
|
223,333
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.mapEmbedded
|
public function mapEmbedded(array $mapping)
{
$this->assertFieldNotMapped($mapping['fieldName']);
$this->embeddedClasses[$mapping['fieldName']] = array(
'class' => $this->fullyQualifiedClassName($mapping['class']),
'columnPrefix' => $mapping['columnPrefix'],
'declaredField' => isset($mapping['declaredField']) ? $mapping['declaredField'] : null,
'originalField' => isset($mapping['originalField']) ? $mapping['originalField'] : null,
);
}
|
php
|
public function mapEmbedded(array $mapping)
{
$this->assertFieldNotMapped($mapping['fieldName']);
$this->embeddedClasses[$mapping['fieldName']] = array(
'class' => $this->fullyQualifiedClassName($mapping['class']),
'columnPrefix' => $mapping['columnPrefix'],
'declaredField' => isset($mapping['declaredField']) ? $mapping['declaredField'] : null,
'originalField' => isset($mapping['originalField']) ? $mapping['originalField'] : null,
);
}
|
[
"public",
"function",
"mapEmbedded",
"(",
"array",
"$",
"mapping",
")",
"{",
"$",
"this",
"->",
"assertFieldNotMapped",
"(",
"$",
"mapping",
"[",
"'fieldName'",
"]",
")",
";",
"$",
"this",
"->",
"embeddedClasses",
"[",
"$",
"mapping",
"[",
"'fieldName'",
"]",
"]",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"this",
"->",
"fullyQualifiedClassName",
"(",
"$",
"mapping",
"[",
"'class'",
"]",
")",
",",
"'columnPrefix'",
"=>",
"$",
"mapping",
"[",
"'columnPrefix'",
"]",
",",
"'declaredField'",
"=>",
"isset",
"(",
"$",
"mapping",
"[",
"'declaredField'",
"]",
")",
"?",
"$",
"mapping",
"[",
"'declaredField'",
"]",
":",
"null",
",",
"'originalField'",
"=>",
"isset",
"(",
"$",
"mapping",
"[",
"'originalField'",
"]",
")",
"?",
"$",
"mapping",
"[",
"'originalField'",
"]",
":",
"null",
",",
")",
";",
"}"
] |
Map Embedded Class
@param array $mapping
@throws MappingException
@return void
|
[
"Map",
"Embedded",
"Class"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L3229-L3239
|
223,334
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.inlineEmbeddable
|
public function inlineEmbeddable($property, ClassMetadataInfo $embeddable)
{
foreach ($embeddable->fieldMappings as $fieldMapping) {
$fieldMapping['originalClass'] = isset($fieldMapping['originalClass'])
? $fieldMapping['originalClass']
: $embeddable->name;
$fieldMapping['declaredField'] = isset($fieldMapping['declaredField'])
? $property . '.' . $fieldMapping['declaredField']
: $property;
$fieldMapping['originalField'] = isset($fieldMapping['originalField'])
? $fieldMapping['originalField']
: $fieldMapping['fieldName'];
$fieldMapping['fieldName'] = $property . "." . $fieldMapping['fieldName'];
if (! empty($this->embeddedClasses[$property]['columnPrefix'])) {
$fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName'];
} elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) {
$fieldMapping['columnName'] = $this->namingStrategy
->embeddedFieldToColumnName(
$property,
$fieldMapping['columnName'],
$this->reflClass->name,
$embeddable->reflClass->name
);
}
$this->mapField($fieldMapping);
}
}
|
php
|
public function inlineEmbeddable($property, ClassMetadataInfo $embeddable)
{
foreach ($embeddable->fieldMappings as $fieldMapping) {
$fieldMapping['originalClass'] = isset($fieldMapping['originalClass'])
? $fieldMapping['originalClass']
: $embeddable->name;
$fieldMapping['declaredField'] = isset($fieldMapping['declaredField'])
? $property . '.' . $fieldMapping['declaredField']
: $property;
$fieldMapping['originalField'] = isset($fieldMapping['originalField'])
? $fieldMapping['originalField']
: $fieldMapping['fieldName'];
$fieldMapping['fieldName'] = $property . "." . $fieldMapping['fieldName'];
if (! empty($this->embeddedClasses[$property]['columnPrefix'])) {
$fieldMapping['columnName'] = $this->embeddedClasses[$property]['columnPrefix'] . $fieldMapping['columnName'];
} elseif ($this->embeddedClasses[$property]['columnPrefix'] !== false) {
$fieldMapping['columnName'] = $this->namingStrategy
->embeddedFieldToColumnName(
$property,
$fieldMapping['columnName'],
$this->reflClass->name,
$embeddable->reflClass->name
);
}
$this->mapField($fieldMapping);
}
}
|
[
"public",
"function",
"inlineEmbeddable",
"(",
"$",
"property",
",",
"ClassMetadataInfo",
"$",
"embeddable",
")",
"{",
"foreach",
"(",
"$",
"embeddable",
"->",
"fieldMappings",
"as",
"$",
"fieldMapping",
")",
"{",
"$",
"fieldMapping",
"[",
"'originalClass'",
"]",
"=",
"isset",
"(",
"$",
"fieldMapping",
"[",
"'originalClass'",
"]",
")",
"?",
"$",
"fieldMapping",
"[",
"'originalClass'",
"]",
":",
"$",
"embeddable",
"->",
"name",
";",
"$",
"fieldMapping",
"[",
"'declaredField'",
"]",
"=",
"isset",
"(",
"$",
"fieldMapping",
"[",
"'declaredField'",
"]",
")",
"?",
"$",
"property",
".",
"'.'",
".",
"$",
"fieldMapping",
"[",
"'declaredField'",
"]",
":",
"$",
"property",
";",
"$",
"fieldMapping",
"[",
"'originalField'",
"]",
"=",
"isset",
"(",
"$",
"fieldMapping",
"[",
"'originalField'",
"]",
")",
"?",
"$",
"fieldMapping",
"[",
"'originalField'",
"]",
":",
"$",
"fieldMapping",
"[",
"'fieldName'",
"]",
";",
"$",
"fieldMapping",
"[",
"'fieldName'",
"]",
"=",
"$",
"property",
".",
"\".\"",
".",
"$",
"fieldMapping",
"[",
"'fieldName'",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"embeddedClasses",
"[",
"$",
"property",
"]",
"[",
"'columnPrefix'",
"]",
")",
")",
"{",
"$",
"fieldMapping",
"[",
"'columnName'",
"]",
"=",
"$",
"this",
"->",
"embeddedClasses",
"[",
"$",
"property",
"]",
"[",
"'columnPrefix'",
"]",
".",
"$",
"fieldMapping",
"[",
"'columnName'",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"embeddedClasses",
"[",
"$",
"property",
"]",
"[",
"'columnPrefix'",
"]",
"!==",
"false",
")",
"{",
"$",
"fieldMapping",
"[",
"'columnName'",
"]",
"=",
"$",
"this",
"->",
"namingStrategy",
"->",
"embeddedFieldToColumnName",
"(",
"$",
"property",
",",
"$",
"fieldMapping",
"[",
"'columnName'",
"]",
",",
"$",
"this",
"->",
"reflClass",
"->",
"name",
",",
"$",
"embeddable",
"->",
"reflClass",
"->",
"name",
")",
";",
"}",
"$",
"this",
"->",
"mapField",
"(",
"$",
"fieldMapping",
")",
";",
"}",
"}"
] |
Inline the embeddable class
@param string $property
@param ClassMetadataInfo $embeddable
|
[
"Inline",
"the",
"embeddable",
"class"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L3247-L3275
|
223,335
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getSequenceName
|
public function getSequenceName(AbstractPlatform $platform)
{
$sequencePrefix = $this->getSequencePrefix($platform);
$columnName = $this->getSingleIdentifierColumnName();
$sequenceName = $sequencePrefix . '_' . $columnName . '_seq';
return $sequenceName;
}
|
php
|
public function getSequenceName(AbstractPlatform $platform)
{
$sequencePrefix = $this->getSequencePrefix($platform);
$columnName = $this->getSingleIdentifierColumnName();
$sequenceName = $sequencePrefix . '_' . $columnName . '_seq';
return $sequenceName;
}
|
[
"public",
"function",
"getSequenceName",
"(",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"$",
"sequencePrefix",
"=",
"$",
"this",
"->",
"getSequencePrefix",
"(",
"$",
"platform",
")",
";",
"$",
"columnName",
"=",
"$",
"this",
"->",
"getSingleIdentifierColumnName",
"(",
")",
";",
"$",
"sequenceName",
"=",
"$",
"sequencePrefix",
".",
"'_'",
".",
"$",
"columnName",
".",
"'_seq'",
";",
"return",
"$",
"sequenceName",
";",
"}"
] |
Gets the sequence name based on class metadata.
@param AbstractPlatform $platform
@return string
@todo Sequence names should be computed in DBAL depending on the platform
|
[
"Gets",
"the",
"sequence",
"name",
"based",
"on",
"class",
"metadata",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L3299-L3307
|
223,336
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
|
ClassMetadataInfo.getSequencePrefix
|
public function getSequencePrefix(AbstractPlatform $platform)
{
$tableName = $this->getTableName();
$sequencePrefix = $tableName;
// Prepend the schema name to the table name if there is one
if ($schemaName = $this->getSchemaName()) {
$sequencePrefix = $schemaName . '.' . $tableName;
if ( ! $platform->supportsSchemas() && $platform->canEmulateSchemas()) {
$sequencePrefix = $schemaName . '__' . $tableName;
}
}
return $sequencePrefix;
}
|
php
|
public function getSequencePrefix(AbstractPlatform $platform)
{
$tableName = $this->getTableName();
$sequencePrefix = $tableName;
// Prepend the schema name to the table name if there is one
if ($schemaName = $this->getSchemaName()) {
$sequencePrefix = $schemaName . '.' . $tableName;
if ( ! $platform->supportsSchemas() && $platform->canEmulateSchemas()) {
$sequencePrefix = $schemaName . '__' . $tableName;
}
}
return $sequencePrefix;
}
|
[
"public",
"function",
"getSequencePrefix",
"(",
"AbstractPlatform",
"$",
"platform",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"getTableName",
"(",
")",
";",
"$",
"sequencePrefix",
"=",
"$",
"tableName",
";",
"// Prepend the schema name to the table name if there is one",
"if",
"(",
"$",
"schemaName",
"=",
"$",
"this",
"->",
"getSchemaName",
"(",
")",
")",
"{",
"$",
"sequencePrefix",
"=",
"$",
"schemaName",
".",
"'.'",
".",
"$",
"tableName",
";",
"if",
"(",
"!",
"$",
"platform",
"->",
"supportsSchemas",
"(",
")",
"&&",
"$",
"platform",
"->",
"canEmulateSchemas",
"(",
")",
")",
"{",
"$",
"sequencePrefix",
"=",
"$",
"schemaName",
".",
"'__'",
".",
"$",
"tableName",
";",
"}",
"}",
"return",
"$",
"sequencePrefix",
";",
"}"
] |
Gets the sequence name prefix based on class metadata.
@param AbstractPlatform $platform
@return string
@todo Sequence names should be computed in DBAL depending on the platform
|
[
"Gets",
"the",
"sequence",
"name",
"prefix",
"based",
"on",
"class",
"metadata",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php#L3317-L3332
|
223,337
|
mespronos/mespronos
|
src/Entity/Getters/GameGettersTrait.php
|
GameGettersTrait.getBets
|
public function getBets() {
$query = \Drupal::entityQuery('bet');
$query->condition('game', $this->id());
$games_ids = $query->execute();
return Bet::loadMultiple($games_ids);
}
|
php
|
public function getBets() {
$query = \Drupal::entityQuery('bet');
$query->condition('game', $this->id());
$games_ids = $query->execute();
return Bet::loadMultiple($games_ids);
}
|
[
"public",
"function",
"getBets",
"(",
")",
"{",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'bet'",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'game'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"games_ids",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"Bet",
"::",
"loadMultiple",
"(",
"$",
"games_ids",
")",
";",
"}"
] |
Return all bets for the current game
@return \Drupal\mespronos\Entity\Bet[]
|
[
"Return",
"all",
"bets",
"for",
"the",
"current",
"game"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Getters/GameGettersTrait.php#L210-L215
|
223,338
|
mespronos/mespronos
|
src/Controller/GameController.php
|
GameController.getGameWithoutMarks
|
public static function getGameWithoutMarks($only_past = true) {
$game_storage = \Drupal::entityTypeManager()->getStorage('game');
$query = \Drupal::entityQuery('game');
if ($only_past) {
$now = new \DateTime(null, new \DateTimeZone("UTC"));
$query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '<');
}
$group = $query->orConditionGroup()
->condition('score_team_1', null, 'is')
->condition('score_team_2', null, 'is');
$query->sort('game_date', 'ASC');
$ids = $query->condition($group)->execute();
$games = $game_storage->loadMultiple($ids);
return $games;
}
|
php
|
public static function getGameWithoutMarks($only_past = true) {
$game_storage = \Drupal::entityTypeManager()->getStorage('game');
$query = \Drupal::entityQuery('game');
if ($only_past) {
$now = new \DateTime(null, new \DateTimeZone("UTC"));
$query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '<');
}
$group = $query->orConditionGroup()
->condition('score_team_1', null, 'is')
->condition('score_team_2', null, 'is');
$query->sort('game_date', 'ASC');
$ids = $query->condition($group)->execute();
$games = $game_storage->loadMultiple($ids);
return $games;
}
|
[
"public",
"static",
"function",
"getGameWithoutMarks",
"(",
"$",
"only_past",
"=",
"true",
")",
"{",
"$",
"game_storage",
"=",
"\\",
"Drupal",
"::",
"entityTypeManager",
"(",
")",
"->",
"getStorage",
"(",
"'game'",
")",
";",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'game'",
")",
";",
"if",
"(",
"$",
"only_past",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"null",
",",
"new",
"\\",
"DateTimeZone",
"(",
"\"UTC\"",
")",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'game_date'",
",",
"$",
"now",
"->",
"format",
"(",
"'Y-m-d\\TH:i:s'",
")",
",",
"'<'",
")",
";",
"}",
"$",
"group",
"=",
"$",
"query",
"->",
"orConditionGroup",
"(",
")",
"->",
"condition",
"(",
"'score_team_1'",
",",
"null",
",",
"'is'",
")",
"->",
"condition",
"(",
"'score_team_2'",
",",
"null",
",",
"'is'",
")",
";",
"$",
"query",
"->",
"sort",
"(",
"'game_date'",
",",
"'ASC'",
")",
";",
"$",
"ids",
"=",
"$",
"query",
"->",
"condition",
"(",
"$",
"group",
")",
"->",
"execute",
"(",
")",
";",
"$",
"games",
"=",
"$",
"game_storage",
"->",
"loadMultiple",
"(",
"$",
"ids",
")",
";",
"return",
"$",
"games",
";",
"}"
] |
Return array of games that has no marks setted
@param bool $only_past
@return \Drupal\mespronos\Entity\Game[]
|
[
"Return",
"array",
"of",
"games",
"that",
"has",
"no",
"marks",
"setted"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Controller/GameController.php#L26-L44
|
223,339
|
mespronos/mespronos
|
src/Controller/GameController.php
|
GameController.getGamesToBet
|
public static function getGamesToBet(Day $day) {
$game_storage = \Drupal::entityTypeManager()->getStorage('game');
$query = \Drupal::entityQuery('game');
$now = new \DateTime(null, new \DateTimeZone("UTC"));
$query->condition('day', $day->id());
$query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '>');
$group = $query->orConditionGroup()
->condition('score_team_1', null, 'is')
->condition('score_team_2', null, 'is');
$query->sort('game_date', 'ASC');
$query->sort('id', 'ASC');
$ids = $query->condition($group)->execute();
$games = $game_storage->loadMultiple($ids);
return $games;
}
|
php
|
public static function getGamesToBet(Day $day) {
$game_storage = \Drupal::entityTypeManager()->getStorage('game');
$query = \Drupal::entityQuery('game');
$now = new \DateTime(null, new \DateTimeZone("UTC"));
$query->condition('day', $day->id());
$query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '>');
$group = $query->orConditionGroup()
->condition('score_team_1', null, 'is')
->condition('score_team_2', null, 'is');
$query->sort('game_date', 'ASC');
$query->sort('id', 'ASC');
$ids = $query->condition($group)->execute();
$games = $game_storage->loadMultiple($ids);
return $games;
}
|
[
"public",
"static",
"function",
"getGamesToBet",
"(",
"Day",
"$",
"day",
")",
"{",
"$",
"game_storage",
"=",
"\\",
"Drupal",
"::",
"entityTypeManager",
"(",
")",
"->",
"getStorage",
"(",
"'game'",
")",
";",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'game'",
")",
";",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"null",
",",
"new",
"\\",
"DateTimeZone",
"(",
"\"UTC\"",
")",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'day'",
",",
"$",
"day",
"->",
"id",
"(",
")",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'game_date'",
",",
"$",
"now",
"->",
"format",
"(",
"'Y-m-d\\TH:i:s'",
")",
",",
"'>'",
")",
";",
"$",
"group",
"=",
"$",
"query",
"->",
"orConditionGroup",
"(",
")",
"->",
"condition",
"(",
"'score_team_1'",
",",
"null",
",",
"'is'",
")",
"->",
"condition",
"(",
"'score_team_2'",
",",
"null",
",",
"'is'",
")",
";",
"$",
"query",
"->",
"sort",
"(",
"'game_date'",
",",
"'ASC'",
")",
";",
"$",
"query",
"->",
"sort",
"(",
"'id'",
",",
"'ASC'",
")",
";",
"$",
"ids",
"=",
"$",
"query",
"->",
"condition",
"(",
"$",
"group",
")",
"->",
"execute",
"(",
")",
";",
"$",
"games",
"=",
"$",
"game_storage",
"->",
"loadMultiple",
"(",
"$",
"ids",
")",
";",
"return",
"$",
"games",
";",
"}"
] |
Return all games available to bet on a given day
@param \Drupal\mespronos\Entity\Day $day
@return \Drupal\mespronos\Entity\Game[]
|
[
"Return",
"all",
"games",
"available",
"to",
"bet",
"on",
"a",
"given",
"day"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Controller/GameController.php#L51-L72
|
223,340
|
fourlabsldn/GmailBundle
|
Swift/GmailApiTransport.php
|
GmailApiTransport.fromArrayToString
|
private function fromArrayToString(array $fromArray): string
{
// $fromArray = [ 'john.doe@example.com' => 'John Doe', 'jane.doe@example.com' => 'Jane Doe' ]; // sample
if (count($fromArray) > 0) {
reset($fromArray);
$fromString = key($fromArray);
return $fromString;
}
throw new \InvalidArgumentException('Set at least one \'from\' address when using '.self::class);
}
|
php
|
private function fromArrayToString(array $fromArray): string
{
// $fromArray = [ 'john.doe@example.com' => 'John Doe', 'jane.doe@example.com' => 'Jane Doe' ]; // sample
if (count($fromArray) > 0) {
reset($fromArray);
$fromString = key($fromArray);
return $fromString;
}
throw new \InvalidArgumentException('Set at least one \'from\' address when using '.self::class);
}
|
[
"private",
"function",
"fromArrayToString",
"(",
"array",
"$",
"fromArray",
")",
":",
"string",
"{",
"// $fromArray = [ 'john.doe@example.com' => 'John Doe', 'jane.doe@example.com' => 'Jane Doe' ]; // sample",
"if",
"(",
"count",
"(",
"$",
"fromArray",
")",
">",
"0",
")",
"{",
"reset",
"(",
"$",
"fromArray",
")",
";",
"$",
"fromString",
"=",
"key",
"(",
"$",
"fromArray",
")",
";",
"return",
"$",
"fromString",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Set at least one \\'from\\' address when using '",
".",
"self",
"::",
"class",
")",
";",
"}"
] |
The Gmail API can only take one address at a time, let's get the very first one.
@param array $fromArray
@return string
|
[
"The",
"Gmail",
"API",
"can",
"only",
"take",
"one",
"address",
"at",
"a",
"time",
"let",
"s",
"get",
"the",
"very",
"first",
"one",
"."
] |
3a7bf480db67502ee16968699c7a28cbf3add178
|
https://github.com/fourlabsldn/GmailBundle/blob/3a7bf480db67502ee16968699c7a28cbf3add178/Swift/GmailApiTransport.php#L146-L157
|
223,341
|
fourlabsldn/GmailBundle
|
Swift/GmailApiTransport.php
|
GmailApiTransport.fromArrayToFailedRecipients
|
private function fromArrayToFailedRecipients(array $fromArray): array
{
if (count($fromArray) > 0) {
reset($fromArray);
$keyOfFirstElement = key($fromArray); // john_doe@example.com
unset($fromArray[$keyOfFirstElement]);
return $fromArray;
}
return [];
}
|
php
|
private function fromArrayToFailedRecipients(array $fromArray): array
{
if (count($fromArray) > 0) {
reset($fromArray);
$keyOfFirstElement = key($fromArray); // john_doe@example.com
unset($fromArray[$keyOfFirstElement]);
return $fromArray;
}
return [];
}
|
[
"private",
"function",
"fromArrayToFailedRecipients",
"(",
"array",
"$",
"fromArray",
")",
":",
"array",
"{",
"if",
"(",
"count",
"(",
"$",
"fromArray",
")",
">",
"0",
")",
"{",
"reset",
"(",
"$",
"fromArray",
")",
";",
"$",
"keyOfFirstElement",
"=",
"key",
"(",
"$",
"fromArray",
")",
";",
"// john_doe@example.com",
"unset",
"(",
"$",
"fromArray",
"[",
"$",
"keyOfFirstElement",
"]",
")",
";",
"return",
"$",
"fromArray",
";",
"}",
"return",
"[",
"]",
";",
"}"
] |
The Gmail API can only take one address at a time, the others are failed recipients.
@param array $fromArray
@return array
|
[
"The",
"Gmail",
"API",
"can",
"only",
"take",
"one",
"address",
"at",
"a",
"time",
"the",
"others",
"are",
"failed",
"recipients",
"."
] |
3a7bf480db67502ee16968699c7a28cbf3add178
|
https://github.com/fourlabsldn/GmailBundle/blob/3a7bf480db67502ee16968699c7a28cbf3add178/Swift/GmailApiTransport.php#L166-L177
|
223,342
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php
|
MappingDescribeCommand.getMappedEntities
|
private function getMappedEntities(EntityManagerInterface $entityManager)
{
$entityClassNames = $entityManager
->getConfiguration()
->getMetadataDriverImpl()
->getAllClassNames();
if ( ! $entityClassNames) {
throw new \InvalidArgumentException(
'You do not have any mapped Doctrine ORM entities according to the current configuration. '.
'If you have entities or mapping files you should check your mapping configuration for errors.'
);
}
return $entityClassNames;
}
|
php
|
private function getMappedEntities(EntityManagerInterface $entityManager)
{
$entityClassNames = $entityManager
->getConfiguration()
->getMetadataDriverImpl()
->getAllClassNames();
if ( ! $entityClassNames) {
throw new \InvalidArgumentException(
'You do not have any mapped Doctrine ORM entities according to the current configuration. '.
'If you have entities or mapping files you should check your mapping configuration for errors.'
);
}
return $entityClassNames;
}
|
[
"private",
"function",
"getMappedEntities",
"(",
"EntityManagerInterface",
"$",
"entityManager",
")",
"{",
"$",
"entityClassNames",
"=",
"$",
"entityManager",
"->",
"getConfiguration",
"(",
")",
"->",
"getMetadataDriverImpl",
"(",
")",
"->",
"getAllClassNames",
"(",
")",
";",
"if",
"(",
"!",
"$",
"entityClassNames",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'You do not have any mapped Doctrine ORM entities according to the current configuration. '",
".",
"'If you have entities or mapping files you should check your mapping configuration for errors.'",
")",
";",
"}",
"return",
"$",
"entityClassNames",
";",
"}"
] |
Return all mapped entity class names
@param EntityManagerInterface $entityManager
@return string[]
|
[
"Return",
"all",
"mapped",
"entity",
"class",
"names"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php#L139-L154
|
223,343
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php
|
MappingDescribeCommand.formatMappings
|
private function formatMappings(array $propertyMappings)
{
$output = array();
foreach ($propertyMappings as $propertyName => $mapping) {
$output[] = $this->formatField(sprintf(' %s', $propertyName), '');
foreach ($mapping as $field => $value) {
$output[] = $this->formatField(sprintf(' %s', $field), $this->formatValue($value));
}
}
return $output;
}
|
php
|
private function formatMappings(array $propertyMappings)
{
$output = array();
foreach ($propertyMappings as $propertyName => $mapping) {
$output[] = $this->formatField(sprintf(' %s', $propertyName), '');
foreach ($mapping as $field => $value) {
$output[] = $this->formatField(sprintf(' %s', $field), $this->formatValue($value));
}
}
return $output;
}
|
[
"private",
"function",
"formatMappings",
"(",
"array",
"$",
"propertyMappings",
")",
"{",
"$",
"output",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"propertyMappings",
"as",
"$",
"propertyName",
"=>",
"$",
"mapping",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"this",
"->",
"formatField",
"(",
"sprintf",
"(",
"' %s'",
",",
"$",
"propertyName",
")",
",",
"''",
")",
";",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"$",
"this",
"->",
"formatField",
"(",
"sprintf",
"(",
"' %s'",
",",
"$",
"field",
")",
",",
"$",
"this",
"->",
"formatValue",
"(",
"$",
"value",
")",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Format the association mappings
@param array
@return array
|
[
"Format",
"the",
"association",
"mappings"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Console/Command/MappingDescribeCommand.php#L264-L277
|
223,344
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php
|
ManyToManyAssociationBuilder.addInverseJoinColumn
|
public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
{
$this->inverseJoinColumns[] = array(
'name' => $columnName,
'referencedColumnName' => $referencedColumnName,
'nullable' => $nullable,
'unique' => $unique,
'onDelete' => $onDelete,
'columnDefinition' => $columnDef,
);
return $this;
}
|
php
|
public function addInverseJoinColumn($columnName, $referencedColumnName, $nullable = true, $unique = false, $onDelete = null, $columnDef = null)
{
$this->inverseJoinColumns[] = array(
'name' => $columnName,
'referencedColumnName' => $referencedColumnName,
'nullable' => $nullable,
'unique' => $unique,
'onDelete' => $onDelete,
'columnDefinition' => $columnDef,
);
return $this;
}
|
[
"public",
"function",
"addInverseJoinColumn",
"(",
"$",
"columnName",
",",
"$",
"referencedColumnName",
",",
"$",
"nullable",
"=",
"true",
",",
"$",
"unique",
"=",
"false",
",",
"$",
"onDelete",
"=",
"null",
",",
"$",
"columnDef",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"inverseJoinColumns",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"columnName",
",",
"'referencedColumnName'",
"=>",
"$",
"referencedColumnName",
",",
"'nullable'",
"=>",
"$",
"nullable",
",",
"'unique'",
"=>",
"$",
"unique",
",",
"'onDelete'",
"=>",
"$",
"onDelete",
",",
"'columnDefinition'",
"=>",
"$",
"columnDef",
",",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds Inverse Join Columns.
@param string $columnName
@param string $referencedColumnName
@param bool $nullable
@param bool $unique
@param string|null $onDelete
@param string|null $columnDef
@return ManyToManyAssociationBuilder
|
[
"Adds",
"Inverse",
"Join",
"Columns",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Mapping/Builder/ManyToManyAssociationBuilder.php#L65-L76
|
223,345
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Proxy/ProxyFactory.php
|
ProxyFactory.createInitializer
|
private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister)
{
if ($classMetadata->getReflectionClass()->hasMethod('__wakeup')) {
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
$initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner();
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
if ($proxy->__isInitialized()) {
return;
}
$properties = $proxy->__getLazyProperties();
foreach ($properties as $propertyName => $property) {
if ( ! isset($proxy->$propertyName)) {
$proxy->$propertyName = $properties[$propertyName];
}
}
$proxy->__setInitialized(true);
$proxy->__wakeup();
$identifier = $classMetadata->getIdentifierValues($proxy);
if (null === $entityPersister->loadById($identifier, $proxy)) {
$proxy->__setInitializer($initializer);
$proxy->__setCloner($cloner);
$proxy->__setInitialized(false);
throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(),
$this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
);
}
};
}
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
$initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner();
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
if ($proxy->__isInitialized()) {
return;
}
$properties = $proxy->__getLazyProperties();
foreach ($properties as $propertyName => $property) {
if (!isset($proxy->$propertyName)) {
$proxy->$propertyName = $properties[$propertyName];
}
}
$proxy->__setInitialized(true);
$identifier = $classMetadata->getIdentifierValues($proxy);
if (null === $entityPersister->loadById($identifier, $proxy)) {
$proxy->__setInitializer($initializer);
$proxy->__setCloner($cloner);
$proxy->__setInitialized(false);
throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(),
$this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
);
}
};
}
|
php
|
private function createInitializer(ClassMetadata $classMetadata, EntityPersister $entityPersister)
{
if ($classMetadata->getReflectionClass()->hasMethod('__wakeup')) {
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
$initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner();
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
if ($proxy->__isInitialized()) {
return;
}
$properties = $proxy->__getLazyProperties();
foreach ($properties as $propertyName => $property) {
if ( ! isset($proxy->$propertyName)) {
$proxy->$propertyName = $properties[$propertyName];
}
}
$proxy->__setInitialized(true);
$proxy->__wakeup();
$identifier = $classMetadata->getIdentifierValues($proxy);
if (null === $entityPersister->loadById($identifier, $proxy)) {
$proxy->__setInitializer($initializer);
$proxy->__setCloner($cloner);
$proxy->__setInitialized(false);
throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(),
$this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
);
}
};
}
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
$initializer = $proxy->__getInitializer();
$cloner = $proxy->__getCloner();
$proxy->__setInitializer(null);
$proxy->__setCloner(null);
if ($proxy->__isInitialized()) {
return;
}
$properties = $proxy->__getLazyProperties();
foreach ($properties as $propertyName => $property) {
if (!isset($proxy->$propertyName)) {
$proxy->$propertyName = $properties[$propertyName];
}
}
$proxy->__setInitialized(true);
$identifier = $classMetadata->getIdentifierValues($proxy);
if (null === $entityPersister->loadById($identifier, $proxy)) {
$proxy->__setInitializer($initializer);
$proxy->__setCloner($cloner);
$proxy->__setInitialized(false);
throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(),
$this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
);
}
};
}
|
[
"private",
"function",
"createInitializer",
"(",
"ClassMetadata",
"$",
"classMetadata",
",",
"EntityPersister",
"$",
"entityPersister",
")",
"{",
"if",
"(",
"$",
"classMetadata",
"->",
"getReflectionClass",
"(",
")",
"->",
"hasMethod",
"(",
"'__wakeup'",
")",
")",
"{",
"return",
"function",
"(",
"BaseProxy",
"$",
"proxy",
")",
"use",
"(",
"$",
"entityPersister",
",",
"$",
"classMetadata",
")",
"{",
"$",
"initializer",
"=",
"$",
"proxy",
"->",
"__getInitializer",
"(",
")",
";",
"$",
"cloner",
"=",
"$",
"proxy",
"->",
"__getCloner",
"(",
")",
";",
"$",
"proxy",
"->",
"__setInitializer",
"(",
"null",
")",
";",
"$",
"proxy",
"->",
"__setCloner",
"(",
"null",
")",
";",
"if",
"(",
"$",
"proxy",
"->",
"__isInitialized",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"properties",
"=",
"$",
"proxy",
"->",
"__getLazyProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"propertyName",
"=>",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"proxy",
"->",
"$",
"propertyName",
")",
")",
"{",
"$",
"proxy",
"->",
"$",
"propertyName",
"=",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
";",
"}",
"}",
"$",
"proxy",
"->",
"__setInitialized",
"(",
"true",
")",
";",
"$",
"proxy",
"->",
"__wakeup",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"classMetadata",
"->",
"getIdentifierValues",
"(",
"$",
"proxy",
")",
";",
"if",
"(",
"null",
"===",
"$",
"entityPersister",
"->",
"loadById",
"(",
"$",
"identifier",
",",
"$",
"proxy",
")",
")",
"{",
"$",
"proxy",
"->",
"__setInitializer",
"(",
"$",
"initializer",
")",
";",
"$",
"proxy",
"->",
"__setCloner",
"(",
"$",
"cloner",
")",
";",
"$",
"proxy",
"->",
"__setInitialized",
"(",
"false",
")",
";",
"throw",
"EntityNotFoundException",
"::",
"fromClassNameAndIdentifier",
"(",
"$",
"classMetadata",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"identifierFlattener",
"->",
"flattenIdentifier",
"(",
"$",
"classMetadata",
",",
"$",
"identifier",
")",
")",
";",
"}",
"}",
";",
"}",
"return",
"function",
"(",
"BaseProxy",
"$",
"proxy",
")",
"use",
"(",
"$",
"entityPersister",
",",
"$",
"classMetadata",
")",
"{",
"$",
"initializer",
"=",
"$",
"proxy",
"->",
"__getInitializer",
"(",
")",
";",
"$",
"cloner",
"=",
"$",
"proxy",
"->",
"__getCloner",
"(",
")",
";",
"$",
"proxy",
"->",
"__setInitializer",
"(",
"null",
")",
";",
"$",
"proxy",
"->",
"__setCloner",
"(",
"null",
")",
";",
"if",
"(",
"$",
"proxy",
"->",
"__isInitialized",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"properties",
"=",
"$",
"proxy",
"->",
"__getLazyProperties",
"(",
")",
";",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"propertyName",
"=>",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"proxy",
"->",
"$",
"propertyName",
")",
")",
"{",
"$",
"proxy",
"->",
"$",
"propertyName",
"=",
"$",
"properties",
"[",
"$",
"propertyName",
"]",
";",
"}",
"}",
"$",
"proxy",
"->",
"__setInitialized",
"(",
"true",
")",
";",
"$",
"identifier",
"=",
"$",
"classMetadata",
"->",
"getIdentifierValues",
"(",
"$",
"proxy",
")",
";",
"if",
"(",
"null",
"===",
"$",
"entityPersister",
"->",
"loadById",
"(",
"$",
"identifier",
",",
"$",
"proxy",
")",
")",
"{",
"$",
"proxy",
"->",
"__setInitializer",
"(",
"$",
"initializer",
")",
";",
"$",
"proxy",
"->",
"__setCloner",
"(",
"$",
"cloner",
")",
";",
"$",
"proxy",
"->",
"__setInitialized",
"(",
"false",
")",
";",
"throw",
"EntityNotFoundException",
"::",
"fromClassNameAndIdentifier",
"(",
"$",
"classMetadata",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"identifierFlattener",
"->",
"flattenIdentifier",
"(",
"$",
"classMetadata",
",",
"$",
"identifier",
")",
")",
";",
"}",
"}",
";",
"}"
] |
Creates a closure capable of initializing a proxy
@param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata
@param \Doctrine\ORM\Persisters\Entity\EntityPersister $entityPersister
@return \Closure
@throws \Doctrine\ORM\EntityNotFoundException
|
[
"Creates",
"a",
"closure",
"capable",
"of",
"initializing",
"a",
"proxy"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L124-L198
|
223,346
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Proxy/ProxyFactory.php
|
ProxyFactory.createCloner
|
private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister)
{
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
if ($proxy->__isInitialized()) {
return;
}
$proxy->__setInitialized(true);
$proxy->__setInitializer(null);
$class = $entityPersister->getClassMetadata();
$identifier = $classMetadata->getIdentifierValues($proxy);
$original = $entityPersister->loadById($identifier);
if (null === $original) {
throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(),
$this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
);
}
foreach ($class->getReflectionClass()->getProperties() as $property) {
if ( ! $class->hasField($property->name) && ! $class->hasAssociation($property->name)) {
continue;
}
$property->setAccessible(true);
$property->setValue($proxy, $property->getValue($original));
}
};
}
|
php
|
private function createCloner(ClassMetadata $classMetadata, EntityPersister $entityPersister)
{
return function (BaseProxy $proxy) use ($entityPersister, $classMetadata) {
if ($proxy->__isInitialized()) {
return;
}
$proxy->__setInitialized(true);
$proxy->__setInitializer(null);
$class = $entityPersister->getClassMetadata();
$identifier = $classMetadata->getIdentifierValues($proxy);
$original = $entityPersister->loadById($identifier);
if (null === $original) {
throw EntityNotFoundException::fromClassNameAndIdentifier(
$classMetadata->getName(),
$this->identifierFlattener->flattenIdentifier($classMetadata, $identifier)
);
}
foreach ($class->getReflectionClass()->getProperties() as $property) {
if ( ! $class->hasField($property->name) && ! $class->hasAssociation($property->name)) {
continue;
}
$property->setAccessible(true);
$property->setValue($proxy, $property->getValue($original));
}
};
}
|
[
"private",
"function",
"createCloner",
"(",
"ClassMetadata",
"$",
"classMetadata",
",",
"EntityPersister",
"$",
"entityPersister",
")",
"{",
"return",
"function",
"(",
"BaseProxy",
"$",
"proxy",
")",
"use",
"(",
"$",
"entityPersister",
",",
"$",
"classMetadata",
")",
"{",
"if",
"(",
"$",
"proxy",
"->",
"__isInitialized",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"proxy",
"->",
"__setInitialized",
"(",
"true",
")",
";",
"$",
"proxy",
"->",
"__setInitializer",
"(",
"null",
")",
";",
"$",
"class",
"=",
"$",
"entityPersister",
"->",
"getClassMetadata",
"(",
")",
";",
"$",
"identifier",
"=",
"$",
"classMetadata",
"->",
"getIdentifierValues",
"(",
"$",
"proxy",
")",
";",
"$",
"original",
"=",
"$",
"entityPersister",
"->",
"loadById",
"(",
"$",
"identifier",
")",
";",
"if",
"(",
"null",
"===",
"$",
"original",
")",
"{",
"throw",
"EntityNotFoundException",
"::",
"fromClassNameAndIdentifier",
"(",
"$",
"classMetadata",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"identifierFlattener",
"->",
"flattenIdentifier",
"(",
"$",
"classMetadata",
",",
"$",
"identifier",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"class",
"->",
"getReflectionClass",
"(",
")",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"{",
"if",
"(",
"!",
"$",
"class",
"->",
"hasField",
"(",
"$",
"property",
"->",
"name",
")",
"&&",
"!",
"$",
"class",
"->",
"hasAssociation",
"(",
"$",
"property",
"->",
"name",
")",
")",
"{",
"continue",
";",
"}",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"property",
"->",
"setValue",
"(",
"$",
"proxy",
",",
"$",
"property",
"->",
"getValue",
"(",
"$",
"original",
")",
")",
";",
"}",
"}",
";",
"}"
] |
Creates a closure capable of finalizing state a cloned proxy
@param \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetadata
@param \Doctrine\ORM\Persisters\Entity\EntityPersister $entityPersister
@return \Closure
@throws \Doctrine\ORM\EntityNotFoundException
|
[
"Creates",
"a",
"closure",
"capable",
"of",
"finalizing",
"state",
"a",
"cloned",
"proxy"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L210-L240
|
223,347
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php
|
ClassMetadataExporter.getExporter
|
public function getExporter($type, $dest = null)
{
if ( ! isset(self::$_exporterDrivers[$type])) {
throw ExportException::invalidExporterDriverType($type);
}
$class = self::$_exporterDrivers[$type];
return new $class($dest);
}
|
php
|
public function getExporter($type, $dest = null)
{
if ( ! isset(self::$_exporterDrivers[$type])) {
throw ExportException::invalidExporterDriverType($type);
}
$class = self::$_exporterDrivers[$type];
return new $class($dest);
}
|
[
"public",
"function",
"getExporter",
"(",
"$",
"type",
",",
"$",
"dest",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_exporterDrivers",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"ExportException",
"::",
"invalidExporterDriverType",
"(",
"$",
"type",
")",
";",
"}",
"$",
"class",
"=",
"self",
"::",
"$",
"_exporterDrivers",
"[",
"$",
"type",
"]",
";",
"return",
"new",
"$",
"class",
"(",
"$",
"dest",
")",
";",
"}"
] |
Gets an exporter driver instance.
@param string $type The type to get (yml, xml, etc.).
@param string|null $dest The directory where the exporter will export to.
@return Driver\AbstractExporter
@throws ExportException
|
[
"Gets",
"an",
"exporter",
"driver",
"instance",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Export/ClassMetadataExporter.php#L66-L75
|
223,348
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php
|
AbstractCollectionPersister.isValidEntityState
|
protected function isValidEntityState($entity)
{
$entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW);
if ($entityState === UnitOfWork::STATE_NEW) {
return false;
}
// If Entity is scheduled for inclusion, it is not in this collection.
// We can assure that because it would have return true before on array check
if ($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($entity)) {
return false;
}
return true;
}
|
php
|
protected function isValidEntityState($entity)
{
$entityState = $this->uow->getEntityState($entity, UnitOfWork::STATE_NEW);
if ($entityState === UnitOfWork::STATE_NEW) {
return false;
}
// If Entity is scheduled for inclusion, it is not in this collection.
// We can assure that because it would have return true before on array check
if ($entityState === UnitOfWork::STATE_MANAGED && $this->uow->isScheduledForInsert($entity)) {
return false;
}
return true;
}
|
[
"protected",
"function",
"isValidEntityState",
"(",
"$",
"entity",
")",
"{",
"$",
"entityState",
"=",
"$",
"this",
"->",
"uow",
"->",
"getEntityState",
"(",
"$",
"entity",
",",
"UnitOfWork",
"::",
"STATE_NEW",
")",
";",
"if",
"(",
"$",
"entityState",
"===",
"UnitOfWork",
"::",
"STATE_NEW",
")",
"{",
"return",
"false",
";",
"}",
"// If Entity is scheduled for inclusion, it is not in this collection.",
"// We can assure that because it would have return true before on array check",
"if",
"(",
"$",
"entityState",
"===",
"UnitOfWork",
"::",
"STATE_MANAGED",
"&&",
"$",
"this",
"->",
"uow",
"->",
"isScheduledForInsert",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check if entity is in a valid state for operations.
@param object $entity
@return bool
|
[
"Check",
"if",
"entity",
"is",
"in",
"a",
"valid",
"state",
"for",
"operations",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Persisters/Collection/AbstractCollectionPersister.php#L83-L98
|
223,349
|
mmerian/phpcrawl
|
libs/PHPCrawlerLinkFinder.class.php
|
PHPCrawlerLinkFinder.findRedirectLinkInHeader
|
protected function findRedirectLinkInHeader(&$http_header)
{
PHPCrawlerBenchmark::start("checking_for_redirect_link");
// Get redirect-URL or link from header
$redirect_link = PHPCrawlerUtils::getRedirectURLFromHeader($http_header);
// Add redirect-URL to linkcache
if ($redirect_link != null)
{
$this->addLinkToCache($redirect_link, "", "", true);
}
PHPCrawlerBenchmark::stop("checking_for_redirect_link");
}
|
php
|
protected function findRedirectLinkInHeader(&$http_header)
{
PHPCrawlerBenchmark::start("checking_for_redirect_link");
// Get redirect-URL or link from header
$redirect_link = PHPCrawlerUtils::getRedirectURLFromHeader($http_header);
// Add redirect-URL to linkcache
if ($redirect_link != null)
{
$this->addLinkToCache($redirect_link, "", "", true);
}
PHPCrawlerBenchmark::stop("checking_for_redirect_link");
}
|
[
"protected",
"function",
"findRedirectLinkInHeader",
"(",
"&",
"$",
"http_header",
")",
"{",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"checking_for_redirect_link\"",
")",
";",
"// Get redirect-URL or link from header\r",
"$",
"redirect_link",
"=",
"PHPCrawlerUtils",
"::",
"getRedirectURLFromHeader",
"(",
"$",
"http_header",
")",
";",
"// Add redirect-URL to linkcache\r",
"if",
"(",
"$",
"redirect_link",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"addLinkToCache",
"(",
"$",
"redirect_link",
",",
"\"\"",
",",
"\"\"",
",",
"true",
")",
";",
"}",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"checking_for_redirect_link\"",
")",
";",
"}"
] |
Checks for a redirect-URL in the given http-header and adds it to the internal link-cache.
|
[
"Checks",
"for",
"a",
"redirect",
"-",
"URL",
"in",
"the",
"given",
"http",
"-",
"header",
"and",
"adds",
"it",
"to",
"the",
"internal",
"link",
"-",
"cache",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerLinkFinder.class.php#L121-L135
|
223,350
|
mmerian/phpcrawl
|
libs/PHPCrawlerLinkFinder.class.php
|
PHPCrawlerLinkFinder.prepareHTMLChunk
|
protected function prepareHTMLChunk(&$html_source)
{
// WARNING:
// When modifying, test thhe following regexes on a huge page for preg_replace segfaults.
// Be sure to set the preg-groups to "non-capture" (?:...)!
// Replace <script>-sections from source, but only those without src in it.
if ($this->ignore_document_sections & PHPCrawlerLinkSearchDocumentSections::SCRIPT_SECTIONS)
{
$html_source = preg_replace("#<script(?:(?!src).)*>.*(?:<\/script>|$)# Uis", "", $html_source);
$html_source = preg_replace("#^(?:(?!<script).)*<\/script># Uis", "", $html_source);
}
// Replace HTML-comments from source
if ($this->ignore_document_sections & PHPCrawlerLinkSearchDocumentSections::HTML_COMMENT_SECTIONS)
{
$html_source = preg_replace("#<\!--.*(?:-->|$)# Uis", "", $html_source);
$html_source = preg_replace("#^(?:(?!<\!--).)*--># Uis", "", $html_source);
}
// Replace javascript-triggering attributes
if ($this->ignore_document_sections & PHPCrawlerLinkSearchDocumentSections::JS_TRIGGERING_SECTIONS)
{
$html_source = preg_replace("#on[a-z]+\s*=\s*(?|\"([^\"]+)\"|'([^']+)'|([^\s><'\"]+))# Uis", "", $html_source);
}
}
|
php
|
protected function prepareHTMLChunk(&$html_source)
{
// WARNING:
// When modifying, test thhe following regexes on a huge page for preg_replace segfaults.
// Be sure to set the preg-groups to "non-capture" (?:...)!
// Replace <script>-sections from source, but only those without src in it.
if ($this->ignore_document_sections & PHPCrawlerLinkSearchDocumentSections::SCRIPT_SECTIONS)
{
$html_source = preg_replace("#<script(?:(?!src).)*>.*(?:<\/script>|$)# Uis", "", $html_source);
$html_source = preg_replace("#^(?:(?!<script).)*<\/script># Uis", "", $html_source);
}
// Replace HTML-comments from source
if ($this->ignore_document_sections & PHPCrawlerLinkSearchDocumentSections::HTML_COMMENT_SECTIONS)
{
$html_source = preg_replace("#<\!--.*(?:-->|$)# Uis", "", $html_source);
$html_source = preg_replace("#^(?:(?!<\!--).)*--># Uis", "", $html_source);
}
// Replace javascript-triggering attributes
if ($this->ignore_document_sections & PHPCrawlerLinkSearchDocumentSections::JS_TRIGGERING_SECTIONS)
{
$html_source = preg_replace("#on[a-z]+\s*=\s*(?|\"([^\"]+)\"|'([^']+)'|([^\s><'\"]+))# Uis", "", $html_source);
}
}
|
[
"protected",
"function",
"prepareHTMLChunk",
"(",
"&",
"$",
"html_source",
")",
"{",
"// WARNING:\r",
"// When modifying, test thhe following regexes on a huge page for preg_replace segfaults.\r",
"// Be sure to set the preg-groups to \"non-capture\" (?:...)!\r",
"// Replace <script>-sections from source, but only those without src in it.\r",
"if",
"(",
"$",
"this",
"->",
"ignore_document_sections",
"&",
"PHPCrawlerLinkSearchDocumentSections",
"::",
"SCRIPT_SECTIONS",
")",
"{",
"$",
"html_source",
"=",
"preg_replace",
"(",
"\"#<script(?:(?!src).)*>.*(?:<\\/script>|$)# Uis\"",
",",
"\"\"",
",",
"$",
"html_source",
")",
";",
"$",
"html_source",
"=",
"preg_replace",
"(",
"\"#^(?:(?!<script).)*<\\/script># Uis\"",
",",
"\"\"",
",",
"$",
"html_source",
")",
";",
"}",
"// Replace HTML-comments from source\r",
"if",
"(",
"$",
"this",
"->",
"ignore_document_sections",
"&",
"PHPCrawlerLinkSearchDocumentSections",
"::",
"HTML_COMMENT_SECTIONS",
")",
"{",
"$",
"html_source",
"=",
"preg_replace",
"(",
"\"#<\\!--.*(?:-->|$)# Uis\"",
",",
"\"\"",
",",
"$",
"html_source",
")",
";",
"$",
"html_source",
"=",
"preg_replace",
"(",
"\"#^(?:(?!<\\!--).)*--># Uis\"",
",",
"\"\"",
",",
"$",
"html_source",
")",
";",
"}",
"// Replace javascript-triggering attributes\r",
"if",
"(",
"$",
"this",
"->",
"ignore_document_sections",
"&",
"PHPCrawlerLinkSearchDocumentSections",
"::",
"JS_TRIGGERING_SECTIONS",
")",
"{",
"$",
"html_source",
"=",
"preg_replace",
"(",
"\"#on[a-z]+\\s*=\\s*(?|\\\"([^\\\"]+)\\\"|'([^']+)'|([^\\s><'\\\"]+))# Uis\"",
",",
"\"\"",
",",
"$",
"html_source",
")",
";",
"}",
"}"
] |
Prepares a chunk of HTML before links get searched in it
|
[
"Prepares",
"a",
"chunk",
"of",
"HTML",
"before",
"links",
"get",
"searched",
"in",
"it"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerLinkFinder.class.php#L244-L269
|
223,351
|
efficiently/jquery-laravel
|
src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php
|
EloquentHtmlHelper.domId
|
public function domId($record, $prefix = null, $fallbackPrefix = 'create')
{
if ($recordId = $this->recordKeyForDomId($record)) {
return $this->domClass($record, $prefix).'_'.$recordId;
} else {
$prefix = $prefix ?: $fallbackPrefix;
return $this->domClass($record, $prefix);
}
}
|
php
|
public function domId($record, $prefix = null, $fallbackPrefix = 'create')
{
if ($recordId = $this->recordKeyForDomId($record)) {
return $this->domClass($record, $prefix).'_'.$recordId;
} else {
$prefix = $prefix ?: $fallbackPrefix;
return $this->domClass($record, $prefix);
}
}
|
[
"public",
"function",
"domId",
"(",
"$",
"record",
",",
"$",
"prefix",
"=",
"null",
",",
"$",
"fallbackPrefix",
"=",
"'create'",
")",
"{",
"if",
"(",
"$",
"recordId",
"=",
"$",
"this",
"->",
"recordKeyForDomId",
"(",
"$",
"record",
")",
")",
"{",
"return",
"$",
"this",
"->",
"domClass",
"(",
"$",
"record",
",",
"$",
"prefix",
")",
".",
"'_'",
".",
"$",
"recordId",
";",
"}",
"else",
"{",
"$",
"prefix",
"=",
"$",
"prefix",
"?",
":",
"$",
"fallbackPrefix",
";",
"return",
"$",
"this",
"->",
"domClass",
"(",
"$",
"record",
",",
"$",
"prefix",
")",
";",
"}",
"}"
] |
The DOM id convention is to use the singular form of an object or class with the id following an underscore.
If no id is found, prefix with "create_" instead.
@param object|\Illuminate\Database\Eloquent\Model $record
@param string $prefix
@param string $fallbackPrefix By default it's 'create'
@return string
|
[
"The",
"DOM",
"id",
"convention",
"is",
"to",
"use",
"the",
"singular",
"form",
"of",
"an",
"object",
"or",
"class",
"with",
"the",
"id",
"following",
"an",
"underscore",
".",
"If",
"no",
"id",
"is",
"found",
"prefix",
"with",
"create_",
"instead",
"."
] |
30e3953e51ac8644e13d90150e2cf56012ce8f6b
|
https://github.com/efficiently/jquery-laravel/blob/30e3953e51ac8644e13d90150e2cf56012ce8f6b/src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php#L16-L24
|
223,352
|
efficiently/jquery-laravel
|
src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php
|
EloquentHtmlHelper.formId
|
public function formId($record, $fallbackPrefix = 'create')
{
if ($recordId = $this->recordKeyForDomId($record)) {
return $this->domClass($record, 'edit').'_'.$recordId;
}
return $this->domClass($record, $fallbackPrefix);
}
|
php
|
public function formId($record, $fallbackPrefix = 'create')
{
if ($recordId = $this->recordKeyForDomId($record)) {
return $this->domClass($record, 'edit').'_'.$recordId;
}
return $this->domClass($record, $fallbackPrefix);
}
|
[
"public",
"function",
"formId",
"(",
"$",
"record",
",",
"$",
"fallbackPrefix",
"=",
"'create'",
")",
"{",
"if",
"(",
"$",
"recordId",
"=",
"$",
"this",
"->",
"recordKeyForDomId",
"(",
"$",
"record",
")",
")",
"{",
"return",
"$",
"this",
"->",
"domClass",
"(",
"$",
"record",
",",
"'edit'",
")",
".",
"'_'",
".",
"$",
"recordId",
";",
"}",
"return",
"$",
"this",
"->",
"domClass",
"(",
"$",
"record",
",",
"$",
"fallbackPrefix",
")",
";",
"}"
] |
The Form id convention is to use the singular form of an object or class with the id following an underscore.
If id is found, prefix with "edit_".
If no id is found, prefix with "create_" instead.
@param object|\Illuminate\Database\Eloquent\Model $record
@param string $fallbackPrefix By default it's 'create'
@return string
|
[
"The",
"Form",
"id",
"convention",
"is",
"to",
"use",
"the",
"singular",
"form",
"of",
"an",
"object",
"or",
"class",
"with",
"the",
"id",
"following",
"an",
"underscore",
".",
"If",
"id",
"is",
"found",
"prefix",
"with",
"edit_",
".",
"If",
"no",
"id",
"is",
"found",
"prefix",
"with",
"create_",
"instead",
"."
] |
30e3953e51ac8644e13d90150e2cf56012ce8f6b
|
https://github.com/efficiently/jquery-laravel/blob/30e3953e51ac8644e13d90150e2cf56012ce8f6b/src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php#L35-L42
|
223,353
|
efficiently/jquery-laravel
|
src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php
|
EloquentHtmlHelper.domClass
|
public function domClass($recordOrClass, $prefix = null)
{
$singular = snake_case(camel_case(preg_replace('/\\\\/', ' ', $this->modelNameFromRecordOrClassname($recordOrClass))));
return $prefix ? $prefix.'_'.$singular : $singular;
}
|
php
|
public function domClass($recordOrClass, $prefix = null)
{
$singular = snake_case(camel_case(preg_replace('/\\\\/', ' ', $this->modelNameFromRecordOrClassname($recordOrClass))));
return $prefix ? $prefix.'_'.$singular : $singular;
}
|
[
"public",
"function",
"domClass",
"(",
"$",
"recordOrClass",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"singular",
"=",
"snake_case",
"(",
"camel_case",
"(",
"preg_replace",
"(",
"'/\\\\\\\\/'",
",",
"' '",
",",
"$",
"this",
"->",
"modelNameFromRecordOrClassname",
"(",
"$",
"recordOrClass",
")",
")",
")",
")",
";",
"return",
"$",
"prefix",
"?",
"$",
"prefix",
".",
"'_'",
".",
"$",
"singular",
":",
"$",
"singular",
";",
"}"
] |
The DOM class convention is to use the singular form of an object or class.
@param string|object|\Illuminate\Database\Eloquent\Model $recordOrClass
@param string $prefix
@return string
|
[
"The",
"DOM",
"class",
"convention",
"is",
"to",
"use",
"the",
"singular",
"form",
"of",
"an",
"object",
"or",
"class",
"."
] |
30e3953e51ac8644e13d90150e2cf56012ce8f6b
|
https://github.com/efficiently/jquery-laravel/blob/30e3953e51ac8644e13d90150e2cf56012ce8f6b/src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php#L62-L66
|
223,354
|
efficiently/jquery-laravel
|
src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php
|
EloquentHtmlHelper.removeRootNamespace
|
protected function removeRootNamespace($classname)
{
$namespaces = $this->splitNamespaces($classname);
if (count($namespaces) > 1) {
$classname = implode('\\', array_slice($namespaces, 1));
}
return $classname;
}
|
php
|
protected function removeRootNamespace($classname)
{
$namespaces = $this->splitNamespaces($classname);
if (count($namespaces) > 1) {
$classname = implode('\\', array_slice($namespaces, 1));
}
return $classname;
}
|
[
"protected",
"function",
"removeRootNamespace",
"(",
"$",
"classname",
")",
"{",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"splitNamespaces",
"(",
"$",
"classname",
")",
";",
"if",
"(",
"count",
"(",
"$",
"namespaces",
")",
">",
"1",
")",
"{",
"$",
"classname",
"=",
"implode",
"(",
"'\\\\'",
",",
"array_slice",
"(",
"$",
"namespaces",
",",
"1",
")",
")",
";",
"}",
"return",
"$",
"classname",
";",
"}"
] |
Remove Root namespace. E.G 'App\Message' -> 'Message'
@param string $classname
|
[
"Remove",
"Root",
"namespace",
".",
"E",
".",
"G",
"App",
"\\",
"Message",
"-",
">",
"Message"
] |
30e3953e51ac8644e13d90150e2cf56012ce8f6b
|
https://github.com/efficiently/jquery-laravel/blob/30e3953e51ac8644e13d90150e2cf56012ce8f6b/src/Efficiently/JqueryLaravel/EloquentHtmlHelper.php#L84-L92
|
223,355
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerEncodingUtils.class.php
|
PHPCrawlerEncodingUtils.isUTF8String
|
public static function isUTF8String($string)
{
$sample = @iconv('utf-8', 'utf-8', $string);
if (md5($sample) == md5($string))
return true;
else
return false;
}
|
php
|
public static function isUTF8String($string)
{
$sample = @iconv('utf-8', 'utf-8', $string);
if (md5($sample) == md5($string))
return true;
else
return false;
}
|
[
"public",
"static",
"function",
"isUTF8String",
"(",
"$",
"string",
")",
"{",
"$",
"sample",
"=",
"@",
"iconv",
"(",
"'utf-8'",
",",
"'utf-8'",
",",
"$",
"string",
")",
";",
"if",
"(",
"md5",
"(",
"$",
"sample",
")",
"==",
"md5",
"(",
"$",
"string",
")",
")",
"return",
"true",
";",
"else",
"return",
"false",
";",
"}"
] |
Checks wether the given string is an UTF8-encoded string.
Taken from http://www.php.net/manual/de/function.mb-detect-encoding.php
(comment from "prgss at bk dot ru")
@param string $string The string
@return bool TRUE if the string is UTF-8 encoded.
|
[
"Checks",
"wether",
"the",
"given",
"string",
"is",
"an",
"UTF8",
"-",
"encoded",
"string",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerEncodingUtils.class.php#L44-L52
|
223,356
|
mmerian/phpcrawl
|
libs/Utils/PHPCrawlerEncodingUtils.class.php
|
PHPCrawlerEncodingUtils.decodeHtmlEntities
|
public static function decodeHtmlEntities($string)
{
// Entities-replacements
$entities = array ("'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i");
$entitie_replacements = array ("\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169));
$string = preg_replace($entities, $entitie_replacements, $string);
// Numeric haracter reference replacement (non-HEX), like @ => "@"
$string = preg_replace_callback("/&#([0-9]{1,4});/ i", function($m) {return chr($m[1]);}, $string);
// Numeric character reference replacement (HEX), like / => "/"
$string = preg_replace_callback("/&#x([0-9a-z]{2,4});/ i", function($m) {return chr(hexdec($m[1]));}, $string);
return $string;
}
|
php
|
public static function decodeHtmlEntities($string)
{
// Entities-replacements
$entities = array ("'&(quot|#34);'i",
"'&(amp|#38);'i",
"'&(lt|#60);'i",
"'&(gt|#62);'i",
"'&(nbsp|#160);'i",
"'&(iexcl|#161);'i",
"'&(cent|#162);'i",
"'&(pound|#163);'i",
"'&(copy|#169);'i");
$entitie_replacements = array ("\"",
"&",
"<",
">",
" ",
chr(161),
chr(162),
chr(163),
chr(169));
$string = preg_replace($entities, $entitie_replacements, $string);
// Numeric haracter reference replacement (non-HEX), like @ => "@"
$string = preg_replace_callback("/&#([0-9]{1,4});/ i", function($m) {return chr($m[1]);}, $string);
// Numeric character reference replacement (HEX), like / => "/"
$string = preg_replace_callback("/&#x([0-9a-z]{2,4});/ i", function($m) {return chr(hexdec($m[1]));}, $string);
return $string;
}
|
[
"public",
"static",
"function",
"decodeHtmlEntities",
"(",
"$",
"string",
")",
"{",
"// Entities-replacements\r",
"$",
"entities",
"=",
"array",
"(",
"\"'&(quot|#34);'i\"",
",",
"\"'&(amp|#38);'i\"",
",",
"\"'&(lt|#60);'i\"",
",",
"\"'&(gt|#62);'i\"",
",",
"\"'&(nbsp|#160);'i\"",
",",
"\"'&(iexcl|#161);'i\"",
",",
"\"'&(cent|#162);'i\"",
",",
"\"'&(pound|#163);'i\"",
",",
"\"'&(copy|#169);'i\"",
")",
";",
"$",
"entitie_replacements",
"=",
"array",
"(",
"\"\\\"\"",
",",
"\"&\"",
",",
"\"<\"",
",",
"\">\"",
",",
"\" \"",
",",
"chr",
"(",
"161",
")",
",",
"chr",
"(",
"162",
")",
",",
"chr",
"(",
"163",
")",
",",
"chr",
"(",
"169",
")",
")",
";",
"$",
"string",
"=",
"preg_replace",
"(",
"$",
"entities",
",",
"$",
"entitie_replacements",
",",
"$",
"string",
")",
";",
"// Numeric haracter reference replacement (non-HEX), like @ => \"@\"\r",
"$",
"string",
"=",
"preg_replace_callback",
"(",
"\"/&#([0-9]{1,4});/ i\"",
",",
"function",
"(",
"$",
"m",
")",
"{",
"return",
"chr",
"(",
"$",
"m",
"[",
"1",
"]",
")",
";",
"}",
",",
"$",
"string",
")",
";",
"// Numeric character reference replacement (HEX), like / => \"/\"\r",
"$",
"string",
"=",
"preg_replace_callback",
"(",
"\"/&#x([0-9a-z]{2,4});/ i\"",
",",
"function",
"(",
"$",
"m",
")",
"{",
"return",
"chr",
"(",
"hexdec",
"(",
"$",
"m",
"[",
"1",
"]",
")",
")",
";",
"}",
",",
"$",
"string",
")",
";",
"return",
"$",
"string",
";",
"}"
] |
Decodes all HTML-entities in the given string including numeric and hexadecimal character references
@param string $string
@return string
|
[
"Decodes",
"all",
"HTML",
"-",
"entities",
"in",
"the",
"given",
"string",
"including",
"numeric",
"and",
"hexadecimal",
"character",
"references"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/Utils/PHPCrawlerEncodingUtils.class.php#L60-L93
|
223,357
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php
|
ConvertDoctrine1Schema.getMetadata
|
public function getMetadata()
{
$schema = array();
foreach ($this->from as $path) {
if (is_dir($path)) {
$files = glob($path . '/*.yml');
foreach ($files as $file) {
$schema = array_merge($schema, (array) Yaml::parse(file_get_contents($file)));
}
} else {
$schema = array_merge($schema, (array) Yaml::parse(file_get_contents($path)));
}
}
$metadatas = array();
foreach ($schema as $className => $mappingInformation) {
$metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation);
}
return $metadatas;
}
|
php
|
public function getMetadata()
{
$schema = array();
foreach ($this->from as $path) {
if (is_dir($path)) {
$files = glob($path . '/*.yml');
foreach ($files as $file) {
$schema = array_merge($schema, (array) Yaml::parse(file_get_contents($file)));
}
} else {
$schema = array_merge($schema, (array) Yaml::parse(file_get_contents($path)));
}
}
$metadatas = array();
foreach ($schema as $className => $mappingInformation) {
$metadatas[] = $this->convertToClassMetadataInfo($className, $mappingInformation);
}
return $metadatas;
}
|
[
"public",
"function",
"getMetadata",
"(",
")",
"{",
"$",
"schema",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"from",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"path",
".",
"'/*.yml'",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"schema",
"=",
"array_merge",
"(",
"$",
"schema",
",",
"(",
"array",
")",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"file",
")",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"schema",
"=",
"array_merge",
"(",
"$",
"schema",
",",
"(",
"array",
")",
"Yaml",
"::",
"parse",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
")",
")",
";",
"}",
"}",
"$",
"metadatas",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"schema",
"as",
"$",
"className",
"=>",
"$",
"mappingInformation",
")",
"{",
"$",
"metadatas",
"[",
"]",
"=",
"$",
"this",
"->",
"convertToClassMetadataInfo",
"(",
"$",
"className",
",",
"$",
"mappingInformation",
")",
";",
"}",
"return",
"$",
"metadatas",
";",
"}"
] |
Gets an array of ClassMetadataInfo instances from the passed
Doctrine 1 schema.
@return array An array of ClassMetadataInfo instances
|
[
"Gets",
"an",
"array",
"of",
"ClassMetadataInfo",
"instances",
"from",
"the",
"passed",
"Doctrine",
"1",
"schema",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/ConvertDoctrine1Schema.php#L73-L93
|
223,358
|
stuttter/wp-event-calendar
|
wp-event-calendar/includes/common/list-table-month.php
|
WP_Event_Calendar_Month_Table.setup_item
|
protected function setup_item( $post = false, $max = 10 ) {
// Bail if there is no post
if ( empty( $post ) ) {
return;
}
// Start day
$time = $this->item_start;
$type = 'items';
$max_int = absint( $max );
// Loop through days and setup the item
for ( $i = 0, $j = $this->item_days; $i < $j; ++$i ) {
$day = (int) date_i18n( 'j', $time );
$month = (int) date_i18n( 'n', $time );
$year = (int) date_i18n( 'Y', $time );
// Skip if not this month
if ( ( $month === (int) $this->month ) && ( $year === (int) $this->year ) ) {
// Setup the pointer for each day
$this->setup_pointer( $post, $day );
// Get count for day
$count = empty( $this->{$type}[ $day ] )
? 0
: count( $this->{$type}[ $day ] );
// Add post to item types for each day in it's duration
if ( $count < $max_int ) {
$this->{$type}[ $day ][ $post->ID ] = $post;
}
}
// Bump the time 1 day
$time += DAY_IN_SECONDS;
}
}
|
php
|
protected function setup_item( $post = false, $max = 10 ) {
// Bail if there is no post
if ( empty( $post ) ) {
return;
}
// Start day
$time = $this->item_start;
$type = 'items';
$max_int = absint( $max );
// Loop through days and setup the item
for ( $i = 0, $j = $this->item_days; $i < $j; ++$i ) {
$day = (int) date_i18n( 'j', $time );
$month = (int) date_i18n( 'n', $time );
$year = (int) date_i18n( 'Y', $time );
// Skip if not this month
if ( ( $month === (int) $this->month ) && ( $year === (int) $this->year ) ) {
// Setup the pointer for each day
$this->setup_pointer( $post, $day );
// Get count for day
$count = empty( $this->{$type}[ $day ] )
? 0
: count( $this->{$type}[ $day ] );
// Add post to item types for each day in it's duration
if ( $count < $max_int ) {
$this->{$type}[ $day ][ $post->ID ] = $post;
}
}
// Bump the time 1 day
$time += DAY_IN_SECONDS;
}
}
|
[
"protected",
"function",
"setup_item",
"(",
"$",
"post",
"=",
"false",
",",
"$",
"max",
"=",
"10",
")",
"{",
"// Bail if there is no post",
"if",
"(",
"empty",
"(",
"$",
"post",
")",
")",
"{",
"return",
";",
"}",
"// Start day",
"$",
"time",
"=",
"$",
"this",
"->",
"item_start",
";",
"$",
"type",
"=",
"'items'",
";",
"$",
"max_int",
"=",
"absint",
"(",
"$",
"max",
")",
";",
"// Loop through days and setup the item",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"j",
"=",
"$",
"this",
"->",
"item_days",
";",
"$",
"i",
"<",
"$",
"j",
";",
"++",
"$",
"i",
")",
"{",
"$",
"day",
"=",
"(",
"int",
")",
"date_i18n",
"(",
"'j'",
",",
"$",
"time",
")",
";",
"$",
"month",
"=",
"(",
"int",
")",
"date_i18n",
"(",
"'n'",
",",
"$",
"time",
")",
";",
"$",
"year",
"=",
"(",
"int",
")",
"date_i18n",
"(",
"'Y'",
",",
"$",
"time",
")",
";",
"// Skip if not this month",
"if",
"(",
"(",
"$",
"month",
"===",
"(",
"int",
")",
"$",
"this",
"->",
"month",
")",
"&&",
"(",
"$",
"year",
"===",
"(",
"int",
")",
"$",
"this",
"->",
"year",
")",
")",
"{",
"// Setup the pointer for each day",
"$",
"this",
"->",
"setup_pointer",
"(",
"$",
"post",
",",
"$",
"day",
")",
";",
"// Get count for day",
"$",
"count",
"=",
"empty",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"[",
"$",
"day",
"]",
")",
"?",
"0",
":",
"count",
"(",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"[",
"$",
"day",
"]",
")",
";",
"// Add post to item types for each day in it's duration",
"if",
"(",
"$",
"count",
"<",
"$",
"max_int",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"type",
"}",
"[",
"$",
"day",
"]",
"[",
"$",
"post",
"->",
"ID",
"]",
"=",
"$",
"post",
";",
"}",
"}",
"// Bump the time 1 day",
"$",
"time",
"+=",
"DAY_IN_SECONDS",
";",
"}",
"}"
] |
Add a post to the item array, keyed by day
@todo Repeat & expire
@since 0.1.1
@param object $post
@param int $max
|
[
"Add",
"a",
"post",
"to",
"the",
"item",
"array",
"keyed",
"by",
"day"
] |
e2221b52f0683c105c64fca056daa63763ea8665
|
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/list-table-month.php#L89-L127
|
223,359
|
stuttter/wp-event-calendar
|
wp-event-calendar/includes/common/list-table-month.php
|
WP_Event_Calendar_Month_Table.display_mode
|
protected function display_mode() {
// Get timestamp
$timestamp = mktime( 0, 0, 0, $this->month, 1, $this->year );
$max_day = date_i18n( 't', $timestamp );
$this_month = getdate( $timestamp );
$start_day = $this_month['wday'];
// Loop through days of the month
for ( $i = 0; $i < ( $max_day + $start_day ); $i++ ) {
// New row
if ( ( $i % 7 ) === 0 ) {
$this->get_row_start();
}
// Pad day
if ( $i < $start_day ) {
$this->get_row_pad( $i, $start_day );
// Month day
} else {
$this->get_row_cell( $i, $start_day );
}
if ( ( $i % 7 ) === 6 ) {
$this->get_row_end();
}
}
}
|
php
|
protected function display_mode() {
// Get timestamp
$timestamp = mktime( 0, 0, 0, $this->month, 1, $this->year );
$max_day = date_i18n( 't', $timestamp );
$this_month = getdate( $timestamp );
$start_day = $this_month['wday'];
// Loop through days of the month
for ( $i = 0; $i < ( $max_day + $start_day ); $i++ ) {
// New row
if ( ( $i % 7 ) === 0 ) {
$this->get_row_start();
}
// Pad day
if ( $i < $start_day ) {
$this->get_row_pad( $i, $start_day );
// Month day
} else {
$this->get_row_cell( $i, $start_day );
}
if ( ( $i % 7 ) === 6 ) {
$this->get_row_end();
}
}
}
|
[
"protected",
"function",
"display_mode",
"(",
")",
"{",
"// Get timestamp",
"$",
"timestamp",
"=",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"month",
",",
"1",
",",
"$",
"this",
"->",
"year",
")",
";",
"$",
"max_day",
"=",
"date_i18n",
"(",
"'t'",
",",
"$",
"timestamp",
")",
";",
"$",
"this_month",
"=",
"getdate",
"(",
"$",
"timestamp",
")",
";",
"$",
"start_day",
"=",
"$",
"this_month",
"[",
"'wday'",
"]",
";",
"// Loop through days of the month",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"(",
"$",
"max_day",
"+",
"$",
"start_day",
")",
";",
"$",
"i",
"++",
")",
"{",
"// New row",
"if",
"(",
"(",
"$",
"i",
"%",
"7",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"get_row_start",
"(",
")",
";",
"}",
"// Pad day",
"if",
"(",
"$",
"i",
"<",
"$",
"start_day",
")",
"{",
"$",
"this",
"->",
"get_row_pad",
"(",
"$",
"i",
",",
"$",
"start_day",
")",
";",
"// Month day",
"}",
"else",
"{",
"$",
"this",
"->",
"get_row_cell",
"(",
"$",
"i",
",",
"$",
"start_day",
")",
";",
"}",
"if",
"(",
"(",
"$",
"i",
"%",
"7",
")",
"===",
"6",
")",
"{",
"$",
"this",
"->",
"get_row_end",
"(",
")",
";",
"}",
"}",
"}"
] |
Display a calendar by month and year
@since 0.1.0
|
[
"Display",
"a",
"calendar",
"by",
"month",
"and",
"year"
] |
e2221b52f0683c105c64fca056daa63763ea8665
|
https://github.com/stuttter/wp-event-calendar/blob/e2221b52f0683c105c64fca056daa63763ea8665/wp-event-calendar/includes/common/list-table-month.php#L214-L243
|
223,360
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php
|
LimitSubqueryOutputWalker.rebuildOrderByClauseForOuterScope
|
private function rebuildOrderByClauseForOuterScope(OrderByClause $orderByClause)
{
$dqlAliasToSqlTableAliasMap
= $searchPatterns
= $replacements
= $dqlAliasToClassMap
= $selectListAdditions
= $orderByItems
= [];
// Generate DQL alias -> SQL table alias mapping
foreach(array_keys($this->rsm->aliasMap) as $dqlAlias) {
$dqlAliasToClassMap[$dqlAlias] = $class = $this->queryComponents[$dqlAlias]['metadata'];
$dqlAliasToSqlTableAliasMap[$dqlAlias] = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
}
// Pattern to find table path expressions in the order by clause
$fieldSearchPattern = '/(?<![a-z0-9_])%s\.%s(?![a-z0-9_])/i';
// Generate search patterns for each field's path expression in the order by clause
foreach($this->rsm->fieldMappings as $fieldAlias => $fieldName) {
$dqlAliasForFieldAlias = $this->rsm->columnOwnerMap[$fieldAlias];
$class = $dqlAliasToClassMap[$dqlAliasForFieldAlias];
// If the field is from a joined child table, we won't be ordering
// on it.
if (!isset($class->fieldMappings[$fieldName])) {
continue;
}
$fieldMapping = $class->fieldMappings[$fieldName];
// Get the proper column name as will appear in the select list
$columnName = $this->quoteStrategy->getColumnName(
$fieldName,
$dqlAliasToClassMap[$dqlAliasForFieldAlias],
$this->em->getConnection()->getDatabasePlatform()
);
// Get the SQL table alias for the entity and field
$sqlTableAliasForFieldAlias = $dqlAliasToSqlTableAliasMap[$dqlAliasForFieldAlias];
if (isset($fieldMapping['declared']) && $fieldMapping['declared'] !== $class->name) {
// Field was declared in a parent class, so we need to get the proper SQL table alias
// for the joined parent table.
$otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);
if (!$otherClassMetadata->isMappedSuperclass) {
$sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
}
}
// Compose search/replace patterns
$searchPatterns[] = sprintf($fieldSearchPattern, $sqlTableAliasForFieldAlias, $columnName);
$replacements[] = $fieldAlias;
}
foreach($orderByClause->orderByItems as $orderByItem) {
// Walk order by item to get string representation of it
$orderByItemString = $this->walkOrderByItem($orderByItem);
// Replace path expressions in the order by clause with their column alias
$orderByItemString = preg_replace($searchPatterns, $replacements, $orderByItemString);
$orderByItems[] = $orderByItemString;
}
return $orderByItems;
}
|
php
|
private function rebuildOrderByClauseForOuterScope(OrderByClause $orderByClause)
{
$dqlAliasToSqlTableAliasMap
= $searchPatterns
= $replacements
= $dqlAliasToClassMap
= $selectListAdditions
= $orderByItems
= [];
// Generate DQL alias -> SQL table alias mapping
foreach(array_keys($this->rsm->aliasMap) as $dqlAlias) {
$dqlAliasToClassMap[$dqlAlias] = $class = $this->queryComponents[$dqlAlias]['metadata'];
$dqlAliasToSqlTableAliasMap[$dqlAlias] = $this->getSQLTableAlias($class->getTableName(), $dqlAlias);
}
// Pattern to find table path expressions in the order by clause
$fieldSearchPattern = '/(?<![a-z0-9_])%s\.%s(?![a-z0-9_])/i';
// Generate search patterns for each field's path expression in the order by clause
foreach($this->rsm->fieldMappings as $fieldAlias => $fieldName) {
$dqlAliasForFieldAlias = $this->rsm->columnOwnerMap[$fieldAlias];
$class = $dqlAliasToClassMap[$dqlAliasForFieldAlias];
// If the field is from a joined child table, we won't be ordering
// on it.
if (!isset($class->fieldMappings[$fieldName])) {
continue;
}
$fieldMapping = $class->fieldMappings[$fieldName];
// Get the proper column name as will appear in the select list
$columnName = $this->quoteStrategy->getColumnName(
$fieldName,
$dqlAliasToClassMap[$dqlAliasForFieldAlias],
$this->em->getConnection()->getDatabasePlatform()
);
// Get the SQL table alias for the entity and field
$sqlTableAliasForFieldAlias = $dqlAliasToSqlTableAliasMap[$dqlAliasForFieldAlias];
if (isset($fieldMapping['declared']) && $fieldMapping['declared'] !== $class->name) {
// Field was declared in a parent class, so we need to get the proper SQL table alias
// for the joined parent table.
$otherClassMetadata = $this->em->getClassMetadata($fieldMapping['declared']);
if (!$otherClassMetadata->isMappedSuperclass) {
$sqlTableAliasForFieldAlias = $this->getSQLTableAlias($otherClassMetadata->getTableName(), $dqlAliasForFieldAlias);
}
}
// Compose search/replace patterns
$searchPatterns[] = sprintf($fieldSearchPattern, $sqlTableAliasForFieldAlias, $columnName);
$replacements[] = $fieldAlias;
}
foreach($orderByClause->orderByItems as $orderByItem) {
// Walk order by item to get string representation of it
$orderByItemString = $this->walkOrderByItem($orderByItem);
// Replace path expressions in the order by clause with their column alias
$orderByItemString = preg_replace($searchPatterns, $replacements, $orderByItemString);
$orderByItems[] = $orderByItemString;
}
return $orderByItems;
}
|
[
"private",
"function",
"rebuildOrderByClauseForOuterScope",
"(",
"OrderByClause",
"$",
"orderByClause",
")",
"{",
"$",
"dqlAliasToSqlTableAliasMap",
"=",
"$",
"searchPatterns",
"=",
"$",
"replacements",
"=",
"$",
"dqlAliasToClassMap",
"=",
"$",
"selectListAdditions",
"=",
"$",
"orderByItems",
"=",
"[",
"]",
";",
"// Generate DQL alias -> SQL table alias mapping",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"rsm",
"->",
"aliasMap",
")",
"as",
"$",
"dqlAlias",
")",
"{",
"$",
"dqlAliasToClassMap",
"[",
"$",
"dqlAlias",
"]",
"=",
"$",
"class",
"=",
"$",
"this",
"->",
"queryComponents",
"[",
"$",
"dqlAlias",
"]",
"[",
"'metadata'",
"]",
";",
"$",
"dqlAliasToSqlTableAliasMap",
"[",
"$",
"dqlAlias",
"]",
"=",
"$",
"this",
"->",
"getSQLTableAlias",
"(",
"$",
"class",
"->",
"getTableName",
"(",
")",
",",
"$",
"dqlAlias",
")",
";",
"}",
"// Pattern to find table path expressions in the order by clause",
"$",
"fieldSearchPattern",
"=",
"'/(?<![a-z0-9_])%s\\.%s(?![a-z0-9_])/i'",
";",
"// Generate search patterns for each field's path expression in the order by clause",
"foreach",
"(",
"$",
"this",
"->",
"rsm",
"->",
"fieldMappings",
"as",
"$",
"fieldAlias",
"=>",
"$",
"fieldName",
")",
"{",
"$",
"dqlAliasForFieldAlias",
"=",
"$",
"this",
"->",
"rsm",
"->",
"columnOwnerMap",
"[",
"$",
"fieldAlias",
"]",
";",
"$",
"class",
"=",
"$",
"dqlAliasToClassMap",
"[",
"$",
"dqlAliasForFieldAlias",
"]",
";",
"// If the field is from a joined child table, we won't be ordering",
"// on it.",
"if",
"(",
"!",
"isset",
"(",
"$",
"class",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fieldMapping",
"=",
"$",
"class",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
";",
"// Get the proper column name as will appear in the select list",
"$",
"columnName",
"=",
"$",
"this",
"->",
"quoteStrategy",
"->",
"getColumnName",
"(",
"$",
"fieldName",
",",
"$",
"dqlAliasToClassMap",
"[",
"$",
"dqlAliasForFieldAlias",
"]",
",",
"$",
"this",
"->",
"em",
"->",
"getConnection",
"(",
")",
"->",
"getDatabasePlatform",
"(",
")",
")",
";",
"// Get the SQL table alias for the entity and field",
"$",
"sqlTableAliasForFieldAlias",
"=",
"$",
"dqlAliasToSqlTableAliasMap",
"[",
"$",
"dqlAliasForFieldAlias",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"fieldMapping",
"[",
"'declared'",
"]",
")",
"&&",
"$",
"fieldMapping",
"[",
"'declared'",
"]",
"!==",
"$",
"class",
"->",
"name",
")",
"{",
"// Field was declared in a parent class, so we need to get the proper SQL table alias",
"// for the joined parent table.",
"$",
"otherClassMetadata",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"$",
"fieldMapping",
"[",
"'declared'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"otherClassMetadata",
"->",
"isMappedSuperclass",
")",
"{",
"$",
"sqlTableAliasForFieldAlias",
"=",
"$",
"this",
"->",
"getSQLTableAlias",
"(",
"$",
"otherClassMetadata",
"->",
"getTableName",
"(",
")",
",",
"$",
"dqlAliasForFieldAlias",
")",
";",
"}",
"}",
"// Compose search/replace patterns",
"$",
"searchPatterns",
"[",
"]",
"=",
"sprintf",
"(",
"$",
"fieldSearchPattern",
",",
"$",
"sqlTableAliasForFieldAlias",
",",
"$",
"columnName",
")",
";",
"$",
"replacements",
"[",
"]",
"=",
"$",
"fieldAlias",
";",
"}",
"foreach",
"(",
"$",
"orderByClause",
"->",
"orderByItems",
"as",
"$",
"orderByItem",
")",
"{",
"// Walk order by item to get string representation of it",
"$",
"orderByItemString",
"=",
"$",
"this",
"->",
"walkOrderByItem",
"(",
"$",
"orderByItem",
")",
";",
"// Replace path expressions in the order by clause with their column alias",
"$",
"orderByItemString",
"=",
"preg_replace",
"(",
"$",
"searchPatterns",
",",
"$",
"replacements",
",",
"$",
"orderByItemString",
")",
";",
"$",
"orderByItems",
"[",
"]",
"=",
"$",
"orderByItemString",
";",
"}",
"return",
"$",
"orderByItems",
";",
"}"
] |
Generates a new order by clause that works in the scope of a select query wrapping the original
@param OrderByClause $orderByClause
@return array
|
[
"Generates",
"a",
"new",
"order",
"by",
"clause",
"that",
"works",
"in",
"the",
"scope",
"of",
"a",
"select",
"query",
"wrapping",
"the",
"original"
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php#L396-L462
|
223,361
|
mmerian/phpcrawl
|
libs/PHPCrawlerRobotsTxtParser.class.php
|
PHPCrawlerRobotsTxtParser.parseRobotsTxt
|
public function parseRobotsTxt(PHPCrawlerURLDescriptor $BaseUrl, $user_agent_string, $robots_txt_uri = null)
{
PHPCrawlerBenchmark::start("processing_robotstxt");
// If robots_txt_uri not given, use the default one for the given BaseUrl
if ($robots_txt_uri === null)
$robots_txt_uri = self::getRobotsTxtURL($BaseUrl->url_rebuild);
// Get robots.txt-content
$robots_txt_content = PHPCrawlerUtils::getURIContent($robots_txt_uri, $user_agent_string);
$non_follow_reg_exps = array();
// If content was found
if ($robots_txt_content != null)
{
// Get all lines in the robots.txt-content that are adressed to our user-agent.
$applying_lines = $this->getUserAgentLines($robots_txt_content, $user_agent_string);
// Get valid reg-expressions for the given disallow-pathes.
$non_follow_reg_exps = $this->buildRegExpressions($applying_lines, PHPCrawlerUtils::getRootUrl($BaseUrl->url_rebuild));
}
PHPCrawlerBenchmark::stop("processing_robots.txt");
return $non_follow_reg_exps;
}
|
php
|
public function parseRobotsTxt(PHPCrawlerURLDescriptor $BaseUrl, $user_agent_string, $robots_txt_uri = null)
{
PHPCrawlerBenchmark::start("processing_robotstxt");
// If robots_txt_uri not given, use the default one for the given BaseUrl
if ($robots_txt_uri === null)
$robots_txt_uri = self::getRobotsTxtURL($BaseUrl->url_rebuild);
// Get robots.txt-content
$robots_txt_content = PHPCrawlerUtils::getURIContent($robots_txt_uri, $user_agent_string);
$non_follow_reg_exps = array();
// If content was found
if ($robots_txt_content != null)
{
// Get all lines in the robots.txt-content that are adressed to our user-agent.
$applying_lines = $this->getUserAgentLines($robots_txt_content, $user_agent_string);
// Get valid reg-expressions for the given disallow-pathes.
$non_follow_reg_exps = $this->buildRegExpressions($applying_lines, PHPCrawlerUtils::getRootUrl($BaseUrl->url_rebuild));
}
PHPCrawlerBenchmark::stop("processing_robots.txt");
return $non_follow_reg_exps;
}
|
[
"public",
"function",
"parseRobotsTxt",
"(",
"PHPCrawlerURLDescriptor",
"$",
"BaseUrl",
",",
"$",
"user_agent_string",
",",
"$",
"robots_txt_uri",
"=",
"null",
")",
"{",
"PHPCrawlerBenchmark",
"::",
"start",
"(",
"\"processing_robotstxt\"",
")",
";",
"// If robots_txt_uri not given, use the default one for the given BaseUrl\r",
"if",
"(",
"$",
"robots_txt_uri",
"===",
"null",
")",
"$",
"robots_txt_uri",
"=",
"self",
"::",
"getRobotsTxtURL",
"(",
"$",
"BaseUrl",
"->",
"url_rebuild",
")",
";",
"// Get robots.txt-content\r",
"$",
"robots_txt_content",
"=",
"PHPCrawlerUtils",
"::",
"getURIContent",
"(",
"$",
"robots_txt_uri",
",",
"$",
"user_agent_string",
")",
";",
"$",
"non_follow_reg_exps",
"=",
"array",
"(",
")",
";",
"// If content was found\r",
"if",
"(",
"$",
"robots_txt_content",
"!=",
"null",
")",
"{",
"// Get all lines in the robots.txt-content that are adressed to our user-agent.\r",
"$",
"applying_lines",
"=",
"$",
"this",
"->",
"getUserAgentLines",
"(",
"$",
"robots_txt_content",
",",
"$",
"user_agent_string",
")",
";",
"// Get valid reg-expressions for the given disallow-pathes.\r",
"$",
"non_follow_reg_exps",
"=",
"$",
"this",
"->",
"buildRegExpressions",
"(",
"$",
"applying_lines",
",",
"PHPCrawlerUtils",
"::",
"getRootUrl",
"(",
"$",
"BaseUrl",
"->",
"url_rebuild",
")",
")",
";",
"}",
"PHPCrawlerBenchmark",
"::",
"stop",
"(",
"\"processing_robots.txt\"",
")",
";",
"return",
"$",
"non_follow_reg_exps",
";",
"}"
] |
Parses a robots.txt-file and returns regular-expression-rules corresponding to the containing "disallow"-rules
that are adressed to the given user-agent.
@param PHPCrawlerURLDescriptor $BaseUrl The root-URL all rules from the robots-txt-file should relate to
@param string $user_agent_string The useragent all rules from the robots-txt-file should relate to
@param string $robots_txt_uri Optional. The location of the robots.txt-file as URI.
If not set, the default robots.txt-file for the given BaseUrl gets parsed.
@return array Numeric array containing regular-expressions for each "disallow"-rule defined in the robots.txt-file
that's adressed to the given user-agent.
|
[
"Parses",
"a",
"robots",
".",
"txt",
"-",
"file",
"and",
"returns",
"regular",
"-",
"expression",
"-",
"rules",
"corresponding",
"to",
"the",
"containing",
"disallow",
"-",
"rules",
"that",
"are",
"adressed",
"to",
"the",
"given",
"user",
"-",
"agent",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerRobotsTxtParser.class.php#L29-L55
|
223,362
|
mmerian/phpcrawl
|
libs/PHPCrawlerRobotsTxtParser.class.php
|
PHPCrawlerRobotsTxtParser.getUserAgentLines
|
protected function getUserAgentLines(&$robots_txt_content, $user_agent_string)
{
// Split the content into its lines
$robotstxt_lines = explode("\n", $robots_txt_content);
$user_agent_lines = array();
$current_user_agent = null;
// Loop over the lines and check if any user-agent-sections match with our agent
$cnt = count($robotstxt_lines);
for ($x=0; $x<$cnt; $x++)
{
$line = trim($robotstxt_lines[$x]);
if ($line == "") continue;
// Check if a line begins with "User-agent"
if (preg_match("#^User-agent:\s*(.*)# i", $line, $match))
{
if (isset($match[1]))
$current_user_agent = trim($match[1]);
else
$current_user_agent = "";
continue;
}
// If User-Agent matches with our user-agent-string
if ($current_user_agent == "*" || strtolower($current_user_agent) == strtolower($user_agent_string))
{
$user_agent_lines[] = trim($line);
}
}
return $user_agent_lines;
}
|
php
|
protected function getUserAgentLines(&$robots_txt_content, $user_agent_string)
{
// Split the content into its lines
$robotstxt_lines = explode("\n", $robots_txt_content);
$user_agent_lines = array();
$current_user_agent = null;
// Loop over the lines and check if any user-agent-sections match with our agent
$cnt = count($robotstxt_lines);
for ($x=0; $x<$cnt; $x++)
{
$line = trim($robotstxt_lines[$x]);
if ($line == "") continue;
// Check if a line begins with "User-agent"
if (preg_match("#^User-agent:\s*(.*)# i", $line, $match))
{
if (isset($match[1]))
$current_user_agent = trim($match[1]);
else
$current_user_agent = "";
continue;
}
// If User-Agent matches with our user-agent-string
if ($current_user_agent == "*" || strtolower($current_user_agent) == strtolower($user_agent_string))
{
$user_agent_lines[] = trim($line);
}
}
return $user_agent_lines;
}
|
[
"protected",
"function",
"getUserAgentLines",
"(",
"&",
"$",
"robots_txt_content",
",",
"$",
"user_agent_string",
")",
"{",
"// Split the content into its lines\r",
"$",
"robotstxt_lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"robots_txt_content",
")",
";",
"$",
"user_agent_lines",
"=",
"array",
"(",
")",
";",
"$",
"current_user_agent",
"=",
"null",
";",
"// Loop over the lines and check if any user-agent-sections match with our agent\r",
"$",
"cnt",
"=",
"count",
"(",
"$",
"robotstxt_lines",
")",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"cnt",
";",
"$",
"x",
"++",
")",
"{",
"$",
"line",
"=",
"trim",
"(",
"$",
"robotstxt_lines",
"[",
"$",
"x",
"]",
")",
";",
"if",
"(",
"$",
"line",
"==",
"\"\"",
")",
"continue",
";",
"// Check if a line begins with \"User-agent\"\r",
"if",
"(",
"preg_match",
"(",
"\"#^User-agent:\\s*(.*)# i\"",
",",
"$",
"line",
",",
"$",
"match",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"match",
"[",
"1",
"]",
")",
")",
"$",
"current_user_agent",
"=",
"trim",
"(",
"$",
"match",
"[",
"1",
"]",
")",
";",
"else",
"$",
"current_user_agent",
"=",
"\"\"",
";",
"continue",
";",
"}",
"// If User-Agent matches with our user-agent-string\r",
"if",
"(",
"$",
"current_user_agent",
"==",
"\"*\"",
"||",
"strtolower",
"(",
"$",
"current_user_agent",
")",
"==",
"strtolower",
"(",
"$",
"user_agent_string",
")",
")",
"{",
"$",
"user_agent_lines",
"[",
"]",
"=",
"trim",
"(",
"$",
"line",
")",
";",
"}",
"}",
"return",
"$",
"user_agent_lines",
";",
"}"
] |
Gets all raw lines from the given robots.txt-content that apply to
the given useragent-string.
@return array Numeric array containing the lines
|
[
"Gets",
"all",
"raw",
"lines",
"from",
"the",
"given",
"robots",
".",
"txt",
"-",
"content",
"that",
"apply",
"to",
"the",
"given",
"useragent",
"-",
"string",
"."
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerRobotsTxtParser.class.php#L63-L98
|
223,363
|
mmerian/phpcrawl
|
libs/PHPCrawlerRobotsTxtParser.class.php
|
PHPCrawlerRobotsTxtParser.getRobotsTxtURL
|
public static function getRobotsTxtURL($url)
{
$url_parts = PHPCrawlerUtils::splitURL($url);
$robots_txt_url = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"] . "/robots.txt";
return $robots_txt_url;
}
|
php
|
public static function getRobotsTxtURL($url)
{
$url_parts = PHPCrawlerUtils::splitURL($url);
$robots_txt_url = $url_parts["protocol"].$url_parts["host"].":".$url_parts["port"] . "/robots.txt";
return $robots_txt_url;
}
|
[
"public",
"static",
"function",
"getRobotsTxtURL",
"(",
"$",
"url",
")",
"{",
"$",
"url_parts",
"=",
"PHPCrawlerUtils",
"::",
"splitURL",
"(",
"$",
"url",
")",
";",
"$",
"robots_txt_url",
"=",
"$",
"url_parts",
"[",
"\"protocol\"",
"]",
".",
"$",
"url_parts",
"[",
"\"host\"",
"]",
".",
"\":\"",
".",
"$",
"url_parts",
"[",
"\"port\"",
"]",
".",
"\"/robots.txt\"",
";",
"return",
"$",
"robots_txt_url",
";",
"}"
] |
Returns the default Robots.txt-URL related to the given URL
@param string $url The URL
@return string Url of the related robots.txt file
|
[
"Returns",
"the",
"default",
"Robots",
".",
"txt",
"-",
"URL",
"related",
"to",
"the",
"given",
"URL"
] |
1c5e07ff33cf079c69191eb9540a3ced64d392dc
|
https://github.com/mmerian/phpcrawl/blob/1c5e07ff33cf079c69191eb9540a3ced64d392dc/libs/PHPCrawlerRobotsTxtParser.class.php#L159-L165
|
223,364
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
|
ResultSetMappingBuilder.getColumnAlias
|
private function getColumnAlias($columnName, $mode, array $customRenameColumns)
{
switch ($mode) {
case self::COLUMN_RENAMING_INCREMENT:
return $columnName . $this->sqlCounter++;
case self::COLUMN_RENAMING_CUSTOM:
return isset($customRenameColumns[$columnName])
? $customRenameColumns[$columnName] : $columnName;
case self::COLUMN_RENAMING_NONE:
return $columnName;
}
}
|
php
|
private function getColumnAlias($columnName, $mode, array $customRenameColumns)
{
switch ($mode) {
case self::COLUMN_RENAMING_INCREMENT:
return $columnName . $this->sqlCounter++;
case self::COLUMN_RENAMING_CUSTOM:
return isset($customRenameColumns[$columnName])
? $customRenameColumns[$columnName] : $columnName;
case self::COLUMN_RENAMING_NONE:
return $columnName;
}
}
|
[
"private",
"function",
"getColumnAlias",
"(",
"$",
"columnName",
",",
"$",
"mode",
",",
"array",
"$",
"customRenameColumns",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"self",
"::",
"COLUMN_RENAMING_INCREMENT",
":",
"return",
"$",
"columnName",
".",
"$",
"this",
"->",
"sqlCounter",
"++",
";",
"case",
"self",
"::",
"COLUMN_RENAMING_CUSTOM",
":",
"return",
"isset",
"(",
"$",
"customRenameColumns",
"[",
"$",
"columnName",
"]",
")",
"?",
"$",
"customRenameColumns",
"[",
"$",
"columnName",
"]",
":",
"$",
"columnName",
";",
"case",
"self",
"::",
"COLUMN_RENAMING_NONE",
":",
"return",
"$",
"columnName",
";",
"}",
"}"
] |
Gets column alias for a given column.
@param string $columnName
@param int $mode
@param array $customRenameColumns
@return string
|
[
"Gets",
"column",
"alias",
"for",
"a",
"given",
"column",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L201-L215
|
223,365
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
|
ResultSetMappingBuilder.getColumnAliasMap
|
private function getColumnAliasMap($className, $mode, array $customRenameColumns)
{
if ($customRenameColumns) { // for BC with 2.2-2.3 API
$mode = self::COLUMN_RENAMING_CUSTOM;
}
$columnAlias = array();
$class = $this->em->getClassMetadata($className);
foreach ($class->getColumnNames() as $columnName) {
$columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns);
}
foreach ($class->associationMappings as $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
foreach ($associationMapping['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name'];
$columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns);
}
}
}
return $columnAlias;
}
|
php
|
private function getColumnAliasMap($className, $mode, array $customRenameColumns)
{
if ($customRenameColumns) { // for BC with 2.2-2.3 API
$mode = self::COLUMN_RENAMING_CUSTOM;
}
$columnAlias = array();
$class = $this->em->getClassMetadata($className);
foreach ($class->getColumnNames() as $columnName) {
$columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns);
}
foreach ($class->associationMappings as $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
foreach ($associationMapping['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name'];
$columnAlias[$columnName] = $this->getColumnAlias($columnName, $mode, $customRenameColumns);
}
}
}
return $columnAlias;
}
|
[
"private",
"function",
"getColumnAliasMap",
"(",
"$",
"className",
",",
"$",
"mode",
",",
"array",
"$",
"customRenameColumns",
")",
"{",
"if",
"(",
"$",
"customRenameColumns",
")",
"{",
"// for BC with 2.2-2.3 API",
"$",
"mode",
"=",
"self",
"::",
"COLUMN_RENAMING_CUSTOM",
";",
"}",
"$",
"columnAlias",
"=",
"array",
"(",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"$",
"className",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"getColumnNames",
"(",
")",
"as",
"$",
"columnName",
")",
"{",
"$",
"columnAlias",
"[",
"$",
"columnName",
"]",
"=",
"$",
"this",
"->",
"getColumnAlias",
"(",
"$",
"columnName",
",",
"$",
"mode",
",",
"$",
"customRenameColumns",
")",
";",
"}",
"foreach",
"(",
"$",
"class",
"->",
"associationMappings",
"as",
"$",
"associationMapping",
")",
"{",
"if",
"(",
"$",
"associationMapping",
"[",
"'isOwningSide'",
"]",
"&&",
"$",
"associationMapping",
"[",
"'type'",
"]",
"&",
"ClassMetadataInfo",
"::",
"TO_ONE",
")",
"{",
"foreach",
"(",
"$",
"associationMapping",
"[",
"'joinColumns'",
"]",
"as",
"$",
"joinColumn",
")",
"{",
"$",
"columnName",
"=",
"$",
"joinColumn",
"[",
"'name'",
"]",
";",
"$",
"columnAlias",
"[",
"$",
"columnName",
"]",
"=",
"$",
"this",
"->",
"getColumnAlias",
"(",
"$",
"columnName",
",",
"$",
"mode",
",",
"$",
"customRenameColumns",
")",
";",
"}",
"}",
"}",
"return",
"$",
"columnAlias",
";",
"}"
] |
Retrieves a class columns and join columns aliases that are used in the SELECT clause.
This depends on the renaming mode selected by the user.
@param string $className
@param int $mode
@param array $customRenameColumns
@return array
|
[
"Retrieves",
"a",
"class",
"columns",
"and",
"join",
"columns",
"aliases",
"that",
"are",
"used",
"in",
"the",
"SELECT",
"clause",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L228-L251
|
223,366
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
|
ResultSetMappingBuilder.addNamedNativeQueryMapping
|
public function addNamedNativeQueryMapping(ClassMetadataInfo $class, array $queryMapping)
{
if (isset($queryMapping['resultClass'])) {
return $this->addNamedNativeQueryResultClassMapping($class, $queryMapping['resultClass']);
}
return $this->addNamedNativeQueryResultSetMapping($class, $queryMapping['resultSetMapping']);
}
|
php
|
public function addNamedNativeQueryMapping(ClassMetadataInfo $class, array $queryMapping)
{
if (isset($queryMapping['resultClass'])) {
return $this->addNamedNativeQueryResultClassMapping($class, $queryMapping['resultClass']);
}
return $this->addNamedNativeQueryResultSetMapping($class, $queryMapping['resultSetMapping']);
}
|
[
"public",
"function",
"addNamedNativeQueryMapping",
"(",
"ClassMetadataInfo",
"$",
"class",
",",
"array",
"$",
"queryMapping",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"queryMapping",
"[",
"'resultClass'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"addNamedNativeQueryResultClassMapping",
"(",
"$",
"class",
",",
"$",
"queryMapping",
"[",
"'resultClass'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"addNamedNativeQueryResultSetMapping",
"(",
"$",
"class",
",",
"$",
"queryMapping",
"[",
"'resultSetMapping'",
"]",
")",
";",
"}"
] |
Adds the mappings of the results of native SQL queries to the result set.
@param ClassMetadataInfo $class
@param array $queryMapping
@return ResultSetMappingBuilder
|
[
"Adds",
"the",
"mappings",
"of",
"the",
"results",
"of",
"native",
"SQL",
"queries",
"to",
"the",
"result",
"set",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L261-L268
|
223,367
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
|
ResultSetMappingBuilder.addNamedNativeQueryResultClassMapping
|
public function addNamedNativeQueryResultClassMapping(ClassMetadataInfo $class, $resultClassName)
{
$classMetadata = $this->em->getClassMetadata($resultClassName);
$shortName = $classMetadata->reflClass->getShortName();
$alias = strtolower($shortName[0]).'0';
$this->addEntityResult($class->name, $alias);
if ($classMetadata->discriminatorColumn) {
$discriminatorColumn = $classMetadata->discriminatorColumn;
$this->setDiscriminatorColumn($alias, $discriminatorColumn['name']);
$this->addMetaResult($alias, $discriminatorColumn['name'], $discriminatorColumn['fieldName']);
}
foreach ($classMetadata->getColumnNames() as $key => $columnName) {
$propertyName = $classMetadata->getFieldName($columnName);
$this->addFieldResult($alias, $columnName, $propertyName);
}
foreach ($classMetadata->associationMappings as $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
foreach ($associationMapping['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name'];
$this->addMetaResult($alias, $columnName, $columnName, $classMetadata->isIdentifier($columnName));
}
}
}
return $this;
}
|
php
|
public function addNamedNativeQueryResultClassMapping(ClassMetadataInfo $class, $resultClassName)
{
$classMetadata = $this->em->getClassMetadata($resultClassName);
$shortName = $classMetadata->reflClass->getShortName();
$alias = strtolower($shortName[0]).'0';
$this->addEntityResult($class->name, $alias);
if ($classMetadata->discriminatorColumn) {
$discriminatorColumn = $classMetadata->discriminatorColumn;
$this->setDiscriminatorColumn($alias, $discriminatorColumn['name']);
$this->addMetaResult($alias, $discriminatorColumn['name'], $discriminatorColumn['fieldName']);
}
foreach ($classMetadata->getColumnNames() as $key => $columnName) {
$propertyName = $classMetadata->getFieldName($columnName);
$this->addFieldResult($alias, $columnName, $propertyName);
}
foreach ($classMetadata->associationMappings as $associationMapping) {
if ($associationMapping['isOwningSide'] && $associationMapping['type'] & ClassMetadataInfo::TO_ONE) {
foreach ($associationMapping['joinColumns'] as $joinColumn) {
$columnName = $joinColumn['name'];
$this->addMetaResult($alias, $columnName, $columnName, $classMetadata->isIdentifier($columnName));
}
}
}
return $this;
}
|
[
"public",
"function",
"addNamedNativeQueryResultClassMapping",
"(",
"ClassMetadataInfo",
"$",
"class",
",",
"$",
"resultClassName",
")",
"{",
"$",
"classMetadata",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"$",
"resultClassName",
")",
";",
"$",
"shortName",
"=",
"$",
"classMetadata",
"->",
"reflClass",
"->",
"getShortName",
"(",
")",
";",
"$",
"alias",
"=",
"strtolower",
"(",
"$",
"shortName",
"[",
"0",
"]",
")",
".",
"'0'",
";",
"$",
"this",
"->",
"addEntityResult",
"(",
"$",
"class",
"->",
"name",
",",
"$",
"alias",
")",
";",
"if",
"(",
"$",
"classMetadata",
"->",
"discriminatorColumn",
")",
"{",
"$",
"discriminatorColumn",
"=",
"$",
"classMetadata",
"->",
"discriminatorColumn",
";",
"$",
"this",
"->",
"setDiscriminatorColumn",
"(",
"$",
"alias",
",",
"$",
"discriminatorColumn",
"[",
"'name'",
"]",
")",
";",
"$",
"this",
"->",
"addMetaResult",
"(",
"$",
"alias",
",",
"$",
"discriminatorColumn",
"[",
"'name'",
"]",
",",
"$",
"discriminatorColumn",
"[",
"'fieldName'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"classMetadata",
"->",
"getColumnNames",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"columnName",
")",
"{",
"$",
"propertyName",
"=",
"$",
"classMetadata",
"->",
"getFieldName",
"(",
"$",
"columnName",
")",
";",
"$",
"this",
"->",
"addFieldResult",
"(",
"$",
"alias",
",",
"$",
"columnName",
",",
"$",
"propertyName",
")",
";",
"}",
"foreach",
"(",
"$",
"classMetadata",
"->",
"associationMappings",
"as",
"$",
"associationMapping",
")",
"{",
"if",
"(",
"$",
"associationMapping",
"[",
"'isOwningSide'",
"]",
"&&",
"$",
"associationMapping",
"[",
"'type'",
"]",
"&",
"ClassMetadataInfo",
"::",
"TO_ONE",
")",
"{",
"foreach",
"(",
"$",
"associationMapping",
"[",
"'joinColumns'",
"]",
"as",
"$",
"joinColumn",
")",
"{",
"$",
"columnName",
"=",
"$",
"joinColumn",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"addMetaResult",
"(",
"$",
"alias",
",",
"$",
"columnName",
",",
"$",
"columnName",
",",
"$",
"classMetadata",
"->",
"isIdentifier",
"(",
"$",
"columnName",
")",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds the class mapping of the results of native SQL queries to the result set.
@param ClassMetadataInfo $class
@param string $resultClassName
@return ResultSetMappingBuilder
|
[
"Adds",
"the",
"class",
"mapping",
"of",
"the",
"results",
"of",
"native",
"SQL",
"queries",
"to",
"the",
"result",
"set",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L278-L307
|
223,368
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
|
ResultSetMappingBuilder.addNamedNativeQueryResultSetMapping
|
public function addNamedNativeQueryResultSetMapping(ClassMetadataInfo $class, $resultSetMappingName)
{
$counter = 0;
$resultMapping = $class->getSqlResultSetMapping($resultSetMappingName);
$rooShortName = $class->reflClass->getShortName();
$rootAlias = strtolower($rooShortName[0]) . $counter;
if (isset($resultMapping['entities'])) {
foreach ($resultMapping['entities'] as $key => $entityMapping) {
$classMetadata = $this->em->getClassMetadata($entityMapping['entityClass']);
if ($class->reflClass->name == $classMetadata->reflClass->name) {
$this->addEntityResult($classMetadata->name, $rootAlias);
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $rootAlias);
} else {
$shortName = $classMetadata->reflClass->getShortName();
$joinAlias = strtolower($shortName[0]) . ++ $counter;
$associations = $class->getAssociationsByTargetClass($classMetadata->name);
foreach ($associations as $relation => $mapping) {
$this->addJoinedEntityResult($mapping['targetEntity'], $joinAlias, $rootAlias, $relation);
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $joinAlias);
}
}
}
}
if (isset($resultMapping['columns'])) {
foreach ($resultMapping['columns'] as $entityMapping) {
$this->addScalarResult($entityMapping['name'], $entityMapping['name']);
}
}
return $this;
}
|
php
|
public function addNamedNativeQueryResultSetMapping(ClassMetadataInfo $class, $resultSetMappingName)
{
$counter = 0;
$resultMapping = $class->getSqlResultSetMapping($resultSetMappingName);
$rooShortName = $class->reflClass->getShortName();
$rootAlias = strtolower($rooShortName[0]) . $counter;
if (isset($resultMapping['entities'])) {
foreach ($resultMapping['entities'] as $key => $entityMapping) {
$classMetadata = $this->em->getClassMetadata($entityMapping['entityClass']);
if ($class->reflClass->name == $classMetadata->reflClass->name) {
$this->addEntityResult($classMetadata->name, $rootAlias);
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $rootAlias);
} else {
$shortName = $classMetadata->reflClass->getShortName();
$joinAlias = strtolower($shortName[0]) . ++ $counter;
$associations = $class->getAssociationsByTargetClass($classMetadata->name);
foreach ($associations as $relation => $mapping) {
$this->addJoinedEntityResult($mapping['targetEntity'], $joinAlias, $rootAlias, $relation);
$this->addNamedNativeQueryEntityResultMapping($classMetadata, $entityMapping, $joinAlias);
}
}
}
}
if (isset($resultMapping['columns'])) {
foreach ($resultMapping['columns'] as $entityMapping) {
$this->addScalarResult($entityMapping['name'], $entityMapping['name']);
}
}
return $this;
}
|
[
"public",
"function",
"addNamedNativeQueryResultSetMapping",
"(",
"ClassMetadataInfo",
"$",
"class",
",",
"$",
"resultSetMappingName",
")",
"{",
"$",
"counter",
"=",
"0",
";",
"$",
"resultMapping",
"=",
"$",
"class",
"->",
"getSqlResultSetMapping",
"(",
"$",
"resultSetMappingName",
")",
";",
"$",
"rooShortName",
"=",
"$",
"class",
"->",
"reflClass",
"->",
"getShortName",
"(",
")",
";",
"$",
"rootAlias",
"=",
"strtolower",
"(",
"$",
"rooShortName",
"[",
"0",
"]",
")",
".",
"$",
"counter",
";",
"if",
"(",
"isset",
"(",
"$",
"resultMapping",
"[",
"'entities'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"resultMapping",
"[",
"'entities'",
"]",
"as",
"$",
"key",
"=>",
"$",
"entityMapping",
")",
"{",
"$",
"classMetadata",
"=",
"$",
"this",
"->",
"em",
"->",
"getClassMetadata",
"(",
"$",
"entityMapping",
"[",
"'entityClass'",
"]",
")",
";",
"if",
"(",
"$",
"class",
"->",
"reflClass",
"->",
"name",
"==",
"$",
"classMetadata",
"->",
"reflClass",
"->",
"name",
")",
"{",
"$",
"this",
"->",
"addEntityResult",
"(",
"$",
"classMetadata",
"->",
"name",
",",
"$",
"rootAlias",
")",
";",
"$",
"this",
"->",
"addNamedNativeQueryEntityResultMapping",
"(",
"$",
"classMetadata",
",",
"$",
"entityMapping",
",",
"$",
"rootAlias",
")",
";",
"}",
"else",
"{",
"$",
"shortName",
"=",
"$",
"classMetadata",
"->",
"reflClass",
"->",
"getShortName",
"(",
")",
";",
"$",
"joinAlias",
"=",
"strtolower",
"(",
"$",
"shortName",
"[",
"0",
"]",
")",
".",
"++",
"$",
"counter",
";",
"$",
"associations",
"=",
"$",
"class",
"->",
"getAssociationsByTargetClass",
"(",
"$",
"classMetadata",
"->",
"name",
")",
";",
"foreach",
"(",
"$",
"associations",
"as",
"$",
"relation",
"=>",
"$",
"mapping",
")",
"{",
"$",
"this",
"->",
"addJoinedEntityResult",
"(",
"$",
"mapping",
"[",
"'targetEntity'",
"]",
",",
"$",
"joinAlias",
",",
"$",
"rootAlias",
",",
"$",
"relation",
")",
";",
"$",
"this",
"->",
"addNamedNativeQueryEntityResultMapping",
"(",
"$",
"classMetadata",
",",
"$",
"entityMapping",
",",
"$",
"joinAlias",
")",
";",
"}",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"resultMapping",
"[",
"'columns'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"resultMapping",
"[",
"'columns'",
"]",
"as",
"$",
"entityMapping",
")",
"{",
"$",
"this",
"->",
"addScalarResult",
"(",
"$",
"entityMapping",
"[",
"'name'",
"]",
",",
"$",
"entityMapping",
"[",
"'name'",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds the result set mapping of the results of native SQL queries to the result set.
@param ClassMetadataInfo $class
@param string $resultSetMappingName
@return ResultSetMappingBuilder
|
[
"Adds",
"the",
"result",
"set",
"mapping",
"of",
"the",
"results",
"of",
"native",
"SQL",
"queries",
"to",
"the",
"result",
"set",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L317-L353
|
223,369
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php
|
ResultSetMappingBuilder.addNamedNativeQueryEntityResultMapping
|
public function addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array $entityMapping, $alias)
{
if (isset($entityMapping['discriminatorColumn']) && $entityMapping['discriminatorColumn']) {
$discriminatorColumn = $entityMapping['discriminatorColumn'];
$this->setDiscriminatorColumn($alias, $discriminatorColumn);
$this->addMetaResult($alias, $discriminatorColumn, $discriminatorColumn);
}
if (isset($entityMapping['fields']) && !empty($entityMapping['fields'])) {
foreach ($entityMapping['fields'] as $field) {
$fieldName = $field['name'];
$relation = null;
if(strpos($fieldName, '.')){
list($relation, $fieldName) = explode('.', $fieldName);
}
if (isset($classMetadata->associationMappings[$relation])) {
if($relation) {
$associationMapping = $classMetadata->associationMappings[$relation];
$joinAlias = $alias.$relation;
$parentAlias = $alias;
$this->addJoinedEntityResult($associationMapping['targetEntity'], $joinAlias, $parentAlias, $relation);
$this->addFieldResult($joinAlias, $field['column'], $fieldName);
}else {
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name);
}
} else {
if(!isset($classMetadata->fieldMappings[$fieldName])) {
throw new \InvalidArgumentException("Entity '".$classMetadata->name."' has no field '".$fieldName."'. ");
}
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name);
}
}
} else {
foreach ($classMetadata->getColumnNames() as $columnName) {
$propertyName = $classMetadata->getFieldName($columnName);
$this->addFieldResult($alias, $columnName, $propertyName);
}
}
return $this;
}
|
php
|
public function addNamedNativeQueryEntityResultMapping(ClassMetadataInfo $classMetadata, array $entityMapping, $alias)
{
if (isset($entityMapping['discriminatorColumn']) && $entityMapping['discriminatorColumn']) {
$discriminatorColumn = $entityMapping['discriminatorColumn'];
$this->setDiscriminatorColumn($alias, $discriminatorColumn);
$this->addMetaResult($alias, $discriminatorColumn, $discriminatorColumn);
}
if (isset($entityMapping['fields']) && !empty($entityMapping['fields'])) {
foreach ($entityMapping['fields'] as $field) {
$fieldName = $field['name'];
$relation = null;
if(strpos($fieldName, '.')){
list($relation, $fieldName) = explode('.', $fieldName);
}
if (isset($classMetadata->associationMappings[$relation])) {
if($relation) {
$associationMapping = $classMetadata->associationMappings[$relation];
$joinAlias = $alias.$relation;
$parentAlias = $alias;
$this->addJoinedEntityResult($associationMapping['targetEntity'], $joinAlias, $parentAlias, $relation);
$this->addFieldResult($joinAlias, $field['column'], $fieldName);
}else {
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name);
}
} else {
if(!isset($classMetadata->fieldMappings[$fieldName])) {
throw new \InvalidArgumentException("Entity '".$classMetadata->name."' has no field '".$fieldName."'. ");
}
$this->addFieldResult($alias, $field['column'], $fieldName, $classMetadata->name);
}
}
} else {
foreach ($classMetadata->getColumnNames() as $columnName) {
$propertyName = $classMetadata->getFieldName($columnName);
$this->addFieldResult($alias, $columnName, $propertyName);
}
}
return $this;
}
|
[
"public",
"function",
"addNamedNativeQueryEntityResultMapping",
"(",
"ClassMetadataInfo",
"$",
"classMetadata",
",",
"array",
"$",
"entityMapping",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"entityMapping",
"[",
"'discriminatorColumn'",
"]",
")",
"&&",
"$",
"entityMapping",
"[",
"'discriminatorColumn'",
"]",
")",
"{",
"$",
"discriminatorColumn",
"=",
"$",
"entityMapping",
"[",
"'discriminatorColumn'",
"]",
";",
"$",
"this",
"->",
"setDiscriminatorColumn",
"(",
"$",
"alias",
",",
"$",
"discriminatorColumn",
")",
";",
"$",
"this",
"->",
"addMetaResult",
"(",
"$",
"alias",
",",
"$",
"discriminatorColumn",
",",
"$",
"discriminatorColumn",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"entityMapping",
"[",
"'fields'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"entityMapping",
"[",
"'fields'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"entityMapping",
"[",
"'fields'",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"fieldName",
"=",
"$",
"field",
"[",
"'name'",
"]",
";",
"$",
"relation",
"=",
"null",
";",
"if",
"(",
"strpos",
"(",
"$",
"fieldName",
",",
"'.'",
")",
")",
"{",
"list",
"(",
"$",
"relation",
",",
"$",
"fieldName",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"fieldName",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"classMetadata",
"->",
"associationMappings",
"[",
"$",
"relation",
"]",
")",
")",
"{",
"if",
"(",
"$",
"relation",
")",
"{",
"$",
"associationMapping",
"=",
"$",
"classMetadata",
"->",
"associationMappings",
"[",
"$",
"relation",
"]",
";",
"$",
"joinAlias",
"=",
"$",
"alias",
".",
"$",
"relation",
";",
"$",
"parentAlias",
"=",
"$",
"alias",
";",
"$",
"this",
"->",
"addJoinedEntityResult",
"(",
"$",
"associationMapping",
"[",
"'targetEntity'",
"]",
",",
"$",
"joinAlias",
",",
"$",
"parentAlias",
",",
"$",
"relation",
")",
";",
"$",
"this",
"->",
"addFieldResult",
"(",
"$",
"joinAlias",
",",
"$",
"field",
"[",
"'column'",
"]",
",",
"$",
"fieldName",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"addFieldResult",
"(",
"$",
"alias",
",",
"$",
"field",
"[",
"'column'",
"]",
",",
"$",
"fieldName",
",",
"$",
"classMetadata",
"->",
"name",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"classMetadata",
"->",
"fieldMappings",
"[",
"$",
"fieldName",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Entity '\"",
".",
"$",
"classMetadata",
"->",
"name",
".",
"\"' has no field '\"",
".",
"$",
"fieldName",
".",
"\"'. \"",
")",
";",
"}",
"$",
"this",
"->",
"addFieldResult",
"(",
"$",
"alias",
",",
"$",
"field",
"[",
"'column'",
"]",
",",
"$",
"fieldName",
",",
"$",
"classMetadata",
"->",
"name",
")",
";",
"}",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"classMetadata",
"->",
"getColumnNames",
"(",
")",
"as",
"$",
"columnName",
")",
"{",
"$",
"propertyName",
"=",
"$",
"classMetadata",
"->",
"getFieldName",
"(",
"$",
"columnName",
")",
";",
"$",
"this",
"->",
"addFieldResult",
"(",
"$",
"alias",
",",
"$",
"columnName",
",",
"$",
"propertyName",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Adds the entity result mapping of the results of native SQL queries to the result set.
@param ClassMetadataInfo $classMetadata
@param array $entityMapping
@param string $alias
@return ResultSetMappingBuilder
@throws \InvalidArgumentException
|
[
"Adds",
"the",
"entity",
"result",
"mapping",
"of",
"the",
"results",
"of",
"native",
"SQL",
"queries",
"to",
"the",
"result",
"set",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Query/ResultSetMappingBuilder.php#L366-L410
|
223,370
|
mespronos/mespronos
|
src/Entity/RankingGeneral.php
|
RankingGeneral.getRankingForBetter
|
public static function getRankingForBetter(\Drupal\user\Entity\User $better, $entity = null, $entity_name = null, $storage_name = null) {
return parent::getRankingForBetter($better, null, null, 'ranking_general');
}
|
php
|
public static function getRankingForBetter(\Drupal\user\Entity\User $better, $entity = null, $entity_name = null, $storage_name = null) {
return parent::getRankingForBetter($better, null, null, 'ranking_general');
}
|
[
"public",
"static",
"function",
"getRankingForBetter",
"(",
"\\",
"Drupal",
"\\",
"user",
"\\",
"Entity",
"\\",
"User",
"$",
"better",
",",
"$",
"entity",
"=",
"null",
",",
"$",
"entity_name",
"=",
"null",
",",
"$",
"storage_name",
"=",
"null",
")",
"{",
"return",
"parent",
"::",
"getRankingForBetter",
"(",
"$",
"better",
",",
"null",
",",
"null",
",",
"'ranking_general'",
")",
";",
"}"
] |
Get General ranking for user
@param \Drupal\user\Entity\User $better
@param \Drupal\mespronos\Entity\Base\RankingBase $entity
@param string $entity_name
@param string $storage_name
@return \Drupal\mespronos\Entity\RankingGeneral
|
[
"Get",
"General",
"ranking",
"for",
"user"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/RankingGeneral.php#L139-L141
|
223,371
|
middlewares/debugbar
|
src/Debugbar.php
|
Debugbar.handleRedirect
|
private function handleRedirect(ResponseInterface $response): ResponseInterface
{
if ($this->debugbar->isDataPersisted() || session_status() === PHP_SESSION_ACTIVE) {
$this->debugbar->stackData();
}
return $response;
}
|
php
|
private function handleRedirect(ResponseInterface $response): ResponseInterface
{
if ($this->debugbar->isDataPersisted() || session_status() === PHP_SESSION_ACTIVE) {
$this->debugbar->stackData();
}
return $response;
}
|
[
"private",
"function",
"handleRedirect",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"ResponseInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"debugbar",
"->",
"isDataPersisted",
"(",
")",
"||",
"session_status",
"(",
")",
"===",
"PHP_SESSION_ACTIVE",
")",
"{",
"$",
"this",
"->",
"debugbar",
"->",
"stackData",
"(",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] |
Handle redirection responses
|
[
"Handle",
"redirection",
"responses"
] |
8e0de02958cb138fc9e29a59e362128eaeb1127c
|
https://github.com/middlewares/debugbar/blob/8e0de02958cb138fc9e29a59e362128eaeb1127c/src/Debugbar.php#L132-L139
|
223,372
|
middlewares/debugbar
|
src/Debugbar.php
|
Debugbar.handleHtml
|
private function handleHtml(ResponseInterface $response, bool $isAjax): ResponseInterface
{
$html = (string) $response->getBody();
$renderer = $this->debugbar->getJavascriptRenderer();
if (!$isAjax) {
if ($this->inline) {
ob_start();
echo "<style>\n";
$renderer->dumpCssAssets();
echo "\n</style>";
echo "<script>\n";
$renderer->dumpJsAssets();
echo "\n</script>";
$code = (string) ob_get_clean();
} else {
$code = $renderer->renderHead();
}
$html = self::injectHtml($html, $code, '</head>');
}
$html = self::injectHtml($html, $renderer->render(!$isAjax), '</body>');
$body = $this->createStream();
$body->write($html);
return $response
->withBody($body)
->withoutHeader('Content-Length');
}
|
php
|
private function handleHtml(ResponseInterface $response, bool $isAjax): ResponseInterface
{
$html = (string) $response->getBody();
$renderer = $this->debugbar->getJavascriptRenderer();
if (!$isAjax) {
if ($this->inline) {
ob_start();
echo "<style>\n";
$renderer->dumpCssAssets();
echo "\n</style>";
echo "<script>\n";
$renderer->dumpJsAssets();
echo "\n</script>";
$code = (string) ob_get_clean();
} else {
$code = $renderer->renderHead();
}
$html = self::injectHtml($html, $code, '</head>');
}
$html = self::injectHtml($html, $renderer->render(!$isAjax), '</body>');
$body = $this->createStream();
$body->write($html);
return $response
->withBody($body)
->withoutHeader('Content-Length');
}
|
[
"private",
"function",
"handleHtml",
"(",
"ResponseInterface",
"$",
"response",
",",
"bool",
"$",
"isAjax",
")",
":",
"ResponseInterface",
"{",
"$",
"html",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"renderer",
"=",
"$",
"this",
"->",
"debugbar",
"->",
"getJavascriptRenderer",
"(",
")",
";",
"if",
"(",
"!",
"$",
"isAjax",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inline",
")",
"{",
"ob_start",
"(",
")",
";",
"echo",
"\"<style>\\n\"",
";",
"$",
"renderer",
"->",
"dumpCssAssets",
"(",
")",
";",
"echo",
"\"\\n</style>\"",
";",
"echo",
"\"<script>\\n\"",
";",
"$",
"renderer",
"->",
"dumpJsAssets",
"(",
")",
";",
"echo",
"\"\\n</script>\"",
";",
"$",
"code",
"=",
"(",
"string",
")",
"ob_get_clean",
"(",
")",
";",
"}",
"else",
"{",
"$",
"code",
"=",
"$",
"renderer",
"->",
"renderHead",
"(",
")",
";",
"}",
"$",
"html",
"=",
"self",
"::",
"injectHtml",
"(",
"$",
"html",
",",
"$",
"code",
",",
"'</head>'",
")",
";",
"}",
"$",
"html",
"=",
"self",
"::",
"injectHtml",
"(",
"$",
"html",
",",
"$",
"renderer",
"->",
"render",
"(",
"!",
"$",
"isAjax",
")",
",",
"'</body>'",
")",
";",
"$",
"body",
"=",
"$",
"this",
"->",
"createStream",
"(",
")",
";",
"$",
"body",
"->",
"write",
"(",
"$",
"html",
")",
";",
"return",
"$",
"response",
"->",
"withBody",
"(",
"$",
"body",
")",
"->",
"withoutHeader",
"(",
"'Content-Length'",
")",
";",
"}"
] |
Handle html responses
|
[
"Handle",
"html",
"responses"
] |
8e0de02958cb138fc9e29a59e362128eaeb1127c
|
https://github.com/middlewares/debugbar/blob/8e0de02958cb138fc9e29a59e362128eaeb1127c/src/Debugbar.php#L144-L174
|
223,373
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php
|
AbstractHydrator.registerManaged
|
protected function registerManaged(ClassMetadata $class, $entity, array $data)
{
if ($class->isIdentifierComposite) {
$id = array();
foreach ($class->identifier as $fieldName) {
$id[$fieldName] = isset($class->associationMappings[$fieldName])
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName];
}
} else {
$fieldName = $class->identifier[0];
$id = array(
$fieldName => isset($class->associationMappings[$fieldName])
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName]
);
}
$this->_em->getUnitOfWork()->registerManaged($entity, $id, $data);
}
|
php
|
protected function registerManaged(ClassMetadata $class, $entity, array $data)
{
if ($class->isIdentifierComposite) {
$id = array();
foreach ($class->identifier as $fieldName) {
$id[$fieldName] = isset($class->associationMappings[$fieldName])
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName];
}
} else {
$fieldName = $class->identifier[0];
$id = array(
$fieldName => isset($class->associationMappings[$fieldName])
? $data[$class->associationMappings[$fieldName]['joinColumns'][0]['name']]
: $data[$fieldName]
);
}
$this->_em->getUnitOfWork()->registerManaged($entity, $id, $data);
}
|
[
"protected",
"function",
"registerManaged",
"(",
"ClassMetadata",
"$",
"class",
",",
"$",
"entity",
",",
"array",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"isIdentifierComposite",
")",
"{",
"$",
"id",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"class",
"->",
"identifier",
"as",
"$",
"fieldName",
")",
"{",
"$",
"id",
"[",
"$",
"fieldName",
"]",
"=",
"isset",
"(",
"$",
"class",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"class",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'joinColumns'",
"]",
"[",
"0",
"]",
"[",
"'name'",
"]",
"]",
":",
"$",
"data",
"[",
"$",
"fieldName",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"fieldName",
"=",
"$",
"class",
"->",
"identifier",
"[",
"0",
"]",
";",
"$",
"id",
"=",
"array",
"(",
"$",
"fieldName",
"=>",
"isset",
"(",
"$",
"class",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"class",
"->",
"associationMappings",
"[",
"$",
"fieldName",
"]",
"[",
"'joinColumns'",
"]",
"[",
"0",
"]",
"[",
"'name'",
"]",
"]",
":",
"$",
"data",
"[",
"$",
"fieldName",
"]",
")",
";",
"}",
"$",
"this",
"->",
"_em",
"->",
"getUnitOfWork",
"(",
")",
"->",
"registerManaged",
"(",
"$",
"entity",
",",
"$",
"id",
",",
"$",
"data",
")",
";",
"}"
] |
Register entity as managed in UnitOfWork.
@param ClassMetadata $class
@param object $entity
@param array $data
@return void
@todo The "$id" generation is the same of UnitOfWork#createEntity. Remove this duplication somehow
|
[
"Register",
"entity",
"as",
"managed",
"in",
"UnitOfWork",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Internal/Hydration/AbstractHydrator.php#L449-L469
|
223,374
|
mespronos/mespronos
|
src/Entity/Getters/DayGettersTrait.php
|
DayGettersTrait.getNbGame
|
public function getNbGame() : int {
$query = \Drupal::entityQuery('game')->condition('day', $this->id());
$ids = $query->execute();
return count($ids);
}
|
php
|
public function getNbGame() : int {
$query = \Drupal::entityQuery('game')->condition('day', $this->id());
$ids = $query->execute();
return count($ids);
}
|
[
"public",
"function",
"getNbGame",
"(",
")",
":",
"int",
"{",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'game'",
")",
"->",
"condition",
"(",
"'day'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"$",
"ids",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"count",
"(",
"$",
"ids",
")",
";",
"}"
] |
Return the number of games of the day
@return int
Number of games for the day
|
[
"Return",
"the",
"number",
"of",
"games",
"of",
"the",
"day"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Getters/DayGettersTrait.php#L51-L55
|
223,375
|
mespronos/mespronos
|
src/Entity/Getters/DayGettersTrait.php
|
DayGettersTrait.getGamesId
|
public function getGamesId($onlyFuture = FALSE) {
$query = \Drupal::entityQuery('game');
$query->condition('day', $this->id());
if($onlyFuture) {
$now = new \DateTime(NULL, new \DateTimeZone('UTC'));
$query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '>');
}
$query->sort('game_date');
$query->sort('id');
return $query->execute();
}
|
php
|
public function getGamesId($onlyFuture = FALSE) {
$query = \Drupal::entityQuery('game');
$query->condition('day', $this->id());
if($onlyFuture) {
$now = new \DateTime(NULL, new \DateTimeZone('UTC'));
$query->condition('game_date', $now->format('Y-m-d\TH:i:s'), '>');
}
$query->sort('game_date');
$query->sort('id');
return $query->execute();
}
|
[
"public",
"function",
"getGamesId",
"(",
"$",
"onlyFuture",
"=",
"FALSE",
")",
"{",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'game'",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'day'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
";",
"if",
"(",
"$",
"onlyFuture",
")",
"{",
"$",
"now",
"=",
"new",
"\\",
"DateTime",
"(",
"NULL",
",",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
";",
"$",
"query",
"->",
"condition",
"(",
"'game_date'",
",",
"$",
"now",
"->",
"format",
"(",
"'Y-m-d\\TH:i:s'",
")",
",",
"'>'",
")",
";",
"}",
"$",
"query",
"->",
"sort",
"(",
"'game_date'",
")",
";",
"$",
"query",
"->",
"sort",
"(",
"'id'",
")",
";",
"return",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"}"
] |
Return all games id for day
@return integer[]
|
[
"Return",
"all",
"games",
"id",
"for",
"day"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Getters/DayGettersTrait.php#L71-L82
|
223,376
|
mespronos/mespronos
|
src/Entity/Getters/DayGettersTrait.php
|
DayGettersTrait.getNbGameWIthScore
|
public function getNbGameWIthScore() {
$query = \Drupal::entityQuery('game')
->condition('day', $this->id())
->condition('score_team_1', NULL, 'IS NOT')
->condition('score_team_2', NULL, 'IS NOT');
$ids = $query->execute();
return \count($ids);
}
|
php
|
public function getNbGameWIthScore() {
$query = \Drupal::entityQuery('game')
->condition('day', $this->id())
->condition('score_team_1', NULL, 'IS NOT')
->condition('score_team_2', NULL, 'IS NOT');
$ids = $query->execute();
return \count($ids);
}
|
[
"public",
"function",
"getNbGameWIthScore",
"(",
")",
"{",
"$",
"query",
"=",
"\\",
"Drupal",
"::",
"entityQuery",
"(",
"'game'",
")",
"->",
"condition",
"(",
"'day'",
",",
"$",
"this",
"->",
"id",
"(",
")",
")",
"->",
"condition",
"(",
"'score_team_1'",
",",
"NULL",
",",
"'IS NOT'",
")",
"->",
"condition",
"(",
"'score_team_2'",
",",
"NULL",
",",
"'IS NOT'",
")",
";",
"$",
"ids",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"return",
"\\",
"count",
"(",
"$",
"ids",
")",
";",
"}"
] |
Return the number of games of the day with score setted
@return int
Number of games with score setted
|
[
"Return",
"the",
"number",
"of",
"games",
"of",
"the",
"day",
"with",
"score",
"setted"
] |
73757663581ed9040944768073d1d9abc761196b
|
https://github.com/mespronos/mespronos/blob/73757663581ed9040944768073d1d9abc761196b/src/Entity/Getters/DayGettersTrait.php#L90-L97
|
223,377
|
Torann/laravel-asana
|
src/ServiceProvider.php
|
ServiceProvider.registerAsanaService
|
public function registerAsanaService()
{
$this->app->singleton('torann.asana', function ($app) {
$config = $app->config->get('asana', []);
return new Asana($config);
});
}
|
php
|
public function registerAsanaService()
{
$this->app->singleton('torann.asana', function ($app) {
$config = $app->config->get('asana', []);
return new Asana($config);
});
}
|
[
"public",
"function",
"registerAsanaService",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'torann.asana'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"config",
"=",
"$",
"app",
"->",
"config",
"->",
"get",
"(",
"'asana'",
",",
"[",
"]",
")",
";",
"return",
"new",
"Asana",
"(",
"$",
"config",
")",
";",
"}",
")",
";",
"}"
] |
Register the Asana service.
@return void
|
[
"Register",
"the",
"Asana",
"service",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/ServiceProvider.php#L38-L45
|
223,378
|
shopsys/doctrine-orm
|
lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php
|
BasicEntityPersister.expandToManyParameters
|
private function expandToManyParameters($criteria)
{
$params = array();
$types = array();
foreach ($criteria as $criterion) {
if ($criterion['value'] === null) {
continue; // skip null values.
}
$types = array_merge($types, $this->getTypes($criterion['field'], $criterion['value'], $criterion['class']));
$params = array_merge($params, $this->getValues($criterion['value']));
}
return array($params, $types);
}
|
php
|
private function expandToManyParameters($criteria)
{
$params = array();
$types = array();
foreach ($criteria as $criterion) {
if ($criterion['value'] === null) {
continue; // skip null values.
}
$types = array_merge($types, $this->getTypes($criterion['field'], $criterion['value'], $criterion['class']));
$params = array_merge($params, $this->getValues($criterion['value']));
}
return array($params, $types);
}
|
[
"private",
"function",
"expandToManyParameters",
"(",
"$",
"criteria",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"types",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"criterion",
")",
"{",
"if",
"(",
"$",
"criterion",
"[",
"'value'",
"]",
"===",
"null",
")",
"{",
"continue",
";",
"// skip null values.",
"}",
"$",
"types",
"=",
"array_merge",
"(",
"$",
"types",
",",
"$",
"this",
"->",
"getTypes",
"(",
"$",
"criterion",
"[",
"'field'",
"]",
",",
"$",
"criterion",
"[",
"'value'",
"]",
",",
"$",
"criterion",
"[",
"'class'",
"]",
")",
")",
";",
"$",
"params",
"=",
"array_merge",
"(",
"$",
"params",
",",
"$",
"this",
"->",
"getValues",
"(",
"$",
"criterion",
"[",
"'value'",
"]",
")",
")",
";",
"}",
"return",
"array",
"(",
"$",
"params",
",",
"$",
"types",
")",
";",
"}"
] |
Expands the parameters from the given criteria and use the correct binding types if found,
specialized for OneToMany or ManyToMany associations.
@param mixed[][] $criteria an array of arrays containing following:
- field to which each criterion will be bound
- value to be bound
- class to which the field belongs to
@return array
|
[
"Expands",
"the",
"parameters",
"from",
"the",
"given",
"criteria",
"and",
"use",
"the",
"correct",
"binding",
"types",
"if",
"found",
"specialized",
"for",
"OneToMany",
"or",
"ManyToMany",
"associations",
"."
] |
faf2288cd1c133c4b5340079a26aa4f14dd7beab
|
https://github.com/shopsys/doctrine-orm/blob/faf2288cd1c133c4b5340079a26aa4f14dd7beab/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php#L1843-L1858
|
223,379
|
fourlabsldn/GmailBundle
|
Services/Email.php
|
Email.get
|
public function get(string $userId, string $emailId, array $options = []): ?\Google_Service_Gmail_Message
{
try {
return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->get($userId, $emailId, $options);
} catch (\Google_Service_Exception $exception) {
// message does not exist
if (404 === $exception->getCode()) {
return null;
} else {
throw $exception;
}
}
}
|
php
|
public function get(string $userId, string $emailId, array $options = []): ?\Google_Service_Gmail_Message
{
try {
return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->get($userId, $emailId, $options);
} catch (\Google_Service_Exception $exception) {
// message does not exist
if (404 === $exception->getCode()) {
return null;
} else {
throw $exception;
}
}
}
|
[
"public",
"function",
"get",
"(",
"string",
"$",
"userId",
",",
"string",
"$",
"emailId",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"?",
"\\",
"Google_Service_Gmail_Message",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"googleServices",
"->",
"getGoogleServiceGmailForUserId",
"(",
"$",
"userId",
")",
"->",
"users_messages",
"->",
"get",
"(",
"$",
"userId",
",",
"$",
"emailId",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"\\",
"Google_Service_Exception",
"$",
"exception",
")",
"{",
"// message does not exist",
"if",
"(",
"404",
"===",
"$",
"exception",
"->",
"getCode",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"else",
"{",
"throw",
"$",
"exception",
";",
"}",
"}",
"}"
] |
Get email information given its ID.
@param string $userId
@param string $emailId
@param array $options
@return \Google_Service_Gmail_Message|null
@throws \Google_Service_Exception
|
[
"Get",
"email",
"information",
"given",
"its",
"ID",
"."
] |
3a7bf480db67502ee16968699c7a28cbf3add178
|
https://github.com/fourlabsldn/GmailBundle/blob/3a7bf480db67502ee16968699c7a28cbf3add178/Services/Email.php#L64-L76
|
223,380
|
fourlabsldn/GmailBundle
|
Services/Email.php
|
Email.trash
|
public function trash(string $userId, string $emailId): ?\Google_Service_Gmail_Message
{
if ($this->get($userId, $emailId)) {
return null;
}
return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->trash($userId, $emailId);
}
|
php
|
public function trash(string $userId, string $emailId): ?\Google_Service_Gmail_Message
{
if ($this->get($userId, $emailId)) {
return null;
}
return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->trash($userId, $emailId);
}
|
[
"public",
"function",
"trash",
"(",
"string",
"$",
"userId",
",",
"string",
"$",
"emailId",
")",
":",
"?",
"\\",
"Google_Service_Gmail_Message",
"{",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"userId",
",",
"$",
"emailId",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"googleServices",
"->",
"getGoogleServiceGmailForUserId",
"(",
"$",
"userId",
")",
"->",
"users_messages",
"->",
"trash",
"(",
"$",
"userId",
",",
"$",
"emailId",
")",
";",
"}"
] |
Delete an email given its ID.
@param string $userId
@param string $emailId
@return \Google_Service_Gmail_Message|null
|
[
"Delete",
"an",
"email",
"given",
"its",
"ID",
"."
] |
3a7bf480db67502ee16968699c7a28cbf3add178
|
https://github.com/fourlabsldn/GmailBundle/blob/3a7bf480db67502ee16968699c7a28cbf3add178/Services/Email.php#L173-L180
|
223,381
|
fourlabsldn/GmailBundle
|
Services/Email.php
|
Email.getLabels
|
public function getLabels(string $userId): \Google_Service_Gmail_ListLabelsResponse
{
return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_labels->listUsersLabels($userId);
}
|
php
|
public function getLabels(string $userId): \Google_Service_Gmail_ListLabelsResponse
{
return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_labels->listUsersLabels($userId);
}
|
[
"public",
"function",
"getLabels",
"(",
"string",
"$",
"userId",
")",
":",
"\\",
"Google_Service_Gmail_ListLabelsResponse",
"{",
"return",
"$",
"this",
"->",
"googleServices",
"->",
"getGoogleServiceGmailForUserId",
"(",
"$",
"userId",
")",
"->",
"users_labels",
"->",
"listUsersLabels",
"(",
"$",
"userId",
")",
";",
"}"
] |
Get user's labels.
@param string $userId
@return \Google_Service_Gmail_ListLabelsResponse
|
[
"Get",
"user",
"s",
"labels",
"."
] |
3a7bf480db67502ee16968699c7a28cbf3add178
|
https://github.com/fourlabsldn/GmailBundle/blob/3a7bf480db67502ee16968699c7a28cbf3add178/Services/Email.php#L206-L209
|
223,382
|
overint/php-paypal-ipn
|
src/PaypalIPN.php
|
PaypalIPN.verifyIPN
|
function verifyIPN()
{
if (!count($_POST)) {
throw new Exception("Missing POST Data");
}
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = [];
foreach ($raw_post_array as $keyval) {
$keyval = explode('=', $keyval);
if (count($keyval) == 2) {
if ($keyval[0] === 'payment_date') {
if (substr_count($keyval[1], '+') === 1) {
$keyval[1] = str_replace('+', '%2B', $keyval[1]);
}
}
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
}
$req = 'cmd=_notify-validate';
$get_magic_quotes_exists = false;
if (function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init($this->getPaypalUri());
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
if ($this->useLocalCerts) {
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . "/cert/cacert.pem");
}
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Connection: Close']);
$res = curl_exec($ch);
$info = curl_getinfo($ch);
$http_code = $info['http_code'];
if ($http_code != 200) {
throw new Exception("PayPal responded with http code $http_code");
}
if (!($res)) {
$errno = curl_errno($ch);
$errstr = curl_error($ch);
curl_close($ch);
throw new Exception("cURL error: [$errno] $errstr");
}
curl_close($ch);
if ($res == self::VALID) {
return true;
} else {
return false;
}
}
|
php
|
function verifyIPN()
{
if (!count($_POST)) {
throw new Exception("Missing POST Data");
}
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = [];
foreach ($raw_post_array as $keyval) {
$keyval = explode('=', $keyval);
if (count($keyval) == 2) {
if ($keyval[0] === 'payment_date') {
if (substr_count($keyval[1], '+') === 1) {
$keyval[1] = str_replace('+', '%2B', $keyval[1]);
}
}
$myPost[$keyval[0]] = urldecode($keyval[1]);
}
}
$req = 'cmd=_notify-validate';
$get_magic_quotes_exists = false;
if (function_exists('get_magic_quotes_gpc')) {
$get_magic_quotes_exists = true;
}
foreach ($myPost as $key => $value) {
if ($get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
$value = urlencode(stripslashes($value));
} else {
$value = urlencode($value);
}
$req .= "&$key=$value";
}
$ch = curl_init($this->getPaypalUri());
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
if ($this->useLocalCerts) {
curl_setopt($ch, CURLOPT_CAINFO, __DIR__ . "/cert/cacert.pem");
}
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Connection: Close']);
$res = curl_exec($ch);
$info = curl_getinfo($ch);
$http_code = $info['http_code'];
if ($http_code != 200) {
throw new Exception("PayPal responded with http code $http_code");
}
if (!($res)) {
$errno = curl_errno($ch);
$errstr = curl_error($ch);
curl_close($ch);
throw new Exception("cURL error: [$errno] $errstr");
}
curl_close($ch);
if ($res == self::VALID) {
return true;
} else {
return false;
}
}
|
[
"function",
"verifyIPN",
"(",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"_POST",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Missing POST Data\"",
")",
";",
"}",
"$",
"raw_post_data",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"$",
"raw_post_array",
"=",
"explode",
"(",
"'&'",
",",
"$",
"raw_post_data",
")",
";",
"$",
"myPost",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"raw_post_array",
"as",
"$",
"keyval",
")",
"{",
"$",
"keyval",
"=",
"explode",
"(",
"'='",
",",
"$",
"keyval",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keyval",
")",
"==",
"2",
")",
"{",
"if",
"(",
"$",
"keyval",
"[",
"0",
"]",
"===",
"'payment_date'",
")",
"{",
"if",
"(",
"substr_count",
"(",
"$",
"keyval",
"[",
"1",
"]",
",",
"'+'",
")",
"===",
"1",
")",
"{",
"$",
"keyval",
"[",
"1",
"]",
"=",
"str_replace",
"(",
"'+'",
",",
"'%2B'",
",",
"$",
"keyval",
"[",
"1",
"]",
")",
";",
"}",
"}",
"$",
"myPost",
"[",
"$",
"keyval",
"[",
"0",
"]",
"]",
"=",
"urldecode",
"(",
"$",
"keyval",
"[",
"1",
"]",
")",
";",
"}",
"}",
"$",
"req",
"=",
"'cmd=_notify-validate'",
";",
"$",
"get_magic_quotes_exists",
"=",
"false",
";",
"if",
"(",
"function_exists",
"(",
"'get_magic_quotes_gpc'",
")",
")",
"{",
"$",
"get_magic_quotes_exists",
"=",
"true",
";",
"}",
"foreach",
"(",
"$",
"myPost",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"get_magic_quotes_exists",
"==",
"true",
"&&",
"get_magic_quotes_gpc",
"(",
")",
"==",
"1",
")",
"{",
"$",
"value",
"=",
"urlencode",
"(",
"stripslashes",
"(",
"$",
"value",
")",
")",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"urlencode",
"(",
"$",
"value",
")",
";",
"}",
"$",
"req",
".=",
"\"&$key=$value\"",
";",
"}",
"$",
"ch",
"=",
"curl_init",
"(",
"$",
"this",
"->",
"getPaypalUri",
"(",
")",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTP_VERSION",
",",
"CURL_HTTP_VERSION_1_1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POST",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_POSTFIELDS",
",",
"$",
"req",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSLVERSION",
",",
"6",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYHOST",
",",
"2",
")",
";",
"if",
"(",
"$",
"this",
"->",
"useLocalCerts",
")",
"{",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CAINFO",
",",
"__DIR__",
".",
"\"/cert/cacert.pem\"",
")",
";",
"}",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_FORBID_REUSE",
",",
"1",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_CONNECTTIMEOUT",
",",
"30",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HTTPHEADER",
",",
"[",
"'Connection: Close'",
"]",
")",
";",
"$",
"res",
"=",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"$",
"info",
"=",
"curl_getinfo",
"(",
"$",
"ch",
")",
";",
"$",
"http_code",
"=",
"$",
"info",
"[",
"'http_code'",
"]",
";",
"if",
"(",
"$",
"http_code",
"!=",
"200",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"PayPal responded with http code $http_code\"",
")",
";",
"}",
"if",
"(",
"!",
"(",
"$",
"res",
")",
")",
"{",
"$",
"errno",
"=",
"curl_errno",
"(",
"$",
"ch",
")",
";",
"$",
"errstr",
"=",
"curl_error",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"throw",
"new",
"Exception",
"(",
"\"cURL error: [$errno] $errstr\"",
")",
";",
"}",
"curl_close",
"(",
"$",
"ch",
")",
";",
"if",
"(",
"$",
"res",
"==",
"self",
"::",
"VALID",
")",
"{",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] |
Verification Function
Sends the incoming post data back to PayPal using the cURL library.
@return bool
@throws Exception
|
[
"Verification",
"Function",
"Sends",
"the",
"incoming",
"post",
"data",
"back",
"to",
"PayPal",
"using",
"the",
"cURL",
"library",
"."
] |
635af4cf75a1e77a0531f46eea867cfcf9d1193d
|
https://github.com/overint/php-paypal-ipn/blob/635af4cf75a1e77a0531f46eea867cfcf9d1193d/src/PaypalIPN.php#L68-L136
|
223,383
|
Torann/laravel-asana
|
src/AsanaCurl.php
|
AsanaCurl.setHeaders
|
public function setHeaders(array $values)
{
foreach ($values as $key => $value) {
$this->setHeader($key, $value);
}
}
|
php
|
public function setHeaders(array $values)
{
foreach ($values as $key => $value) {
$this->setHeader($key, $value);
}
}
|
[
"public",
"function",
"setHeaders",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Add multiple headers to request.
@param array $values
|
[
"Add",
"multiple",
"headers",
"to",
"request",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/AsanaCurl.php#L68-L73
|
223,384
|
Torann/laravel-asana
|
src/AsanaCurl.php
|
AsanaCurl.request
|
private function request($method, $url, array $parameters = [], array $headers = [])
{
$this->errors = null;
// Set default content type
$this->setHeader('Content-Type', 'application/json');
$curl = curl_init();
// Set options
curl_setopt_array($curl, [
CURLOPT_URL => "{$this->endpoint}{$url}",
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 90,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_HEADER => 1,
CURLINFO_HEADER_OUT => 1,
CURLOPT_VERBOSE => 1,
]);
// Setup method specific options
switch ($method) {
case 'PUT':
case 'PATCH':
case 'POST':
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $this->buildArrayForCurl($parameters),
]);
break;
case 'DELETE':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
default:
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
break;
}
// Set request headers
curl_setopt($curl, CURLOPT_HTTPHEADER, array_filter(array_values($this->headers)));
// Make request
$response = curl_exec($curl);
// Set HTTP response code
$this->http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Set errors if there are any
if (curl_errno($curl)) {
$this->errors = curl_error($curl);
}
// Parse body
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$json = json_decode(substr($response, $header_size), false, 512, JSON_BIGINT_AS_STRING);
// Check for errors
$this->checkForCurlErrors($json);
curl_close($curl);
return $json;
}
|
php
|
private function request($method, $url, array $parameters = [], array $headers = [])
{
$this->errors = null;
// Set default content type
$this->setHeader('Content-Type', 'application/json');
$curl = curl_init();
// Set options
curl_setopt_array($curl, [
CURLOPT_URL => "{$this->endpoint}{$url}",
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 90,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_HEADER => 1,
CURLINFO_HEADER_OUT => 1,
CURLOPT_VERBOSE => 1,
]);
// Setup method specific options
switch ($method) {
case 'PUT':
case 'PATCH':
case 'POST':
curl_setopt_array($curl, [
CURLOPT_CUSTOMREQUEST => $method,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $this->buildArrayForCurl($parameters),
]);
break;
case 'DELETE':
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'DELETE');
break;
default:
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'GET');
break;
}
// Set request headers
curl_setopt($curl, CURLOPT_HTTPHEADER, array_filter(array_values($this->headers)));
// Make request
$response = curl_exec($curl);
// Set HTTP response code
$this->http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
// Set errors if there are any
if (curl_errno($curl)) {
$this->errors = curl_error($curl);
}
// Parse body
$header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$json = json_decode(substr($response, $header_size), false, 512, JSON_BIGINT_AS_STRING);
// Check for errors
$this->checkForCurlErrors($json);
curl_close($curl);
return $json;
}
|
[
"private",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"null",
";",
"// Set default content type",
"$",
"this",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"'application/json'",
")",
";",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"// Set options",
"curl_setopt_array",
"(",
"$",
"curl",
",",
"[",
"CURLOPT_URL",
"=>",
"\"{$this->endpoint}{$url}\"",
",",
"CURLOPT_CONNECTTIMEOUT",
"=>",
"10",
",",
"CURLOPT_TIMEOUT",
"=>",
"90",
",",
"CURLOPT_RETURNTRANSFER",
"=>",
"1",
",",
"CURLOPT_SSL_VERIFYPEER",
"=>",
"0",
",",
"CURLOPT_SSL_VERIFYHOST",
"=>",
"0",
",",
"CURLOPT_HEADER",
"=>",
"1",
",",
"CURLINFO_HEADER_OUT",
"=>",
"1",
",",
"CURLOPT_VERBOSE",
"=>",
"1",
",",
"]",
")",
";",
"// Setup method specific options",
"switch",
"(",
"$",
"method",
")",
"{",
"case",
"'PUT'",
":",
"case",
"'PATCH'",
":",
"case",
"'POST'",
":",
"curl_setopt_array",
"(",
"$",
"curl",
",",
"[",
"CURLOPT_CUSTOMREQUEST",
"=>",
"$",
"method",
",",
"CURLOPT_POST",
"=>",
"true",
",",
"CURLOPT_POSTFIELDS",
"=>",
"$",
"this",
"->",
"buildArrayForCurl",
"(",
"$",
"parameters",
")",
",",
"]",
")",
";",
"break",
";",
"case",
"'DELETE'",
":",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'DELETE'",
")",
";",
"break",
";",
"default",
":",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"'GET'",
")",
";",
"break",
";",
"}",
"// Set request headers",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HTTPHEADER",
",",
"array_filter",
"(",
"array_values",
"(",
"$",
"this",
"->",
"headers",
")",
")",
")",
";",
"// Make request",
"$",
"response",
"=",
"curl_exec",
"(",
"$",
"curl",
")",
";",
"// Set HTTP response code",
"$",
"this",
"->",
"http_code",
"=",
"curl_getinfo",
"(",
"$",
"curl",
",",
"CURLINFO_HTTP_CODE",
")",
";",
"// Set errors if there are any",
"if",
"(",
"curl_errno",
"(",
"$",
"curl",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"curl_error",
"(",
"$",
"curl",
")",
";",
"}",
"// Parse body",
"$",
"header_size",
"=",
"curl_getinfo",
"(",
"$",
"curl",
",",
"CURLINFO_HEADER_SIZE",
")",
";",
"$",
"header",
"=",
"substr",
"(",
"$",
"response",
",",
"0",
",",
"$",
"header_size",
")",
";",
"$",
"json",
"=",
"json_decode",
"(",
"substr",
"(",
"$",
"response",
",",
"$",
"header_size",
")",
",",
"false",
",",
"512",
",",
"JSON_BIGINT_AS_STRING",
")",
";",
"// Check for errors",
"$",
"this",
"->",
"checkForCurlErrors",
"(",
"$",
"json",
")",
";",
"curl_close",
"(",
"$",
"curl",
")",
";",
"return",
"$",
"json",
";",
"}"
] |
This function communicates with Asana REST API.
You don't need to call this function directly. It's only for inner class working.
@param int $method
@param string $url
@param array $parameters
@param array $headers
@return string|null
@throws Exception
|
[
"This",
"function",
"communicates",
"with",
"Asana",
"REST",
"API",
".",
"You",
"don",
"t",
"need",
"to",
"call",
"this",
"function",
"directly",
".",
"It",
"s",
"only",
"for",
"inner",
"class",
"working",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/AsanaCurl.php#L169-L237
|
223,385
|
Torann/laravel-asana
|
src/AsanaCurl.php
|
AsanaCurl.buildArrayForCurl
|
protected function buildArrayForCurl($params)
{
if (isset($params['file'])) {
// Have cUrl set the correct content type for upload
$this->setHeader('Content-Type', null);
// Convert array to a simple cUrl usable array
return $this->http_build_query_for_curl($params);
}
return json_encode($params);
}
|
php
|
protected function buildArrayForCurl($params)
{
if (isset($params['file'])) {
// Have cUrl set the correct content type for upload
$this->setHeader('Content-Type', null);
// Convert array to a simple cUrl usable array
return $this->http_build_query_for_curl($params);
}
return json_encode($params);
}
|
[
"protected",
"function",
"buildArrayForCurl",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'file'",
"]",
")",
")",
"{",
"// Have cUrl set the correct content type for upload",
"$",
"this",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"null",
")",
";",
"// Convert array to a simple cUrl usable array",
"return",
"$",
"this",
"->",
"http_build_query_for_curl",
"(",
"$",
"params",
")",
";",
"}",
"return",
"json_encode",
"(",
"$",
"params",
")",
";",
"}"
] |
Build http query that will be cUrl compliant.
@param array $params
@return array
|
[
"Build",
"http",
"query",
"that",
"will",
"be",
"cUrl",
"compliant",
"."
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/AsanaCurl.php#L246-L258
|
223,386
|
Torann/laravel-asana
|
src/AsanaCurl.php
|
AsanaCurl.http_build_query_for_curl
|
protected function http_build_query_for_curl($var, $prefix = null)
{
$return = [];
foreach ($var as $key => $value) {
$name = $prefix ? $prefix . '[' . $key . ']' : $key;
if (is_array($value)) {
$return = array_merge($return, $this->http_build_query_for_curl($value, $name));
}
else {
// Convert file to something usable
if ($key === 'file') {
$value = $this->addPostFile($value);
}
$return[$name] = $value;
}
}
return $return;
}
|
php
|
protected function http_build_query_for_curl($var, $prefix = null)
{
$return = [];
foreach ($var as $key => $value) {
$name = $prefix ? $prefix . '[' . $key . ']' : $key;
if (is_array($value)) {
$return = array_merge($return, $this->http_build_query_for_curl($value, $name));
}
else {
// Convert file to something usable
if ($key === 'file') {
$value = $this->addPostFile($value);
}
$return[$name] = $value;
}
}
return $return;
}
|
[
"protected",
"function",
"http_build_query_for_curl",
"(",
"$",
"var",
",",
"$",
"prefix",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"var",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"name",
"=",
"$",
"prefix",
"?",
"$",
"prefix",
".",
"'['",
".",
"$",
"key",
".",
"']'",
":",
"$",
"key",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"return",
"=",
"array_merge",
"(",
"$",
"return",
",",
"$",
"this",
"->",
"http_build_query_for_curl",
"(",
"$",
"value",
",",
"$",
"name",
")",
")",
";",
"}",
"else",
"{",
"// Convert file to something usable",
"if",
"(",
"$",
"key",
"===",
"'file'",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"addPostFile",
"(",
"$",
"value",
")",
";",
"}",
"$",
"return",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Handle nested arrays when posting
@param mixed $var
@param string $prefix
@return array
|
[
"Handle",
"nested",
"arrays",
"when",
"posting"
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/AsanaCurl.php#L268-L289
|
223,387
|
Torann/laravel-asana
|
src/AsanaCurl.php
|
AsanaCurl.addPostFile
|
public function addPostFile($filename)
{
if ($filename instanceof UploadedFile) {
// Get original filename
$name = $filename->getClientOriginalName();
// Move the file
$file = $filename->move(sys_get_temp_dir() . '/' . uniqid(), $name);
// Get the new file path
$filename = $file->getRealPath();
}
if (!is_readable($filename)) {
throw new InvalidArgumentException("Unable to open {$filename} for reading");
}
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
// See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
return curl_file_create($filename);
}
// Use the old style if using an older version of PHP
return "@{$filename}";
}
|
php
|
public function addPostFile($filename)
{
if ($filename instanceof UploadedFile) {
// Get original filename
$name = $filename->getClientOriginalName();
// Move the file
$file = $filename->move(sys_get_temp_dir() . '/' . uniqid(), $name);
// Get the new file path
$filename = $file->getRealPath();
}
if (!is_readable($filename)) {
throw new InvalidArgumentException("Unable to open {$filename} for reading");
}
// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax
// See: https://wiki.php.net/rfc/curl-file-upload
if (function_exists('curl_file_create')) {
return curl_file_create($filename);
}
// Use the old style if using an older version of PHP
return "@{$filename}";
}
|
[
"public",
"function",
"addPostFile",
"(",
"$",
"filename",
")",
"{",
"if",
"(",
"$",
"filename",
"instanceof",
"UploadedFile",
")",
"{",
"// Get original filename",
"$",
"name",
"=",
"$",
"filename",
"->",
"getClientOriginalName",
"(",
")",
";",
"// Move the file",
"$",
"file",
"=",
"$",
"filename",
"->",
"move",
"(",
"sys_get_temp_dir",
"(",
")",
".",
"'/'",
".",
"uniqid",
"(",
")",
",",
"$",
"name",
")",
";",
"// Get the new file path",
"$",
"filename",
"=",
"$",
"file",
"->",
"getRealPath",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_readable",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Unable to open {$filename} for reading\"",
")",
";",
"}",
"// PHP 5.5 introduced a CurlFile object that deprecates the old @filename syntax",
"// See: https://wiki.php.net/rfc/curl-file-upload",
"if",
"(",
"function_exists",
"(",
"'curl_file_create'",
")",
")",
"{",
"return",
"curl_file_create",
"(",
"$",
"filename",
")",
";",
"}",
"// Use the old style if using an older version of PHP",
"return",
"\"@{$filename}\"",
";",
"}"
] |
POST file upload
@param string $filename File to be uploaded
@return mixed
@throws InvalidArgumentException
|
[
"POST",
"file",
"upload"
] |
6e669720dbc3e66f19ffb637865eab9d5ae9d299
|
https://github.com/Torann/laravel-asana/blob/6e669720dbc3e66f19ffb637865eab9d5ae9d299/src/AsanaCurl.php#L299-L325
|
223,388
|
imanee/imanee
|
src/ImageResource/GDPixel.php
|
GDPixel.load
|
public static function load($color, $resource)
{
if ($color === 'transparent') {
return imagecolorallocatealpha($resource, 0, 0, 0, 127);
}
$gdpixel = new GDPixel($color);
return imagecolorallocate($resource, $gdpixel->channelR, $gdpixel->channelG, $gdpixel->channelB);
}
|
php
|
public static function load($color, $resource)
{
if ($color === 'transparent') {
return imagecolorallocatealpha($resource, 0, 0, 0, 127);
}
$gdpixel = new GDPixel($color);
return imagecolorallocate($resource, $gdpixel->channelR, $gdpixel->channelG, $gdpixel->channelB);
}
|
[
"public",
"static",
"function",
"load",
"(",
"$",
"color",
",",
"$",
"resource",
")",
"{",
"if",
"(",
"$",
"color",
"===",
"'transparent'",
")",
"{",
"return",
"imagecolorallocatealpha",
"(",
"$",
"resource",
",",
"0",
",",
"0",
",",
"0",
",",
"127",
")",
";",
"}",
"$",
"gdpixel",
"=",
"new",
"GDPixel",
"(",
"$",
"color",
")",
";",
"return",
"imagecolorallocate",
"(",
"$",
"resource",
",",
"$",
"gdpixel",
"->",
"channelR",
",",
"$",
"gdpixel",
"->",
"channelG",
",",
"$",
"gdpixel",
"->",
"channelB",
")",
";",
"}"
] |
Returns a color representation for GD based on a color string.
Examples of valid color strings:
- black
- white
- purple
- #00FFCC
- 00FFCC
@param string $color
@param resource $resource
@return int
|
[
"Returns",
"a",
"color",
"representation",
"for",
"GD",
"based",
"on",
"a",
"color",
"string",
"."
] |
cf390b5e7f92ca21d6e388abe51433e9ed671b1b
|
https://github.com/imanee/imanee/blob/cf390b5e7f92ca21d6e388abe51433e9ed671b1b/src/ImageResource/GDPixel.php#L54-L64
|
223,389
|
yii2mod/yii2-validators
|
ECCValidator.php
|
ECCValidator.validateNumber
|
public function validateNumber($creditCardNumber)
{
if (!$this->checkType()) {
throw new Exception(Yii::t('ECCValidator', 'The "format" property must be specified with a supported Credit Card format.'));
}
$creditCardNumber = preg_replace('/[ -]+/', '', $creditCardNumber);
return $this->checkFormat($creditCardNumber) && $this->mod10($creditCardNumber);
}
|
php
|
public function validateNumber($creditCardNumber)
{
if (!$this->checkType()) {
throw new Exception(Yii::t('ECCValidator', 'The "format" property must be specified with a supported Credit Card format.'));
}
$creditCardNumber = preg_replace('/[ -]+/', '', $creditCardNumber);
return $this->checkFormat($creditCardNumber) && $this->mod10($creditCardNumber);
}
|
[
"public",
"function",
"validateNumber",
"(",
"$",
"creditCardNumber",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"checkType",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"Yii",
"::",
"t",
"(",
"'ECCValidator'",
",",
"'The \"format\" property must be specified with a supported Credit Card format.'",
")",
")",
";",
"}",
"$",
"creditCardNumber",
"=",
"preg_replace",
"(",
"'/[ -]+/'",
",",
"''",
",",
"$",
"creditCardNumber",
")",
";",
"return",
"$",
"this",
"->",
"checkFormat",
"(",
"$",
"creditCardNumber",
")",
"&&",
"$",
"this",
"->",
"mod10",
"(",
"$",
"creditCardNumber",
")",
";",
"}"
] |
Validates a Credit Card number
@param string $creditCardNumber
@throws \yii\base\Exception
@return bool
@return bool
|
[
"Validates",
"a",
"Credit",
"Card",
"number"
] |
6c60328757b78cd33883b26c66c3d663f8ded47e
|
https://github.com/yii2mod/yii2-validators/blob/6c60328757b78cd33883b26c66c3d663f8ded47e/ECCValidator.php#L103-L112
|
223,390
|
yii2mod/yii2-validators
|
ECCValidator.php
|
ECCValidator.validateDate
|
public function validateDate($creditCardExpiredMonth, $creditCardExpiredYear)
{
$currentYear = intval(date('Y'));
$currentMonth = intval(date('m'));
if (is_scalar($creditCardExpiredMonth)) {
$creditCardExpiredMonth = intval($creditCardExpiredMonth);
}
if (is_scalar($creditCardExpiredYear)) {
$creditCardExpiredYear = intval($creditCardExpiredYear);
}
return is_int($creditCardExpiredMonth) && is_int($creditCardExpiredYear) && $creditCardExpiredMonth <= 12
&& ($creditCardExpiredMonth >= 1 && $creditCardExpiredYear > $currentYear
&& $creditCardExpiredYear < $currentYear + 21) || ($creditCardExpiredYear == $currentYear && $creditCardExpiredMonth >= $currentMonth);
}
|
php
|
public function validateDate($creditCardExpiredMonth, $creditCardExpiredYear)
{
$currentYear = intval(date('Y'));
$currentMonth = intval(date('m'));
if (is_scalar($creditCardExpiredMonth)) {
$creditCardExpiredMonth = intval($creditCardExpiredMonth);
}
if (is_scalar($creditCardExpiredYear)) {
$creditCardExpiredYear = intval($creditCardExpiredYear);
}
return is_int($creditCardExpiredMonth) && is_int($creditCardExpiredYear) && $creditCardExpiredMonth <= 12
&& ($creditCardExpiredMonth >= 1 && $creditCardExpiredYear > $currentYear
&& $creditCardExpiredYear < $currentYear + 21) || ($creditCardExpiredYear == $currentYear && $creditCardExpiredMonth >= $currentMonth);
}
|
[
"public",
"function",
"validateDate",
"(",
"$",
"creditCardExpiredMonth",
",",
"$",
"creditCardExpiredYear",
")",
"{",
"$",
"currentYear",
"=",
"intval",
"(",
"date",
"(",
"'Y'",
")",
")",
";",
"$",
"currentMonth",
"=",
"intval",
"(",
"date",
"(",
"'m'",
")",
")",
";",
"if",
"(",
"is_scalar",
"(",
"$",
"creditCardExpiredMonth",
")",
")",
"{",
"$",
"creditCardExpiredMonth",
"=",
"intval",
"(",
"$",
"creditCardExpiredMonth",
")",
";",
"}",
"if",
"(",
"is_scalar",
"(",
"$",
"creditCardExpiredYear",
")",
")",
"{",
"$",
"creditCardExpiredYear",
"=",
"intval",
"(",
"$",
"creditCardExpiredYear",
")",
";",
"}",
"return",
"is_int",
"(",
"$",
"creditCardExpiredMonth",
")",
"&&",
"is_int",
"(",
"$",
"creditCardExpiredYear",
")",
"&&",
"$",
"creditCardExpiredMonth",
"<=",
"12",
"&&",
"(",
"$",
"creditCardExpiredMonth",
">=",
"1",
"&&",
"$",
"creditCardExpiredYear",
">",
"$",
"currentYear",
"&&",
"$",
"creditCardExpiredYear",
"<",
"$",
"currentYear",
"+",
"21",
")",
"||",
"(",
"$",
"creditCardExpiredYear",
"==",
"$",
"currentYear",
"&&",
"$",
"creditCardExpiredMonth",
">=",
"$",
"currentMonth",
")",
";",
"}"
] |
Validates a Credit Card date
@param int $creditCardExpiredMonth
@param int $creditCardExpiredYear
@return bool
|
[
"Validates",
"a",
"Credit",
"Card",
"date"
] |
6c60328757b78cd33883b26c66c3d663f8ded47e
|
https://github.com/yii2mod/yii2-validators/blob/6c60328757b78cd33883b26c66c3d663f8ded47e/ECCValidator.php#L122-L137
|
223,391
|
yii2mod/yii2-validators
|
ECCValidator.php
|
ECCValidator.validateAll
|
public function validateAll($creditCardHolder, $creditCardNumber, $creditCardExpiredMonth, $creditCardExpiredYear)
{
return $this->validateName($creditCardHolder) && $this->validateNumber($creditCardNumber) && $this->validateDate($creditCardExpiredMonth, $creditCardExpiredYear);
}
|
php
|
public function validateAll($creditCardHolder, $creditCardNumber, $creditCardExpiredMonth, $creditCardExpiredYear)
{
return $this->validateName($creditCardHolder) && $this->validateNumber($creditCardNumber) && $this->validateDate($creditCardExpiredMonth, $creditCardExpiredYear);
}
|
[
"public",
"function",
"validateAll",
"(",
"$",
"creditCardHolder",
",",
"$",
"creditCardNumber",
",",
"$",
"creditCardExpiredMonth",
",",
"$",
"creditCardExpiredYear",
")",
"{",
"return",
"$",
"this",
"->",
"validateName",
"(",
"$",
"creditCardHolder",
")",
"&&",
"$",
"this",
"->",
"validateNumber",
"(",
"$",
"creditCardNumber",
")",
"&&",
"$",
"this",
"->",
"validateDate",
"(",
"$",
"creditCardExpiredMonth",
",",
"$",
"creditCardExpiredYear",
")",
";",
"}"
] |
Validates holder, number, and dates of Credit Card numbers
@param string $creditCardHolder
@param string $creditCardNumber
@param int $creditCardExpiredMonth
@param int $creditCardExpiredYear
@return bool
|
[
"Validates",
"holder",
"number",
"and",
"dates",
"of",
"Credit",
"Card",
"numbers"
] |
6c60328757b78cd33883b26c66c3d663f8ded47e
|
https://github.com/yii2mod/yii2-validators/blob/6c60328757b78cd33883b26c66c3d663f8ded47e/ECCValidator.php#L161-L164
|
223,392
|
yii2mod/yii2-validators
|
ECCValidator.php
|
ECCValidator.checkFormat
|
protected function checkFormat($cardNumber)
{
return preg_match('/^[0-9]+$/', $cardNumber) && preg_match($this->patterns[$this->format], $cardNumber);
}
|
php
|
protected function checkFormat($cardNumber)
{
return preg_match('/^[0-9]+$/', $cardNumber) && preg_match($this->patterns[$this->format], $cardNumber);
}
|
[
"protected",
"function",
"checkFormat",
"(",
"$",
"cardNumber",
")",
"{",
"return",
"preg_match",
"(",
"'/^[0-9]+$/'",
",",
"$",
"cardNumber",
")",
"&&",
"preg_match",
"(",
"$",
"this",
"->",
"patterns",
"[",
"$",
"this",
"->",
"format",
"]",
",",
"$",
"cardNumber",
")",
";",
"}"
] |
Checks Credit Card Prefixes
@param $cardNumber
@return bool
|
[
"Checks",
"Credit",
"Card",
"Prefixes"
] |
6c60328757b78cd33883b26c66c3d663f8ded47e
|
https://github.com/yii2mod/yii2-validators/blob/6c60328757b78cd33883b26c66c3d663f8ded47e/ECCValidator.php#L173-L176
|
223,393
|
yii2mod/yii2-validators
|
ECCValidator.php
|
ECCValidator.mod10
|
protected function mod10($cardNumber)
{
$cardNumber = strrev($cardNumber);
$numSum = 0;
for ($i = 0; $i < strlen($cardNumber); $i++) {
$currentNum = substr($cardNumber, $i, 1);
if ($i % 2 == 1) {
$currentNum *= 2;
}
if ($currentNum > 9) {
$firstNum = $currentNum % 10;
$secondNum = ($currentNum - $firstNum) / 10;
$currentNum = $firstNum + $secondNum;
}
$numSum += $currentNum;
}
return $numSum % 10 == 0;
}
|
php
|
protected function mod10($cardNumber)
{
$cardNumber = strrev($cardNumber);
$numSum = 0;
for ($i = 0; $i < strlen($cardNumber); $i++) {
$currentNum = substr($cardNumber, $i, 1);
if ($i % 2 == 1) {
$currentNum *= 2;
}
if ($currentNum > 9) {
$firstNum = $currentNum % 10;
$secondNum = ($currentNum - $firstNum) / 10;
$currentNum = $firstNum + $secondNum;
}
$numSum += $currentNum;
}
return $numSum % 10 == 0;
}
|
[
"protected",
"function",
"mod10",
"(",
"$",
"cardNumber",
")",
"{",
"$",
"cardNumber",
"=",
"strrev",
"(",
"$",
"cardNumber",
")",
";",
"$",
"numSum",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"cardNumber",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"currentNum",
"=",
"substr",
"(",
"$",
"cardNumber",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"$",
"i",
"%",
"2",
"==",
"1",
")",
"{",
"$",
"currentNum",
"*=",
"2",
";",
"}",
"if",
"(",
"$",
"currentNum",
">",
"9",
")",
"{",
"$",
"firstNum",
"=",
"$",
"currentNum",
"%",
"10",
";",
"$",
"secondNum",
"=",
"(",
"$",
"currentNum",
"-",
"$",
"firstNum",
")",
"/",
"10",
";",
"$",
"currentNum",
"=",
"$",
"firstNum",
"+",
"$",
"secondNum",
";",
"}",
"$",
"numSum",
"+=",
"$",
"currentNum",
";",
"}",
"return",
"$",
"numSum",
"%",
"10",
"==",
"0",
";",
"}"
] |
Check credit card number by Mod 10 algorithm
@param $cardNumber
@return bool
@see http://en.wikipedia.org/wiki/Luhn_algorithm#Mod_10.2B5_Variant
|
[
"Check",
"credit",
"card",
"number",
"by",
"Mod",
"10",
"algorithm"
] |
6c60328757b78cd33883b26c66c3d663f8ded47e
|
https://github.com/yii2mod/yii2-validators/blob/6c60328757b78cd33883b26c66c3d663f8ded47e/ECCValidator.php#L187-L205
|
223,394
|
ConsoleTVs/Links
|
src/Builder.php
|
Builder.track
|
public static function track($jquery = false)
{
$link = new Link(Request::url());
return $link->ajax($jquery);
}
|
php
|
public static function track($jquery = false)
{
$link = new Link(Request::url());
return $link->ajax($jquery);
}
|
[
"public",
"static",
"function",
"track",
"(",
"$",
"jquery",
"=",
"false",
")",
"{",
"$",
"link",
"=",
"new",
"Link",
"(",
"Request",
"::",
"url",
"(",
")",
")",
";",
"return",
"$",
"link",
"->",
"ajax",
"(",
"$",
"jquery",
")",
";",
"}"
] |
Create a new link from the current page url.
@param string $url
|
[
"Create",
"a",
"new",
"link",
"from",
"the",
"current",
"page",
"url",
"."
] |
f9afe304137f8d7682eac9c46f8aa4c82f5e625c
|
https://github.com/ConsoleTVs/Links/blob/f9afe304137f8d7682eac9c46f8aa4c82f5e625c/src/Builder.php#L51-L56
|
223,395
|
personnummer/php
|
src/Personnummer.php
|
Personnummer.luhn
|
private static function luhn($str)
{
$v = 0;
$sum = 0;
for ($i = 0; $i < strlen($str); $i ++) {
$v = intval($str[$i]);
$v *= 2 - ($i % 2);
if ($v > 9) {
$v -= 9;
}
$sum += $v;
}
return intval(ceil($sum / 10) * 10 - $sum);
}
|
php
|
private static function luhn($str)
{
$v = 0;
$sum = 0;
for ($i = 0; $i < strlen($str); $i ++) {
$v = intval($str[$i]);
$v *= 2 - ($i % 2);
if ($v > 9) {
$v -= 9;
}
$sum += $v;
}
return intval(ceil($sum / 10) * 10 - $sum);
}
|
[
"private",
"static",
"function",
"luhn",
"(",
"$",
"str",
")",
"{",
"$",
"v",
"=",
"0",
";",
"$",
"sum",
"=",
"0",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"str",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"v",
"=",
"intval",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
")",
";",
"$",
"v",
"*=",
"2",
"-",
"(",
"$",
"i",
"%",
"2",
")",
";",
"if",
"(",
"$",
"v",
">",
"9",
")",
"{",
"$",
"v",
"-=",
"9",
";",
"}",
"$",
"sum",
"+=",
"$",
"v",
";",
"}",
"return",
"intval",
"(",
"ceil",
"(",
"$",
"sum",
"/",
"10",
")",
"*",
"10",
"-",
"$",
"sum",
")",
";",
"}"
] |
The Luhn algorithm.
@param string str
@return int
|
[
"The",
"Luhn",
"algorithm",
"."
] |
acb1376e96b48744d863b2c59c9cd438f39c0330
|
https://github.com/personnummer/php/blob/acb1376e96b48744d863b2c59c9cd438f39c0330/src/Personnummer.php#L14-L31
|
223,396
|
personnummer/php
|
src/Personnummer.php
|
Personnummer.getParts
|
protected static function getParts($str) {
$reg = '/^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\+\-\s]?)(\d{3})(\d)$/';
preg_match($reg, $str, $match);
if (!isset($match) || count($match) !== 8) {
return array();
}
$century = $match[1];
$year = $match[2];
$month = $match[3];
$day = $match[4];
$sep = $match[5];
$num = $match[6];
$check = $match[7];
if (!in_array($sep, array('-', '+'))) {
if (empty($century) || date('Y') - intval(strval($century) . strval($year)) < 100) {
$sep = '-';
} else {
$sep = '+';
}
}
if (empty($century)) {
if ($sep === '+') {
$baseYear = date('Y', strtotime('-100 years'));
} else {
$baseYear = date('Y');
}
$century = substr(($baseYear - (($baseYear - $year) % 100)), 0, 2);
}
return array(
'century' => $century,
'year' => $year,
'month' => $month,
'day' => $day,
'sep' => $sep,
'num' => $num,
'check' => $check
);
}
|
php
|
protected static function getParts($str) {
$reg = '/^(\d{2}){0,1}(\d{2})(\d{2})(\d{2})([\+\-\s]?)(\d{3})(\d)$/';
preg_match($reg, $str, $match);
if (!isset($match) || count($match) !== 8) {
return array();
}
$century = $match[1];
$year = $match[2];
$month = $match[3];
$day = $match[4];
$sep = $match[5];
$num = $match[6];
$check = $match[7];
if (!in_array($sep, array('-', '+'))) {
if (empty($century) || date('Y') - intval(strval($century) . strval($year)) < 100) {
$sep = '-';
} else {
$sep = '+';
}
}
if (empty($century)) {
if ($sep === '+') {
$baseYear = date('Y', strtotime('-100 years'));
} else {
$baseYear = date('Y');
}
$century = substr(($baseYear - (($baseYear - $year) % 100)), 0, 2);
}
return array(
'century' => $century,
'year' => $year,
'month' => $month,
'day' => $day,
'sep' => $sep,
'num' => $num,
'check' => $check
);
}
|
[
"protected",
"static",
"function",
"getParts",
"(",
"$",
"str",
")",
"{",
"$",
"reg",
"=",
"'/^(\\d{2}){0,1}(\\d{2})(\\d{2})(\\d{2})([\\+\\-\\s]?)(\\d{3})(\\d)$/'",
";",
"preg_match",
"(",
"$",
"reg",
",",
"$",
"str",
",",
"$",
"match",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"match",
")",
"||",
"count",
"(",
"$",
"match",
")",
"!==",
"8",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"century",
"=",
"$",
"match",
"[",
"1",
"]",
";",
"$",
"year",
"=",
"$",
"match",
"[",
"2",
"]",
";",
"$",
"month",
"=",
"$",
"match",
"[",
"3",
"]",
";",
"$",
"day",
"=",
"$",
"match",
"[",
"4",
"]",
";",
"$",
"sep",
"=",
"$",
"match",
"[",
"5",
"]",
";",
"$",
"num",
"=",
"$",
"match",
"[",
"6",
"]",
";",
"$",
"check",
"=",
"$",
"match",
"[",
"7",
"]",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"sep",
",",
"array",
"(",
"'-'",
",",
"'+'",
")",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"century",
")",
"||",
"date",
"(",
"'Y'",
")",
"-",
"intval",
"(",
"strval",
"(",
"$",
"century",
")",
".",
"strval",
"(",
"$",
"year",
")",
")",
"<",
"100",
")",
"{",
"$",
"sep",
"=",
"'-'",
";",
"}",
"else",
"{",
"$",
"sep",
"=",
"'+'",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"century",
")",
")",
"{",
"if",
"(",
"$",
"sep",
"===",
"'+'",
")",
"{",
"$",
"baseYear",
"=",
"date",
"(",
"'Y'",
",",
"strtotime",
"(",
"'-100 years'",
")",
")",
";",
"}",
"else",
"{",
"$",
"baseYear",
"=",
"date",
"(",
"'Y'",
")",
";",
"}",
"$",
"century",
"=",
"substr",
"(",
"(",
"$",
"baseYear",
"-",
"(",
"(",
"$",
"baseYear",
"-",
"$",
"year",
")",
"%",
"100",
")",
")",
",",
"0",
",",
"2",
")",
";",
"}",
"return",
"array",
"(",
"'century'",
"=>",
"$",
"century",
",",
"'year'",
"=>",
"$",
"year",
",",
"'month'",
"=>",
"$",
"month",
",",
"'day'",
"=>",
"$",
"day",
",",
"'sep'",
"=>",
"$",
"sep",
",",
"'num'",
"=>",
"$",
"num",
",",
"'check'",
"=>",
"$",
"check",
")",
";",
"}"
] |
Parse Swedish social security numbers and get the parts
@param string $str
@return array
|
[
"Parse",
"Swedish",
"social",
"security",
"numbers",
"and",
"get",
"the",
"parts"
] |
acb1376e96b48744d863b2c59c9cd438f39c0330
|
https://github.com/personnummer/php/blob/acb1376e96b48744d863b2c59c9cd438f39c0330/src/Personnummer.php#L40-L82
|
223,397
|
personnummer/php
|
src/Personnummer.php
|
Personnummer.valid
|
public static function valid($str)
{
if (!is_numeric($str) && !is_string($str)) {
return false;
}
$str = strval($str);
$parts = array_pad(self::getParts($str), 7, '');
if (in_array('', $parts, true)) {
return false;
}
list($century, $year, $month, $day, $sep, $num, $check) = array_values($parts);
$validDate = checkdate($month, $day, strval($century) . strval($year));
$validCoOrdinationNumber = checkdate($month, intval($day) - 60, strval($century) . strval($year));
if (!$validDate && !$validCoOrdinationNumber) {
return false;
}
$valid = self::luhn($year . $month . $day . $num) === intval($check);
return $valid;
}
|
php
|
public static function valid($str)
{
if (!is_numeric($str) && !is_string($str)) {
return false;
}
$str = strval($str);
$parts = array_pad(self::getParts($str), 7, '');
if (in_array('', $parts, true)) {
return false;
}
list($century, $year, $month, $day, $sep, $num, $check) = array_values($parts);
$validDate = checkdate($month, $day, strval($century) . strval($year));
$validCoOrdinationNumber = checkdate($month, intval($day) - 60, strval($century) . strval($year));
if (!$validDate && !$validCoOrdinationNumber) {
return false;
}
$valid = self::luhn($year . $month . $day . $num) === intval($check);
return $valid;
}
|
[
"public",
"static",
"function",
"valid",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"str",
")",
"&&",
"!",
"is_string",
"(",
"$",
"str",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"str",
"=",
"strval",
"(",
"$",
"str",
")",
";",
"$",
"parts",
"=",
"array_pad",
"(",
"self",
"::",
"getParts",
"(",
"$",
"str",
")",
",",
"7",
",",
"''",
")",
";",
"if",
"(",
"in_array",
"(",
"''",
",",
"$",
"parts",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"list",
"(",
"$",
"century",
",",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
",",
"$",
"sep",
",",
"$",
"num",
",",
"$",
"check",
")",
"=",
"array_values",
"(",
"$",
"parts",
")",
";",
"$",
"validDate",
"=",
"checkdate",
"(",
"$",
"month",
",",
"$",
"day",
",",
"strval",
"(",
"$",
"century",
")",
".",
"strval",
"(",
"$",
"year",
")",
")",
";",
"$",
"validCoOrdinationNumber",
"=",
"checkdate",
"(",
"$",
"month",
",",
"intval",
"(",
"$",
"day",
")",
"-",
"60",
",",
"strval",
"(",
"$",
"century",
")",
".",
"strval",
"(",
"$",
"year",
")",
")",
";",
"if",
"(",
"!",
"$",
"validDate",
"&&",
"!",
"$",
"validCoOrdinationNumber",
")",
"{",
"return",
"false",
";",
"}",
"$",
"valid",
"=",
"self",
"::",
"luhn",
"(",
"$",
"year",
".",
"$",
"month",
".",
"$",
"day",
".",
"$",
"num",
")",
"===",
"intval",
"(",
"$",
"check",
")",
";",
"return",
"$",
"valid",
";",
"}"
] |
Validate Swedish social security numbers.
@param string|int $str
@return bool
|
[
"Validate",
"Swedish",
"social",
"security",
"numbers",
"."
] |
acb1376e96b48744d863b2c59c9cd438f39c0330
|
https://github.com/personnummer/php/blob/acb1376e96b48744d863b2c59c9cd438f39c0330/src/Personnummer.php#L91-L117
|
223,398
|
personnummer/php
|
src/Personnummer.php
|
Personnummer.format
|
public static function format($str, $longFormat = false) {
if (!self::valid($str)) {
return '';
}
$parts = self::getParts($str);
if ($longFormat) {
$format = '%1$s%2$s%3$s%4$s%6$s%7$s';
} else {
$format = '%2$s%3$s%4$s%5$s%6$s%7$s';
}
$return = sprintf(
$format,
$parts['century'],
$parts['year'],
$parts['month'],
$parts['day'],
$parts['sep'],
$parts['num'],
$parts['check']
);
return $return;
}
|
php
|
public static function format($str, $longFormat = false) {
if (!self::valid($str)) {
return '';
}
$parts = self::getParts($str);
if ($longFormat) {
$format = '%1$s%2$s%3$s%4$s%6$s%7$s';
} else {
$format = '%2$s%3$s%4$s%5$s%6$s%7$s';
}
$return = sprintf(
$format,
$parts['century'],
$parts['year'],
$parts['month'],
$parts['day'],
$parts['sep'],
$parts['num'],
$parts['check']
);
return $return;
}
|
[
"public",
"static",
"function",
"format",
"(",
"$",
"str",
",",
"$",
"longFormat",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"valid",
"(",
"$",
"str",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"parts",
"=",
"self",
"::",
"getParts",
"(",
"$",
"str",
")",
";",
"if",
"(",
"$",
"longFormat",
")",
"{",
"$",
"format",
"=",
"'%1$s%2$s%3$s%4$s%6$s%7$s'",
";",
"}",
"else",
"{",
"$",
"format",
"=",
"'%2$s%3$s%4$s%5$s%6$s%7$s'",
";",
"}",
"$",
"return",
"=",
"sprintf",
"(",
"$",
"format",
",",
"$",
"parts",
"[",
"'century'",
"]",
",",
"$",
"parts",
"[",
"'year'",
"]",
",",
"$",
"parts",
"[",
"'month'",
"]",
",",
"$",
"parts",
"[",
"'day'",
"]",
",",
"$",
"parts",
"[",
"'sep'",
"]",
",",
"$",
"parts",
"[",
"'num'",
"]",
",",
"$",
"parts",
"[",
"'check'",
"]",
")",
";",
"return",
"$",
"return",
";",
"}"
] |
Format Swedish social security numbers to official format
@param string|int $str
@param bool $longFormat YYMMDD-XXXX or YYYYMMDDXXXX since the tax office says both are official
@return string
|
[
"Format",
"Swedish",
"social",
"security",
"numbers",
"to",
"official",
"format"
] |
acb1376e96b48744d863b2c59c9cd438f39c0330
|
https://github.com/personnummer/php/blob/acb1376e96b48744d863b2c59c9cd438f39c0330/src/Personnummer.php#L127-L152
|
223,399
|
lexik/LexikWorkflowBundle
|
Flow/Node.php
|
Node.addNextState
|
public function addNextState($name, $type, Node $target)
{
$this->nextStates[$name] = new NextState($name, $type, $target);
}
|
php
|
public function addNextState($name, $type, Node $target)
{
$this->nextStates[$name] = new NextState($name, $type, $target);
}
|
[
"public",
"function",
"addNextState",
"(",
"$",
"name",
",",
"$",
"type",
",",
"Node",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"nextStates",
"[",
"$",
"name",
"]",
"=",
"new",
"NextState",
"(",
"$",
"name",
",",
"$",
"type",
",",
"$",
"target",
")",
";",
"}"
] |
Add a next state.
@param string $name
@param string $type
@param Node $state
|
[
"Add",
"a",
"next",
"state",
"."
] |
0caf4609843c8b1929f14d7c717e37626c3f2f71
|
https://github.com/lexik/LexikWorkflowBundle/blob/0caf4609843c8b1929f14d7c717e37626c3f2f71/Flow/Node.php#L87-L90
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.