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
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Template/ElfinderTemplate.php | ElfinderTemplate.elfinderConfigAsJson | public function elfinderConfigAsJson()
{
$property = $this->formProperty();
$settings = [];
if ($this->elfinderConfig['client']) {
$settings = $this->elfinderConfig['client'];
}
$settings['lang'] = $this->translator()->getLocale();
if ($property) {
$mimeTypes = filter_input(INPUT_GET, 'filetype', FILTER_SANITIZE_STRING);
if ($mimeTypes) {
if ($mimeTypes === 'file') {
$mimeTypes = [];
}
$settings['onlyMimes'] = (array)$mimeTypes;
} elseif ($property instanceof FileProperty) {
$settings['onlyMimes'] = $property->acceptedMimetypes();
}
$settings['rememberLastDir'] = !($property instanceof FileProperty);
}
return json_encode($settings, (JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
} | php | public function elfinderConfigAsJson()
{
$property = $this->formProperty();
$settings = [];
if ($this->elfinderConfig['client']) {
$settings = $this->elfinderConfig['client'];
}
$settings['lang'] = $this->translator()->getLocale();
if ($property) {
$mimeTypes = filter_input(INPUT_GET, 'filetype', FILTER_SANITIZE_STRING);
if ($mimeTypes) {
if ($mimeTypes === 'file') {
$mimeTypes = [];
}
$settings['onlyMimes'] = (array)$mimeTypes;
} elseif ($property instanceof FileProperty) {
$settings['onlyMimes'] = $property->acceptedMimetypes();
}
$settings['rememberLastDir'] = !($property instanceof FileProperty);
}
return json_encode($settings, (JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE));
} | [
"public",
"function",
"elfinderConfigAsJson",
"(",
")",
"{",
"$",
"property",
"=",
"$",
"this",
"->",
"formProperty",
"(",
")",
";",
"$",
"settings",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"elfinderConfig",
"[",
"'client'",
"]",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"elfinderConfig",
"[",
"'client'",
"]",
";",
"}",
"$",
"settings",
"[",
"'lang'",
"]",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"getLocale",
"(",
")",
";",
"if",
"(",
"$",
"property",
")",
"{",
"$",
"mimeTypes",
"=",
"filter_input",
"(",
"INPUT_GET",
",",
"'filetype'",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"if",
"(",
"$",
"mimeTypes",
")",
"{",
"if",
"(",
"$",
"mimeTypes",
"===",
"'file'",
")",
"{",
"$",
"mimeTypes",
"=",
"[",
"]",
";",
"}",
"$",
"settings",
"[",
"'onlyMimes'",
"]",
"=",
"(",
"array",
")",
"$",
"mimeTypes",
";",
"}",
"elseif",
"(",
"$",
"property",
"instanceof",
"FileProperty",
")",
"{",
"$",
"settings",
"[",
"'onlyMimes'",
"]",
"=",
"$",
"property",
"->",
"acceptedMimetypes",
"(",
")",
";",
"}",
"$",
"settings",
"[",
"'rememberLastDir'",
"]",
"=",
"!",
"(",
"$",
"property",
"instanceof",
"FileProperty",
")",
";",
"}",
"return",
"json_encode",
"(",
"$",
"settings",
",",
"(",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_UNESCAPED_UNICODE",
")",
")",
";",
"}"
]
| Retrieve the current property's client-side settings for elFinder.
@return string Returns data serialized with {@see json_encode()}. | [
"Retrieve",
"the",
"current",
"property",
"s",
"client",
"-",
"side",
"settings",
"for",
"elFinder",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Template/ElfinderTemplate.php#L386-L414 | train |
acquia/commerce-manager | modules/acm/src/User/CommerceAccountProxyFactory.php | CommerceAccountProxyFactory.get | public static function get(ContainerInterface $container) {
$use_ecomm_sessions = $container
->get('config.factory')
->get('acm.commerce_users')
->get('use_ecomm_sessions');
if ($use_ecomm_sessions) {
return $container->get('acm.external_commerce_account_proxy');
}
return $container->get('acm.commerce_account_proxy');
} | php | public static function get(ContainerInterface $container) {
$use_ecomm_sessions = $container
->get('config.factory')
->get('acm.commerce_users')
->get('use_ecomm_sessions');
if ($use_ecomm_sessions) {
return $container->get('acm.external_commerce_account_proxy');
}
return $container->get('acm.commerce_account_proxy');
} | [
"public",
"static",
"function",
"get",
"(",
"ContainerInterface",
"$",
"container",
")",
"{",
"$",
"use_ecomm_sessions",
"=",
"$",
"container",
"->",
"get",
"(",
"'config.factory'",
")",
"->",
"get",
"(",
"'acm.commerce_users'",
")",
"->",
"get",
"(",
"'use_ecomm_sessions'",
")",
";",
"if",
"(",
"$",
"use_ecomm_sessions",
")",
"{",
"return",
"$",
"container",
"->",
"get",
"(",
"'acm.external_commerce_account_proxy'",
")",
";",
"}",
"return",
"$",
"container",
"->",
"get",
"(",
"'acm.commerce_account_proxy'",
")",
";",
"}"
]
| Creates an AccountProxyInterface object.
@param \Symfony\Component\DependencyInjection\ContainerInterface $container
The current service container.
@return \Drupal\Core\Session\AccountProxyInterface
An account proxy object. | [
"Creates",
"an",
"AccountProxyInterface",
"object",
"."
]
| e6c3a5fb9166d6c447725339ac4e0ae341c06d50 | https://github.com/acquia/commerce-manager/blob/e6c3a5fb9166d6c447725339ac4e0ae341c06d50/modules/acm/src/User/CommerceAccountProxyFactory.php#L21-L32 | train |
yzalis/SupervisorBundle | Manager/GroupRestrictedSupervisor.php | GroupRestrictedSupervisor.startAllProcesses | public function startAllProcesses($wait = true)
{
if (empty($this->groups)) {
return parent::startAllProcesses($wait);
}
$results = [];
foreach ($this->groups as $group) {
$results = array_merge($results, parent::startProcessGroup($group, $wait));
}
return $results;
} | php | public function startAllProcesses($wait = true)
{
if (empty($this->groups)) {
return parent::startAllProcesses($wait);
}
$results = [];
foreach ($this->groups as $group) {
$results = array_merge($results, parent::startProcessGroup($group, $wait));
}
return $results;
} | [
"public",
"function",
"startAllProcesses",
"(",
"$",
"wait",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"groups",
")",
")",
"{",
"return",
"parent",
"::",
"startAllProcesses",
"(",
"$",
"wait",
")",
";",
"}",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"results",
"=",
"array_merge",
"(",
"$",
"results",
",",
"parent",
"::",
"startProcessGroup",
"(",
"$",
"group",
",",
"$",
"wait",
")",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
]
| Start all processes listed in the configuration file.
@param bool $wait Wait for each process to be fully started
@return array result An array containing start statuses | [
"Start",
"all",
"processes",
"listed",
"in",
"the",
"configuration",
"file",
"."
]
| 0b3fae253246fe861d0223a3ddbb37a5465eae6f | https://github.com/yzalis/SupervisorBundle/blob/0b3fae253246fe861d0223a3ddbb37a5465eae6f/Manager/GroupRestrictedSupervisor.php#L53-L66 | train |
yzalis/SupervisorBundle | Manager/GroupRestrictedSupervisor.php | GroupRestrictedSupervisor.stopAllProcesses | public function stopAllProcesses($wait = true)
{
if (empty($this->groups)) {
return parent::stopAllProcesses($wait);
}
$results = [];
foreach ($this->groups as $group) {
$results = array_merge($results, parent::stopProcessGroup($group, $wait));
}
return $results;
} | php | public function stopAllProcesses($wait = true)
{
if (empty($this->groups)) {
return parent::stopAllProcesses($wait);
}
$results = [];
foreach ($this->groups as $group) {
$results = array_merge($results, parent::stopProcessGroup($group, $wait));
}
return $results;
} | [
"public",
"function",
"stopAllProcesses",
"(",
"$",
"wait",
"=",
"true",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"groups",
")",
")",
"{",
"return",
"parent",
"::",
"stopAllProcesses",
"(",
"$",
"wait",
")",
";",
"}",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"groups",
"as",
"$",
"group",
")",
"{",
"$",
"results",
"=",
"array_merge",
"(",
"$",
"results",
",",
"parent",
"::",
"stopProcessGroup",
"(",
"$",
"group",
",",
"$",
"wait",
")",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
]
| Stop all processes listed in the configuration file.
@param bool $wait Wait for each process to be fully stoped
@return array result An array containing start statuses | [
"Stop",
"all",
"processes",
"listed",
"in",
"the",
"configuration",
"file",
"."
]
| 0b3fae253246fe861d0223a3ddbb37a5465eae6f | https://github.com/yzalis/SupervisorBundle/blob/0b3fae253246fe861d0223a3ddbb37a5465eae6f/Manager/GroupRestrictedSupervisor.php#L75-L88 | train |
acquia/commerce-manager | modules/acm_customer/src/Plugin/CustomerForm/Addresses.php | Addresses.buildSummary | public function buildSummary(array $addresses = [], $show_add = TRUE) {
$build = [];
// Display an "Add Address" button.
if ($show_add) {
$build['add_address'] = [
'#type' => 'acm_composite',
'#field_type' => 'acm_address',
'#default_value' => empty($addresses) ? $this->t('You have no saved addresses.') : '',
'#form_mode' => FALSE,
'#buttons' => [
'add' => [
'#type' => 'link',
'#title' => $this->t('Add address'),
'#url' => Url::fromRoute('acm_customer.view_page', [
'page' => $this->getPageId(),
'action' => 'add',
]),
'#attributes' => [
'class' => [
'form-item__add-button',
],
],
],
],
];
}
// Build the summary for each user address.
foreach ($addresses as $address) {
if ($address['default_billing'] && $address['default_shipping']) {
$address['heading'] = $this->t('Default Billing and Shipping Address');
}
elseif ($address['default_billing']) {
$address['heading'] = $this->t('Default Billing Address');
}
elseif ($address['default_shipping']) {
$address['heading'] = $this->t('Default Shipping Address');
}
else {
$address['heading'] = '';
}
// Build a link for each action.
$actions = [
'edit' => [
'label' => t('Edit'),
],
'delete' => [
'label' => t('Delete'),
'options' => [
'attributes' => [
'class' => ['bypass-js'],
],
],
],
];
$links = [];
foreach ($actions as $action => $config) {
$options = isset($config['options']) ? $config['options'] : [];
$label = isset($config['label']) ? $config['label'] : $action;
$link = Link::fromTextAndUrl($label, Url::fromRoute('acm_customer.view_page', [
'page' => $this->getPageId(),
'action' => $action,
'id' => $address['address_id'],
], $options));
$link = $link->toRenderable();
$links[$action] = [
'#type' => 'container',
'#attributes' => [
'class' => ["customer-address__{$action}-button"],
],
'link' => $link,
];
}
$build[] = [
'#theme' => 'user_address',
'#address' => $address,
'#links' => $links,
];
}
return $build;
} | php | public function buildSummary(array $addresses = [], $show_add = TRUE) {
$build = [];
// Display an "Add Address" button.
if ($show_add) {
$build['add_address'] = [
'#type' => 'acm_composite',
'#field_type' => 'acm_address',
'#default_value' => empty($addresses) ? $this->t('You have no saved addresses.') : '',
'#form_mode' => FALSE,
'#buttons' => [
'add' => [
'#type' => 'link',
'#title' => $this->t('Add address'),
'#url' => Url::fromRoute('acm_customer.view_page', [
'page' => $this->getPageId(),
'action' => 'add',
]),
'#attributes' => [
'class' => [
'form-item__add-button',
],
],
],
],
];
}
// Build the summary for each user address.
foreach ($addresses as $address) {
if ($address['default_billing'] && $address['default_shipping']) {
$address['heading'] = $this->t('Default Billing and Shipping Address');
}
elseif ($address['default_billing']) {
$address['heading'] = $this->t('Default Billing Address');
}
elseif ($address['default_shipping']) {
$address['heading'] = $this->t('Default Shipping Address');
}
else {
$address['heading'] = '';
}
// Build a link for each action.
$actions = [
'edit' => [
'label' => t('Edit'),
],
'delete' => [
'label' => t('Delete'),
'options' => [
'attributes' => [
'class' => ['bypass-js'],
],
],
],
];
$links = [];
foreach ($actions as $action => $config) {
$options = isset($config['options']) ? $config['options'] : [];
$label = isset($config['label']) ? $config['label'] : $action;
$link = Link::fromTextAndUrl($label, Url::fromRoute('acm_customer.view_page', [
'page' => $this->getPageId(),
'action' => $action,
'id' => $address['address_id'],
], $options));
$link = $link->toRenderable();
$links[$action] = [
'#type' => 'container',
'#attributes' => [
'class' => ["customer-address__{$action}-button"],
],
'link' => $link,
];
}
$build[] = [
'#theme' => 'user_address',
'#address' => $address,
'#links' => $links,
];
}
return $build;
} | [
"public",
"function",
"buildSummary",
"(",
"array",
"$",
"addresses",
"=",
"[",
"]",
",",
"$",
"show_add",
"=",
"TRUE",
")",
"{",
"$",
"build",
"=",
"[",
"]",
";",
"// Display an \"Add Address\" button.",
"if",
"(",
"$",
"show_add",
")",
"{",
"$",
"build",
"[",
"'add_address'",
"]",
"=",
"[",
"'#type'",
"=>",
"'acm_composite'",
",",
"'#field_type'",
"=>",
"'acm_address'",
",",
"'#default_value'",
"=>",
"empty",
"(",
"$",
"addresses",
")",
"?",
"$",
"this",
"->",
"t",
"(",
"'You have no saved addresses.'",
")",
":",
"''",
",",
"'#form_mode'",
"=>",
"FALSE",
",",
"'#buttons'",
"=>",
"[",
"'add'",
"=>",
"[",
"'#type'",
"=>",
"'link'",
",",
"'#title'",
"=>",
"$",
"this",
"->",
"t",
"(",
"'Add address'",
")",
",",
"'#url'",
"=>",
"Url",
"::",
"fromRoute",
"(",
"'acm_customer.view_page'",
",",
"[",
"'page'",
"=>",
"$",
"this",
"->",
"getPageId",
"(",
")",
",",
"'action'",
"=>",
"'add'",
",",
"]",
")",
",",
"'#attributes'",
"=>",
"[",
"'class'",
"=>",
"[",
"'form-item__add-button'",
",",
"]",
",",
"]",
",",
"]",
",",
"]",
",",
"]",
";",
"}",
"// Build the summary for each user address.",
"foreach",
"(",
"$",
"addresses",
"as",
"$",
"address",
")",
"{",
"if",
"(",
"$",
"address",
"[",
"'default_billing'",
"]",
"&&",
"$",
"address",
"[",
"'default_shipping'",
"]",
")",
"{",
"$",
"address",
"[",
"'heading'",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'Default Billing and Shipping Address'",
")",
";",
"}",
"elseif",
"(",
"$",
"address",
"[",
"'default_billing'",
"]",
")",
"{",
"$",
"address",
"[",
"'heading'",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'Default Billing Address'",
")",
";",
"}",
"elseif",
"(",
"$",
"address",
"[",
"'default_shipping'",
"]",
")",
"{",
"$",
"address",
"[",
"'heading'",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'Default Shipping Address'",
")",
";",
"}",
"else",
"{",
"$",
"address",
"[",
"'heading'",
"]",
"=",
"''",
";",
"}",
"// Build a link for each action.",
"$",
"actions",
"=",
"[",
"'edit'",
"=>",
"[",
"'label'",
"=>",
"t",
"(",
"'Edit'",
")",
",",
"]",
",",
"'delete'",
"=>",
"[",
"'label'",
"=>",
"t",
"(",
"'Delete'",
")",
",",
"'options'",
"=>",
"[",
"'attributes'",
"=>",
"[",
"'class'",
"=>",
"[",
"'bypass-js'",
"]",
",",
"]",
",",
"]",
",",
"]",
",",
"]",
";",
"$",
"links",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
"=>",
"$",
"config",
")",
"{",
"$",
"options",
"=",
"isset",
"(",
"$",
"config",
"[",
"'options'",
"]",
")",
"?",
"$",
"config",
"[",
"'options'",
"]",
":",
"[",
"]",
";",
"$",
"label",
"=",
"isset",
"(",
"$",
"config",
"[",
"'label'",
"]",
")",
"?",
"$",
"config",
"[",
"'label'",
"]",
":",
"$",
"action",
";",
"$",
"link",
"=",
"Link",
"::",
"fromTextAndUrl",
"(",
"$",
"label",
",",
"Url",
"::",
"fromRoute",
"(",
"'acm_customer.view_page'",
",",
"[",
"'page'",
"=>",
"$",
"this",
"->",
"getPageId",
"(",
")",
",",
"'action'",
"=>",
"$",
"action",
",",
"'id'",
"=>",
"$",
"address",
"[",
"'address_id'",
"]",
",",
"]",
",",
"$",
"options",
")",
")",
";",
"$",
"link",
"=",
"$",
"link",
"->",
"toRenderable",
"(",
")",
";",
"$",
"links",
"[",
"$",
"action",
"]",
"=",
"[",
"'#type'",
"=>",
"'container'",
",",
"'#attributes'",
"=>",
"[",
"'class'",
"=>",
"[",
"\"customer-address__{$action}-button\"",
"]",
",",
"]",
",",
"'link'",
"=>",
"$",
"link",
",",
"]",
";",
"}",
"$",
"build",
"[",
"]",
"=",
"[",
"'#theme'",
"=>",
"'user_address'",
",",
"'#address'",
"=>",
"$",
"address",
",",
"'#links'",
"=>",
"$",
"links",
",",
"]",
";",
"}",
"return",
"$",
"build",
";",
"}"
]
| Builds a summary of addresses.
@param array $addresses
The addresses to build a summary for.
@param bool $show_add
TRUE to show an add address button, FALSE to not show it.
@return array
An render array. | [
"Builds",
"a",
"summary",
"of",
"addresses",
"."
]
| e6c3a5fb9166d6c447725339ac4e0ae341c06d50 | https://github.com/acquia/commerce-manager/blob/e6c3a5fb9166d6c447725339ac4e0ae341c06d50/modules/acm_customer/src/Plugin/CustomerForm/Addresses.php#L40-L127 | train |
acquia/commerce-manager | modules/acm_customer/src/Plugin/CustomerForm/Addresses.php | Addresses.buildAddressFields | protected function buildAddressFields(array &$form, array &$complete_form, array $address = []) {
$form['address_wrapper'] = [
'#type' => 'container',
'#attributes' => [
'id' => ['address_wrapper'],
'class' => ['customer-address-form'],
],
];
$checkout_config = \Drupal::config('acm_checkout.settings');
$validate_saved_address = $checkout_config->get('validate_saved_address');
$address_review_text = $checkout_config->get('saved_address_review_text');
$address_failed_text = $checkout_config->get('saved_address_failed_text');
$include_address_id = empty($address) ? FALSE : TRUE;
$form['address_wrapper']['address'] = [
'#type' => 'acm_address',
'#default_value' => $address,
'#display_title' => TRUE,
'#display_firstname' => TRUE,
'#display_lastname' => TRUE,
'#display_billing' => TRUE,
'#display_shipping' => TRUE,
'#include_address_id' => $include_address_id,
'#validate_address' => $validate_saved_address,
'#address_review_text' => $address_review_text,
'#address_failed_text' => $address_failed_text,
];
$form['address_wrapper']['actions'] = [
'#type' => 'actions',
];
$form['address_wrapper']['actions']['cancel'] = [
'#type' => 'link',
'#title' => $this->t('Cancel'),
'#url' => Url::fromRoute('acm_customer.view_page', [
'page' => $this->getPageId(),
]),
];
$form['address_wrapper']['actions']['save'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
];
// Remove parent actions.
unset($complete_form['actions']);
} | php | protected function buildAddressFields(array &$form, array &$complete_form, array $address = []) {
$form['address_wrapper'] = [
'#type' => 'container',
'#attributes' => [
'id' => ['address_wrapper'],
'class' => ['customer-address-form'],
],
];
$checkout_config = \Drupal::config('acm_checkout.settings');
$validate_saved_address = $checkout_config->get('validate_saved_address');
$address_review_text = $checkout_config->get('saved_address_review_text');
$address_failed_text = $checkout_config->get('saved_address_failed_text');
$include_address_id = empty($address) ? FALSE : TRUE;
$form['address_wrapper']['address'] = [
'#type' => 'acm_address',
'#default_value' => $address,
'#display_title' => TRUE,
'#display_firstname' => TRUE,
'#display_lastname' => TRUE,
'#display_billing' => TRUE,
'#display_shipping' => TRUE,
'#include_address_id' => $include_address_id,
'#validate_address' => $validate_saved_address,
'#address_review_text' => $address_review_text,
'#address_failed_text' => $address_failed_text,
];
$form['address_wrapper']['actions'] = [
'#type' => 'actions',
];
$form['address_wrapper']['actions']['cancel'] = [
'#type' => 'link',
'#title' => $this->t('Cancel'),
'#url' => Url::fromRoute('acm_customer.view_page', [
'page' => $this->getPageId(),
]),
];
$form['address_wrapper']['actions']['save'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
];
// Remove parent actions.
unset($complete_form['actions']);
} | [
"protected",
"function",
"buildAddressFields",
"(",
"array",
"&",
"$",
"form",
",",
"array",
"&",
"$",
"complete_form",
",",
"array",
"$",
"address",
"=",
"[",
"]",
")",
"{",
"$",
"form",
"[",
"'address_wrapper'",
"]",
"=",
"[",
"'#type'",
"=>",
"'container'",
",",
"'#attributes'",
"=>",
"[",
"'id'",
"=>",
"[",
"'address_wrapper'",
"]",
",",
"'class'",
"=>",
"[",
"'customer-address-form'",
"]",
",",
"]",
",",
"]",
";",
"$",
"checkout_config",
"=",
"\\",
"Drupal",
"::",
"config",
"(",
"'acm_checkout.settings'",
")",
";",
"$",
"validate_saved_address",
"=",
"$",
"checkout_config",
"->",
"get",
"(",
"'validate_saved_address'",
")",
";",
"$",
"address_review_text",
"=",
"$",
"checkout_config",
"->",
"get",
"(",
"'saved_address_review_text'",
")",
";",
"$",
"address_failed_text",
"=",
"$",
"checkout_config",
"->",
"get",
"(",
"'saved_address_failed_text'",
")",
";",
"$",
"include_address_id",
"=",
"empty",
"(",
"$",
"address",
")",
"?",
"FALSE",
":",
"TRUE",
";",
"$",
"form",
"[",
"'address_wrapper'",
"]",
"[",
"'address'",
"]",
"=",
"[",
"'#type'",
"=>",
"'acm_address'",
",",
"'#default_value'",
"=>",
"$",
"address",
",",
"'#display_title'",
"=>",
"TRUE",
",",
"'#display_firstname'",
"=>",
"TRUE",
",",
"'#display_lastname'",
"=>",
"TRUE",
",",
"'#display_billing'",
"=>",
"TRUE",
",",
"'#display_shipping'",
"=>",
"TRUE",
",",
"'#include_address_id'",
"=>",
"$",
"include_address_id",
",",
"'#validate_address'",
"=>",
"$",
"validate_saved_address",
",",
"'#address_review_text'",
"=>",
"$",
"address_review_text",
",",
"'#address_failed_text'",
"=>",
"$",
"address_failed_text",
",",
"]",
";",
"$",
"form",
"[",
"'address_wrapper'",
"]",
"[",
"'actions'",
"]",
"=",
"[",
"'#type'",
"=>",
"'actions'",
",",
"]",
";",
"$",
"form",
"[",
"'address_wrapper'",
"]",
"[",
"'actions'",
"]",
"[",
"'cancel'",
"]",
"=",
"[",
"'#type'",
"=>",
"'link'",
",",
"'#title'",
"=>",
"$",
"this",
"->",
"t",
"(",
"'Cancel'",
")",
",",
"'#url'",
"=>",
"Url",
"::",
"fromRoute",
"(",
"'acm_customer.view_page'",
",",
"[",
"'page'",
"=>",
"$",
"this",
"->",
"getPageId",
"(",
")",
",",
"]",
")",
",",
"]",
";",
"$",
"form",
"[",
"'address_wrapper'",
"]",
"[",
"'actions'",
"]",
"[",
"'save'",
"]",
"=",
"[",
"'#type'",
"=>",
"'submit'",
",",
"'#value'",
"=>",
"$",
"this",
"->",
"t",
"(",
"'Save'",
")",
",",
"]",
";",
"// Remove parent actions.",
"unset",
"(",
"$",
"complete_form",
"[",
"'actions'",
"]",
")",
";",
"}"
]
| Builds the address fields.
@param array $form
The form.
@param array $complete_form
The complete form structure.
@param array $address
The default address values. | [
"Builds",
"the",
"address",
"fields",
"."
]
| e6c3a5fb9166d6c447725339ac4e0ae341c06d50 | https://github.com/acquia/commerce-manager/blob/e6c3a5fb9166d6c447725339ac4e0ae341c06d50/modules/acm_customer/src/Plugin/CustomerForm/Addresses.php#L232-L280 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.run | public function run(RequestInterface $request, ResponseInterface $response)
{
unset($request);
try {
$this->start();
} catch (Exception $e) {
$this->climate()->error($e->getMessage());
}
return $response;
} | php | public function run(RequestInterface $request, ResponseInterface $response)
{
unset($request);
try {
$this->start();
} catch (Exception $e) {
$this->climate()->error($e->getMessage());
}
return $response;
} | [
"public",
"function",
"run",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"unset",
"(",
"$",
"request",
")",
";",
"try",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
]
| Run the script.
@param RequestInterface $request A PSR-7 compatible Request instance.
@param ResponseInterface $response A PSR-7 compatible Response instance.
@return ResponseInterface | [
"Run",
"the",
"script",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L104-L115 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.prepareProperties | protected function prepareProperties($oldKey, $newKey, &$oldProp = null, &$newProp = null)
{
$model = $this->targetModel();
$source = $model->source();
/**
* Either:
* - TRUE if the $oldKey exists in the model's datasource.
* - FALSE if the $oldKey does NOT exist in the model's datasource.
* - NULL if the $oldKey does NOT exist in the model's datasource and is different from $newKey.
*
* @var boolean|null
*/
$oldKeyExists = null;
if ($this->isPrimaryKeyDifferent()) {
$newProp = $model->property($newKey)->setAllowNull(false);
$oldProp = clone $newProp;
$oldProp->setIdent($oldKey);
} else {
$oldKeyExists = false;
$oldProp = $model->property($oldKey)->setAllowNull(false);
$newProp = clone $oldProp;
$newProp->setIdent($newKey);
}
$sql = strtr(
'SHOW COLUMNS FROM `%table`',
[
'%table' => $source->table(),
]
);
$cols = $source->db()->query($sql, PDO::FETCH_ASSOC);
foreach ($cols as $col) {
if ($col['Field'] !== $oldKey) {
continue;
}
$oldKeyExists = true;
if (!$this->quiet()) {
$this->climate()->comment(
sprintf('Evaluating the current `%s` column.', $oldKey)
);
}
if (preg_match('~\bINT\(?(?:$|\b)~i', $col['Type'])) {
$oldProp->setMode(IdProperty::MODE_AUTO_INCREMENT);
} elseif (preg_match('~(?:^|\b)(?:VAR)?CHAR\(13\)(?:$|\b)~i', $col['Type'])) {
$oldProp->setMode(IdProperty::MODE_UNIQID);
} elseif (preg_match('~(?:^|\b)(?:VAR)?CHAR\(36\)(?:$|\b)~i', $col['Type'])) {
$oldProp->setMode(IdProperty::MODE_UUID);
} else {
$oldProp->setMode(IdProperty::MODE_CUSTOM);
}
break;
}
if (!$oldKeyExists) {
throw new RuntimeException(
sprintf(
'The model [%1$s] does not have the target field [%2$s]',
get_class($model),
$oldKey
)
);
}
return [
'old' => $oldProp,
'new' => $newProp,
];
} | php | protected function prepareProperties($oldKey, $newKey, &$oldProp = null, &$newProp = null)
{
$model = $this->targetModel();
$source = $model->source();
/**
* Either:
* - TRUE if the $oldKey exists in the model's datasource.
* - FALSE if the $oldKey does NOT exist in the model's datasource.
* - NULL if the $oldKey does NOT exist in the model's datasource and is different from $newKey.
*
* @var boolean|null
*/
$oldKeyExists = null;
if ($this->isPrimaryKeyDifferent()) {
$newProp = $model->property($newKey)->setAllowNull(false);
$oldProp = clone $newProp;
$oldProp->setIdent($oldKey);
} else {
$oldKeyExists = false;
$oldProp = $model->property($oldKey)->setAllowNull(false);
$newProp = clone $oldProp;
$newProp->setIdent($newKey);
}
$sql = strtr(
'SHOW COLUMNS FROM `%table`',
[
'%table' => $source->table(),
]
);
$cols = $source->db()->query($sql, PDO::FETCH_ASSOC);
foreach ($cols as $col) {
if ($col['Field'] !== $oldKey) {
continue;
}
$oldKeyExists = true;
if (!$this->quiet()) {
$this->climate()->comment(
sprintf('Evaluating the current `%s` column.', $oldKey)
);
}
if (preg_match('~\bINT\(?(?:$|\b)~i', $col['Type'])) {
$oldProp->setMode(IdProperty::MODE_AUTO_INCREMENT);
} elseif (preg_match('~(?:^|\b)(?:VAR)?CHAR\(13\)(?:$|\b)~i', $col['Type'])) {
$oldProp->setMode(IdProperty::MODE_UNIQID);
} elseif (preg_match('~(?:^|\b)(?:VAR)?CHAR\(36\)(?:$|\b)~i', $col['Type'])) {
$oldProp->setMode(IdProperty::MODE_UUID);
} else {
$oldProp->setMode(IdProperty::MODE_CUSTOM);
}
break;
}
if (!$oldKeyExists) {
throw new RuntimeException(
sprintf(
'The model [%1$s] does not have the target field [%2$s]',
get_class($model),
$oldKey
)
);
}
return [
'old' => $oldProp,
'new' => $newProp,
];
} | [
"protected",
"function",
"prepareProperties",
"(",
"$",
"oldKey",
",",
"$",
"newKey",
",",
"&",
"$",
"oldProp",
"=",
"null",
",",
"&",
"$",
"newProp",
"=",
"null",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"source",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"/**\n * Either:\n * - TRUE if the $oldKey exists in the model's datasource.\n * - FALSE if the $oldKey does NOT exist in the model's datasource.\n * - NULL if the $oldKey does NOT exist in the model's datasource and is different from $newKey.\n *\n * @var boolean|null\n */",
"$",
"oldKeyExists",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"isPrimaryKeyDifferent",
"(",
")",
")",
"{",
"$",
"newProp",
"=",
"$",
"model",
"->",
"property",
"(",
"$",
"newKey",
")",
"->",
"setAllowNull",
"(",
"false",
")",
";",
"$",
"oldProp",
"=",
"clone",
"$",
"newProp",
";",
"$",
"oldProp",
"->",
"setIdent",
"(",
"$",
"oldKey",
")",
";",
"}",
"else",
"{",
"$",
"oldKeyExists",
"=",
"false",
";",
"$",
"oldProp",
"=",
"$",
"model",
"->",
"property",
"(",
"$",
"oldKey",
")",
"->",
"setAllowNull",
"(",
"false",
")",
";",
"$",
"newProp",
"=",
"clone",
"$",
"oldProp",
";",
"$",
"newProp",
"->",
"setIdent",
"(",
"$",
"newKey",
")",
";",
"}",
"$",
"sql",
"=",
"strtr",
"(",
"'SHOW COLUMNS FROM `%table`'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"]",
")",
";",
"$",
"cols",
"=",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
",",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"foreach",
"(",
"$",
"cols",
"as",
"$",
"col",
")",
"{",
"if",
"(",
"$",
"col",
"[",
"'Field'",
"]",
"!==",
"$",
"oldKey",
")",
"{",
"continue",
";",
"}",
"$",
"oldKeyExists",
"=",
"true",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"quiet",
"(",
")",
")",
"{",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"comment",
"(",
"sprintf",
"(",
"'Evaluating the current `%s` column.'",
",",
"$",
"oldKey",
")",
")",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'~\\bINT\\(?(?:$|\\b)~i'",
",",
"$",
"col",
"[",
"'Type'",
"]",
")",
")",
"{",
"$",
"oldProp",
"->",
"setMode",
"(",
"IdProperty",
"::",
"MODE_AUTO_INCREMENT",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'~(?:^|\\b)(?:VAR)?CHAR\\(13\\)(?:$|\\b)~i'",
",",
"$",
"col",
"[",
"'Type'",
"]",
")",
")",
"{",
"$",
"oldProp",
"->",
"setMode",
"(",
"IdProperty",
"::",
"MODE_UNIQID",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'~(?:^|\\b)(?:VAR)?CHAR\\(36\\)(?:$|\\b)~i'",
",",
"$",
"col",
"[",
"'Type'",
"]",
")",
")",
"{",
"$",
"oldProp",
"->",
"setMode",
"(",
"IdProperty",
"::",
"MODE_UUID",
")",
";",
"}",
"else",
"{",
"$",
"oldProp",
"->",
"setMode",
"(",
"IdProperty",
"::",
"MODE_CUSTOM",
")",
";",
"}",
"break",
";",
"}",
"if",
"(",
"!",
"$",
"oldKeyExists",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'The model [%1$s] does not have the target field [%2$s]'",
",",
"get_class",
"(",
"$",
"model",
")",
",",
"$",
"oldKey",
")",
")",
";",
"}",
"return",
"[",
"'old'",
"=>",
"$",
"oldProp",
",",
"'new'",
"=>",
"$",
"newProp",
",",
"]",
";",
"}"
]
| Retrieve the old and new ID properties.
@param string $oldKey The previous key.
@param string $newKey The new key.
@param IdProperty|null $oldProp If provided, then it is filled with an instance of IdProperty.
@param IdProperty|null $newProp If provided, then it is filled with an instance of IdProperty.
@throws RuntimeException If the $oldKey does not exist.
@return IdProperty[] | [
"Retrieve",
"the",
"old",
"and",
"new",
"ID",
"properties",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L244-L318 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.labelFromMode | protected function labelFromMode($mode)
{
if ($mode instanceof IdProperty) {
$mode = $mode->mode();
}
switch ($mode) {
case IdProperty::MODE_AUTO_INCREMENT:
return 'auto-increment';
case IdProperty::MODE_UNIQID:
return 'uniqid()';
case IdProperty::MODE_UUID:
return 'RFC-4122 UUID';
case IdProperty::MODE_CUSTOM:
return 'custom';
}
throw new UnexpectedValueException(sprintf(
'The ID mode was not recognized: %s',
is_object($mode) ? get_class($mode) : gettype($mode)
));
} | php | protected function labelFromMode($mode)
{
if ($mode instanceof IdProperty) {
$mode = $mode->mode();
}
switch ($mode) {
case IdProperty::MODE_AUTO_INCREMENT:
return 'auto-increment';
case IdProperty::MODE_UNIQID:
return 'uniqid()';
case IdProperty::MODE_UUID:
return 'RFC-4122 UUID';
case IdProperty::MODE_CUSTOM:
return 'custom';
}
throw new UnexpectedValueException(sprintf(
'The ID mode was not recognized: %s',
is_object($mode) ? get_class($mode) : gettype($mode)
));
} | [
"protected",
"function",
"labelFromMode",
"(",
"$",
"mode",
")",
"{",
"if",
"(",
"$",
"mode",
"instanceof",
"IdProperty",
")",
"{",
"$",
"mode",
"=",
"$",
"mode",
"->",
"mode",
"(",
")",
";",
"}",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"IdProperty",
"::",
"MODE_AUTO_INCREMENT",
":",
"return",
"'auto-increment'",
";",
"case",
"IdProperty",
"::",
"MODE_UNIQID",
":",
"return",
"'uniqid()'",
";",
"case",
"IdProperty",
"::",
"MODE_UUID",
":",
"return",
"'RFC-4122 UUID'",
";",
"case",
"IdProperty",
"::",
"MODE_CUSTOM",
":",
"return",
"'custom'",
";",
"}",
"throw",
"new",
"UnexpectedValueException",
"(",
"sprintf",
"(",
"'The ID mode was not recognized: %s'",
",",
"is_object",
"(",
"$",
"mode",
")",
"?",
"get_class",
"(",
"$",
"mode",
")",
":",
"gettype",
"(",
"$",
"mode",
")",
")",
")",
";",
"}"
]
| Retrieve a label for the ID's mode.
@param string|IdProperty $mode The mode or property to resolve.
@throws UnexpectedValueException If the ID mode is invalid.
@return string | [
"Retrieve",
"a",
"label",
"for",
"the",
"ID",
"s",
"mode",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L327-L351 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.labelFromProp | protected function labelFromProp(IdProperty $prop)
{
$mode = $prop->mode();
switch ($mode) {
case IdProperty::MODE_AUTO_INCREMENT:
return 'auto-increment ID';
case IdProperty::MODE_CUSTOM:
return 'custom ID';
default:
$label = $this->labelFromMode($mode);
if ($label) {
return sprintf('auto-generated ID (%s)', $label);
} else {
return 'auto-generated ID';
}
}
return null;
} | php | protected function labelFromProp(IdProperty $prop)
{
$mode = $prop->mode();
switch ($mode) {
case IdProperty::MODE_AUTO_INCREMENT:
return 'auto-increment ID';
case IdProperty::MODE_CUSTOM:
return 'custom ID';
default:
$label = $this->labelFromMode($mode);
if ($label) {
return sprintf('auto-generated ID (%s)', $label);
} else {
return 'auto-generated ID';
}
}
return null;
} | [
"protected",
"function",
"labelFromProp",
"(",
"IdProperty",
"$",
"prop",
")",
"{",
"$",
"mode",
"=",
"$",
"prop",
"->",
"mode",
"(",
")",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"IdProperty",
"::",
"MODE_AUTO_INCREMENT",
":",
"return",
"'auto-increment ID'",
";",
"case",
"IdProperty",
"::",
"MODE_CUSTOM",
":",
"return",
"'custom ID'",
";",
"default",
":",
"$",
"label",
"=",
"$",
"this",
"->",
"labelFromMode",
"(",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"label",
")",
"{",
"return",
"sprintf",
"(",
"'auto-generated ID (%s)'",
",",
"$",
"label",
")",
";",
"}",
"else",
"{",
"return",
"'auto-generated ID'",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Retrieve a label for the property.
@param IdProperty $prop The new ID property to analyse.
@return string|null | [
"Retrieve",
"a",
"label",
"for",
"the",
"property",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L359-L379 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.describeConversion | protected function describeConversion(IdProperty $newProp, IdProperty $oldProp = null)
{
if ($oldProp) {
$new = $this->labelFromProp($newProp);
$old = $this->labelFromProp($oldProp);
$desc = sprintf('Converting to %s from %s.', $new, $old);
} else {
$new = $this->labelFromProp($newProp);
$desc = sprintf('Converting to %s.', $new);
}
$this->climate()->comment($desc);
return $this;
} | php | protected function describeConversion(IdProperty $newProp, IdProperty $oldProp = null)
{
if ($oldProp) {
$new = $this->labelFromProp($newProp);
$old = $this->labelFromProp($oldProp);
$desc = sprintf('Converting to %s from %s.', $new, $old);
} else {
$new = $this->labelFromProp($newProp);
$desc = sprintf('Converting to %s.', $new);
}
$this->climate()->comment($desc);
return $this;
} | [
"protected",
"function",
"describeConversion",
"(",
"IdProperty",
"$",
"newProp",
",",
"IdProperty",
"$",
"oldProp",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"oldProp",
")",
"{",
"$",
"new",
"=",
"$",
"this",
"->",
"labelFromProp",
"(",
"$",
"newProp",
")",
";",
"$",
"old",
"=",
"$",
"this",
"->",
"labelFromProp",
"(",
"$",
"oldProp",
")",
";",
"$",
"desc",
"=",
"sprintf",
"(",
"'Converting to %s from %s.'",
",",
"$",
"new",
",",
"$",
"old",
")",
";",
"}",
"else",
"{",
"$",
"new",
"=",
"$",
"this",
"->",
"labelFromProp",
"(",
"$",
"newProp",
")",
";",
"$",
"desc",
"=",
"sprintf",
"(",
"'Converting to %s.'",
",",
"$",
"new",
")",
";",
"}",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"comment",
"(",
"$",
"desc",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Describe what we are converting to.
@param IdProperty $newProp The new ID property to analyse.
@param IdProperty $oldProp The previous ID property to analyse.
@return self | [
"Describe",
"what",
"we",
"are",
"converting",
"to",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L388-L402 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.fetchTargetRows | private function fetchTargetRows()
{
$model = $this->targetModel();
$source = $model->source();
$sql = strtr(
'SELECT %key FROM `%table`',
[
'%table' => $source->table(),
'%key' => $this->oldPrimaryKey(),
]
);
return $source->db()->query($sql, PDO::FETCH_ASSOC);
} | php | private function fetchTargetRows()
{
$model = $this->targetModel();
$source = $model->source();
$sql = strtr(
'SELECT %key FROM `%table`',
[
'%table' => $source->table(),
'%key' => $this->oldPrimaryKey(),
]
);
return $source->db()->query($sql, PDO::FETCH_ASSOC);
} | [
"private",
"function",
"fetchTargetRows",
"(",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"source",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"$",
"sql",
"=",
"strtr",
"(",
"'SELECT %key FROM `%table`'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%key'",
"=>",
"$",
"this",
"->",
"oldPrimaryKey",
"(",
")",
",",
"]",
")",
";",
"return",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
",",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"}"
]
| Retrieve the target model's rows.
@return array|Traversable | [
"Retrieve",
"the",
"target",
"model",
"s",
"rows",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L422-L436 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.oldPrimaryKey | private function oldPrimaryKey()
{
if ($this->oldPrimaryKey === null) {
if ($this->isPrimaryKeyDifferent()) {
$oldKey = $this->climate()->arguments->get('old_key');
} else {
$oldKey = $this->targetModel()->key();
}
$this->oldPrimaryKey = $oldKey;
}
return $this->oldPrimaryKey;
} | php | private function oldPrimaryKey()
{
if ($this->oldPrimaryKey === null) {
if ($this->isPrimaryKeyDifferent()) {
$oldKey = $this->climate()->arguments->get('old_key');
} else {
$oldKey = $this->targetModel()->key();
}
$this->oldPrimaryKey = $oldKey;
}
return $this->oldPrimaryKey;
} | [
"private",
"function",
"oldPrimaryKey",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"oldPrimaryKey",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isPrimaryKeyDifferent",
"(",
")",
")",
"{",
"$",
"oldKey",
"=",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"arguments",
"->",
"get",
"(",
"'old_key'",
")",
";",
"}",
"else",
"{",
"$",
"oldKey",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
"->",
"key",
"(",
")",
";",
"}",
"$",
"this",
"->",
"oldPrimaryKey",
"=",
"$",
"oldKey",
";",
"}",
"return",
"$",
"this",
"->",
"oldPrimaryKey",
";",
"}"
]
| Retrieve the target model's old primary key name.
@return string|null | [
"Retrieve",
"the",
"target",
"model",
"s",
"old",
"primary",
"key",
"name",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L453-L466 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.describeCount | private function describeCount($rows = null)
{
if ($rows === null) {
$rows = $this->fetchTargetRows();
}
if (!is_array($rows) && !($rows instanceof Traversable)) {
throw new InvalidArgumentException(
sprintf(
'The rows must be iterable; received %s',
is_object($rows) ? get_class($rows) : gettype($rows)
)
);
}
$cli = $this->climate();
$model = $this->targetModel();
if (is_array($rows) || $rows instanceof Countable) {
$count = count($rows);
} elseif ($rows instanceof PDOStatement) {
$count = $rows->rowCount();
} else {
$count = iterator_count($rows);
}
if ($count === 0) {
$cli->comment('The object table is empty.');
$cli->comment(
sprintf('Only changing `%s` column.', $model->key())
);
return false;
} elseif ($count === 1) {
if (!$this->quiet()) {
$cli->comment('The object table has 1 row.');
}
} else {
if (!$this->quiet()) {
$cli->comment(
sprintf('The object table has %s rows.', $count)
);
}
}
return true;
} | php | private function describeCount($rows = null)
{
if ($rows === null) {
$rows = $this->fetchTargetRows();
}
if (!is_array($rows) && !($rows instanceof Traversable)) {
throw new InvalidArgumentException(
sprintf(
'The rows must be iterable; received %s',
is_object($rows) ? get_class($rows) : gettype($rows)
)
);
}
$cli = $this->climate();
$model = $this->targetModel();
if (is_array($rows) || $rows instanceof Countable) {
$count = count($rows);
} elseif ($rows instanceof PDOStatement) {
$count = $rows->rowCount();
} else {
$count = iterator_count($rows);
}
if ($count === 0) {
$cli->comment('The object table is empty.');
$cli->comment(
sprintf('Only changing `%s` column.', $model->key())
);
return false;
} elseif ($count === 1) {
if (!$this->quiet()) {
$cli->comment('The object table has 1 row.');
}
} else {
if (!$this->quiet()) {
$cli->comment(
sprintf('The object table has %s rows.', $count)
);
}
}
return true;
} | [
"private",
"function",
"describeCount",
"(",
"$",
"rows",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"rows",
"===",
"null",
")",
"{",
"$",
"rows",
"=",
"$",
"this",
"->",
"fetchTargetRows",
"(",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"rows",
")",
"&&",
"!",
"(",
"$",
"rows",
"instanceof",
"Traversable",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The rows must be iterable; received %s'",
",",
"is_object",
"(",
"$",
"rows",
")",
"?",
"get_class",
"(",
"$",
"rows",
")",
":",
"gettype",
"(",
"$",
"rows",
")",
")",
")",
";",
"}",
"$",
"cli",
"=",
"$",
"this",
"->",
"climate",
"(",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"rows",
")",
"||",
"$",
"rows",
"instanceof",
"Countable",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"rows",
")",
";",
"}",
"elseif",
"(",
"$",
"rows",
"instanceof",
"PDOStatement",
")",
"{",
"$",
"count",
"=",
"$",
"rows",
"->",
"rowCount",
"(",
")",
";",
"}",
"else",
"{",
"$",
"count",
"=",
"iterator_count",
"(",
"$",
"rows",
")",
";",
"}",
"if",
"(",
"$",
"count",
"===",
"0",
")",
"{",
"$",
"cli",
"->",
"comment",
"(",
"'The object table is empty.'",
")",
";",
"$",
"cli",
"->",
"comment",
"(",
"sprintf",
"(",
"'Only changing `%s` column.'",
",",
"$",
"model",
"->",
"key",
"(",
")",
")",
")",
";",
"return",
"false",
";",
"}",
"elseif",
"(",
"$",
"count",
"===",
"1",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"quiet",
"(",
")",
")",
"{",
"$",
"cli",
"->",
"comment",
"(",
"'The object table has 1 row.'",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"quiet",
"(",
")",
")",
"{",
"$",
"cli",
"->",
"comment",
"(",
"sprintf",
"(",
"'The object table has %s rows.'",
",",
"$",
"count",
")",
")",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| Describe the given count.
@param array|Traversable $rows The target model's existing rows.
@throws InvalidArgumentException If the given argument is not iterable.
@return boolean | [
"Describe",
"the",
"given",
"count",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L497-L543 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.insertNewField | private function insertNewField(PropertyField $field, IdProperty $prop)
{
unset($prop);
$model = $this->targetModel();
$source = $model->source();
$extra = $field->extra();
$field->setExtra('');
// Don't alter table if column name already exists.
$sql = strtr(
'SHOW COLUMNS FROM `%table` LIKE "%key"',
[
'%table' => $source->table(),
'%key' => $field->ident(),
]
);
$res = $source->db()->query($sql);
if ($res->fetch(1)) {
// Column name already exists.
return $this;
}
$sql = strtr(
'ALTER TABLE `%table` ADD COLUMN %field FIRST',
[
'%table' => $source->table(),
'%field' => $field->sql(),
]
);
$field->setExtra($extra);
$source->db()->query($sql);
return $this;
} | php | private function insertNewField(PropertyField $field, IdProperty $prop)
{
unset($prop);
$model = $this->targetModel();
$source = $model->source();
$extra = $field->extra();
$field->setExtra('');
// Don't alter table if column name already exists.
$sql = strtr(
'SHOW COLUMNS FROM `%table` LIKE "%key"',
[
'%table' => $source->table(),
'%key' => $field->ident(),
]
);
$res = $source->db()->query($sql);
if ($res->fetch(1)) {
// Column name already exists.
return $this;
}
$sql = strtr(
'ALTER TABLE `%table` ADD COLUMN %field FIRST',
[
'%table' => $source->table(),
'%field' => $field->sql(),
]
);
$field->setExtra($extra);
$source->db()->query($sql);
return $this;
} | [
"private",
"function",
"insertNewField",
"(",
"PropertyField",
"$",
"field",
",",
"IdProperty",
"$",
"prop",
")",
"{",
"unset",
"(",
"$",
"prop",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"source",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"$",
"extra",
"=",
"$",
"field",
"->",
"extra",
"(",
")",
";",
"$",
"field",
"->",
"setExtra",
"(",
"''",
")",
";",
"// Don't alter table if column name already exists.",
"$",
"sql",
"=",
"strtr",
"(",
"'SHOW COLUMNS FROM `%table` LIKE \"%key\"'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%key'",
"=>",
"$",
"field",
"->",
"ident",
"(",
")",
",",
"]",
")",
";",
"$",
"res",
"=",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"res",
"->",
"fetch",
"(",
"1",
")",
")",
"{",
"// Column name already exists.",
"return",
"$",
"this",
";",
"}",
"$",
"sql",
"=",
"strtr",
"(",
"'ALTER TABLE `%table` ADD COLUMN %field FIRST'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%field'",
"=>",
"$",
"field",
"->",
"sql",
"(",
")",
",",
"]",
")",
";",
"$",
"field",
"->",
"setExtra",
"(",
"$",
"extra",
")",
";",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Insert the given field.
@param PropertyField $field The new ID field.
@param IdProperty $prop The new ID property.
@return self | [
"Insert",
"the",
"given",
"field",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L552-L590 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.dropPrimaryKey | private function dropPrimaryKey(PropertyField $field, IdProperty $prop)
{
$keepId = $this->climate()->arguments->defined('keep_id');
$model = $this->targetModel();
$source = $model->source();
$dbh = $source->db();
$key = $prop->ident();
if ($keepId) {
$field->setIdent(sprintf('%1$s_%2$s', $key, date('YmdHis')));
$sql = strtr(
'ALTER TABLE `%table` CHANGE COLUMN `%key` %field, DROP PRIMARY KEY',
[
'%table' => $source->table(),
'%field' => $field->sql(),
'%key' => $key,
]
);
} else {
$sql = strtr(
'ALTER TABLE `%table` MODIFY COLUMN %field, DROP PRIMARY KEY',
[
'%table' => $source->table(),
'%field' => $field->sql(),
]
);
}
$dbh->query($sql);
return $this;
} | php | private function dropPrimaryKey(PropertyField $field, IdProperty $prop)
{
$keepId = $this->climate()->arguments->defined('keep_id');
$model = $this->targetModel();
$source = $model->source();
$dbh = $source->db();
$key = $prop->ident();
if ($keepId) {
$field->setIdent(sprintf('%1$s_%2$s', $key, date('YmdHis')));
$sql = strtr(
'ALTER TABLE `%table` CHANGE COLUMN `%key` %field, DROP PRIMARY KEY',
[
'%table' => $source->table(),
'%field' => $field->sql(),
'%key' => $key,
]
);
} else {
$sql = strtr(
'ALTER TABLE `%table` MODIFY COLUMN %field, DROP PRIMARY KEY',
[
'%table' => $source->table(),
'%field' => $field->sql(),
]
);
}
$dbh->query($sql);
return $this;
} | [
"private",
"function",
"dropPrimaryKey",
"(",
"PropertyField",
"$",
"field",
",",
"IdProperty",
"$",
"prop",
")",
"{",
"$",
"keepId",
"=",
"$",
"this",
"->",
"climate",
"(",
")",
"->",
"arguments",
"->",
"defined",
"(",
"'keep_id'",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"source",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"$",
"dbh",
"=",
"$",
"source",
"->",
"db",
"(",
")",
";",
"$",
"key",
"=",
"$",
"prop",
"->",
"ident",
"(",
")",
";",
"if",
"(",
"$",
"keepId",
")",
"{",
"$",
"field",
"->",
"setIdent",
"(",
"sprintf",
"(",
"'%1$s_%2$s'",
",",
"$",
"key",
",",
"date",
"(",
"'YmdHis'",
")",
")",
")",
";",
"$",
"sql",
"=",
"strtr",
"(",
"'ALTER TABLE `%table` CHANGE COLUMN `%key` %field, DROP PRIMARY KEY'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%field'",
"=>",
"$",
"field",
"->",
"sql",
"(",
")",
",",
"'%key'",
"=>",
"$",
"key",
",",
"]",
")",
";",
"}",
"else",
"{",
"$",
"sql",
"=",
"strtr",
"(",
"'ALTER TABLE `%table` MODIFY COLUMN %field, DROP PRIMARY KEY'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%field'",
"=>",
"$",
"field",
"->",
"sql",
"(",
")",
",",
"]",
")",
";",
"}",
"$",
"dbh",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Drop the primary key from the given field.
@param PropertyField $field The previous ID field.
@param IdProperty $prop The previous ID property.
@return self | [
"Drop",
"the",
"primary",
"key",
"from",
"the",
"given",
"field",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L599-L630 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.applyPrimaryKey | private function applyPrimaryKey(PropertyField $field, IdProperty $prop)
{
unset($prop);
$model = $this->targetModel();
$source = $model->source();
$sql = strtr(
'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)',
[
'%table' => $source->table(),
'%key' => $field->ident(),
]
);
$source->db()->query($sql);
return $this;
} | php | private function applyPrimaryKey(PropertyField $field, IdProperty $prop)
{
unset($prop);
$model = $this->targetModel();
$source = $model->source();
$sql = strtr(
'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)',
[
'%table' => $source->table(),
'%key' => $field->ident(),
]
);
$source->db()->query($sql);
return $this;
} | [
"private",
"function",
"applyPrimaryKey",
"(",
"PropertyField",
"$",
"field",
",",
"IdProperty",
"$",
"prop",
")",
"{",
"unset",
"(",
"$",
"prop",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"source",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"$",
"sql",
"=",
"strtr",
"(",
"'ALTER TABLE `%table` ADD PRIMARY KEY (`%key`)'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%key'",
"=>",
"$",
"field",
"->",
"ident",
"(",
")",
",",
"]",
")",
";",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the given field as the primary key.
@param PropertyField $field The new ID field.
@param IdProperty $prop The new ID property.
@return self | [
"Set",
"the",
"given",
"field",
"as",
"the",
"primary",
"key",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L639-L656 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.renameColumn | private function renameColumn(PropertyField $field, $from, $to)
{
$model = $this->targetModel();
$source = $model->source();
$field->setIdent($to);
$sql = strtr(
'ALTER TABLE `%table` CHANGE COLUMN `%from` %field',
[
'%table' => $source->table(),
'%field' => $field->sql(),
'%from' => $from,
'%to' => $to,
]
);
$source->db()->query($sql);
return $this;
} | php | private function renameColumn(PropertyField $field, $from, $to)
{
$model = $this->targetModel();
$source = $model->source();
$field->setIdent($to);
$sql = strtr(
'ALTER TABLE `%table` CHANGE COLUMN `%from` %field',
[
'%table' => $source->table(),
'%field' => $field->sql(),
'%from' => $from,
'%to' => $to,
]
);
$source->db()->query($sql);
return $this;
} | [
"private",
"function",
"renameColumn",
"(",
"PropertyField",
"$",
"field",
",",
"$",
"from",
",",
"$",
"to",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"source",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"$",
"field",
"->",
"setIdent",
"(",
"$",
"to",
")",
";",
"$",
"sql",
"=",
"strtr",
"(",
"'ALTER TABLE `%table` CHANGE COLUMN `%from` %field'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%field'",
"=>",
"$",
"field",
"->",
"sql",
"(",
")",
",",
"'%from'",
"=>",
"$",
"from",
",",
"'%to'",
"=>",
"$",
"to",
",",
"]",
")",
";",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Rename the given field.
@param PropertyField $field The field to rename.
@param string $from The original field key.
@param string $to The new field key.
@return self | [
"Rename",
"the",
"given",
"field",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L666-L684 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.removeColumn | private function removeColumn(PropertyField $field)
{
$source = $this->targetModel()->source();
$sql = strtr(
'ALTER TABLE `%table` DROP COLUMN `%key`',
[
'%table' => $source->table(),
'%key' => $field->ident(),
]
);
$source->db()->query($sql);
return $this;
} | php | private function removeColumn(PropertyField $field)
{
$source = $this->targetModel()->source();
$sql = strtr(
'ALTER TABLE `%table` DROP COLUMN `%key`',
[
'%table' => $source->table(),
'%key' => $field->ident(),
]
);
$source->db()->query($sql);
return $this;
} | [
"private",
"function",
"removeColumn",
"(",
"PropertyField",
"$",
"field",
")",
"{",
"$",
"source",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
"->",
"source",
"(",
")",
";",
"$",
"sql",
"=",
"strtr",
"(",
"'ALTER TABLE `%table` DROP COLUMN `%key`'",
",",
"[",
"'%table'",
"=>",
"$",
"source",
"->",
"table",
"(",
")",
",",
"'%key'",
"=>",
"$",
"field",
"->",
"ident",
"(",
")",
",",
"]",
")",
";",
"$",
"source",
"->",
"db",
"(",
")",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Remove the given field.
@param PropertyField $field The field to remove.
@return self | [
"Remove",
"the",
"given",
"field",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L692-L706 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.syncRelatedFields | protected function syncRelatedFields(
IdProperty $newProp,
PropertyField $newField,
IdProperty $oldProp,
PropertyField $oldField
) {
unset($newProp, $oldProp, $oldField);
$cli = $this->climate();
if (!$this->quiet()) {
$cli->br();
$cli->comment('Syncing new IDs to related tables.');
}
$related = $cli->arguments->get('related_model');
if (!$related) {
$cli->br();
$input = $cli->confirm('Are there any model(s) related to the target?');
if (!$input->confirmed()) {
return $this;
}
$related = $this->argOrInput('related_model');
}
$this->setRelatedModels($related);
$target = $this->targetModel();
$table = $target->source()->table();
foreach ($this->relatedModels() as $model) {
$src = $model->source();
$tbl = $src->table();
$dbh = $src->db();
$dbh->query(
strtr(
'LOCK TABLES
`%relatedTable` AS a WRITE,
`%sourceTable` AS b WRITE',
[
'%relatedTable' => $tbl,
'%sourceTable' => $table,
]
)
);
$sql = strtr(
'UPDATE `%relatedTable` AS a '.
'JOIN `%sourceTable` AS b ON a.`%prop` = b.`%oldKey` '.
'SET a.`%prop` = b.`%newKey`',
[
'%relatedTable' => $tbl,
'%prop' => $this->relatedProperties[$model->objType()],
'%sourceTable' => $table,
'%newKey' => $newField->ident(),
'%oldKey' => $target->key(),
]
);
$dbh->query($sql);
$dbh->query('UNLOCK TABLES');
}
return $this;
} | php | protected function syncRelatedFields(
IdProperty $newProp,
PropertyField $newField,
IdProperty $oldProp,
PropertyField $oldField
) {
unset($newProp, $oldProp, $oldField);
$cli = $this->climate();
if (!$this->quiet()) {
$cli->br();
$cli->comment('Syncing new IDs to related tables.');
}
$related = $cli->arguments->get('related_model');
if (!$related) {
$cli->br();
$input = $cli->confirm('Are there any model(s) related to the target?');
if (!$input->confirmed()) {
return $this;
}
$related = $this->argOrInput('related_model');
}
$this->setRelatedModels($related);
$target = $this->targetModel();
$table = $target->source()->table();
foreach ($this->relatedModels() as $model) {
$src = $model->source();
$tbl = $src->table();
$dbh = $src->db();
$dbh->query(
strtr(
'LOCK TABLES
`%relatedTable` AS a WRITE,
`%sourceTable` AS b WRITE',
[
'%relatedTable' => $tbl,
'%sourceTable' => $table,
]
)
);
$sql = strtr(
'UPDATE `%relatedTable` AS a '.
'JOIN `%sourceTable` AS b ON a.`%prop` = b.`%oldKey` '.
'SET a.`%prop` = b.`%newKey`',
[
'%relatedTable' => $tbl,
'%prop' => $this->relatedProperties[$model->objType()],
'%sourceTable' => $table,
'%newKey' => $newField->ident(),
'%oldKey' => $target->key(),
]
);
$dbh->query($sql);
$dbh->query('UNLOCK TABLES');
}
return $this;
} | [
"protected",
"function",
"syncRelatedFields",
"(",
"IdProperty",
"$",
"newProp",
",",
"PropertyField",
"$",
"newField",
",",
"IdProperty",
"$",
"oldProp",
",",
"PropertyField",
"$",
"oldField",
")",
"{",
"unset",
"(",
"$",
"newProp",
",",
"$",
"oldProp",
",",
"$",
"oldField",
")",
";",
"$",
"cli",
"=",
"$",
"this",
"->",
"climate",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"quiet",
"(",
")",
")",
"{",
"$",
"cli",
"->",
"br",
"(",
")",
";",
"$",
"cli",
"->",
"comment",
"(",
"'Syncing new IDs to related tables.'",
")",
";",
"}",
"$",
"related",
"=",
"$",
"cli",
"->",
"arguments",
"->",
"get",
"(",
"'related_model'",
")",
";",
"if",
"(",
"!",
"$",
"related",
")",
"{",
"$",
"cli",
"->",
"br",
"(",
")",
";",
"$",
"input",
"=",
"$",
"cli",
"->",
"confirm",
"(",
"'Are there any model(s) related to the target?'",
")",
";",
"if",
"(",
"!",
"$",
"input",
"->",
"confirmed",
"(",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"related",
"=",
"$",
"this",
"->",
"argOrInput",
"(",
"'related_model'",
")",
";",
"}",
"$",
"this",
"->",
"setRelatedModels",
"(",
"$",
"related",
")",
";",
"$",
"target",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"table",
"=",
"$",
"target",
"->",
"source",
"(",
")",
"->",
"table",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"relatedModels",
"(",
")",
"as",
"$",
"model",
")",
"{",
"$",
"src",
"=",
"$",
"model",
"->",
"source",
"(",
")",
";",
"$",
"tbl",
"=",
"$",
"src",
"->",
"table",
"(",
")",
";",
"$",
"dbh",
"=",
"$",
"src",
"->",
"db",
"(",
")",
";",
"$",
"dbh",
"->",
"query",
"(",
"strtr",
"(",
"'LOCK TABLES\n `%relatedTable` AS a WRITE,\n `%sourceTable` AS b WRITE'",
",",
"[",
"'%relatedTable'",
"=>",
"$",
"tbl",
",",
"'%sourceTable'",
"=>",
"$",
"table",
",",
"]",
")",
")",
";",
"$",
"sql",
"=",
"strtr",
"(",
"'UPDATE `%relatedTable` AS a '",
".",
"'JOIN `%sourceTable` AS b ON a.`%prop` = b.`%oldKey` '",
".",
"'SET a.`%prop` = b.`%newKey`'",
",",
"[",
"'%relatedTable'",
"=>",
"$",
"tbl",
",",
"'%prop'",
"=>",
"$",
"this",
"->",
"relatedProperties",
"[",
"$",
"model",
"->",
"objType",
"(",
")",
"]",
",",
"'%sourceTable'",
"=>",
"$",
"table",
",",
"'%newKey'",
"=>",
"$",
"newField",
"->",
"ident",
"(",
")",
",",
"'%oldKey'",
"=>",
"$",
"target",
"->",
"key",
"(",
")",
",",
"]",
")",
";",
"$",
"dbh",
"->",
"query",
"(",
"$",
"sql",
")",
";",
"$",
"dbh",
"->",
"query",
"(",
"'UNLOCK TABLES'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sync the new primary keys to related models.
@param IdProperty $newProp The new ID property.
@param PropertyField $newField The new ID field.
@param IdProperty $oldProp The previous ID property.
@param PropertyField $oldField The previous ID field.
@throws InvalidArgumentException If the new property does not implement the proper mode.
@return self | [
"Sync",
"the",
"new",
"primary",
"keys",
"to",
"related",
"models",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L841-L904 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.parseIdGenerator | public function parseIdGenerator($callable)
{
if ($callable instanceof Closure) {
return $callable;
}
$class = null;
$method = null;
$isMethod = false;
$isModel = false;
$bail = false;
if (is_array($callable) && count($callable) === 2) {
list($class, $func) = $callable;
$isMethod = ($class && $func);
} elseif (is_string($callable) && strpos($callable, '::') > 1) {
list($class, $func) = explode('::', $callable);
$isMethod = ($class && $func);
}
if ($isMethod) {
$model = $this->targetModel();
$isModel = is_a($model, $class);
$method = new ReflectionMethod($class, $func);
if ($isModel && $method->isPublic()) {
return $method->getClosure($model);
} elseif ($method->isStatic() && $method->isPublic()) {
return $callable;
} else {
$bail = true;
}
}
if ($bail || !(is_string($callable) && function_exists($callable))) {
throw new InvalidArgumentException(
sprintf(
'The ID generator must be callable, received: %s',
is_object($callable)
? get_class($callable)
: (is_string($callable)
? $callable
: gettype($callable)
)
)
);
}
return $callable;
} | php | public function parseIdGenerator($callable)
{
if ($callable instanceof Closure) {
return $callable;
}
$class = null;
$method = null;
$isMethod = false;
$isModel = false;
$bail = false;
if (is_array($callable) && count($callable) === 2) {
list($class, $func) = $callable;
$isMethod = ($class && $func);
} elseif (is_string($callable) && strpos($callable, '::') > 1) {
list($class, $func) = explode('::', $callable);
$isMethod = ($class && $func);
}
if ($isMethod) {
$model = $this->targetModel();
$isModel = is_a($model, $class);
$method = new ReflectionMethod($class, $func);
if ($isModel && $method->isPublic()) {
return $method->getClosure($model);
} elseif ($method->isStatic() && $method->isPublic()) {
return $callable;
} else {
$bail = true;
}
}
if ($bail || !(is_string($callable) && function_exists($callable))) {
throw new InvalidArgumentException(
sprintf(
'The ID generator must be callable, received: %s',
is_object($callable)
? get_class($callable)
: (is_string($callable)
? $callable
: gettype($callable)
)
)
);
}
return $callable;
} | [
"public",
"function",
"parseIdGenerator",
"(",
"$",
"callable",
")",
"{",
"if",
"(",
"$",
"callable",
"instanceof",
"Closure",
")",
"{",
"return",
"$",
"callable",
";",
"}",
"$",
"class",
"=",
"null",
";",
"$",
"method",
"=",
"null",
";",
"$",
"isMethod",
"=",
"false",
";",
"$",
"isModel",
"=",
"false",
";",
"$",
"bail",
"=",
"false",
";",
"if",
"(",
"is_array",
"(",
"$",
"callable",
")",
"&&",
"count",
"(",
"$",
"callable",
")",
"===",
"2",
")",
"{",
"list",
"(",
"$",
"class",
",",
"$",
"func",
")",
"=",
"$",
"callable",
";",
"$",
"isMethod",
"=",
"(",
"$",
"class",
"&&",
"$",
"func",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"callable",
")",
"&&",
"strpos",
"(",
"$",
"callable",
",",
"'::'",
")",
">",
"1",
")",
"{",
"list",
"(",
"$",
"class",
",",
"$",
"func",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"callable",
")",
";",
"$",
"isMethod",
"=",
"(",
"$",
"class",
"&&",
"$",
"func",
")",
";",
"}",
"if",
"(",
"$",
"isMethod",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"targetModel",
"(",
")",
";",
"$",
"isModel",
"=",
"is_a",
"(",
"$",
"model",
",",
"$",
"class",
")",
";",
"$",
"method",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"func",
")",
";",
"if",
"(",
"$",
"isModel",
"&&",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"return",
"$",
"method",
"->",
"getClosure",
"(",
"$",
"model",
")",
";",
"}",
"elseif",
"(",
"$",
"method",
"->",
"isStatic",
"(",
")",
"&&",
"$",
"method",
"->",
"isPublic",
"(",
")",
")",
"{",
"return",
"$",
"callable",
";",
"}",
"else",
"{",
"$",
"bail",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"bail",
"||",
"!",
"(",
"is_string",
"(",
"$",
"callable",
")",
"&&",
"function_exists",
"(",
"$",
"callable",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The ID generator must be callable, received: %s'",
",",
"is_object",
"(",
"$",
"callable",
")",
"?",
"get_class",
"(",
"$",
"callable",
")",
":",
"(",
"is_string",
"(",
"$",
"callable",
")",
"?",
"$",
"callable",
":",
"gettype",
"(",
"$",
"callable",
")",
")",
")",
")",
";",
"}",
"return",
"$",
"callable",
";",
"}"
]
| Parse and validate the given function is callable.
@param mixed $callable A function or method.
@throws InvalidArgumentException If the given argument is not a callable function.
@return callable | [
"Parse",
"and",
"validate",
"the",
"given",
"function",
"is",
"callable",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L1043-L1092 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.setTargetModel | public function setTargetModel($model)
{
if (is_string($model)) {
$model = $this->modelFactory()->get($model);
}
if (!$model instanceof ModelInterface) {
throw new InvalidArgumentException(
sprintf(
'The model must be an instance of "%s"',
ModelInterface::class
)
);
}
$this->targetModel = $model;
return $this;
} | php | public function setTargetModel($model)
{
if (is_string($model)) {
$model = $this->modelFactory()->get($model);
}
if (!$model instanceof ModelInterface) {
throw new InvalidArgumentException(
sprintf(
'The model must be an instance of "%s"',
ModelInterface::class
)
);
}
$this->targetModel = $model;
return $this;
} | [
"public",
"function",
"setTargetModel",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"model",
")",
")",
"{",
"$",
"model",
"=",
"$",
"this",
"->",
"modelFactory",
"(",
")",
"->",
"get",
"(",
"$",
"model",
")",
";",
"}",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"ModelInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The model must be an instance of \"%s\"'",
",",
"ModelInterface",
"::",
"class",
")",
")",
";",
"}",
"$",
"this",
"->",
"targetModel",
"=",
"$",
"model",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the model to alter.
@param string|ModelInterface $model An object model.
@throws InvalidArgumentException If the given argument is not a model.
@return self | [
"Set",
"the",
"model",
"to",
"alter",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L1116-L1134 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.setRelatedModels | public function setRelatedModels($models)
{
$models = $this->parseAsArray($models);
foreach ($models as $i => $model) {
if (is_string($model)) {
list($model, $prop) = $this->resolveRelatedModel($model);
$models[$i] = $model;
$this->relatedProperties[$model->objType()] = $prop;
} elseif ($model instanceof ModelInterface) {
if (!isset($this->relatedProperties[$model->objType()])) {
throw new InvalidArgumentException(
sprintf(
'The related model [%s] requires a target property',
get_class($model)
)
);
}
$models[$i] = $model;
} else {
throw new InvalidArgumentException(
sprintf(
'A related model must be defined as "%s"',
'ObjType:propertyIdent'
)
);
}
}
$this->relatedModels = $models;
return $this;
} | php | public function setRelatedModels($models)
{
$models = $this->parseAsArray($models);
foreach ($models as $i => $model) {
if (is_string($model)) {
list($model, $prop) = $this->resolveRelatedModel($model);
$models[$i] = $model;
$this->relatedProperties[$model->objType()] = $prop;
} elseif ($model instanceof ModelInterface) {
if (!isset($this->relatedProperties[$model->objType()])) {
throw new InvalidArgumentException(
sprintf(
'The related model [%s] requires a target property',
get_class($model)
)
);
}
$models[$i] = $model;
} else {
throw new InvalidArgumentException(
sprintf(
'A related model must be defined as "%s"',
'ObjType:propertyIdent'
)
);
}
}
$this->relatedModels = $models;
return $this;
} | [
"public",
"function",
"setRelatedModels",
"(",
"$",
"models",
")",
"{",
"$",
"models",
"=",
"$",
"this",
"->",
"parseAsArray",
"(",
"$",
"models",
")",
";",
"foreach",
"(",
"$",
"models",
"as",
"$",
"i",
"=>",
"$",
"model",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"model",
")",
")",
"{",
"list",
"(",
"$",
"model",
",",
"$",
"prop",
")",
"=",
"$",
"this",
"->",
"resolveRelatedModel",
"(",
"$",
"model",
")",
";",
"$",
"models",
"[",
"$",
"i",
"]",
"=",
"$",
"model",
";",
"$",
"this",
"->",
"relatedProperties",
"[",
"$",
"model",
"->",
"objType",
"(",
")",
"]",
"=",
"$",
"prop",
";",
"}",
"elseif",
"(",
"$",
"model",
"instanceof",
"ModelInterface",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"relatedProperties",
"[",
"$",
"model",
"->",
"objType",
"(",
")",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The related model [%s] requires a target property'",
",",
"get_class",
"(",
"$",
"model",
")",
")",
")",
";",
"}",
"$",
"models",
"[",
"$",
"i",
"]",
"=",
"$",
"model",
";",
"}",
"else",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'A related model must be defined as \"%s\"'",
",",
"'ObjType:propertyIdent'",
")",
")",
";",
"}",
"}",
"$",
"this",
"->",
"relatedModels",
"=",
"$",
"models",
";",
"return",
"$",
"this",
";",
"}"
]
| Set the related models to update.
@param string|array $models One or more object models.
@throws InvalidArgumentException If the given argument is not a model.
@return self | [
"Set",
"the",
"related",
"models",
"to",
"update",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L1158-L1189 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php | AlterPrimaryKeyScript.resolveRelatedModel | protected function resolveRelatedModel($pattern)
{
list($class, $prop) = array_pad($this->parseAsArray($pattern, ':'), 2, null);
$model = $this->modelFactory()->get($class);
if (!$prop) {
throw new InvalidArgumentException(
sprintf(
'The related model [%s] requires a target property',
get_class($model)
)
);
}
$metadata = $model->metadata();
if (!$metadata->property($prop)) {
throw new InvalidArgumentException(
sprintf(
'The related model [%1$s] does not have the target property [%2$s]',
$class,
(is_string($prop) ? $prop : gettype($prop))
)
);
}
return [$model, $prop];
} | php | protected function resolveRelatedModel($pattern)
{
list($class, $prop) = array_pad($this->parseAsArray($pattern, ':'), 2, null);
$model = $this->modelFactory()->get($class);
if (!$prop) {
throw new InvalidArgumentException(
sprintf(
'The related model [%s] requires a target property',
get_class($model)
)
);
}
$metadata = $model->metadata();
if (!$metadata->property($prop)) {
throw new InvalidArgumentException(
sprintf(
'The related model [%1$s] does not have the target property [%2$s]',
$class,
(is_string($prop) ? $prop : gettype($prop))
)
);
}
return [$model, $prop];
} | [
"protected",
"function",
"resolveRelatedModel",
"(",
"$",
"pattern",
")",
"{",
"list",
"(",
"$",
"class",
",",
"$",
"prop",
")",
"=",
"array_pad",
"(",
"$",
"this",
"->",
"parseAsArray",
"(",
"$",
"pattern",
",",
"':'",
")",
",",
"2",
",",
"null",
")",
";",
"$",
"model",
"=",
"$",
"this",
"->",
"modelFactory",
"(",
")",
"->",
"get",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"$",
"prop",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The related model [%s] requires a target property'",
",",
"get_class",
"(",
"$",
"model",
")",
")",
")",
";",
"}",
"$",
"metadata",
"=",
"$",
"model",
"->",
"metadata",
"(",
")",
";",
"if",
"(",
"!",
"$",
"metadata",
"->",
"property",
"(",
"$",
"prop",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The related model [%1$s] does not have the target property [%2$s]'",
",",
"$",
"class",
",",
"(",
"is_string",
"(",
"$",
"prop",
")",
"?",
"$",
"prop",
":",
"gettype",
"(",
"$",
"prop",
")",
")",
")",
")",
";",
"}",
"return",
"[",
"$",
"model",
",",
"$",
"prop",
"]",
";",
"}"
]
| Resolve the given related model.
@param string $pattern A 'model:property' identifier.
@throws InvalidArgumentException If the identifier is invalid.
@return array Returns an array containing a ModelInterface and a property identifier. | [
"Resolve",
"the",
"given",
"related",
"model",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Script/Object/Table/AlterPrimaryKeyScript.php#L1198-L1224 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.mainMenu | public function mainMenu()
{
if ($this->mainMenu === null) {
$options = null;
if ($this instanceof DashboardContainerInterface) {
$dashboardConfig = $this->dashboardConfig();
if (isset($dashboardConfig['secondary_menu'])) {
$options = $dashboardConfig['secondary_menu'];
}
}
$this->mainMenu = $this->createMainMenu($options);
}
return $this->mainMenu;
} | php | public function mainMenu()
{
if ($this->mainMenu === null) {
$options = null;
if ($this instanceof DashboardContainerInterface) {
$dashboardConfig = $this->dashboardConfig();
if (isset($dashboardConfig['secondary_menu'])) {
$options = $dashboardConfig['secondary_menu'];
}
}
$this->mainMenu = $this->createMainMenu($options);
}
return $this->mainMenu;
} | [
"public",
"function",
"mainMenu",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mainMenu",
"===",
"null",
")",
"{",
"$",
"options",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"instanceof",
"DashboardContainerInterface",
")",
"{",
"$",
"dashboardConfig",
"=",
"$",
"this",
"->",
"dashboardConfig",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"dashboardConfig",
"[",
"'secondary_menu'",
"]",
")",
")",
"{",
"$",
"options",
"=",
"$",
"dashboardConfig",
"[",
"'secondary_menu'",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"mainMenu",
"=",
"$",
"this",
"->",
"createMainMenu",
"(",
"$",
"options",
")",
";",
"}",
"return",
"$",
"this",
"->",
"mainMenu",
";",
"}"
]
| Yield the main menu.
@return array|Generator | [
"Yield",
"the",
"main",
"menu",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L334-L351 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.visitSiteLabel | public function visitSiteLabel()
{
$label = $this->adminConfig('main_menu.visit_site');
if ($label === false) {
return false;
}
if (empty($label) || $label === true) {
$label = $this->translator()->translate('Visit Site');
} else {
$label = $this->translator()->translate($label);
}
return $label;
} | php | public function visitSiteLabel()
{
$label = $this->adminConfig('main_menu.visit_site');
if ($label === false) {
return false;
}
if (empty($label) || $label === true) {
$label = $this->translator()->translate('Visit Site');
} else {
$label = $this->translator()->translate($label);
}
return $label;
} | [
"public",
"function",
"visitSiteLabel",
"(",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"adminConfig",
"(",
"'main_menu.visit_site'",
")",
";",
"if",
"(",
"$",
"label",
"===",
"false",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"label",
")",
"||",
"$",
"label",
"===",
"true",
")",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"translate",
"(",
"'Visit Site'",
")",
";",
"}",
"else",
"{",
"$",
"label",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"translate",
"(",
"$",
"label",
")",
";",
"}",
"return",
"$",
"label",
";",
"}"
]
| Get the "Visit website" label.
@return string|boolean The button's label,
TRUE to use the default label,
or FALSE to disable the link. | [
"Get",
"the",
"Visit",
"website",
"label",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L458-L472 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.locale | public function locale()
{
$lang = $this->lang();
$locales = $this->translator()->locales();
if (isset($locales[$lang]['locale'])) {
$locale = $locales[$lang]['locale'];
if (is_array($locale)) {
$locale = implode(' ', $locale);
}
} else {
$locale = 'en-US';
}
return $locale;
} | php | public function locale()
{
$lang = $this->lang();
$locales = $this->translator()->locales();
if (isset($locales[$lang]['locale'])) {
$locale = $locales[$lang]['locale'];
if (is_array($locale)) {
$locale = implode(' ', $locale);
}
} else {
$locale = 'en-US';
}
return $locale;
} | [
"public",
"function",
"locale",
"(",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"lang",
"(",
")",
";",
"$",
"locales",
"=",
"$",
"this",
"->",
"translator",
"(",
")",
"->",
"locales",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"locales",
"[",
"$",
"lang",
"]",
"[",
"'locale'",
"]",
")",
")",
"{",
"$",
"locale",
"=",
"$",
"locales",
"[",
"$",
"lang",
"]",
"[",
"'locale'",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"locale",
"=",
"implode",
"(",
"' '",
",",
"$",
"locale",
")",
";",
"}",
"}",
"else",
"{",
"$",
"locale",
"=",
"'en-US'",
";",
"}",
"return",
"$",
"locale",
";",
"}"
]
| Retrieve the current language.
@return string | [
"Retrieve",
"the",
"current",
"language",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L520-L535 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.recaptchaInvisible | public function recaptchaInvisible()
{
$recaptcha = $this->apiConfig('google.recaptcha');
$hasInvisible = isset($recaptcha['invisible']);
if ($hasInvisible && $recaptcha['invisible'] === true) {
return true;
}
$hasSize = isset($recaptcha['size']);
if ($hasSize && $recaptcha['size'] === 'invisible') {
return true;
}
if (!$hasInvisible && !$hasSize) {
return true;
}
return false;
} | php | public function recaptchaInvisible()
{
$recaptcha = $this->apiConfig('google.recaptcha');
$hasInvisible = isset($recaptcha['invisible']);
if ($hasInvisible && $recaptcha['invisible'] === true) {
return true;
}
$hasSize = isset($recaptcha['size']);
if ($hasSize && $recaptcha['size'] === 'invisible') {
return true;
}
if (!$hasInvisible && !$hasSize) {
return true;
}
return false;
} | [
"public",
"function",
"recaptchaInvisible",
"(",
")",
"{",
"$",
"recaptcha",
"=",
"$",
"this",
"->",
"apiConfig",
"(",
"'google.recaptcha'",
")",
";",
"$",
"hasInvisible",
"=",
"isset",
"(",
"$",
"recaptcha",
"[",
"'invisible'",
"]",
")",
";",
"if",
"(",
"$",
"hasInvisible",
"&&",
"$",
"recaptcha",
"[",
"'invisible'",
"]",
"===",
"true",
")",
"{",
"return",
"true",
";",
"}",
"$",
"hasSize",
"=",
"isset",
"(",
"$",
"recaptcha",
"[",
"'size'",
"]",
")",
";",
"if",
"(",
"$",
"hasSize",
"&&",
"$",
"recaptcha",
"[",
"'size'",
"]",
"===",
"'invisible'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"$",
"hasInvisible",
"&&",
"!",
"$",
"hasSize",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Determine if the CAPTCHA test is invisible.
Note: Charcoal's implementation of Google reCAPTCHA defaults to "invisible".
@return boolean | [
"Determine",
"if",
"the",
"CAPTCHA",
"test",
"is",
"invisible",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L565-L584 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.recaptchaHtmlAttr | public function recaptchaHtmlAttr()
{
$params = $this->recaptchaParameters();
$attributes = [];
foreach ($params as $key => $val) {
if ($val !== null) {
$attributes[] = sprintf('data-%s="%s"', $key, htmlspecialchars($val, ENT_QUOTES));
}
}
return implode(' ', $attributes);
} | php | public function recaptchaHtmlAttr()
{
$params = $this->recaptchaParameters();
$attributes = [];
foreach ($params as $key => $val) {
if ($val !== null) {
$attributes[] = sprintf('data-%s="%s"', $key, htmlspecialchars($val, ENT_QUOTES));
}
}
return implode(' ', $attributes);
} | [
"public",
"function",
"recaptchaHtmlAttr",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"recaptchaParameters",
"(",
")",
";",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"$",
"attributes",
"[",
"]",
"=",
"sprintf",
"(",
"'data-%s=\"%s\"'",
",",
"$",
"key",
",",
"htmlspecialchars",
"(",
"$",
"val",
",",
"ENT_QUOTES",
")",
")",
";",
"}",
"}",
"return",
"implode",
"(",
"' '",
",",
"$",
"attributes",
")",
";",
"}"
]
| Generate a string representation of HTML attributes for the Google reCAPTCHA tag.
@return string | [
"Generate",
"a",
"string",
"representation",
"of",
"HTML",
"attributes",
"for",
"the",
"Google",
"reCAPTCHA",
"tag",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L659-L671 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.createMainMenu | protected function createMainMenu($options = null)
{
$mainMenuConfig = $this->adminConfig('main_menu');
if (!isset($mainMenuConfig['items'])) {
throw new InvalidArgumentException(
'Missing "admin.main_menu.items"'
);
}
$mainMenuIdent = $this->mainMenuIdent($options);
$menu = $this->menuBuilder->build([]);
$menuItems = [];
foreach ($mainMenuConfig['items'] as $menuIdent => $menuItem) {
$menuItem['menu'] = $menu;
$test = $this->menuItemBuilder->build($menuItem);
if ($test->isAuthorized() === false) {
continue;
}
unset($menuItem['menu']);
if (isset($menuItem['active']) && $menuItem['active'] === false) {
continue;
}
$menuItems[] = $this->parseMainMenuItem($menuItem, $menuIdent, $mainMenuIdent);
}
return $menuItems;
} | php | protected function createMainMenu($options = null)
{
$mainMenuConfig = $this->adminConfig('main_menu');
if (!isset($mainMenuConfig['items'])) {
throw new InvalidArgumentException(
'Missing "admin.main_menu.items"'
);
}
$mainMenuIdent = $this->mainMenuIdent($options);
$menu = $this->menuBuilder->build([]);
$menuItems = [];
foreach ($mainMenuConfig['items'] as $menuIdent => $menuItem) {
$menuItem['menu'] = $menu;
$test = $this->menuItemBuilder->build($menuItem);
if ($test->isAuthorized() === false) {
continue;
}
unset($menuItem['menu']);
if (isset($menuItem['active']) && $menuItem['active'] === false) {
continue;
}
$menuItems[] = $this->parseMainMenuItem($menuItem, $menuIdent, $mainMenuIdent);
}
return $menuItems;
} | [
"protected",
"function",
"createMainMenu",
"(",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"mainMenuConfig",
"=",
"$",
"this",
"->",
"adminConfig",
"(",
"'main_menu'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"mainMenuConfig",
"[",
"'items'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Missing \"admin.main_menu.items\"'",
")",
";",
"}",
"$",
"mainMenuIdent",
"=",
"$",
"this",
"->",
"mainMenuIdent",
"(",
"$",
"options",
")",
";",
"$",
"menu",
"=",
"$",
"this",
"->",
"menuBuilder",
"->",
"build",
"(",
"[",
"]",
")",
";",
"$",
"menuItems",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mainMenuConfig",
"[",
"'items'",
"]",
"as",
"$",
"menuIdent",
"=>",
"$",
"menuItem",
")",
"{",
"$",
"menuItem",
"[",
"'menu'",
"]",
"=",
"$",
"menu",
";",
"$",
"test",
"=",
"$",
"this",
"->",
"menuItemBuilder",
"->",
"build",
"(",
"$",
"menuItem",
")",
";",
"if",
"(",
"$",
"test",
"->",
"isAuthorized",
"(",
")",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"unset",
"(",
"$",
"menuItem",
"[",
"'menu'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"menuItem",
"[",
"'active'",
"]",
")",
"&&",
"$",
"menuItem",
"[",
"'active'",
"]",
"===",
"false",
")",
"{",
"continue",
";",
"}",
"$",
"menuItems",
"[",
"]",
"=",
"$",
"this",
"->",
"parseMainMenuItem",
"(",
"$",
"menuItem",
",",
"$",
"menuIdent",
",",
"$",
"mainMenuIdent",
")",
";",
"}",
"return",
"$",
"menuItems",
";",
"}"
]
| Create the main menu using the admin config.
@param mixed $options The main menu widget ID or config.
@throws InvalidArgumentException If the admin config is missing, invalid, or malformed.
@return array | [
"Create",
"the",
"main",
"menu",
"using",
"the",
"admin",
"config",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L756-L787 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.mainMenuIdent | private function mainMenuIdent($options = null)
{
if ($this->mainMenuIdentLoaded === false) {
$mainMenuIdent = null;
if (isset($this['main_menu_item'])) {
$mainMenuIdent = $this['main_menu_item'];
}
if (!(empty($options) && !is_numeric($options))) {
if (is_string($options)) {
$mainMenuIdent = $options;
} elseif (is_array($options)) {
if (isset($options['widget_options']['ident'])) {
$mainMenuIdent = $options['widget_options']['ident'];
}
}
}
// Get main menu from the obj_type
$objType = filter_input(INPUT_GET, 'obj_type', FILTER_SANITIZE_STRING);
if ($objType) {
$secondaryMenuItems = $this->adminConfig('secondary_menu');
foreach ($secondaryMenuItems as $main => $item) {
if ($this->isObjTypeInSecondaryMenuItem($objType, $item)) {
$mainMenuIdent = $main;
break;
}
}
}
// Choose main menu with a get parameter
$mainMenuFromRequest = filter_input(INPUT_GET, 'main_menu', FILTER_SANITIZE_STRING);
if ($mainMenuFromRequest) {
$mainMenuIdent = $mainMenuFromRequest;
}
$this->mainMenuIdent = $mainMenuIdent;
$this->mainMenuIdentLoaded = true;
}
return $this->mainMenuIdent;
} | php | private function mainMenuIdent($options = null)
{
if ($this->mainMenuIdentLoaded === false) {
$mainMenuIdent = null;
if (isset($this['main_menu_item'])) {
$mainMenuIdent = $this['main_menu_item'];
}
if (!(empty($options) && !is_numeric($options))) {
if (is_string($options)) {
$mainMenuIdent = $options;
} elseif (is_array($options)) {
if (isset($options['widget_options']['ident'])) {
$mainMenuIdent = $options['widget_options']['ident'];
}
}
}
// Get main menu from the obj_type
$objType = filter_input(INPUT_GET, 'obj_type', FILTER_SANITIZE_STRING);
if ($objType) {
$secondaryMenuItems = $this->adminConfig('secondary_menu');
foreach ($secondaryMenuItems as $main => $item) {
if ($this->isObjTypeInSecondaryMenuItem($objType, $item)) {
$mainMenuIdent = $main;
break;
}
}
}
// Choose main menu with a get parameter
$mainMenuFromRequest = filter_input(INPUT_GET, 'main_menu', FILTER_SANITIZE_STRING);
if ($mainMenuFromRequest) {
$mainMenuIdent = $mainMenuFromRequest;
}
$this->mainMenuIdent = $mainMenuIdent;
$this->mainMenuIdentLoaded = true;
}
return $this->mainMenuIdent;
} | [
"private",
"function",
"mainMenuIdent",
"(",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"mainMenuIdentLoaded",
"===",
"false",
")",
"{",
"$",
"mainMenuIdent",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"[",
"'main_menu_item'",
"]",
")",
")",
"{",
"$",
"mainMenuIdent",
"=",
"$",
"this",
"[",
"'main_menu_item'",
"]",
";",
"}",
"if",
"(",
"!",
"(",
"empty",
"(",
"$",
"options",
")",
"&&",
"!",
"is_numeric",
"(",
"$",
"options",
")",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"options",
")",
")",
"{",
"$",
"mainMenuIdent",
"=",
"$",
"options",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"options",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'widget_options'",
"]",
"[",
"'ident'",
"]",
")",
")",
"{",
"$",
"mainMenuIdent",
"=",
"$",
"options",
"[",
"'widget_options'",
"]",
"[",
"'ident'",
"]",
";",
"}",
"}",
"}",
"// Get main menu from the obj_type",
"$",
"objType",
"=",
"filter_input",
"(",
"INPUT_GET",
",",
"'obj_type'",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"if",
"(",
"$",
"objType",
")",
"{",
"$",
"secondaryMenuItems",
"=",
"$",
"this",
"->",
"adminConfig",
"(",
"'secondary_menu'",
")",
";",
"foreach",
"(",
"$",
"secondaryMenuItems",
"as",
"$",
"main",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isObjTypeInSecondaryMenuItem",
"(",
"$",
"objType",
",",
"$",
"item",
")",
")",
"{",
"$",
"mainMenuIdent",
"=",
"$",
"main",
";",
"break",
";",
"}",
"}",
"}",
"// Choose main menu with a get parameter",
"$",
"mainMenuFromRequest",
"=",
"filter_input",
"(",
"INPUT_GET",
",",
"'main_menu'",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"if",
"(",
"$",
"mainMenuFromRequest",
")",
"{",
"$",
"mainMenuIdent",
"=",
"$",
"mainMenuFromRequest",
";",
"}",
"$",
"this",
"->",
"mainMenuIdent",
"=",
"$",
"mainMenuIdent",
";",
"$",
"this",
"->",
"mainMenuIdentLoaded",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"mainMenuIdent",
";",
"}"
]
| Determine and retrieve the active main menu item's identifier.
@param mixed $options The secondary menu widget ID or config.
@return string|null | [
"Determine",
"and",
"retrieve",
"the",
"active",
"main",
"menu",
"item",
"s",
"identifier",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L795-L837 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.isObjTypeInSecondaryMenuItem | protected function isObjTypeInSecondaryMenuItem($objType, $item)
{
if (isset($item['links'])) {
foreach ($item['links'] as $obj => $i) {
if ($obj === $objType) {
return true;
}
}
}
if (isset($item['groups'])) {
foreach ($item['groups'] as $group) {
if ($this->isObjTypeInSecondaryMenuItem($objType, $group)) {
return true;
}
}
}
return false;
} | php | protected function isObjTypeInSecondaryMenuItem($objType, $item)
{
if (isset($item['links'])) {
foreach ($item['links'] as $obj => $i) {
if ($obj === $objType) {
return true;
}
}
}
if (isset($item['groups'])) {
foreach ($item['groups'] as $group) {
if ($this->isObjTypeInSecondaryMenuItem($objType, $group)) {
return true;
}
}
}
return false;
} | [
"protected",
"function",
"isObjTypeInSecondaryMenuItem",
"(",
"$",
"objType",
",",
"$",
"item",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'links'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"[",
"'links'",
"]",
"as",
"$",
"obj",
"=>",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"obj",
"===",
"$",
"objType",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'groups'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"item",
"[",
"'groups'",
"]",
"as",
"$",
"group",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isObjTypeInSecondaryMenuItem",
"(",
"$",
"objType",
",",
"$",
"group",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
]
| Check for the objType in the secondary menu items
returning true as soon as it its.
@param string $objType The ObjType to search.
@param array|mixed $item The secondary menu item to search in.
@return boolean | [
"Check",
"for",
"the",
"objType",
"in",
"the",
"secondary",
"menu",
"items",
"returning",
"true",
"as",
"soon",
"as",
"it",
"its",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L847-L866 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/AdminTemplate.php | AdminTemplate.templateName | public function templateName()
{
$key = substr(strrchr('\\'.get_class($this), '\\'), 1);
if (!isset(static::$templateNameCache[$key])) {
$value = $key;
if (!ctype_lower($value)) {
$value = preg_replace('/\s+/u', '', $value);
$value = mb_strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1-', $value), 'UTF-8');
}
$value = str_replace(
[ 'abstract', 'trait', 'interface', 'template', '\\' ],
'',
$value
);
static::$templateNameCache[$key] = trim($value, '-');
}
return static::$templateNameCache[$key];
} | php | public function templateName()
{
$key = substr(strrchr('\\'.get_class($this), '\\'), 1);
if (!isset(static::$templateNameCache[$key])) {
$value = $key;
if (!ctype_lower($value)) {
$value = preg_replace('/\s+/u', '', $value);
$value = mb_strtolower(preg_replace('/(.)(?=[A-Z])/u', '$1-', $value), 'UTF-8');
}
$value = str_replace(
[ 'abstract', 'trait', 'interface', 'template', '\\' ],
'',
$value
);
static::$templateNameCache[$key] = trim($value, '-');
}
return static::$templateNameCache[$key];
} | [
"public",
"function",
"templateName",
"(",
")",
"{",
"$",
"key",
"=",
"substr",
"(",
"strrchr",
"(",
"'\\\\'",
".",
"get_class",
"(",
"$",
"this",
")",
",",
"'\\\\'",
")",
",",
"1",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"templateNameCache",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"key",
";",
"if",
"(",
"!",
"ctype_lower",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"preg_replace",
"(",
"'/\\s+/u'",
",",
"''",
",",
"$",
"value",
")",
";",
"$",
"value",
"=",
"mb_strtolower",
"(",
"preg_replace",
"(",
"'/(.)(?=[A-Z])/u'",
",",
"'$1-'",
",",
"$",
"value",
")",
",",
"'UTF-8'",
")",
";",
"}",
"$",
"value",
"=",
"str_replace",
"(",
"[",
"'abstract'",
",",
"'trait'",
",",
"'interface'",
",",
"'template'",
",",
"'\\\\'",
"]",
",",
"''",
",",
"$",
"value",
")",
";",
"static",
"::",
"$",
"templateNameCache",
"[",
"$",
"key",
"]",
"=",
"trim",
"(",
"$",
"value",
",",
"'-'",
")",
";",
"}",
"return",
"static",
"::",
"$",
"templateNameCache",
"[",
"$",
"key",
"]",
";",
"}"
]
| Retrieve the template's identifier.
@return string | [
"Retrieve",
"the",
"template",
"s",
"identifier",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/AdminTemplate.php#L1140-L1162 | train |
locomotivemtl/charcoal-admin | src/Charcoal/Admin/Property/Input/ReadonlySelectInput.php | ReadonlySelectInput.displayVal | public function displayVal()
{
$selectedChoices = [];
foreach ($this->choices() as $choice) {
if ($this->isChoiceSelected($choice)) {
$selectedChoices[] = $choice['label'];
// break;
}
}
return implode(', ', $selectedChoices);
} | php | public function displayVal()
{
$selectedChoices = [];
foreach ($this->choices() as $choice) {
if ($this->isChoiceSelected($choice)) {
$selectedChoices[] = $choice['label'];
// break;
}
}
return implode(', ', $selectedChoices);
} | [
"public",
"function",
"displayVal",
"(",
")",
"{",
"$",
"selectedChoices",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"choices",
"(",
")",
"as",
"$",
"choice",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isChoiceSelected",
"(",
"$",
"choice",
")",
")",
"{",
"$",
"selectedChoices",
"[",
"]",
"=",
"$",
"choice",
"[",
"'label'",
"]",
";",
"// break;",
"}",
"}",
"return",
"implode",
"(",
"', '",
",",
"$",
"selectedChoices",
")",
";",
"}"
]
| Retrieve the selected value and display it.
@return string | [
"Retrieve",
"the",
"selected",
"value",
"and",
"display",
"it",
"."
]
| d7394e62ab8b374bcdd1dbeaedec0f6c35624571 | https://github.com/locomotivemtl/charcoal-admin/blob/d7394e62ab8b374bcdd1dbeaedec0f6c35624571/src/Charcoal/Admin/Property/Input/ReadonlySelectInput.php#L17-L29 | train |
cleverage/eav-manager | ApiPlatformBundle/EAV/Filter/AbstractEAVFilter.php | AbstractEAVFilter.getDescription | public function getDescription(string $resourceClass): array
{
$description = [];
$properties = $this->properties;
if (null === $properties) {
$family = $this->getFamily($resourceClass);
$properties = array_fill_keys(array_keys($family->getAttributes()), null);
}
foreach ($properties as $property => $strategy) {
try {
$attribute = $this->getAttribute($resourceClass, $property);
} catch (MissingAttributeException $e) {
continue;
}
$typeOfField = $this->getType($attribute);
if (!\in_array($typeOfField, $this->supportedTypes, true)) {
continue;
}
$this->appendFilterDescription($description, $attribute, $property, $typeOfField, $strategy);
}
return $description;
} | php | public function getDescription(string $resourceClass): array
{
$description = [];
$properties = $this->properties;
if (null === $properties) {
$family = $this->getFamily($resourceClass);
$properties = array_fill_keys(array_keys($family->getAttributes()), null);
}
foreach ($properties as $property => $strategy) {
try {
$attribute = $this->getAttribute($resourceClass, $property);
} catch (MissingAttributeException $e) {
continue;
}
$typeOfField = $this->getType($attribute);
if (!\in_array($typeOfField, $this->supportedTypes, true)) {
continue;
}
$this->appendFilterDescription($description, $attribute, $property, $typeOfField, $strategy);
}
return $description;
} | [
"public",
"function",
"getDescription",
"(",
"string",
"$",
"resourceClass",
")",
":",
"array",
"{",
"$",
"description",
"=",
"[",
"]",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"properties",
";",
"if",
"(",
"null",
"===",
"$",
"properties",
")",
"{",
"$",
"family",
"=",
"$",
"this",
"->",
"getFamily",
"(",
"$",
"resourceClass",
")",
";",
"$",
"properties",
"=",
"array_fill_keys",
"(",
"array_keys",
"(",
"$",
"family",
"->",
"getAttributes",
"(",
")",
")",
",",
"null",
")",
";",
"}",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"property",
"=>",
"$",
"strategy",
")",
"{",
"try",
"{",
"$",
"attribute",
"=",
"$",
"this",
"->",
"getAttribute",
"(",
"$",
"resourceClass",
",",
"$",
"property",
")",
";",
"}",
"catch",
"(",
"MissingAttributeException",
"$",
"e",
")",
"{",
"continue",
";",
"}",
"$",
"typeOfField",
"=",
"$",
"this",
"->",
"getType",
"(",
"$",
"attribute",
")",
";",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"typeOfField",
",",
"$",
"this",
"->",
"supportedTypes",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"appendFilterDescription",
"(",
"$",
"description",
",",
"$",
"attribute",
",",
"$",
"property",
",",
"$",
"typeOfField",
",",
"$",
"strategy",
")",
";",
"}",
"return",
"$",
"description",
";",
"}"
]
| Gets the description of this filter for the given resource.
Returns an array with the filter parameter names as keys and array with the following data as values:
- property: the property where the filter is applied
- type: the type of the filter
- required: if this filter is required
- strategy: the used strategy
- swagger (optional): additional parameters for the path operation, e.g. 'swagger' => ['description' => 'My
Description'] The description can contain additional data specific to a filter.
@param string $resourceClass
@throws \LogicException
@throws \Sidus\EAVModelBundle\Exception\MissingAttributeException
@throws \Sidus\EAVModelBundle\Exception\MissingFamilyException
@throws \UnexpectedValueException
@return array | [
"Gets",
"the",
"description",
"of",
"this",
"filter",
"for",
"the",
"given",
"resource",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/ApiPlatformBundle/EAV/Filter/AbstractEAVFilter.php#L127-L152 | train |
php-api-clients/pusher | src/ApiSettings.php | ApiSettings.getVersion | public static function getVersion(string $version = ''): string
{
if ($version === '') {
$version = PrettyVersions::getVersion('api-clients/pusher')->getFullVersion();
}
list($version, $hash) = explode('@', $version);
if (strpos($version, 'dev') !== false) {
return '0.0.1-' . $hash;
}
return $version;
} | php | public static function getVersion(string $version = ''): string
{
if ($version === '') {
$version = PrettyVersions::getVersion('api-clients/pusher')->getFullVersion();
}
list($version, $hash) = explode('@', $version);
if (strpos($version, 'dev') !== false) {
return '0.0.1-' . $hash;
}
return $version;
} | [
"public",
"static",
"function",
"getVersion",
"(",
"string",
"$",
"version",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"$",
"version",
"===",
"''",
")",
"{",
"$",
"version",
"=",
"PrettyVersions",
"::",
"getVersion",
"(",
"'api-clients/pusher'",
")",
"->",
"getFullVersion",
"(",
")",
";",
"}",
"list",
"(",
"$",
"version",
",",
"$",
"hash",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"version",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"version",
",",
"'dev'",
")",
"!==",
"false",
")",
"{",
"return",
"'0.0.1-'",
".",
"$",
"hash",
";",
"}",
"return",
"$",
"version",
";",
"}"
]
| Create Pusher compatible version.
@param string $version
@return string | [
"Create",
"Pusher",
"compatible",
"version",
"."
]
| 446f852af1ae17fa732481900da40b080e5c4cf3 | https://github.com/php-api-clients/pusher/blob/446f852af1ae17fa732481900da40b080e5c4cf3/src/ApiSettings.php#L15-L28 | train |
php-api-clients/pusher | src/ApiSettings.php | ApiSettings.createUrl | public static function createUrl(string $appId, string $cluster = null): string
{
$query = [
'client' => 'api-clients/pusher (https://php-api-clients.org/clients/pusher)',
'protocol' => 7,
'version' => ApiSettings::getVersion(),
];
$host = ($cluster !== null) ? "ws-{$cluster}.pusher.com" : 'ws.pusherapp.com';
return 'wss://'.$host.'/app/' .
$appId .
'?' . http_build_query($query)
;
} | php | public static function createUrl(string $appId, string $cluster = null): string
{
$query = [
'client' => 'api-clients/pusher (https://php-api-clients.org/clients/pusher)',
'protocol' => 7,
'version' => ApiSettings::getVersion(),
];
$host = ($cluster !== null) ? "ws-{$cluster}.pusher.com" : 'ws.pusherapp.com';
return 'wss://'.$host.'/app/' .
$appId .
'?' . http_build_query($query)
;
} | [
"public",
"static",
"function",
"createUrl",
"(",
"string",
"$",
"appId",
",",
"string",
"$",
"cluster",
"=",
"null",
")",
":",
"string",
"{",
"$",
"query",
"=",
"[",
"'client'",
"=>",
"'api-clients/pusher (https://php-api-clients.org/clients/pusher)'",
",",
"'protocol'",
"=>",
"7",
",",
"'version'",
"=>",
"ApiSettings",
"::",
"getVersion",
"(",
")",
",",
"]",
";",
"$",
"host",
"=",
"(",
"$",
"cluster",
"!==",
"null",
")",
"?",
"\"ws-{$cluster}.pusher.com\"",
":",
"'ws.pusherapp.com'",
";",
"return",
"'wss://'",
".",
"$",
"host",
".",
"'/app/'",
".",
"$",
"appId",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"query",
")",
";",
"}"
]
| Create WebSocket URL for given App ID.
@param string $appId
@return string | [
"Create",
"WebSocket",
"URL",
"for",
"given",
"App",
"ID",
"."
]
| 446f852af1ae17fa732481900da40b080e5c4cf3 | https://github.com/php-api-clients/pusher/blob/446f852af1ae17fa732481900da40b080e5c4cf3/src/ApiSettings.php#L36-L50 | train |
cleverage/eav-manager | AdminBundle/Controller/EAVDataController.php | EAVDataController.cloneAction | public function cloneAction(Request $request, DataInterface $data, FamilyInterface $family = null)
{
return $this->editAction($request, clone $data, $family);
} | php | public function cloneAction(Request $request, DataInterface $data, FamilyInterface $family = null)
{
return $this->editAction($request, clone $data, $family);
} | [
"public",
"function",
"cloneAction",
"(",
"Request",
"$",
"request",
",",
"DataInterface",
"$",
"data",
",",
"FamilyInterface",
"$",
"family",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"editAction",
"(",
"$",
"request",
",",
"clone",
"$",
"data",
",",
"$",
"family",
")",
";",
"}"
]
| Dedicated permission for cloning ?
@Security("(is_granted('create', family) and is_granted('read', data))")
@param Request $request
@param DataInterface $data
@param FamilyInterface $family
@throws \Exception
@return Response | [
"Dedicated",
"permission",
"for",
"cloning",
"?"
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/AdminBundle/Controller/EAVDataController.php#L217-L220 | train |
cleverage/eav-manager | AdminBundle/Controller/EAVDataController.php | EAVDataController.getDataGridConfigCode | protected function getDataGridConfigCode(): string
{
if ($this->family) {
// If datagrid code set in options, use it
$familyCode = $this->family->getCode();
/* @noinspection UnSafeIsSetOverArrayInspection */
if (isset($this->admin->getOption('families')[$familyCode]['datagrid'])) {
return $this->admin->getOption('families')[$familyCode]['datagrid'];
}
// Check if family has a datagrid with the same name
if ($this->get(DataGridRegistry::class)->hasDataGrid($familyCode)) {
return $familyCode;
}
// Check in lowercase (this should be deprecated ?)
$code = strtolower($familyCode);
if ($this->get(DataGridRegistry::class)->hasDataGrid($code)) {
return $code;
}
}
return parent::getDataGridConfigCode();
} | php | protected function getDataGridConfigCode(): string
{
if ($this->family) {
// If datagrid code set in options, use it
$familyCode = $this->family->getCode();
/* @noinspection UnSafeIsSetOverArrayInspection */
if (isset($this->admin->getOption('families')[$familyCode]['datagrid'])) {
return $this->admin->getOption('families')[$familyCode]['datagrid'];
}
// Check if family has a datagrid with the same name
if ($this->get(DataGridRegistry::class)->hasDataGrid($familyCode)) {
return $familyCode;
}
// Check in lowercase (this should be deprecated ?)
$code = strtolower($familyCode);
if ($this->get(DataGridRegistry::class)->hasDataGrid($code)) {
return $code;
}
}
return parent::getDataGridConfigCode();
} | [
"protected",
"function",
"getDataGridConfigCode",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"family",
")",
"{",
"// If datagrid code set in options, use it",
"$",
"familyCode",
"=",
"$",
"this",
"->",
"family",
"->",
"getCode",
"(",
")",
";",
"/* @noinspection UnSafeIsSetOverArrayInspection */",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"admin",
"->",
"getOption",
"(",
"'families'",
")",
"[",
"$",
"familyCode",
"]",
"[",
"'datagrid'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"admin",
"->",
"getOption",
"(",
"'families'",
")",
"[",
"$",
"familyCode",
"]",
"[",
"'datagrid'",
"]",
";",
"}",
"// Check if family has a datagrid with the same name",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"DataGridRegistry",
"::",
"class",
")",
"->",
"hasDataGrid",
"(",
"$",
"familyCode",
")",
")",
"{",
"return",
"$",
"familyCode",
";",
"}",
"// Check in lowercase (this should be deprecated ?)",
"$",
"code",
"=",
"strtolower",
"(",
"$",
"familyCode",
")",
";",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"DataGridRegistry",
"::",
"class",
")",
"->",
"hasDataGrid",
"(",
"$",
"code",
")",
")",
"{",
"return",
"$",
"code",
";",
"}",
"}",
"return",
"parent",
"::",
"getDataGridConfigCode",
"(",
")",
";",
"}"
]
| Resolve datagrid code.
@throws \UnexpectedValueException
@return string | [
"Resolve",
"datagrid",
"code",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/AdminBundle/Controller/EAVDataController.php#L283-L305 | train |
cleverage/eav-manager | ProcessBundle/Task/AbstractEAVQueryTask.php | AbstractEAVQueryTask.getPaginator | protected function getPaginator(ProcessState $state, $alias = 'e')
{
$options = $this->getOptions($state);
/** @noinspection PhpDeprecationInspection */
$paginator = new Paginator($this->getQueryBuilder($state, $alias));
if (null !== $options['limit']) {
$paginator->getQuery()->setMaxResults($options['limit']);
}
if (null !== $options['offset']) {
$paginator->getQuery()->setFirstResult($options['offset']);
}
return $paginator;
} | php | protected function getPaginator(ProcessState $state, $alias = 'e')
{
$options = $this->getOptions($state);
/** @noinspection PhpDeprecationInspection */
$paginator = new Paginator($this->getQueryBuilder($state, $alias));
if (null !== $options['limit']) {
$paginator->getQuery()->setMaxResults($options['limit']);
}
if (null !== $options['offset']) {
$paginator->getQuery()->setFirstResult($options['offset']);
}
return $paginator;
} | [
"protected",
"function",
"getPaginator",
"(",
"ProcessState",
"$",
"state",
",",
"$",
"alias",
"=",
"'e'",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
"$",
"state",
")",
";",
"/** @noinspection PhpDeprecationInspection */",
"$",
"paginator",
"=",
"new",
"Paginator",
"(",
"$",
"this",
"->",
"getQueryBuilder",
"(",
"$",
"state",
",",
"$",
"alias",
")",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"options",
"[",
"'limit'",
"]",
")",
"{",
"$",
"paginator",
"->",
"getQuery",
"(",
")",
"->",
"setMaxResults",
"(",
"$",
"options",
"[",
"'limit'",
"]",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"options",
"[",
"'offset'",
"]",
")",
"{",
"$",
"paginator",
"->",
"getQuery",
"(",
")",
"->",
"setFirstResult",
"(",
"$",
"options",
"[",
"'offset'",
"]",
")",
";",
"}",
"return",
"$",
"paginator",
";",
"}"
]
| If a limit or an offset is specified, we are forced to use a paginator to handle joins properly
@param ProcessState $state
@param string $alias
@throws \InvalidArgumentException
@throws \UnexpectedValueException
@throws \Sidus\EAVModelBundle\Exception\MissingAttributeException
@throws \LogicException
@throws \Symfony\Component\OptionsResolver\Exception\ExceptionInterface
@return Paginator | [
"If",
"a",
"limit",
"or",
"an",
"offset",
"is",
"specified",
"we",
"are",
"forced",
"to",
"use",
"a",
"paginator",
"to",
"handle",
"joins",
"properly"
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/ProcessBundle/Task/AbstractEAVQueryTask.php#L131-L144 | train |
cleverage/eav-manager | ProcessBundle/Task/EAVReaderTask.php | EAVReaderTask.next | public function next(ProcessState $state)
{
if (!$this->iterator instanceof \Iterator) {
throw new \LogicException('No iterator initialized');
}
$this->iterator->next();
$valid = $this->iterator->valid();
if (!$valid) {
$this->closed = true;
}
return $valid;
} | php | public function next(ProcessState $state)
{
if (!$this->iterator instanceof \Iterator) {
throw new \LogicException('No iterator initialized');
}
$this->iterator->next();
$valid = $this->iterator->valid();
if (!$valid) {
$this->closed = true;
}
return $valid;
} | [
"public",
"function",
"next",
"(",
"ProcessState",
"$",
"state",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"iterator",
"instanceof",
"\\",
"Iterator",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'No iterator initialized'",
")",
";",
"}",
"$",
"this",
"->",
"iterator",
"->",
"next",
"(",
")",
";",
"$",
"valid",
"=",
"$",
"this",
"->",
"iterator",
"->",
"valid",
"(",
")",
";",
"if",
"(",
"!",
"$",
"valid",
")",
"{",
"$",
"this",
"->",
"closed",
"=",
"true",
";",
"}",
"return",
"$",
"valid",
";",
"}"
]
| Moves the internal pointer to the next element,
return true if the task has a next element
return false if the task has terminated it's iteration
@param ProcessState $state
@throws \LogicException
@return bool | [
"Moves",
"the",
"internal",
"pointer",
"to",
"the",
"next",
"element",
"return",
"true",
"if",
"the",
"task",
"has",
"a",
"next",
"element",
"return",
"false",
"if",
"the",
"task",
"has",
"terminated",
"it",
"s",
"iteration"
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/ProcessBundle/Task/EAVReaderTask.php#L113-L126 | train |
cleverage/eav-manager | ApiPlatformBundle/DataProvider/FamilyDataProvider.php | FamilyDataProvider.getCollection | public function getCollection(string $resourceClass, string $operationName = null)
{
if (!is_a($resourceClass, FamilyInterface::class, true)) {
throw new ResourceClassNotSupportedException();
}
return $this->familyRegistry->getFamilies();
} | php | public function getCollection(string $resourceClass, string $operationName = null)
{
if (!is_a($resourceClass, FamilyInterface::class, true)) {
throw new ResourceClassNotSupportedException();
}
return $this->familyRegistry->getFamilies();
} | [
"public",
"function",
"getCollection",
"(",
"string",
"$",
"resourceClass",
",",
"string",
"$",
"operationName",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"resourceClass",
",",
"FamilyInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"throw",
"new",
"ResourceClassNotSupportedException",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"familyRegistry",
"->",
"getFamilies",
"(",
")",
";",
"}"
]
| Retrieves a collection.
@param string $resourceClass
@param string|null $operationName
@throws ResourceClassNotSupportedException
@return FamilyInterface[]|PaginatorInterface|\Traversable | [
"Retrieves",
"a",
"collection",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/ApiPlatformBundle/DataProvider/FamilyDataProvider.php#L48-L55 | train |
cleverage/eav-manager | UserBundle/Entity/User.php | User.getRoles | public function getRoles()
{
$roles = $this->roles;
foreach ($this->getGroups() as $group) {
/** @noinspection SlowArrayOperationsInLoopInspection */
$roles = array_merge($roles, $group->getRoles());
}
// we need to make sure to have at least one role
$roles[] = static::ROLE_DEFAULT;
return array_unique($roles);
} | php | public function getRoles()
{
$roles = $this->roles;
foreach ($this->getGroups() as $group) {
/** @noinspection SlowArrayOperationsInLoopInspection */
$roles = array_merge($roles, $group->getRoles());
}
// we need to make sure to have at least one role
$roles[] = static::ROLE_DEFAULT;
return array_unique($roles);
} | [
"public",
"function",
"getRoles",
"(",
")",
"{",
"$",
"roles",
"=",
"$",
"this",
"->",
"roles",
";",
"foreach",
"(",
"$",
"this",
"->",
"getGroups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"/** @noinspection SlowArrayOperationsInLoopInspection */",
"$",
"roles",
"=",
"array_merge",
"(",
"$",
"roles",
",",
"$",
"group",
"->",
"getRoles",
"(",
")",
")",
";",
"}",
"// we need to make sure to have at least one role",
"$",
"roles",
"[",
"]",
"=",
"static",
"::",
"ROLE_DEFAULT",
";",
"return",
"array_unique",
"(",
"$",
"roles",
")",
";",
"}"
]
| Returns the user roles.
@return array The roles | [
"Returns",
"the",
"user",
"roles",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/UserBundle/Entity/User.php#L303-L316 | train |
cleverage/eav-manager | AdminBundle/Controller/InlineEAVDataController.php | InlineEAVDataController.previewAction | public function previewAction(Request $request, DataInterface $data)
{
return $this->editAction($request, $data, $data->getFamily());
} | php | public function previewAction(Request $request, DataInterface $data)
{
return $this->editAction($request, $data, $data->getFamily());
} | [
"public",
"function",
"previewAction",
"(",
"Request",
"$",
"request",
",",
"DataInterface",
"$",
"data",
")",
"{",
"return",
"$",
"this",
"->",
"editAction",
"(",
"$",
"request",
",",
"$",
"data",
",",
"$",
"data",
"->",
"getFamily",
"(",
")",
")",
";",
"}"
]
| Alias for edit action but with custom form options
@param Request $request
@param DataInterface $data
@throws \Exception
@return Response | [
"Alias",
"for",
"edit",
"action",
"but",
"with",
"custom",
"form",
"options"
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/AdminBundle/Controller/InlineEAVDataController.php#L58-L61 | train |
cleverage/eav-manager | EAVKernelBundleLoader.php | EAVKernelBundleLoader.getBundles | public static function getBundles(): array
{
// Dependencies
return [
// Required by SidusEAVBootstrapBundle
new \Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle(),
// Required by SidusFilterBundle
new \WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
// Required by SidusEAVBootstrapBundle
new \Pinano\Select2Bundle\PinanoSelect2Bundle(),
// Required by SidusFileUploadBundle
new \Oneup\UploaderBundle\OneupUploaderBundle(),
// Required by SidusFileUploadBundle
new \Oneup\FlysystemBundle\OneupFlysystemBundle(),
// Sidus bundles
// Base bundle containing many dependencies
new \Sidus\BaseBundle\SidusBaseBundle(),
// Base bundle for EAV model
new \Sidus\EAVModelBundle\SidusEAVModelBundle(),
// Data filtering based on user input
new \Sidus\FilterBundle\SidusFilterBundle(),
// Data filtering with EAV support
new \Sidus\EAVFilterBundle\SidusEAVFilterBundle(),
// Bootstrap integration + additional EAV components
new \Sidus\EAVBootstrapBundle\SidusEAVBootstrapBundle(),
// DataGrid made easy
new \Sidus\DataGridBundle\SidusDataGridBundle(),
// Easily attach file to doctrine's entities
new \Sidus\FileUploadBundle\SidusFileUploadBundle(),
// Very basic admin configuration in YML to regroup entities and route actions easily
new \Sidus\AdminBundle\SidusAdminBundle(),
// Additionnal Bundles
// TinyMCE WYSIWYG integration
new \Stfalcon\Bundle\TinymceBundle\StfalconTinymceBundle(),
// JS routing needed for TinyMCE extensions
new \FOS\JsRoutingBundle\FOSJsRoutingBundle(),
// Automatic image resizing
new \Liip\ImagineBundle\LiipImagineBundle(),
// Default cache system
new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
// Clever Process Bundle
new \CleverAge\ProcessBundle\CleverAgeProcessBundle(),
// Simple permission management
new \CleverAge\PermissionBundle\CleverAgePermissionBundle(),
// CleverAge EAVManager
new \CleverAge\EAVManager\EAVModelBundle\CleverAgeEAVManagerEAVModelBundle(),
new \CleverAge\EAVManager\LayoutBundle\CleverAgeEAVManagerLayoutBundle(),
new \CleverAge\EAVManager\AdminBundle\CleverAgeEAVManagerAdminBundle(),
new \CleverAge\EAVManager\UserBundle\CleverAgeEAVManagerUserBundle(),
new \CleverAge\EAVManager\SecurityBundle\CleverAgeEAVManagerSecurityBundle(),
new \CleverAge\EAVManager\AssetBundle\CleverAgeEAVManagerAssetBundle(),
new \CleverAge\EAVManager\ProcessBundle\CleverAgeEAVManagerProcessBundle(),
// ApiPlatformBundle support for EAV manager
new \CleverAge\EAVManager\ApiPlatformBundle\CleverAgeEAVManagerApiPlatformBundle(),
];
} | php | public static function getBundles(): array
{
// Dependencies
return [
// Required by SidusEAVBootstrapBundle
new \Mopa\Bundle\BootstrapBundle\MopaBootstrapBundle(),
// Required by SidusFilterBundle
new \WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
// Required by SidusEAVBootstrapBundle
new \Pinano\Select2Bundle\PinanoSelect2Bundle(),
// Required by SidusFileUploadBundle
new \Oneup\UploaderBundle\OneupUploaderBundle(),
// Required by SidusFileUploadBundle
new \Oneup\FlysystemBundle\OneupFlysystemBundle(),
// Sidus bundles
// Base bundle containing many dependencies
new \Sidus\BaseBundle\SidusBaseBundle(),
// Base bundle for EAV model
new \Sidus\EAVModelBundle\SidusEAVModelBundle(),
// Data filtering based on user input
new \Sidus\FilterBundle\SidusFilterBundle(),
// Data filtering with EAV support
new \Sidus\EAVFilterBundle\SidusEAVFilterBundle(),
// Bootstrap integration + additional EAV components
new \Sidus\EAVBootstrapBundle\SidusEAVBootstrapBundle(),
// DataGrid made easy
new \Sidus\DataGridBundle\SidusDataGridBundle(),
// Easily attach file to doctrine's entities
new \Sidus\FileUploadBundle\SidusFileUploadBundle(),
// Very basic admin configuration in YML to regroup entities and route actions easily
new \Sidus\AdminBundle\SidusAdminBundle(),
// Additionnal Bundles
// TinyMCE WYSIWYG integration
new \Stfalcon\Bundle\TinymceBundle\StfalconTinymceBundle(),
// JS routing needed for TinyMCE extensions
new \FOS\JsRoutingBundle\FOSJsRoutingBundle(),
// Automatic image resizing
new \Liip\ImagineBundle\LiipImagineBundle(),
// Default cache system
new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
// Clever Process Bundle
new \CleverAge\ProcessBundle\CleverAgeProcessBundle(),
// Simple permission management
new \CleverAge\PermissionBundle\CleverAgePermissionBundle(),
// CleverAge EAVManager
new \CleverAge\EAVManager\EAVModelBundle\CleverAgeEAVManagerEAVModelBundle(),
new \CleverAge\EAVManager\LayoutBundle\CleverAgeEAVManagerLayoutBundle(),
new \CleverAge\EAVManager\AdminBundle\CleverAgeEAVManagerAdminBundle(),
new \CleverAge\EAVManager\UserBundle\CleverAgeEAVManagerUserBundle(),
new \CleverAge\EAVManager\SecurityBundle\CleverAgeEAVManagerSecurityBundle(),
new \CleverAge\EAVManager\AssetBundle\CleverAgeEAVManagerAssetBundle(),
new \CleverAge\EAVManager\ProcessBundle\CleverAgeEAVManagerProcessBundle(),
// ApiPlatformBundle support for EAV manager
new \CleverAge\EAVManager\ApiPlatformBundle\CleverAgeEAVManagerApiPlatformBundle(),
];
} | [
"public",
"static",
"function",
"getBundles",
"(",
")",
":",
"array",
"{",
"// Dependencies",
"return",
"[",
"// Required by SidusEAVBootstrapBundle",
"new",
"\\",
"Mopa",
"\\",
"Bundle",
"\\",
"BootstrapBundle",
"\\",
"MopaBootstrapBundle",
"(",
")",
",",
"// Required by SidusFilterBundle",
"new",
"\\",
"WhiteOctober",
"\\",
"PagerfantaBundle",
"\\",
"WhiteOctoberPagerfantaBundle",
"(",
")",
",",
"// Required by SidusEAVBootstrapBundle",
"new",
"\\",
"Pinano",
"\\",
"Select2Bundle",
"\\",
"PinanoSelect2Bundle",
"(",
")",
",",
"// Required by SidusFileUploadBundle",
"new",
"\\",
"Oneup",
"\\",
"UploaderBundle",
"\\",
"OneupUploaderBundle",
"(",
")",
",",
"// Required by SidusFileUploadBundle",
"new",
"\\",
"Oneup",
"\\",
"FlysystemBundle",
"\\",
"OneupFlysystemBundle",
"(",
")",
",",
"// Sidus bundles",
"// Base bundle containing many dependencies",
"new",
"\\",
"Sidus",
"\\",
"BaseBundle",
"\\",
"SidusBaseBundle",
"(",
")",
",",
"// Base bundle for EAV model",
"new",
"\\",
"Sidus",
"\\",
"EAVModelBundle",
"\\",
"SidusEAVModelBundle",
"(",
")",
",",
"// Data filtering based on user input",
"new",
"\\",
"Sidus",
"\\",
"FilterBundle",
"\\",
"SidusFilterBundle",
"(",
")",
",",
"// Data filtering with EAV support",
"new",
"\\",
"Sidus",
"\\",
"EAVFilterBundle",
"\\",
"SidusEAVFilterBundle",
"(",
")",
",",
"// Bootstrap integration + additional EAV components",
"new",
"\\",
"Sidus",
"\\",
"EAVBootstrapBundle",
"\\",
"SidusEAVBootstrapBundle",
"(",
")",
",",
"// DataGrid made easy",
"new",
"\\",
"Sidus",
"\\",
"DataGridBundle",
"\\",
"SidusDataGridBundle",
"(",
")",
",",
"// Easily attach file to doctrine's entities",
"new",
"\\",
"Sidus",
"\\",
"FileUploadBundle",
"\\",
"SidusFileUploadBundle",
"(",
")",
",",
"// Very basic admin configuration in YML to regroup entities and route actions easily",
"new",
"\\",
"Sidus",
"\\",
"AdminBundle",
"\\",
"SidusAdminBundle",
"(",
")",
",",
"// Additionnal Bundles",
"// TinyMCE WYSIWYG integration",
"new",
"\\",
"Stfalcon",
"\\",
"Bundle",
"\\",
"TinymceBundle",
"\\",
"StfalconTinymceBundle",
"(",
")",
",",
"// JS routing needed for TinyMCE extensions",
"new",
"\\",
"FOS",
"\\",
"JsRoutingBundle",
"\\",
"FOSJsRoutingBundle",
"(",
")",
",",
"// Automatic image resizing",
"new",
"\\",
"Liip",
"\\",
"ImagineBundle",
"\\",
"LiipImagineBundle",
"(",
")",
",",
"// Default cache system",
"new",
"\\",
"Doctrine",
"\\",
"Bundle",
"\\",
"DoctrineCacheBundle",
"\\",
"DoctrineCacheBundle",
"(",
")",
",",
"// Clever Process Bundle",
"new",
"\\",
"CleverAge",
"\\",
"ProcessBundle",
"\\",
"CleverAgeProcessBundle",
"(",
")",
",",
"// Simple permission management",
"new",
"\\",
"CleverAge",
"\\",
"PermissionBundle",
"\\",
"CleverAgePermissionBundle",
"(",
")",
",",
"// CleverAge EAVManager",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"EAVModelBundle",
"\\",
"CleverAgeEAVManagerEAVModelBundle",
"(",
")",
",",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"LayoutBundle",
"\\",
"CleverAgeEAVManagerLayoutBundle",
"(",
")",
",",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"AdminBundle",
"\\",
"CleverAgeEAVManagerAdminBundle",
"(",
")",
",",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"UserBundle",
"\\",
"CleverAgeEAVManagerUserBundle",
"(",
")",
",",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"SecurityBundle",
"\\",
"CleverAgeEAVManagerSecurityBundle",
"(",
")",
",",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"AssetBundle",
"\\",
"CleverAgeEAVManagerAssetBundle",
"(",
")",
",",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"ProcessBundle",
"\\",
"CleverAgeEAVManagerProcessBundle",
"(",
")",
",",
"// ApiPlatformBundle support for EAV manager",
"new",
"\\",
"CleverAge",
"\\",
"EAVManager",
"\\",
"ApiPlatformBundle",
"\\",
"CleverAgeEAVManagerApiPlatformBundle",
"(",
")",
",",
"]",
";",
"}"
]
| Return the required bundles.
@return array | [
"Return",
"the",
"required",
"bundles",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/EAVKernelBundleLoader.php#L23-L84 | train |
php-api-clients/pusher | src/AsyncClient.php | AsyncClient.channel | public function channel(string $channel): Observable
{
// Only join a channel once
if (isset($this->channels[$channel])) {
return $this->channels[$channel];
}
// Ensure we only get messages for the given channel
$channelMessages = $this->messages->filter(function (Event $event) use ($channel) {
return $event->getChannel() !== '' && $event->getChannel() === $channel;
});
$subscribe = $this->connected
->do(function () use ($channel) {
// Subscribe to pusher channel after connected
$this->send(Event::subscribeOn($channel));
})
->flatMapTo(Observable::empty());
// Observable representing channel events
$this->channels[$channel] = $channelMessages
->merge($subscribe)
->filter([Event::class, 'subscriptionSucceeded'])
->retryWhen(function (Observable $errors) {
return $errors->flatMap(function (Throwable $throwable) {
return $this->handleLowLevelError($throwable);
});
})
->finally(function () use ($channel) {
// Send unsubscribe event
$this->send(Event::unsubscribeOn($channel));
// Remove our channel from the channel list so we don't resubscribe in case we reconnect
unset($this->channels[$channel]);
})
->singleInstance();
return $this->channels[$channel];
} | php | public function channel(string $channel): Observable
{
// Only join a channel once
if (isset($this->channels[$channel])) {
return $this->channels[$channel];
}
// Ensure we only get messages for the given channel
$channelMessages = $this->messages->filter(function (Event $event) use ($channel) {
return $event->getChannel() !== '' && $event->getChannel() === $channel;
});
$subscribe = $this->connected
->do(function () use ($channel) {
// Subscribe to pusher channel after connected
$this->send(Event::subscribeOn($channel));
})
->flatMapTo(Observable::empty());
// Observable representing channel events
$this->channels[$channel] = $channelMessages
->merge($subscribe)
->filter([Event::class, 'subscriptionSucceeded'])
->retryWhen(function (Observable $errors) {
return $errors->flatMap(function (Throwable $throwable) {
return $this->handleLowLevelError($throwable);
});
})
->finally(function () use ($channel) {
// Send unsubscribe event
$this->send(Event::unsubscribeOn($channel));
// Remove our channel from the channel list so we don't resubscribe in case we reconnect
unset($this->channels[$channel]);
})
->singleInstance();
return $this->channels[$channel];
} | [
"public",
"function",
"channel",
"(",
"string",
"$",
"channel",
")",
":",
"Observable",
"{",
"// Only join a channel once",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"channel",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"channels",
"[",
"$",
"channel",
"]",
";",
"}",
"// Ensure we only get messages for the given channel",
"$",
"channelMessages",
"=",
"$",
"this",
"->",
"messages",
"->",
"filter",
"(",
"function",
"(",
"Event",
"$",
"event",
")",
"use",
"(",
"$",
"channel",
")",
"{",
"return",
"$",
"event",
"->",
"getChannel",
"(",
")",
"!==",
"''",
"&&",
"$",
"event",
"->",
"getChannel",
"(",
")",
"===",
"$",
"channel",
";",
"}",
")",
";",
"$",
"subscribe",
"=",
"$",
"this",
"->",
"connected",
"->",
"do",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"channel",
")",
"{",
"// Subscribe to pusher channel after connected",
"$",
"this",
"->",
"send",
"(",
"Event",
"::",
"subscribeOn",
"(",
"$",
"channel",
")",
")",
";",
"}",
")",
"->",
"flatMapTo",
"(",
"Observable",
"::",
"empty",
"(",
")",
")",
";",
"// Observable representing channel events",
"$",
"this",
"->",
"channels",
"[",
"$",
"channel",
"]",
"=",
"$",
"channelMessages",
"->",
"merge",
"(",
"$",
"subscribe",
")",
"->",
"filter",
"(",
"[",
"Event",
"::",
"class",
",",
"'subscriptionSucceeded'",
"]",
")",
"->",
"retryWhen",
"(",
"function",
"(",
"Observable",
"$",
"errors",
")",
"{",
"return",
"$",
"errors",
"->",
"flatMap",
"(",
"function",
"(",
"Throwable",
"$",
"throwable",
")",
"{",
"return",
"$",
"this",
"->",
"handleLowLevelError",
"(",
"$",
"throwable",
")",
";",
"}",
")",
";",
"}",
")",
"->",
"finally",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"channel",
")",
"{",
"// Send unsubscribe event",
"$",
"this",
"->",
"send",
"(",
"Event",
"::",
"unsubscribeOn",
"(",
"$",
"channel",
")",
")",
";",
"// Remove our channel from the channel list so we don't resubscribe in case we reconnect",
"unset",
"(",
"$",
"this",
"->",
"channels",
"[",
"$",
"channel",
"]",
")",
";",
"}",
")",
"->",
"singleInstance",
"(",
")",
";",
"return",
"$",
"this",
"->",
"channels",
"[",
"$",
"channel",
"]",
";",
"}"
]
| Listen on a channel.
@param string $channel Channel to listen on
@throws \InvalidArgumentException
@return Observable | [
"Listen",
"on",
"a",
"channel",
"."
]
| 446f852af1ae17fa732481900da40b080e5c4cf3 | https://github.com/php-api-clients/pusher/blob/446f852af1ae17fa732481900da40b080e5c4cf3/src/AsyncClient.php#L111-L149 | train |
php-api-clients/pusher | src/AsyncClient.php | AsyncClient.timeout | private function timeout(Observable $events): Observable
{
$timeoutDuration = $this->connected->map(function (Event $event) {
return ($event->getData()['activity_timeout'] ?? self::NO_ACTIVITY_TIMEOUT) * 1000;
});
return $timeoutDuration
->combineLatest([$events])
->pluck(0)
->concat(Observable::of(-1))
->flatMapLatest(function (int $time) {
// If the events observable ends, return an empty observable so we don't keep the stream alive
if ($time === -1) {
return Observable::empty();
}
return Observable::never()
->timeout($time)
->catch(function () use ($time) {
// ping (do something that causes incoming stream to get a message)
$this->send(Event::ping());
// this timeout will actually timeout with a TimeoutException - causing
// everything above this to dispose
return Observable::never()->timeout($time);
});
});
} | php | private function timeout(Observable $events): Observable
{
$timeoutDuration = $this->connected->map(function (Event $event) {
return ($event->getData()['activity_timeout'] ?? self::NO_ACTIVITY_TIMEOUT) * 1000;
});
return $timeoutDuration
->combineLatest([$events])
->pluck(0)
->concat(Observable::of(-1))
->flatMapLatest(function (int $time) {
// If the events observable ends, return an empty observable so we don't keep the stream alive
if ($time === -1) {
return Observable::empty();
}
return Observable::never()
->timeout($time)
->catch(function () use ($time) {
// ping (do something that causes incoming stream to get a message)
$this->send(Event::ping());
// this timeout will actually timeout with a TimeoutException - causing
// everything above this to dispose
return Observable::never()->timeout($time);
});
});
} | [
"private",
"function",
"timeout",
"(",
"Observable",
"$",
"events",
")",
":",
"Observable",
"{",
"$",
"timeoutDuration",
"=",
"$",
"this",
"->",
"connected",
"->",
"map",
"(",
"function",
"(",
"Event",
"$",
"event",
")",
"{",
"return",
"(",
"$",
"event",
"->",
"getData",
"(",
")",
"[",
"'activity_timeout'",
"]",
"??",
"self",
"::",
"NO_ACTIVITY_TIMEOUT",
")",
"*",
"1000",
";",
"}",
")",
";",
"return",
"$",
"timeoutDuration",
"->",
"combineLatest",
"(",
"[",
"$",
"events",
"]",
")",
"->",
"pluck",
"(",
"0",
")",
"->",
"concat",
"(",
"Observable",
"::",
"of",
"(",
"-",
"1",
")",
")",
"->",
"flatMapLatest",
"(",
"function",
"(",
"int",
"$",
"time",
")",
"{",
"// If the events observable ends, return an empty observable so we don't keep the stream alive",
"if",
"(",
"$",
"time",
"===",
"-",
"1",
")",
"{",
"return",
"Observable",
"::",
"empty",
"(",
")",
";",
"}",
"return",
"Observable",
"::",
"never",
"(",
")",
"->",
"timeout",
"(",
"$",
"time",
")",
"->",
"catch",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"time",
")",
"{",
"// ping (do something that causes incoming stream to get a message)",
"$",
"this",
"->",
"send",
"(",
"Event",
"::",
"ping",
"(",
")",
")",
";",
"// this timeout will actually timeout with a TimeoutException - causing",
"// everything above this to dispose",
"return",
"Observable",
"::",
"never",
"(",
")",
"->",
"timeout",
"(",
"$",
"time",
")",
";",
"}",
")",
";",
"}",
")",
";",
"}"
]
| Returns an observable of TimeoutException.
The timeout observable will get cancelled every time a new event is received.
@param Observable $events
@return Observable | [
"Returns",
"an",
"observable",
"of",
"TimeoutException",
".",
"The",
"timeout",
"observable",
"will",
"get",
"cancelled",
"every",
"time",
"a",
"new",
"event",
"is",
"received",
"."
]
| 446f852af1ae17fa732481900da40b080e5c4cf3 | https://github.com/php-api-clients/pusher/blob/446f852af1ae17fa732481900da40b080e5c4cf3/src/AsyncClient.php#L169-L196 | train |
cleverage/eav-manager | ApiPlatformBundle/Metadata/Property/Factory/EAVPropertyNameCollectionFactory.php | EAVPropertyNameCollectionFactory.create | public function create(string $resourceClass, array $options = []): PropertyNameCollection
{
$propertyNameCollection = $this->propertyNameCollectionFactory->create($resourceClass, $options);
if (is_a($resourceClass, DataInterface::class, true)) {
$resolvedProperties = [];
foreach ($propertyNameCollection as $propertyName) {
if (!\in_array($propertyName, $this->ignoredAttributes, true)) {
$resolvedProperties[] = $propertyName;
}
}
$propertyNameCollection = new PropertyNameCollection($resolvedProperties);
}
return $propertyNameCollection;
} | php | public function create(string $resourceClass, array $options = []): PropertyNameCollection
{
$propertyNameCollection = $this->propertyNameCollectionFactory->create($resourceClass, $options);
if (is_a($resourceClass, DataInterface::class, true)) {
$resolvedProperties = [];
foreach ($propertyNameCollection as $propertyName) {
if (!\in_array($propertyName, $this->ignoredAttributes, true)) {
$resolvedProperties[] = $propertyName;
}
}
$propertyNameCollection = new PropertyNameCollection($resolvedProperties);
}
return $propertyNameCollection;
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"resourceClass",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"PropertyNameCollection",
"{",
"$",
"propertyNameCollection",
"=",
"$",
"this",
"->",
"propertyNameCollectionFactory",
"->",
"create",
"(",
"$",
"resourceClass",
",",
"$",
"options",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"resourceClass",
",",
"DataInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"$",
"resolvedProperties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"propertyNameCollection",
"as",
"$",
"propertyName",
")",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"propertyName",
",",
"$",
"this",
"->",
"ignoredAttributes",
",",
"true",
")",
")",
"{",
"$",
"resolvedProperties",
"[",
"]",
"=",
"$",
"propertyName",
";",
"}",
"}",
"$",
"propertyNameCollection",
"=",
"new",
"PropertyNameCollection",
"(",
"$",
"resolvedProperties",
")",
";",
"}",
"return",
"$",
"propertyNameCollection",
";",
"}"
]
| Creates the property name collection for the given class and options.
@param string $resourceClass
@param array $options
@throws ResourceClassNotFoundException
@return PropertyNameCollection | [
"Creates",
"the",
"property",
"name",
"collection",
"for",
"the",
"given",
"class",
"and",
"options",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/ApiPlatformBundle/Metadata/Property/Factory/EAVPropertyNameCollectionFactory.php#L60-L74 | train |
cleverage/eav-manager | ApiPlatformBundle/Metadata/Property/Factory/FamilyPropertyMetadataFactory.php | FamilyPropertyMetadataFactory.create | public function create(string $resourceClass, string $property, array $options = []): PropertyMetadata
{
$propertyMetadata = $this->propertyMetadata->create($resourceClass, $property, $options);
if ('code' === $property && is_a($resourceClass, FamilyInterface::class, true)) {
return $propertyMetadata->withIdentifier(true);
}
return $propertyMetadata;
} | php | public function create(string $resourceClass, string $property, array $options = []): PropertyMetadata
{
$propertyMetadata = $this->propertyMetadata->create($resourceClass, $property, $options);
if ('code' === $property && is_a($resourceClass, FamilyInterface::class, true)) {
return $propertyMetadata->withIdentifier(true);
}
return $propertyMetadata;
} | [
"public",
"function",
"create",
"(",
"string",
"$",
"resourceClass",
",",
"string",
"$",
"property",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"PropertyMetadata",
"{",
"$",
"propertyMetadata",
"=",
"$",
"this",
"->",
"propertyMetadata",
"->",
"create",
"(",
"$",
"resourceClass",
",",
"$",
"property",
",",
"$",
"options",
")",
";",
"if",
"(",
"'code'",
"===",
"$",
"property",
"&&",
"is_a",
"(",
"$",
"resourceClass",
",",
"FamilyInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"return",
"$",
"propertyMetadata",
"->",
"withIdentifier",
"(",
"true",
")",
";",
"}",
"return",
"$",
"propertyMetadata",
";",
"}"
]
| Creates a property metadata.
@param string $resourceClass
@param string $property
@param array $options
@throws PropertyNotFoundException
@return PropertyMetadata | [
"Creates",
"a",
"property",
"metadata",
"."
]
| 20fc8dd72a3213537ec241f564a2aaf5d315cd2d | https://github.com/cleverage/eav-manager/blob/20fc8dd72a3213537ec241f564a2aaf5d315cd2d/ApiPlatformBundle/Metadata/Property/Factory/FamilyPropertyMetadataFactory.php#L47-L56 | train |
artkonekt/enum | src/Enum.php | Enum.equals | public function equals($object)
{
if (!($object instanceof self) || !self::compatibles(get_class($object), static::class)) {
return false;
}
return $this->value() == $object->value();
} | php | public function equals($object)
{
if (!($object instanceof self) || !self::compatibles(get_class($object), static::class)) {
return false;
}
return $this->value() == $object->value();
} | [
"public",
"function",
"equals",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"object",
"instanceof",
"self",
")",
"||",
"!",
"self",
"::",
"compatibles",
"(",
"get_class",
"(",
"$",
"object",
")",
",",
"static",
"::",
"class",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"this",
"->",
"value",
"(",
")",
"==",
"$",
"object",
"->",
"value",
"(",
")",
";",
"}"
]
| Checks if two enums are equal. Value and class are both matched.
Value check is not type strict.
@param mixed $object
@return bool True if enums are equal | [
"Checks",
"if",
"two",
"enums",
"are",
"equal",
".",
"Value",
"and",
"class",
"are",
"both",
"matched",
".",
"Value",
"check",
"is",
"not",
"type",
"strict",
"."
]
| 303bd76f0d19d328f99eb11510655c0a64b90c77 | https://github.com/artkonekt/enum/blob/303bd76f0d19d328f99eb11510655c0a64b90c77/src/Enum.php#L84-L91 | train |
artkonekt/enum | src/Enum.php | Enum.labels | public static function labels()
{
self::bootClass();
$result = [];
foreach (static::values() as $value) {
$result[] = static::getLabel($value);
}
return $result;
} | php | public static function labels()
{
self::bootClass();
$result = [];
foreach (static::values() as $value) {
$result[] = static::getLabel($value);
}
return $result;
} | [
"public",
"static",
"function",
"labels",
"(",
")",
"{",
"self",
"::",
"bootClass",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"values",
"(",
")",
"as",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"static",
"::",
"getLabel",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Returns the array of labels.
@return array | [
"Returns",
"the",
"array",
"of",
"labels",
"."
]
| 303bd76f0d19d328f99eb11510655c0a64b90c77 | https://github.com/artkonekt/enum/blob/303bd76f0d19d328f99eb11510655c0a64b90c77/src/Enum.php#L252-L263 | train |
artkonekt/enum | src/Enum.php | Enum.choices | public static function choices()
{
self::bootClass();
$result = [];
foreach (static::values() as $value) {
$result[$value] = static::getLabel($value);
}
return $result;
} | php | public static function choices()
{
self::bootClass();
$result = [];
foreach (static::values() as $value) {
$result[$value] = static::getLabel($value);
}
return $result;
} | [
"public",
"static",
"function",
"choices",
"(",
")",
"{",
"self",
"::",
"bootClass",
"(",
")",
";",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"static",
"::",
"values",
"(",
")",
"as",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"$",
"value",
"]",
"=",
"static",
"::",
"getLabel",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Returns an array of value => label pairs.
Ready to pass to dropdowns.
Example:
```
const FOO = 'foo';
const BAR = 'bar'
protected static $labels = [
self::FOO => 'I am foo',
self::BAR => 'I am bar'
];
```
self::choices returns:
```
[
'foo' => 'I am foo',
'bar' => 'I am bar'
]
```
@return array | [
"Returns",
"an",
"array",
"of",
"value",
"=",
">",
"label",
"pairs",
".",
"Ready",
"to",
"pass",
"to",
"dropdowns",
"."
]
| 303bd76f0d19d328f99eb11510655c0a64b90c77 | https://github.com/artkonekt/enum/blob/303bd76f0d19d328f99eb11510655c0a64b90c77/src/Enum.php#L289-L300 | train |
artkonekt/enum | src/Enum.php | Enum.bootClass | private static function bootClass()
{
if (!array_key_exists(static::class, self::$meta)) {
self::$meta[static::class] = (new \ReflectionClass(static::class))->getConstants();
unset(self::$meta[static::class]['__default']);
if (method_exists(static::class, 'boot')) {
static::boot();
}
}
} | php | private static function bootClass()
{
if (!array_key_exists(static::class, self::$meta)) {
self::$meta[static::class] = (new \ReflectionClass(static::class))->getConstants();
unset(self::$meta[static::class]['__default']);
if (method_exists(static::class, 'boot')) {
static::boot();
}
}
} | [
"private",
"static",
"function",
"bootClass",
"(",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"static",
"::",
"class",
",",
"self",
"::",
"$",
"meta",
")",
")",
"{",
"self",
"::",
"$",
"meta",
"[",
"static",
"::",
"class",
"]",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"static",
"::",
"class",
")",
")",
"->",
"getConstants",
"(",
")",
";",
"unset",
"(",
"self",
"::",
"$",
"meta",
"[",
"static",
"::",
"class",
"]",
"[",
"'__default'",
"]",
")",
";",
"if",
"(",
"method_exists",
"(",
"static",
"::",
"class",
",",
"'boot'",
")",
")",
"{",
"static",
"::",
"boot",
"(",
")",
";",
"}",
"}",
"}"
]
| Initializes the constants array for the class if necessary. | [
"Initializes",
"the",
"constants",
"array",
"for",
"the",
"class",
"if",
"necessary",
"."
]
| 303bd76f0d19d328f99eb11510655c0a64b90c77 | https://github.com/artkonekt/enum/blob/303bd76f0d19d328f99eb11510655c0a64b90c77/src/Enum.php#L345-L355 | train |
artkonekt/enum | src/Enum.php | Enum.getLabel | private static function getLabel($value)
{
self::bootClass();
if (static::hasLabels() && isset(static::$labels[$value])) {
return (string) static::$labels[$value];
}
return (string) $value;
} | php | private static function getLabel($value)
{
self::bootClass();
if (static::hasLabels() && isset(static::$labels[$value])) {
return (string) static::$labels[$value];
}
return (string) $value;
} | [
"private",
"static",
"function",
"getLabel",
"(",
"$",
"value",
")",
"{",
"self",
"::",
"bootClass",
"(",
")",
";",
"if",
"(",
"static",
"::",
"hasLabels",
"(",
")",
"&&",
"isset",
"(",
"static",
"::",
"$",
"labels",
"[",
"$",
"value",
"]",
")",
")",
"{",
"return",
"(",
"string",
")",
"static",
"::",
"$",
"labels",
"[",
"$",
"value",
"]",
";",
"}",
"return",
"(",
"string",
")",
"$",
"value",
";",
"}"
]
| Returns the label for a given value.
!!Make sure it only gets called after bootClass()!!
@param $value
@return string | [
"Returns",
"the",
"label",
"for",
"a",
"given",
"value",
"."
]
| 303bd76f0d19d328f99eb11510655c0a64b90c77 | https://github.com/artkonekt/enum/blob/303bd76f0d19d328f99eb11510655c0a64b90c77/src/Enum.php#L397-L406 | train |
contao-bootstrap/form | src/FormLayout/AbstractBootstrapFormLayout.php | AbstractBootstrapFormLayout.getInputGroup | public function getInputGroup(Widget $widget)
{
if ($this->widgetConfig[$widget->type]['input_group'] && $widget->bs_addInputGroup) {
return InputGroupHelper::forWidget($widget);
}
return null;
} | php | public function getInputGroup(Widget $widget)
{
if ($this->widgetConfig[$widget->type]['input_group'] && $widget->bs_addInputGroup) {
return InputGroupHelper::forWidget($widget);
}
return null;
} | [
"public",
"function",
"getInputGroup",
"(",
"Widget",
"$",
"widget",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"widgetConfig",
"[",
"$",
"widget",
"->",
"type",
"]",
"[",
"'input_group'",
"]",
"&&",
"$",
"widget",
"->",
"bs_addInputGroup",
")",
"{",
"return",
"InputGroupHelper",
"::",
"forWidget",
"(",
"$",
"widget",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Get the input group.
@param Widget $widget Widget.
@return InputGroupHelper | [
"Get",
"the",
"input",
"group",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/FormLayout/AbstractBootstrapFormLayout.php#L100-L107 | train |
contao-bootstrap/form | src/FormLayout/AbstractBootstrapFormLayout.php | AbstractBootstrapFormLayout.getTemplate | protected function getTemplate(Widget $widget, string $section): string
{
if ($section === 'help' && empty($this->widgetConfig[$widget->type]['help'])) {
return '';
}
if (isset($this->widgetConfig[$widget->type]['templates'][$section])) {
return $this->widgetConfig[$widget->type]['templates'][$section];
}
if (isset($this->fallbackConfig['templates'][$section])) {
return $this->fallbackConfig['templates'][$section];
}
return '';
} | php | protected function getTemplate(Widget $widget, string $section): string
{
if ($section === 'help' && empty($this->widgetConfig[$widget->type]['help'])) {
return '';
}
if (isset($this->widgetConfig[$widget->type]['templates'][$section])) {
return $this->widgetConfig[$widget->type]['templates'][$section];
}
if (isset($this->fallbackConfig['templates'][$section])) {
return $this->fallbackConfig['templates'][$section];
}
return '';
} | [
"protected",
"function",
"getTemplate",
"(",
"Widget",
"$",
"widget",
",",
"string",
"$",
"section",
")",
":",
"string",
"{",
"if",
"(",
"$",
"section",
"===",
"'help'",
"&&",
"empty",
"(",
"$",
"this",
"->",
"widgetConfig",
"[",
"$",
"widget",
"->",
"type",
"]",
"[",
"'help'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"widgetConfig",
"[",
"$",
"widget",
"->",
"type",
"]",
"[",
"'templates'",
"]",
"[",
"$",
"section",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"widgetConfig",
"[",
"$",
"widget",
"->",
"type",
"]",
"[",
"'templates'",
"]",
"[",
"$",
"section",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"fallbackConfig",
"[",
"'templates'",
"]",
"[",
"$",
"section",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"fallbackConfig",
"[",
"'templates'",
"]",
"[",
"$",
"section",
"]",
";",
"}",
"return",
"''",
";",
"}"
]
| Get a template for a section.
@param Widget $widget Widget.
@param string $section Section.
@return string | [
"Get",
"a",
"template",
"for",
"a",
"section",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/FormLayout/AbstractBootstrapFormLayout.php#L117-L132 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Handler.php | Handler.fire | protected function fire($action, $params)
{
if(!isset($this->events[$action])){
throw new HandlerException('Action handler not exists', HandlerException::ACTION_HANDLER_NOT_EXISTS);
}
// prepare params array for handler
// we provide a client library as a param for further requests
$callbackParams = $params;
$callbackParams['client'] = $this->getClient();
$callbackParams = new \ArrayObject($callbackParams, \ArrayObject::STD_PROP_LIST);
// fire handlers for every event
foreach($this->events[$action] as $e){
$result = call_user_func($e, $callbackParams);
if(!$result){
break;
}
}
} | php | protected function fire($action, $params)
{
if(!isset($this->events[$action])){
throw new HandlerException('Action handler not exists', HandlerException::ACTION_HANDLER_NOT_EXISTS);
}
// prepare params array for handler
// we provide a client library as a param for further requests
$callbackParams = $params;
$callbackParams['client'] = $this->getClient();
$callbackParams = new \ArrayObject($callbackParams, \ArrayObject::STD_PROP_LIST);
// fire handlers for every event
foreach($this->events[$action] as $e){
$result = call_user_func($e, $callbackParams);
if(!$result){
break;
}
}
} | [
"protected",
"function",
"fire",
"(",
"$",
"action",
",",
"$",
"params",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"action",
"]",
")",
")",
"{",
"throw",
"new",
"HandlerException",
"(",
"'Action handler not exists'",
",",
"HandlerException",
"::",
"ACTION_HANDLER_NOT_EXISTS",
")",
";",
"}",
"// prepare params array for handler",
"// we provide a client library as a param for further requests",
"$",
"callbackParams",
"=",
"$",
"params",
";",
"$",
"callbackParams",
"[",
"'client'",
"]",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
";",
"$",
"callbackParams",
"=",
"new",
"\\",
"ArrayObject",
"(",
"$",
"callbackParams",
",",
"\\",
"ArrayObject",
"::",
"STD_PROP_LIST",
")",
";",
"// fire handlers for every event",
"foreach",
"(",
"$",
"this",
"->",
"events",
"[",
"$",
"action",
"]",
"as",
"$",
"e",
")",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"e",
",",
"$",
"callbackParams",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"break",
";",
"}",
"}",
"}"
]
| fires handlers for a specific action
@param $action
@param $params
@throws HandlerException | [
"fires",
"handlers",
"for",
"a",
"specific",
"action"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Handler.php#L153-L173 | train |
devgeniem/wp-no-admin-ajax | plugin.php | No_Admin_Ajax.redirect_ajax_url | public function redirect_ajax_url( $url, $path, $blog_id ) {
if( strpos( $url, 'admin-ajax' ) ) {
return home_url( "/". $this->keyword ."/" );
}
else {
return $url;
}
} | php | public function redirect_ajax_url( $url, $path, $blog_id ) {
if( strpos( $url, 'admin-ajax' ) ) {
return home_url( "/". $this->keyword ."/" );
}
else {
return $url;
}
} | [
"public",
"function",
"redirect_ajax_url",
"(",
"$",
"url",
",",
"$",
"path",
",",
"$",
"blog_id",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"'admin-ajax'",
")",
")",
"{",
"return",
"home_url",
"(",
"\"/\"",
".",
"$",
"this",
"->",
"keyword",
".",
"\"/\"",
")",
";",
"}",
"else",
"{",
"return",
"$",
"url",
";",
"}",
"}"
]
| Function that handles rewriting the admin-ajax url to the one we want | [
"Function",
"that",
"handles",
"rewriting",
"the",
"admin",
"-",
"ajax",
"url",
"to",
"the",
"one",
"we",
"want"
]
| ebee2d29870e03dc7db0b584acbaa891c08c48b0 | https://github.com/devgeniem/wp-no-admin-ajax/blob/ebee2d29870e03dc7db0b584acbaa891c08c48b0/plugin.php#L56-L63 | train |
devgeniem/wp-no-admin-ajax | plugin.php | No_Admin_Ajax.rewrite | public function rewrite() {
global $wp_rewrite;
add_rewrite_tag( "%no-admin-ajax%", "([0-9]+)" );
// The whole ajax url matching pattern can be altered with filter "no-admin-ajax/rule"
$default_rule = "^". $this->keyword ."/?$";
$rule = apply_filters( "no-admin-ajax/rule", $default_rule );
add_rewrite_rule(
$rule,
"index.php?no-admin-ajax=true",
"top"
);
} | php | public function rewrite() {
global $wp_rewrite;
add_rewrite_tag( "%no-admin-ajax%", "([0-9]+)" );
// The whole ajax url matching pattern can be altered with filter "no-admin-ajax/rule"
$default_rule = "^". $this->keyword ."/?$";
$rule = apply_filters( "no-admin-ajax/rule", $default_rule );
add_rewrite_rule(
$rule,
"index.php?no-admin-ajax=true",
"top"
);
} | [
"public",
"function",
"rewrite",
"(",
")",
"{",
"global",
"$",
"wp_rewrite",
";",
"add_rewrite_tag",
"(",
"\"%no-admin-ajax%\"",
",",
"\"([0-9]+)\"",
")",
";",
"// The whole ajax url matching pattern can be altered with filter \"no-admin-ajax/rule\"",
"$",
"default_rule",
"=",
"\"^\"",
".",
"$",
"this",
"->",
"keyword",
".",
"\"/?$\"",
";",
"$",
"rule",
"=",
"apply_filters",
"(",
"\"no-admin-ajax/rule\"",
",",
"$",
"default_rule",
")",
";",
"add_rewrite_rule",
"(",
"$",
"rule",
",",
"\"index.php?no-admin-ajax=true\"",
",",
"\"top\"",
")",
";",
"}"
]
| Creates the rewrite | [
"Creates",
"the",
"rewrite"
]
| ebee2d29870e03dc7db0b584acbaa891c08c48b0 | https://github.com/devgeniem/wp-no-admin-ajax/blob/ebee2d29870e03dc7db0b584acbaa891c08c48b0/plugin.php#L66-L81 | train |
devgeniem/wp-no-admin-ajax | plugin.php | No_Admin_Ajax.run_ajax | public function run_ajax() {
global $wp_query;
if ( $wp_query->get("no-admin-ajax") ) {
// Constant for plugins to know that we are on an AJAX request
define("DOING_AJAX", true);
// If we don't have an action, do nothing
if ( ! isset( $_REQUEST["action"] ) ) {
die(0);
}
// Escape the parameter to prevent disastrous things
$action = esc_attr( $_REQUEST["action"] );
// Run customized no-admin-ajax methods with action "no-admin-ajax/before"
do_action( "no-admin-ajax/before" );
// Run customized no-admin-ajax methods for specific ajax actions with "no-admin-ajax/before/{action}"
do_action( "no-admin-ajax/before/". $action );
// Same headers as WordPress normal AJAX routine sends
$default_headers = array(
"Content-Type: text/html; charset=" . get_option( "blog_charset" ),
"X-Robots-Tag: noindex"
);
// Filter to customize the headers sent by ajax calls
$headers = apply_filters( "no-admin-ajax/headers", $default_headers );
// Send the headers to the user
if ( is_array( $headers ) && count( $headers ) > 0 ) {
foreach ( $headers as $header ) {
@header( $header );
}
}
send_nosniff_header();
nocache_headers();
// Run the actions
if(is_user_logged_in()) {
do_action( "wp_ajax_" . $action );
}
else {
do_action( "wp_ajax_nopriv_" . $action );
}
die(0);
}
} | php | public function run_ajax() {
global $wp_query;
if ( $wp_query->get("no-admin-ajax") ) {
// Constant for plugins to know that we are on an AJAX request
define("DOING_AJAX", true);
// If we don't have an action, do nothing
if ( ! isset( $_REQUEST["action"] ) ) {
die(0);
}
// Escape the parameter to prevent disastrous things
$action = esc_attr( $_REQUEST["action"] );
// Run customized no-admin-ajax methods with action "no-admin-ajax/before"
do_action( "no-admin-ajax/before" );
// Run customized no-admin-ajax methods for specific ajax actions with "no-admin-ajax/before/{action}"
do_action( "no-admin-ajax/before/". $action );
// Same headers as WordPress normal AJAX routine sends
$default_headers = array(
"Content-Type: text/html; charset=" . get_option( "blog_charset" ),
"X-Robots-Tag: noindex"
);
// Filter to customize the headers sent by ajax calls
$headers = apply_filters( "no-admin-ajax/headers", $default_headers );
// Send the headers to the user
if ( is_array( $headers ) && count( $headers ) > 0 ) {
foreach ( $headers as $header ) {
@header( $header );
}
}
send_nosniff_header();
nocache_headers();
// Run the actions
if(is_user_logged_in()) {
do_action( "wp_ajax_" . $action );
}
else {
do_action( "wp_ajax_nopriv_" . $action );
}
die(0);
}
} | [
"public",
"function",
"run_ajax",
"(",
")",
"{",
"global",
"$",
"wp_query",
";",
"if",
"(",
"$",
"wp_query",
"->",
"get",
"(",
"\"no-admin-ajax\"",
")",
")",
"{",
"// Constant for plugins to know that we are on an AJAX request",
"define",
"(",
"\"DOING_AJAX\"",
",",
"true",
")",
";",
"// If we don't have an action, do nothing",
"if",
"(",
"!",
"isset",
"(",
"$",
"_REQUEST",
"[",
"\"action\"",
"]",
")",
")",
"{",
"die",
"(",
"0",
")",
";",
"}",
"// Escape the parameter to prevent disastrous things",
"$",
"action",
"=",
"esc_attr",
"(",
"$",
"_REQUEST",
"[",
"\"action\"",
"]",
")",
";",
"// Run customized no-admin-ajax methods with action \"no-admin-ajax/before\"",
"do_action",
"(",
"\"no-admin-ajax/before\"",
")",
";",
"// Run customized no-admin-ajax methods for specific ajax actions with \"no-admin-ajax/before/{action}\"",
"do_action",
"(",
"\"no-admin-ajax/before/\"",
".",
"$",
"action",
")",
";",
"// Same headers as WordPress normal AJAX routine sends",
"$",
"default_headers",
"=",
"array",
"(",
"\"Content-Type: text/html; charset=\"",
".",
"get_option",
"(",
"\"blog_charset\"",
")",
",",
"\"X-Robots-Tag: noindex\"",
")",
";",
"// Filter to customize the headers sent by ajax calls",
"$",
"headers",
"=",
"apply_filters",
"(",
"\"no-admin-ajax/headers\"",
",",
"$",
"default_headers",
")",
";",
"// Send the headers to the user",
"if",
"(",
"is_array",
"(",
"$",
"headers",
")",
"&&",
"count",
"(",
"$",
"headers",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"@",
"header",
"(",
"$",
"header",
")",
";",
"}",
"}",
"send_nosniff_header",
"(",
")",
";",
"nocache_headers",
"(",
")",
";",
"// Run the actions",
"if",
"(",
"is_user_logged_in",
"(",
")",
")",
"{",
"do_action",
"(",
"\"wp_ajax_\"",
".",
"$",
"action",
")",
";",
"}",
"else",
"{",
"do_action",
"(",
"\"wp_ajax_nopriv_\"",
".",
"$",
"action",
")",
";",
"}",
"die",
"(",
"0",
")",
";",
"}",
"}"
]
| Runs the ajax calls. Equivalent to the real admin-ajax.php | [
"Runs",
"the",
"ajax",
"calls",
".",
"Equivalent",
"to",
"the",
"real",
"admin",
"-",
"ajax",
".",
"php"
]
| ebee2d29870e03dc7db0b584acbaa891c08c48b0 | https://github.com/devgeniem/wp-no-admin-ajax/blob/ebee2d29870e03dc7db0b584acbaa891c08c48b0/plugin.php#L84-L134 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Http.php | Http.prepareUrl | protected function prepareUrl($url, $query = array())
{
$processedUrl = $url;
if ($query) {
// URL has already query string, merge
if (strpos($url, '?') !== false) {
$components = parse_url($url);
$params = array();
parse_str($components['query'], $params);
$params = $params + $query;
$components['query'] = http_build_query($params);
$processedUrl = http_build_url($components);
} else {
$processedUrl .= '?' . http_build_query($query);
}
}
return $processedUrl;
} | php | protected function prepareUrl($url, $query = array())
{
$processedUrl = $url;
if ($query) {
// URL has already query string, merge
if (strpos($url, '?') !== false) {
$components = parse_url($url);
$params = array();
parse_str($components['query'], $params);
$params = $params + $query;
$components['query'] = http_build_query($params);
$processedUrl = http_build_url($components);
} else {
$processedUrl .= '?' . http_build_query($query);
}
}
return $processedUrl;
} | [
"protected",
"function",
"prepareUrl",
"(",
"$",
"url",
",",
"$",
"query",
"=",
"array",
"(",
")",
")",
"{",
"$",
"processedUrl",
"=",
"$",
"url",
";",
"if",
"(",
"$",
"query",
")",
"{",
"// URL has already query string, merge",
"if",
"(",
"strpos",
"(",
"$",
"url",
",",
"'?'",
")",
"!==",
"false",
")",
"{",
"$",
"components",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"parse_str",
"(",
"$",
"components",
"[",
"'query'",
"]",
",",
"$",
"params",
")",
";",
"$",
"params",
"=",
"$",
"params",
"+",
"$",
"query",
";",
"$",
"components",
"[",
"'query'",
"]",
"=",
"http_build_query",
"(",
"$",
"params",
")",
";",
"$",
"processedUrl",
"=",
"http_build_url",
"(",
"$",
"components",
")",
";",
"}",
"else",
"{",
"$",
"processedUrl",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"query",
")",
";",
"}",
"}",
"return",
"$",
"processedUrl",
";",
"}"
]
| return an URL with query string
@param string $url base URL
@param array $query query string contents
@return string | [
"return",
"an",
"URL",
"with",
"query",
"string"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Http.php#L351-L370 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Http.php | Http.doRequest | protected function doRequest($url, $ctx, &$responseHeaders, $methodName) {
// make a real request
$result = @file_get_contents($url, null, $ctx);
if (!$result) {
throw new \Exception('HTTP request failed', HttpException::REQUEST_FAILED);
}
// catch headers
$responseHeaders = $this->parseHeaders($http_response_header);
foreach (array('Content-Encoding', 'content-encoding') as $header) {
if (isset($responseHeaders[$header])) {
if (strtolower($responseHeaders[$header]) == 'gzip') {
$result = gzinflate(substr($result, 10, -8));
break;
}
}
}
$logger = $this->getLogger();
$logger->debug('Response headers: ' . var_export($responseHeaders, true));
$logger->debug('Response body: ' . $result);
// completely failed
if (!$result && $methodName != 'HEAD') {
throw new \Exception('No response from server');
} else if ($responseHeaders['Code'] < 200 || $responseHeaders['Code'] >= 400) {
// server returned error code
// decode if it's JSON
if ($responseHeaders['Content-Type'] == 'application/json') {
$parsedResult = @json_decode($result, true);
}
// pass responses (not) decoded to the adequate exception parameters
if (isset($parsedResult) && is_array($parsedResult)) {
$description = $parsedResult['error'];
if (isset($parsedResult['error_description'])) {
$description = $parsedResult['error_description'];
}
} else {
$description = 'Server error occurred';
}
throw new HttpException(
$description,
$responseHeaders['Code'],
null,
$methodName,
null,
array(),
array(),
array(),
$result,
$responseHeaders
);
}
return $result;
} | php | protected function doRequest($url, $ctx, &$responseHeaders, $methodName) {
// make a real request
$result = @file_get_contents($url, null, $ctx);
if (!$result) {
throw new \Exception('HTTP request failed', HttpException::REQUEST_FAILED);
}
// catch headers
$responseHeaders = $this->parseHeaders($http_response_header);
foreach (array('Content-Encoding', 'content-encoding') as $header) {
if (isset($responseHeaders[$header])) {
if (strtolower($responseHeaders[$header]) == 'gzip') {
$result = gzinflate(substr($result, 10, -8));
break;
}
}
}
$logger = $this->getLogger();
$logger->debug('Response headers: ' . var_export($responseHeaders, true));
$logger->debug('Response body: ' . $result);
// completely failed
if (!$result && $methodName != 'HEAD') {
throw new \Exception('No response from server');
} else if ($responseHeaders['Code'] < 200 || $responseHeaders['Code'] >= 400) {
// server returned error code
// decode if it's JSON
if ($responseHeaders['Content-Type'] == 'application/json') {
$parsedResult = @json_decode($result, true);
}
// pass responses (not) decoded to the adequate exception parameters
if (isset($parsedResult) && is_array($parsedResult)) {
$description = $parsedResult['error'];
if (isset($parsedResult['error_description'])) {
$description = $parsedResult['error_description'];
}
} else {
$description = 'Server error occurred';
}
throw new HttpException(
$description,
$responseHeaders['Code'],
null,
$methodName,
null,
array(),
array(),
array(),
$result,
$responseHeaders
);
}
return $result;
} | [
"protected",
"function",
"doRequest",
"(",
"$",
"url",
",",
"$",
"ctx",
",",
"&",
"$",
"responseHeaders",
",",
"$",
"methodName",
")",
"{",
"// make a real request",
"$",
"result",
"=",
"@",
"file_get_contents",
"(",
"$",
"url",
",",
"null",
",",
"$",
"ctx",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'HTTP request failed'",
",",
"HttpException",
"::",
"REQUEST_FAILED",
")",
";",
"}",
"// catch headers",
"$",
"responseHeaders",
"=",
"$",
"this",
"->",
"parseHeaders",
"(",
"$",
"http_response_header",
")",
";",
"foreach",
"(",
"array",
"(",
"'Content-Encoding'",
",",
"'content-encoding'",
")",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"responseHeaders",
"[",
"$",
"header",
"]",
")",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"responseHeaders",
"[",
"$",
"header",
"]",
")",
"==",
"'gzip'",
")",
"{",
"$",
"result",
"=",
"gzinflate",
"(",
"substr",
"(",
"$",
"result",
",",
"10",
",",
"-",
"8",
")",
")",
";",
"break",
";",
"}",
"}",
"}",
"$",
"logger",
"=",
"$",
"this",
"->",
"getLogger",
"(",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Response headers: '",
".",
"var_export",
"(",
"$",
"responseHeaders",
",",
"true",
")",
")",
";",
"$",
"logger",
"->",
"debug",
"(",
"'Response body: '",
".",
"$",
"result",
")",
";",
"// completely failed",
"if",
"(",
"!",
"$",
"result",
"&&",
"$",
"methodName",
"!=",
"'HEAD'",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'No response from server'",
")",
";",
"}",
"else",
"if",
"(",
"$",
"responseHeaders",
"[",
"'Code'",
"]",
"<",
"200",
"||",
"$",
"responseHeaders",
"[",
"'Code'",
"]",
">=",
"400",
")",
"{",
"// server returned error code",
"// decode if it's JSON",
"if",
"(",
"$",
"responseHeaders",
"[",
"'Content-Type'",
"]",
"==",
"'application/json'",
")",
"{",
"$",
"parsedResult",
"=",
"@",
"json_decode",
"(",
"$",
"result",
",",
"true",
")",
";",
"}",
"// pass responses (not) decoded to the adequate exception parameters",
"if",
"(",
"isset",
"(",
"$",
"parsedResult",
")",
"&&",
"is_array",
"(",
"$",
"parsedResult",
")",
")",
"{",
"$",
"description",
"=",
"$",
"parsedResult",
"[",
"'error'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"parsedResult",
"[",
"'error_description'",
"]",
")",
")",
"{",
"$",
"description",
"=",
"$",
"parsedResult",
"[",
"'error_description'",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"description",
"=",
"'Server error occurred'",
";",
"}",
"throw",
"new",
"HttpException",
"(",
"$",
"description",
",",
"$",
"responseHeaders",
"[",
"'Code'",
"]",
",",
"null",
",",
"$",
"methodName",
",",
"null",
",",
"array",
"(",
")",
",",
"array",
"(",
")",
",",
"array",
"(",
")",
",",
"$",
"result",
",",
"$",
"responseHeaders",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| perform target request
@param string $url URL
@param Resource $ctx context
@param array $responseHeaders reference to returned headers
@param string $methodName HTTP method
@return mixed|string
@throws \Exception | [
"perform",
"target",
"request"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Http.php#L381-L440 | train |
contao-bootstrap/form | src/FormLayout/HorizontalFormLayout.php | HorizontalFormLayout.getColumnClass | public function getColumnClass(bool $withOffset = false): string
{
$class = (string) $this->horizontalConfig['control'];
if ($withOffset) {
$class .= ' ' . $this->horizontalConfig['offset'];
}
return $class;
} | php | public function getColumnClass(bool $withOffset = false): string
{
$class = (string) $this->horizontalConfig['control'];
if ($withOffset) {
$class .= ' ' . $this->horizontalConfig['offset'];
}
return $class;
} | [
"public",
"function",
"getColumnClass",
"(",
"bool",
"$",
"withOffset",
"=",
"false",
")",
":",
"string",
"{",
"$",
"class",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"horizontalConfig",
"[",
"'control'",
"]",
";",
"if",
"(",
"$",
"withOffset",
")",
"{",
"$",
"class",
".=",
"' '",
".",
"$",
"this",
"->",
"horizontalConfig",
"[",
"'offset'",
"]",
";",
"}",
"return",
"$",
"class",
";",
"}"
]
| Get the column class.
@param bool $withOffset If true the offset class is added.
@return string | [
"Get",
"the",
"column",
"class",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/FormLayout/HorizontalFormLayout.php#L78-L87 | train |
contao-bootstrap/form | src/FormLayout/BootstrapFormLayoutFactory.php | BootstrapFormLayoutFactory.buildWidgetConfig | private function buildWidgetConfig(string $type, array $config): array
{
$type = substr($type, 3);
$configKey = 'form.layouts.' . $type . '.widgets';
$bootstrapConfig = $this->environment->getConfig();
$widgetConfig = ArrayUtil::merge($this->widgetConfig, $bootstrapConfig->get('form.widgets'));
if ($bootstrapConfig->has($configKey)) {
$widgetConfig = ArrayUtil::merge($widgetConfig, $bootstrapConfig->get($configKey));
}
foreach (StringUtil::deserialize($config['widgets'], true) as $widget) {
if ($widget['widget'] === '') {
continue;
}
foreach ($this->sections as $section) {
if ($widget[$section]) {
$widgetConfig[$widget['widget']]['templates'][$section] = $widget[$section];
}
}
}
return $widgetConfig;
} | php | private function buildWidgetConfig(string $type, array $config): array
{
$type = substr($type, 3);
$configKey = 'form.layouts.' . $type . '.widgets';
$bootstrapConfig = $this->environment->getConfig();
$widgetConfig = ArrayUtil::merge($this->widgetConfig, $bootstrapConfig->get('form.widgets'));
if ($bootstrapConfig->has($configKey)) {
$widgetConfig = ArrayUtil::merge($widgetConfig, $bootstrapConfig->get($configKey));
}
foreach (StringUtil::deserialize($config['widgets'], true) as $widget) {
if ($widget['widget'] === '') {
continue;
}
foreach ($this->sections as $section) {
if ($widget[$section]) {
$widgetConfig[$widget['widget']]['templates'][$section] = $widget[$section];
}
}
}
return $widgetConfig;
} | [
"private",
"function",
"buildWidgetConfig",
"(",
"string",
"$",
"type",
",",
"array",
"$",
"config",
")",
":",
"array",
"{",
"$",
"type",
"=",
"substr",
"(",
"$",
"type",
",",
"3",
")",
";",
"$",
"configKey",
"=",
"'form.layouts.'",
".",
"$",
"type",
".",
"'.widgets'",
";",
"$",
"bootstrapConfig",
"=",
"$",
"this",
"->",
"environment",
"->",
"getConfig",
"(",
")",
";",
"$",
"widgetConfig",
"=",
"ArrayUtil",
"::",
"merge",
"(",
"$",
"this",
"->",
"widgetConfig",
",",
"$",
"bootstrapConfig",
"->",
"get",
"(",
"'form.widgets'",
")",
")",
";",
"if",
"(",
"$",
"bootstrapConfig",
"->",
"has",
"(",
"$",
"configKey",
")",
")",
"{",
"$",
"widgetConfig",
"=",
"ArrayUtil",
"::",
"merge",
"(",
"$",
"widgetConfig",
",",
"$",
"bootstrapConfig",
"->",
"get",
"(",
"$",
"configKey",
")",
")",
";",
"}",
"foreach",
"(",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"config",
"[",
"'widgets'",
"]",
",",
"true",
")",
"as",
"$",
"widget",
")",
"{",
"if",
"(",
"$",
"widget",
"[",
"'widget'",
"]",
"===",
"''",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"sections",
"as",
"$",
"section",
")",
"{",
"if",
"(",
"$",
"widget",
"[",
"$",
"section",
"]",
")",
"{",
"$",
"widgetConfig",
"[",
"$",
"widget",
"[",
"'widget'",
"]",
"]",
"[",
"'templates'",
"]",
"[",
"$",
"section",
"]",
"=",
"$",
"widget",
"[",
"$",
"section",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"widgetConfig",
";",
"}"
]
| Build the widget config.
@param string $type Widget type.
@param array $config Configuration.
@return array | [
"Build",
"the",
"widget",
"config",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/FormLayout/BootstrapFormLayoutFactory.php#L110-L134 | train |
contao-bootstrap/form | src/FormLayout/BootstrapFormLayoutFactory.php | BootstrapFormLayoutFactory.buildFallbackConfig | private function buildFallbackConfig(string $type, array $config): array
{
$type = substr($type, 3);
$fallbackConfig = $this->environment->getConfig()->get('form.layouts.' . $type, []);
$fallbackConfig = ArrayUtil::merge($this->fallbackConfig, $fallbackConfig);
foreach ($this->sections as $section) {
$name = 'fallback' . ucfirst($section);
if ($config[$name]) {
$fallbackConfig['templates'][$section] = $config[$name];
}
}
return $fallbackConfig;
} | php | private function buildFallbackConfig(string $type, array $config): array
{
$type = substr($type, 3);
$fallbackConfig = $this->environment->getConfig()->get('form.layouts.' . $type, []);
$fallbackConfig = ArrayUtil::merge($this->fallbackConfig, $fallbackConfig);
foreach ($this->sections as $section) {
$name = 'fallback' . ucfirst($section);
if ($config[$name]) {
$fallbackConfig['templates'][$section] = $config[$name];
}
}
return $fallbackConfig;
} | [
"private",
"function",
"buildFallbackConfig",
"(",
"string",
"$",
"type",
",",
"array",
"$",
"config",
")",
":",
"array",
"{",
"$",
"type",
"=",
"substr",
"(",
"$",
"type",
",",
"3",
")",
";",
"$",
"fallbackConfig",
"=",
"$",
"this",
"->",
"environment",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'form.layouts.'",
".",
"$",
"type",
",",
"[",
"]",
")",
";",
"$",
"fallbackConfig",
"=",
"ArrayUtil",
"::",
"merge",
"(",
"$",
"this",
"->",
"fallbackConfig",
",",
"$",
"fallbackConfig",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"sections",
"as",
"$",
"section",
")",
"{",
"$",
"name",
"=",
"'fallback'",
".",
"ucfirst",
"(",
"$",
"section",
")",
";",
"if",
"(",
"$",
"config",
"[",
"$",
"name",
"]",
")",
"{",
"$",
"fallbackConfig",
"[",
"'templates'",
"]",
"[",
"$",
"section",
"]",
"=",
"$",
"config",
"[",
"$",
"name",
"]",
";",
"}",
"}",
"return",
"$",
"fallbackConfig",
";",
"}"
]
| Build the fallback config.
@param string $type Layout type.
@param array $config Configuration.
@return array | [
"Build",
"the",
"fallback",
"config",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/FormLayout/BootstrapFormLayoutFactory.php#L144-L159 | train |
contao-bootstrap/form | src/FormLayout/BootstrapFormLayoutFactory.php | BootstrapFormLayoutFactory.buildHorizontalConfig | private function buildHorizontalConfig(array $config): array
{
$horizontalConfig = $this->environment->getConfig()->get('form.layouts.horizontal.classes', []);
foreach (['row', 'label', 'control', 'offset'] as $key) {
if (!empty($config['bs_' . $key])) {
$horizontalConfig[$key] = $config['bs_' . $key];
}
}
return $horizontalConfig;
} | php | private function buildHorizontalConfig(array $config): array
{
$horizontalConfig = $this->environment->getConfig()->get('form.layouts.horizontal.classes', []);
foreach (['row', 'label', 'control', 'offset'] as $key) {
if (!empty($config['bs_' . $key])) {
$horizontalConfig[$key] = $config['bs_' . $key];
}
}
return $horizontalConfig;
} | [
"private",
"function",
"buildHorizontalConfig",
"(",
"array",
"$",
"config",
")",
":",
"array",
"{",
"$",
"horizontalConfig",
"=",
"$",
"this",
"->",
"environment",
"->",
"getConfig",
"(",
")",
"->",
"get",
"(",
"'form.layouts.horizontal.classes'",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"[",
"'row'",
",",
"'label'",
",",
"'control'",
",",
"'offset'",
"]",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"config",
"[",
"'bs_'",
".",
"$",
"key",
"]",
")",
")",
"{",
"$",
"horizontalConfig",
"[",
"$",
"key",
"]",
"=",
"$",
"config",
"[",
"'bs_'",
".",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"horizontalConfig",
";",
"}"
]
| Build horizontal config.
@param array $config Horizontal config.
@return array | [
"Build",
"horizontal",
"config",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/FormLayout/BootstrapFormLayoutFactory.php#L168-L179 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Resource.php | Resource.reset | public function reset()
{
$this->filters = array();
$this->limit = null;
$this->order = null;
$this->page = null;
return $this;
} | php | public function reset()
{
$this->filters = array();
$this->limit = null;
$this->order = null;
$this->page = null;
return $this;
} | [
"public",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"filters",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"limit",
"=",
"null",
";",
"$",
"this",
"->",
"order",
"=",
"null",
";",
"$",
"this",
"->",
"page",
"=",
"null",
";",
"return",
"$",
"this",
";",
"}"
]
| reset filters object state | [
"reset",
"filters",
"object",
"state"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Resource.php#L182-L190 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Resource.php | Resource.getCriteria | protected function getCriteria()
{
$result = array();
if($this->filters){
$result['filters'] = $this->filters;
}
if($this->limit!==null){
$result['limit'] = $this->limit;
}
if($this->order!==null){
$result['order'] = $this->order;
}
if($this->page!==null){
$result['page'] = $this->page;
}
return $result;
} | php | protected function getCriteria()
{
$result = array();
if($this->filters){
$result['filters'] = $this->filters;
}
if($this->limit!==null){
$result['limit'] = $this->limit;
}
if($this->order!==null){
$result['order'] = $this->order;
}
if($this->page!==null){
$result['page'] = $this->page;
}
return $result;
} | [
"protected",
"function",
"getCriteria",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"filters",
")",
"{",
"$",
"result",
"[",
"'filters'",
"]",
"=",
"$",
"this",
"->",
"filters",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"limit",
"!==",
"null",
")",
"{",
"$",
"result",
"[",
"'limit'",
"]",
"=",
"$",
"this",
"->",
"limit",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"order",
"!==",
"null",
")",
"{",
"$",
"result",
"[",
"'order'",
"]",
"=",
"$",
"this",
"->",
"order",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"page",
"!==",
"null",
")",
"{",
"$",
"result",
"[",
"'page'",
"]",
"=",
"$",
"this",
"->",
"page",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| get an array with specified criteria
@return array | [
"get",
"an",
"array",
"with",
"specified",
"criteria"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Resource.php#L196-L217 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Resource.php | Resource.limit | public function limit($count)
{
if($count<1 || $count>50){
throw new \RuntimeException('Limit beyond 1-50 range', ResourceException::LIMIT_BEYOND_RANGE);
}
$this->limit = $count;
return $this;
} | php | public function limit($count)
{
if($count<1 || $count>50){
throw new \RuntimeException('Limit beyond 1-50 range', ResourceException::LIMIT_BEYOND_RANGE);
}
$this->limit = $count;
return $this;
} | [
"public",
"function",
"limit",
"(",
"$",
"count",
")",
"{",
"if",
"(",
"$",
"count",
"<",
"1",
"||",
"$",
"count",
">",
"50",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Limit beyond 1-50 range'",
",",
"ResourceException",
"::",
"LIMIT_BEYOND_RANGE",
")",
";",
"}",
"$",
"this",
"->",
"limit",
"=",
"$",
"count",
";",
"return",
"$",
"this",
";",
"}"
]
| set records limit
@param int $count collection's items limit in range 1-50
@return $this
@throws \RuntimeException | [
"set",
"records",
"limit"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Resource.php#L225-L234 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Resource.php | Resource.filters | public function filters($filters)
{
if(!is_array($filters)){
throw new \RuntimeException('Filters not specified', ResourceException::FILTERS_NOT_SPECIFIED);
}
$this->filters = json_encode($filters);
return $this;
} | php | public function filters($filters)
{
if(!is_array($filters)){
throw new \RuntimeException('Filters not specified', ResourceException::FILTERS_NOT_SPECIFIED);
}
$this->filters = json_encode($filters);
return $this;
} | [
"public",
"function",
"filters",
"(",
"$",
"filters",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"filters",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Filters not specified'",
",",
"ResourceException",
"::",
"FILTERS_NOT_SPECIFIED",
")",
";",
"}",
"$",
"this",
"->",
"filters",
"=",
"json_encode",
"(",
"$",
"filters",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| set filters for finding
@param array $filters
@return $this
@throws \RuntimeException | [
"set",
"filters",
"for",
"finding"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Resource.php#L242-L251 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Resource.php | Resource.order | public function order($expr)
{
$matches = array();
$expr = (array)$expr;
$result = array();
foreach($expr as $e) {
// basic syntax, with asc/desc suffix
if (preg_match('/([a-z_0-9.]+) (asc|desc)$/i', $e)) {
$result[] = $e;
} else if (preg_match('/([\+\-]?)([a-z_0-9.]+)/i', $e, $matches)) {
// alternative syntax - with +/- prefix
$subResult = $matches[2];
if ($matches[1] == '' || $matches[1] == '+') {
$subResult .= ' asc';
} else {
$subResult .= ' desc';
}
$result[] = $subResult;
} else {
// something which should never happen but take care [;
throw new \RuntimeException('Cannot understand ordering expression', ResourceException::ORDER_NOT_SUPPORTED);
}
}
$this->order = $result;
} | php | public function order($expr)
{
$matches = array();
$expr = (array)$expr;
$result = array();
foreach($expr as $e) {
// basic syntax, with asc/desc suffix
if (preg_match('/([a-z_0-9.]+) (asc|desc)$/i', $e)) {
$result[] = $e;
} else if (preg_match('/([\+\-]?)([a-z_0-9.]+)/i', $e, $matches)) {
// alternative syntax - with +/- prefix
$subResult = $matches[2];
if ($matches[1] == '' || $matches[1] == '+') {
$subResult .= ' asc';
} else {
$subResult .= ' desc';
}
$result[] = $subResult;
} else {
// something which should never happen but take care [;
throw new \RuntimeException('Cannot understand ordering expression', ResourceException::ORDER_NOT_SUPPORTED);
}
}
$this->order = $result;
} | [
"public",
"function",
"order",
"(",
"$",
"expr",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"expr",
"=",
"(",
"array",
")",
"$",
"expr",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"expr",
"as",
"$",
"e",
")",
"{",
"// basic syntax, with asc/desc suffix",
"if",
"(",
"preg_match",
"(",
"'/([a-z_0-9.]+) (asc|desc)$/i'",
",",
"$",
"e",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"e",
";",
"}",
"else",
"if",
"(",
"preg_match",
"(",
"'/([\\+\\-]?)([a-z_0-9.]+)/i'",
",",
"$",
"e",
",",
"$",
"matches",
")",
")",
"{",
"// alternative syntax - with +/- prefix",
"$",
"subResult",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"if",
"(",
"$",
"matches",
"[",
"1",
"]",
"==",
"''",
"||",
"$",
"matches",
"[",
"1",
"]",
"==",
"'+'",
")",
"{",
"$",
"subResult",
".=",
"' asc'",
";",
"}",
"else",
"{",
"$",
"subResult",
".=",
"' desc'",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"subResult",
";",
"}",
"else",
"{",
"// something which should never happen but take care [;",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot understand ordering expression'",
",",
"ResourceException",
"::",
"ORDER_NOT_SUPPORTED",
")",
";",
"}",
"}",
"$",
"this",
"->",
"order",
"=",
"$",
"result",
";",
"}"
]
| order record by column
@param string $expr syntax:
<field> (asc|desc)
or
(+|-)<field>
@return $this
@throws \RuntimeException | [
"order",
"record",
"by",
"column"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Resource.php#L281-L311 | train |
dreamcommerce/shop-appstore-lib | src/DreamCommerce/ShopAppstoreLib/Resource.php | Resource.head | public function head()
{
$query = $this->getCriteria();
$args = func_get_args();
if(empty($args)){
$args = null;
}
$response = '';
try {
$response = $this->client->request($this, 'head', $args, array(), $query);
} catch(Exception $ex) {
$this->dispatchException($ex);
}
return $this->transformResponse($response, true);
} | php | public function head()
{
$query = $this->getCriteria();
$args = func_get_args();
if(empty($args)){
$args = null;
}
$response = '';
try {
$response = $this->client->request($this, 'head', $args, array(), $query);
} catch(Exception $ex) {
$this->dispatchException($ex);
}
return $this->transformResponse($response, true);
} | [
"public",
"function",
"head",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getCriteria",
"(",
")",
";",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"args",
")",
")",
"{",
"$",
"args",
"=",
"null",
";",
"}",
"$",
"response",
"=",
"''",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"$",
"this",
",",
"'head'",
",",
"$",
"args",
",",
"array",
"(",
")",
",",
"$",
"query",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"dispatchException",
"(",
"$",
"ex",
")",
";",
"}",
"return",
"$",
"this",
"->",
"transformResponse",
"(",
"$",
"response",
",",
"true",
")",
";",
"}"
]
| Read Resource without data
@return \ArrayObject
@throws ResourceException | [
"Read",
"Resource",
"without",
"data"
]
| f87ceb4953a6476d092792a4926da39161b31b25 | https://github.com/dreamcommerce/shop-appstore-lib/blob/f87ceb4953a6476d092792a4926da39161b31b25/src/DreamCommerce/ShopAppstoreLib/Resource.php#L348-L366 | train |
contao-bootstrap/form | src/Helper/InputGroupHelper.php | InputGroupHelper.forWidget | public static function forWidget(Widget $widget): self
{
$values = StringUtil::deserialize($widget->bs_inputGroup, true);
$helper = new static();
foreach ($values as $entry) {
if (!strlen($entry['addon'])) {
continue;
}
if ($entry['position'] === 'after') {
$helper->addAfter($entry['addon']);
} else {
$helper->addBefore($entry['addon']);
}
}
return $helper;
} | php | public static function forWidget(Widget $widget): self
{
$values = StringUtil::deserialize($widget->bs_inputGroup, true);
$helper = new static();
foreach ($values as $entry) {
if (!strlen($entry['addon'])) {
continue;
}
if ($entry['position'] === 'after') {
$helper->addAfter($entry['addon']);
} else {
$helper->addBefore($entry['addon']);
}
}
return $helper;
} | [
"public",
"static",
"function",
"forWidget",
"(",
"Widget",
"$",
"widget",
")",
":",
"self",
"{",
"$",
"values",
"=",
"StringUtil",
"::",
"deserialize",
"(",
"$",
"widget",
"->",
"bs_inputGroup",
",",
"true",
")",
";",
"$",
"helper",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"!",
"strlen",
"(",
"$",
"entry",
"[",
"'addon'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"entry",
"[",
"'position'",
"]",
"===",
"'after'",
")",
"{",
"$",
"helper",
"->",
"addAfter",
"(",
"$",
"entry",
"[",
"'addon'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"helper",
"->",
"addBefore",
"(",
"$",
"entry",
"[",
"'addon'",
"]",
")",
";",
"}",
"}",
"return",
"$",
"helper",
";",
"}"
]
| Create input group helper for a widget.
@param Widget $widget Form widget.
@return static | [
"Create",
"input",
"group",
"helper",
"for",
"a",
"widget",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/Helper/InputGroupHelper.php#L51-L69 | train |
contao-bootstrap/form | src/Helper/InputGroupHelper.php | InputGroupHelper.addAfter | public function addAfter(string $content, bool $text = true): self
{
$this->after[] = [
'content' => $content,
'text' => $text
];
return $this;
} | php | public function addAfter(string $content, bool $text = true): self
{
$this->after[] = [
'content' => $content,
'text' => $text
];
return $this;
} | [
"public",
"function",
"addAfter",
"(",
"string",
"$",
"content",
",",
"bool",
"$",
"text",
"=",
"true",
")",
":",
"self",
"{",
"$",
"this",
"->",
"after",
"[",
"]",
"=",
"[",
"'content'",
"=>",
"$",
"content",
",",
"'text'",
"=>",
"$",
"text",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Add after entry.
@param string $content Content of the add on.
@param bool $text If true, no input-group-text wrapper is added.
@return $this | [
"Add",
"after",
"entry",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/Helper/InputGroupHelper.php#L79-L87 | train |
contao-bootstrap/form | src/Helper/InputGroupHelper.php | InputGroupHelper.addBefore | public function addBefore(string $content, bool $text = true): self
{
$this->before[] = [
'content' => $content,
'text' => $text
];
return $this;
} | php | public function addBefore(string $content, bool $text = true): self
{
$this->before[] = [
'content' => $content,
'text' => $text
];
return $this;
} | [
"public",
"function",
"addBefore",
"(",
"string",
"$",
"content",
",",
"bool",
"$",
"text",
"=",
"true",
")",
":",
"self",
"{",
"$",
"this",
"->",
"before",
"[",
"]",
"=",
"[",
"'content'",
"=>",
"$",
"content",
",",
"'text'",
"=>",
"$",
"text",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Add before entry.
@param string $content Content of the addo n.
@param bool $text If true, no input-group-text wrapper is added.
@return $this | [
"Add",
"before",
"entry",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/Helper/InputGroupHelper.php#L97-L105 | train |
contao-bootstrap/form | src/Listener/DefaultFormLayoutListener.php | DefaultFormLayoutListener.onGetPageLayout | public function onGetPageLayout(PageModel $pageModel, LayoutModel $layoutModel): void
{
if ($this->manager->hasDefaultThemeLayout()) {
return;
}
$this->manager->setDefaultThemeLayout($this->factory->create('bs_default', []));
} | php | public function onGetPageLayout(PageModel $pageModel, LayoutModel $layoutModel): void
{
if ($this->manager->hasDefaultThemeLayout()) {
return;
}
$this->manager->setDefaultThemeLayout($this->factory->create('bs_default', []));
} | [
"public",
"function",
"onGetPageLayout",
"(",
"PageModel",
"$",
"pageModel",
",",
"LayoutModel",
"$",
"layoutModel",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"manager",
"->",
"hasDefaultThemeLayout",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"manager",
"->",
"setDefaultThemeLayout",
"(",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"'bs_default'",
",",
"[",
"]",
")",
")",
";",
"}"
]
| Create default bootstrap form layout.
@param PageModel $pageModel Page model.
@param LayoutModel $layoutModel Layout model.
@return void
@SuppressWarnings(PHPMD.UnusedFormalParameter) | [
"Create",
"default",
"bootstrap",
"form",
"layout",
"."
]
| 7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7 | https://github.com/contao-bootstrap/form/blob/7e6a83190b852207ba41a1f8ffa2b4b02f9e9eb7/src/Listener/DefaultFormLayoutListener.php#L38-L45 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/RequestBodyListener.php | RequestBodyListener.onKernelRequest | public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
if (!$event->isMasterRequest()) {
return;
}
if ($request->attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
return;
}
if (!$this->isDecodeable($request)) {
return;
}
try {
$data = $this->decoder->decode((string) $request->getContent(), 'json');
} catch (UnexpectedValueException $e) {
throw new BadRequestHttpException('Request body has an invalid format', $e);
}
if (!is_array($data)) {
throw new BadRequestHttpException('Request body has an invalid format');
}
$request->attributes->set('data', new ParameterBag($data));
} | php | public function onKernelRequest(GetResponseEvent $event): void
{
$request = $event->getRequest();
if (!$event->isMasterRequest()) {
return;
}
if ($request->attributes->get(SetIsApiRequestListener::API_FLAG_NAME) !== true) {
return;
}
if (!$this->isDecodeable($request)) {
return;
}
try {
$data = $this->decoder->decode((string) $request->getContent(), 'json');
} catch (UnexpectedValueException $e) {
throw new BadRequestHttpException('Request body has an invalid format', $e);
}
if (!is_array($data)) {
throw new BadRequestHttpException('Request body has an invalid format');
}
$request->attributes->set('data', new ParameterBag($data));
} | [
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"if",
"(",
"!",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"SetIsApiRequestListener",
"::",
"API_FLAG_NAME",
")",
"!==",
"true",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isDecodeable",
"(",
"$",
"request",
")",
")",
"{",
"return",
";",
"}",
"try",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"decoder",
"->",
"decode",
"(",
"(",
"string",
")",
"$",
"request",
"->",
"getContent",
"(",
")",
",",
"'json'",
")",
";",
"}",
"catch",
"(",
"UnexpectedValueException",
"$",
"e",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
"'Request body has an invalid format'",
",",
"$",
"e",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"BadRequestHttpException",
"(",
"'Request body has an invalid format'",
")",
";",
"}",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'data'",
",",
"new",
"ParameterBag",
"(",
"$",
"data",
")",
")",
";",
"}"
]
| Decodes the request data into request parameter bag. | [
"Decodes",
"the",
"request",
"data",
"into",
"request",
"parameter",
"bag",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/RequestBodyListener.php#L36-L63 | train |
netgen-layouts/layouts-core | lib/Block/Form/EditType.php | EditType.addViewTypeForm | protected function addViewTypeForm(FormBuilderInterface $builder, array $options): void
{
/** @var \Netgen\BlockManager\Block\BlockDefinitionInterface $blockDefinition */
$blockDefinition = $options['block']->getDefinition();
$this->processViewTypeConfig($blockDefinition);
$builder->add(
'view_type',
ChoiceType::class,
[
'label' => 'block.view_type',
'choices' => array_flip($this->viewTypes),
'property_path' => 'viewType',
] + $this->getChoicesAsValuesOption()
);
$builder->add(
'item_view_type',
ChoiceType::class,
[
'label' => 'block.item_view_type',
'choices' => array_flip(call_user_func_array('array_merge', $this->itemViewTypes)),
'choice_attr' => function ($value): array {
return [
'data-master' => implode(',', $this->viewTypesByItemViewType[$value]),
];
},
'property_path' => 'itemViewType',
] + $this->getChoicesAsValuesOption()
);
} | php | protected function addViewTypeForm(FormBuilderInterface $builder, array $options): void
{
/** @var \Netgen\BlockManager\Block\BlockDefinitionInterface $blockDefinition */
$blockDefinition = $options['block']->getDefinition();
$this->processViewTypeConfig($blockDefinition);
$builder->add(
'view_type',
ChoiceType::class,
[
'label' => 'block.view_type',
'choices' => array_flip($this->viewTypes),
'property_path' => 'viewType',
] + $this->getChoicesAsValuesOption()
);
$builder->add(
'item_view_type',
ChoiceType::class,
[
'label' => 'block.item_view_type',
'choices' => array_flip(call_user_func_array('array_merge', $this->itemViewTypes)),
'choice_attr' => function ($value): array {
return [
'data-master' => implode(',', $this->viewTypesByItemViewType[$value]),
];
},
'property_path' => 'itemViewType',
] + $this->getChoicesAsValuesOption()
);
} | [
"protected",
"function",
"addViewTypeForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
")",
":",
"void",
"{",
"/** @var \\Netgen\\BlockManager\\Block\\BlockDefinitionInterface $blockDefinition */",
"$",
"blockDefinition",
"=",
"$",
"options",
"[",
"'block'",
"]",
"->",
"getDefinition",
"(",
")",
";",
"$",
"this",
"->",
"processViewTypeConfig",
"(",
"$",
"blockDefinition",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'view_type'",
",",
"ChoiceType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'block.view_type'",
",",
"'choices'",
"=>",
"array_flip",
"(",
"$",
"this",
"->",
"viewTypes",
")",
",",
"'property_path'",
"=>",
"'viewType'",
",",
"]",
"+",
"$",
"this",
"->",
"getChoicesAsValuesOption",
"(",
")",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'item_view_type'",
",",
"ChoiceType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"'block.item_view_type'",
",",
"'choices'",
"=>",
"array_flip",
"(",
"call_user_func_array",
"(",
"'array_merge'",
",",
"$",
"this",
"->",
"itemViewTypes",
")",
")",
",",
"'choice_attr'",
"=>",
"function",
"(",
"$",
"value",
")",
":",
"array",
"{",
"return",
"[",
"'data-master'",
"=>",
"implode",
"(",
"','",
",",
"$",
"this",
"->",
"viewTypesByItemViewType",
"[",
"$",
"value",
"]",
")",
",",
"]",
";",
"}",
",",
"'property_path'",
"=>",
"'itemViewType'",
",",
"]",
"+",
"$",
"this",
"->",
"getChoicesAsValuesOption",
"(",
")",
")",
";",
"}"
]
| Adds view type and item view type forms to the provided form builder. | [
"Adds",
"view",
"type",
"and",
"item",
"view",
"type",
"forms",
"to",
"the",
"provided",
"form",
"builder",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/Form/EditType.php#L77-L108 | train |
netgen-layouts/layouts-core | lib/Block/Form/EditType.php | EditType.addParametersForm | protected function addParametersForm(FormBuilderInterface $builder, array $options, array $groups = []): void
{
/** @var \Netgen\BlockManager\Block\BlockDefinitionInterface $blockDefinition */
$blockDefinition = $options['block']->getDefinition();
$builder->add(
'parameters',
ParametersType::class,
[
'label' => false,
'inherit_data' => true,
'property_path' => 'parameterValues',
'parameter_definitions' => $blockDefinition,
'label_prefix' => 'block.' . $blockDefinition->getIdentifier(),
'groups' => $groups,
]
);
} | php | protected function addParametersForm(FormBuilderInterface $builder, array $options, array $groups = []): void
{
/** @var \Netgen\BlockManager\Block\BlockDefinitionInterface $blockDefinition */
$blockDefinition = $options['block']->getDefinition();
$builder->add(
'parameters',
ParametersType::class,
[
'label' => false,
'inherit_data' => true,
'property_path' => 'parameterValues',
'parameter_definitions' => $blockDefinition,
'label_prefix' => 'block.' . $blockDefinition->getIdentifier(),
'groups' => $groups,
]
);
} | [
"protected",
"function",
"addParametersForm",
"(",
"FormBuilderInterface",
"$",
"builder",
",",
"array",
"$",
"options",
",",
"array",
"$",
"groups",
"=",
"[",
"]",
")",
":",
"void",
"{",
"/** @var \\Netgen\\BlockManager\\Block\\BlockDefinitionInterface $blockDefinition */",
"$",
"blockDefinition",
"=",
"$",
"options",
"[",
"'block'",
"]",
"->",
"getDefinition",
"(",
")",
";",
"$",
"builder",
"->",
"add",
"(",
"'parameters'",
",",
"ParametersType",
"::",
"class",
",",
"[",
"'label'",
"=>",
"false",
",",
"'inherit_data'",
"=>",
"true",
",",
"'property_path'",
"=>",
"'parameterValues'",
",",
"'parameter_definitions'",
"=>",
"$",
"blockDefinition",
",",
"'label_prefix'",
"=>",
"'block.'",
".",
"$",
"blockDefinition",
"->",
"getIdentifier",
"(",
")",
",",
"'groups'",
"=>",
"$",
"groups",
",",
"]",
")",
";",
"}"
]
| Adds the parameters form to the provided builder. | [
"Adds",
"the",
"parameters",
"form",
"to",
"the",
"provided",
"builder",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/Form/EditType.php#L133-L150 | train |
netgen-layouts/layouts-core | lib/Block/Form/EditType.php | EditType.processViewTypeConfig | private function processViewTypeConfig(BlockDefinitionInterface $blockDefinition): void
{
$blockDefinitionParameters = array_keys($blockDefinition->getParameterDefinitions());
foreach ($blockDefinition->getViewTypes() as $viewType) {
$this->viewTypes[$viewType->getIdentifier()] = $viewType->getName();
foreach ($viewType->getItemViewTypes() as $itemViewType) {
$this->itemViewTypes[$viewType->getIdentifier()][$itemViewType->getIdentifier()] = $itemViewType->getName();
$this->viewTypesByItemViewType[$itemViewType->getIdentifier()][] = $viewType->getIdentifier();
}
$includedParameters = [];
$excludedParameters = [];
$validParameters = $viewType->getValidParameters();
if (!is_array($validParameters)) {
$includedParameters = $blockDefinitionParameters;
} elseif (count($validParameters) > 0) {
foreach ($validParameters as $validParameter) {
mb_strpos($validParameter, '!') === 0 ?
$excludedParameters[] = mb_substr($validParameter, 1) :
$includedParameters[] = $validParameter;
if (count($includedParameters) === 0) {
$includedParameters = $blockDefinitionParameters;
}
}
}
foreach ($includedParameters as $includedParameter) {
if (!in_array($includedParameter, $excludedParameters, true)) {
$this->viewTypesByParameters[$includedParameter][] = $viewType->getIdentifier();
}
}
}
} | php | private function processViewTypeConfig(BlockDefinitionInterface $blockDefinition): void
{
$blockDefinitionParameters = array_keys($blockDefinition->getParameterDefinitions());
foreach ($blockDefinition->getViewTypes() as $viewType) {
$this->viewTypes[$viewType->getIdentifier()] = $viewType->getName();
foreach ($viewType->getItemViewTypes() as $itemViewType) {
$this->itemViewTypes[$viewType->getIdentifier()][$itemViewType->getIdentifier()] = $itemViewType->getName();
$this->viewTypesByItemViewType[$itemViewType->getIdentifier()][] = $viewType->getIdentifier();
}
$includedParameters = [];
$excludedParameters = [];
$validParameters = $viewType->getValidParameters();
if (!is_array($validParameters)) {
$includedParameters = $blockDefinitionParameters;
} elseif (count($validParameters) > 0) {
foreach ($validParameters as $validParameter) {
mb_strpos($validParameter, '!') === 0 ?
$excludedParameters[] = mb_substr($validParameter, 1) :
$includedParameters[] = $validParameter;
if (count($includedParameters) === 0) {
$includedParameters = $blockDefinitionParameters;
}
}
}
foreach ($includedParameters as $includedParameter) {
if (!in_array($includedParameter, $excludedParameters, true)) {
$this->viewTypesByParameters[$includedParameter][] = $viewType->getIdentifier();
}
}
}
} | [
"private",
"function",
"processViewTypeConfig",
"(",
"BlockDefinitionInterface",
"$",
"blockDefinition",
")",
":",
"void",
"{",
"$",
"blockDefinitionParameters",
"=",
"array_keys",
"(",
"$",
"blockDefinition",
"->",
"getParameterDefinitions",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"blockDefinition",
"->",
"getViewTypes",
"(",
")",
"as",
"$",
"viewType",
")",
"{",
"$",
"this",
"->",
"viewTypes",
"[",
"$",
"viewType",
"->",
"getIdentifier",
"(",
")",
"]",
"=",
"$",
"viewType",
"->",
"getName",
"(",
")",
";",
"foreach",
"(",
"$",
"viewType",
"->",
"getItemViewTypes",
"(",
")",
"as",
"$",
"itemViewType",
")",
"{",
"$",
"this",
"->",
"itemViewTypes",
"[",
"$",
"viewType",
"->",
"getIdentifier",
"(",
")",
"]",
"[",
"$",
"itemViewType",
"->",
"getIdentifier",
"(",
")",
"]",
"=",
"$",
"itemViewType",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"viewTypesByItemViewType",
"[",
"$",
"itemViewType",
"->",
"getIdentifier",
"(",
")",
"]",
"[",
"]",
"=",
"$",
"viewType",
"->",
"getIdentifier",
"(",
")",
";",
"}",
"$",
"includedParameters",
"=",
"[",
"]",
";",
"$",
"excludedParameters",
"=",
"[",
"]",
";",
"$",
"validParameters",
"=",
"$",
"viewType",
"->",
"getValidParameters",
"(",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"validParameters",
")",
")",
"{",
"$",
"includedParameters",
"=",
"$",
"blockDefinitionParameters",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"validParameters",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"validParameters",
"as",
"$",
"validParameter",
")",
"{",
"mb_strpos",
"(",
"$",
"validParameter",
",",
"'!'",
")",
"===",
"0",
"?",
"$",
"excludedParameters",
"[",
"]",
"=",
"mb_substr",
"(",
"$",
"validParameter",
",",
"1",
")",
":",
"$",
"includedParameters",
"[",
"]",
"=",
"$",
"validParameter",
";",
"if",
"(",
"count",
"(",
"$",
"includedParameters",
")",
"===",
"0",
")",
"{",
"$",
"includedParameters",
"=",
"$",
"blockDefinitionParameters",
";",
"}",
"}",
"}",
"foreach",
"(",
"$",
"includedParameters",
"as",
"$",
"includedParameter",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"includedParameter",
",",
"$",
"excludedParameters",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"viewTypesByParameters",
"[",
"$",
"includedParameter",
"]",
"[",
"]",
"=",
"$",
"viewType",
"->",
"getIdentifier",
"(",
")",
";",
"}",
"}",
"}",
"}"
]
| Generates the list of valid view types for every item view type
and for every parameter, according to config provided by the block definition.
These lists are used by the interface to hide and show item view types
and parameters based on selected view type.
@todo Move this code somewhere else | [
"Generates",
"the",
"list",
"of",
"valid",
"view",
"types",
"for",
"every",
"item",
"view",
"type",
"and",
"for",
"every",
"parameter",
"according",
"to",
"config",
"provided",
"by",
"the",
"block",
"definition",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Block/Form/EditType.php#L161-L197 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/EventListener/HttpCache/BlockResponseListener.php | BlockResponseListener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$blockView = $event->getRequest()->attributes->get('ngbmView');
if (!$blockView instanceof BlockViewInterface) {
return;
}
$this->tagger->tagBlock($event->getResponse(), $blockView->getBlock());
} | php | public function onKernelResponse(FilterResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
}
$blockView = $event->getRequest()->attributes->get('ngbmView');
if (!$blockView instanceof BlockViewInterface) {
return;
}
$this->tagger->tagBlock($event->getResponse(), $blockView->getBlock());
} | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"event",
"->",
"isMasterRequest",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"blockView",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
"->",
"attributes",
"->",
"get",
"(",
"'ngbmView'",
")",
";",
"if",
"(",
"!",
"$",
"blockView",
"instanceof",
"BlockViewInterface",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"tagger",
"->",
"tagBlock",
"(",
"$",
"event",
"->",
"getResponse",
"(",
")",
",",
"$",
"blockView",
"->",
"getBlock",
"(",
")",
")",
";",
"}"
]
| Tags the response with the data for block provided by the event. | [
"Tags",
"the",
"response",
"with",
"the",
"data",
"for",
"block",
"provided",
"by",
"the",
"event",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/EventListener/HttpCache/BlockResponseListener.php#L33-L45 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/ConfigMapper.php | ConfigMapper.mapConfig | public function mapConfig(array $config, array $configDefinitions): Generator
{
foreach ($configDefinitions as $configKey => $configDefinition) {
yield $configKey => Config::fromArray(
[
'configKey' => $configKey,
'definition' => $configDefinition,
'parameters' => iterator_to_array(
$this->parameterMapper->mapParameters(
$configDefinition,
$config[$configKey] ?? []
)
),
]
);
}
} | php | public function mapConfig(array $config, array $configDefinitions): Generator
{
foreach ($configDefinitions as $configKey => $configDefinition) {
yield $configKey => Config::fromArray(
[
'configKey' => $configKey,
'definition' => $configDefinition,
'parameters' => iterator_to_array(
$this->parameterMapper->mapParameters(
$configDefinition,
$config[$configKey] ?? []
)
),
]
);
}
} | [
"public",
"function",
"mapConfig",
"(",
"array",
"$",
"config",
",",
"array",
"$",
"configDefinitions",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"configDefinitions",
"as",
"$",
"configKey",
"=>",
"$",
"configDefinition",
")",
"{",
"yield",
"$",
"configKey",
"=>",
"Config",
"::",
"fromArray",
"(",
"[",
"'configKey'",
"=>",
"$",
"configKey",
",",
"'definition'",
"=>",
"$",
"configDefinition",
",",
"'parameters'",
"=>",
"iterator_to_array",
"(",
"$",
"this",
"->",
"parameterMapper",
"->",
"mapParameters",
"(",
"$",
"configDefinition",
",",
"$",
"config",
"[",
"$",
"configKey",
"]",
"??",
"[",
"]",
")",
")",
",",
"]",
")",
";",
"}",
"}"
]
| Maps the provided config array to API values according to provided config definitions.
@param array<string, array<string, mixed>> $config
@param \Netgen\BlockManager\Config\ConfigDefinitionInterface[] $configDefinitions
@return \Generator | [
"Maps",
"the",
"provided",
"config",
"array",
"to",
"API",
"values",
"according",
"to",
"provided",
"config",
"definitions",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/ConfigMapper.php#L31-L47 | train |
netgen-layouts/layouts-core | lib/Core/Mapper/ConfigMapper.php | ConfigMapper.serializeValues | public function serializeValues(array $configStructs, array $configDefinitions, array $fallbackValues = []): Generator
{
foreach ($configDefinitions as $configKey => $configDefinition) {
$configValues = [];
if (
isset($configStructs[$configKey]) &&
$configStructs[$configKey] instanceof ParameterStruct
) {
$configValues = $configStructs[$configKey]->getParameterValues();
}
yield $configKey => iterator_to_array(
$this->parameterMapper->serializeValues(
$configDefinition,
$configValues,
$fallbackValues[$configKey] ?? []
)
);
}
} | php | public function serializeValues(array $configStructs, array $configDefinitions, array $fallbackValues = []): Generator
{
foreach ($configDefinitions as $configKey => $configDefinition) {
$configValues = [];
if (
isset($configStructs[$configKey]) &&
$configStructs[$configKey] instanceof ParameterStruct
) {
$configValues = $configStructs[$configKey]->getParameterValues();
}
yield $configKey => iterator_to_array(
$this->parameterMapper->serializeValues(
$configDefinition,
$configValues,
$fallbackValues[$configKey] ?? []
)
);
}
} | [
"public",
"function",
"serializeValues",
"(",
"array",
"$",
"configStructs",
",",
"array",
"$",
"configDefinitions",
",",
"array",
"$",
"fallbackValues",
"=",
"[",
"]",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"configDefinitions",
"as",
"$",
"configKey",
"=>",
"$",
"configDefinition",
")",
"{",
"$",
"configValues",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"configStructs",
"[",
"$",
"configKey",
"]",
")",
"&&",
"$",
"configStructs",
"[",
"$",
"configKey",
"]",
"instanceof",
"ParameterStruct",
")",
"{",
"$",
"configValues",
"=",
"$",
"configStructs",
"[",
"$",
"configKey",
"]",
"->",
"getParameterValues",
"(",
")",
";",
"}",
"yield",
"$",
"configKey",
"=>",
"iterator_to_array",
"(",
"$",
"this",
"->",
"parameterMapper",
"->",
"serializeValues",
"(",
"$",
"configDefinition",
",",
"$",
"configValues",
",",
"$",
"fallbackValues",
"[",
"$",
"configKey",
"]",
"??",
"[",
"]",
")",
")",
";",
"}",
"}"
]
| Serializes the existing config struct values based on provided config definitions.
@param \Netgen\BlockManager\API\Values\ParameterStruct[] $configStructs
@param \Netgen\BlockManager\Config\ConfigDefinitionInterface[] $configDefinitions
@param array<string, array<string, mixed>> $fallbackValues
@return \Generator | [
"Serializes",
"the",
"existing",
"config",
"struct",
"values",
"based",
"on",
"provided",
"config",
"definitions",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Core/Mapper/ConfigMapper.php#L58-L78 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Helper/PositionHelper.php | PositionHelper.createPosition | public function createPosition(array $conditions, ?int $position = null, ?int $endPosition = null, bool $allowOutOfRange = false): int
{
$nextPosition = $this->getNextPosition($conditions);
if ($position === null) {
return $nextPosition;
}
if ($position < 0) {
throw new BadStateException('position', 'Position cannot be negative.');
}
if (!$allowOutOfRange && $position > $nextPosition) {
throw new BadStateException('position', 'Position is out of range.');
}
if ($endPosition !== null && $endPosition < $position) {
throw new BadStateException('position', 'When creating a position, end position needs to be greater or equal than start position.');
}
$this->incrementPositions(
$conditions,
$position,
$endPosition
);
return $position;
} | php | public function createPosition(array $conditions, ?int $position = null, ?int $endPosition = null, bool $allowOutOfRange = false): int
{
$nextPosition = $this->getNextPosition($conditions);
if ($position === null) {
return $nextPosition;
}
if ($position < 0) {
throw new BadStateException('position', 'Position cannot be negative.');
}
if (!$allowOutOfRange && $position > $nextPosition) {
throw new BadStateException('position', 'Position is out of range.');
}
if ($endPosition !== null && $endPosition < $position) {
throw new BadStateException('position', 'When creating a position, end position needs to be greater or equal than start position.');
}
$this->incrementPositions(
$conditions,
$position,
$endPosition
);
return $position;
} | [
"public",
"function",
"createPosition",
"(",
"array",
"$",
"conditions",
",",
"?",
"int",
"$",
"position",
"=",
"null",
",",
"?",
"int",
"$",
"endPosition",
"=",
"null",
",",
"bool",
"$",
"allowOutOfRange",
"=",
"false",
")",
":",
"int",
"{",
"$",
"nextPosition",
"=",
"$",
"this",
"->",
"getNextPosition",
"(",
"$",
"conditions",
")",
";",
"if",
"(",
"$",
"position",
"===",
"null",
")",
"{",
"return",
"$",
"nextPosition",
";",
"}",
"if",
"(",
"$",
"position",
"<",
"0",
")",
"{",
"throw",
"new",
"BadStateException",
"(",
"'position'",
",",
"'Position cannot be negative.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"allowOutOfRange",
"&&",
"$",
"position",
">",
"$",
"nextPosition",
")",
"{",
"throw",
"new",
"BadStateException",
"(",
"'position'",
",",
"'Position is out of range.'",
")",
";",
"}",
"if",
"(",
"$",
"endPosition",
"!==",
"null",
"&&",
"$",
"endPosition",
"<",
"$",
"position",
")",
"{",
"throw",
"new",
"BadStateException",
"(",
"'position'",
",",
"'When creating a position, end position needs to be greater or equal than start position.'",
")",
";",
"}",
"$",
"this",
"->",
"incrementPositions",
"(",
"$",
"conditions",
",",
"$",
"position",
",",
"$",
"endPosition",
")",
";",
"return",
"$",
"position",
";",
"}"
]
| Processes the database table to create space for an item which will
be inserted at specified position.
@throws \Netgen\BlockManager\Exception\BadStateException If position is out of range | [
"Processes",
"the",
"database",
"table",
"to",
"create",
"space",
"for",
"an",
"item",
"which",
"will",
"be",
"inserted",
"at",
"specified",
"position",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Helper/PositionHelper.php#L31-L58 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Helper/PositionHelper.php | PositionHelper.moveToPosition | public function moveToPosition(array $conditions, int $originalPosition, int $position, bool $allowOutOfRange = false): int
{
$nextPosition = $this->getNextPosition($conditions);
if ($position < 0) {
throw new BadStateException('position', 'Position cannot be negative.');
}
if (!$allowOutOfRange && $position >= $nextPosition) {
throw new BadStateException('position', 'Position is out of range.');
}
if ($position > $originalPosition) {
$this->decrementPositions(
$conditions,
$originalPosition + 1,
$position
);
} elseif ($position < $originalPosition) {
$this->incrementPositions(
$conditions,
$position,
$originalPosition - 1
);
}
return $position;
} | php | public function moveToPosition(array $conditions, int $originalPosition, int $position, bool $allowOutOfRange = false): int
{
$nextPosition = $this->getNextPosition($conditions);
if ($position < 0) {
throw new BadStateException('position', 'Position cannot be negative.');
}
if (!$allowOutOfRange && $position >= $nextPosition) {
throw new BadStateException('position', 'Position is out of range.');
}
if ($position > $originalPosition) {
$this->decrementPositions(
$conditions,
$originalPosition + 1,
$position
);
} elseif ($position < $originalPosition) {
$this->incrementPositions(
$conditions,
$position,
$originalPosition - 1
);
}
return $position;
} | [
"public",
"function",
"moveToPosition",
"(",
"array",
"$",
"conditions",
",",
"int",
"$",
"originalPosition",
",",
"int",
"$",
"position",
",",
"bool",
"$",
"allowOutOfRange",
"=",
"false",
")",
":",
"int",
"{",
"$",
"nextPosition",
"=",
"$",
"this",
"->",
"getNextPosition",
"(",
"$",
"conditions",
")",
";",
"if",
"(",
"$",
"position",
"<",
"0",
")",
"{",
"throw",
"new",
"BadStateException",
"(",
"'position'",
",",
"'Position cannot be negative.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"allowOutOfRange",
"&&",
"$",
"position",
">=",
"$",
"nextPosition",
")",
"{",
"throw",
"new",
"BadStateException",
"(",
"'position'",
",",
"'Position is out of range.'",
")",
";",
"}",
"if",
"(",
"$",
"position",
">",
"$",
"originalPosition",
")",
"{",
"$",
"this",
"->",
"decrementPositions",
"(",
"$",
"conditions",
",",
"$",
"originalPosition",
"+",
"1",
",",
"$",
"position",
")",
";",
"}",
"elseif",
"(",
"$",
"position",
"<",
"$",
"originalPosition",
")",
"{",
"$",
"this",
"->",
"incrementPositions",
"(",
"$",
"conditions",
",",
"$",
"position",
",",
"$",
"originalPosition",
"-",
"1",
")",
";",
"}",
"return",
"$",
"position",
";",
"}"
]
| Processes the database table to make space for the item which
will be moved inside the table.
@throws \Netgen\BlockManager\Exception\BadStateException If position is out of range | [
"Processes",
"the",
"database",
"table",
"to",
"make",
"space",
"for",
"the",
"item",
"which",
"will",
"be",
"moved",
"inside",
"the",
"table",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Helper/PositionHelper.php#L66-L93 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Helper/PositionHelper.php | PositionHelper.getNextPosition | public function getNextPosition(array $conditions): int
{
$columnName = $conditions['column'];
$query = $this->connection->createQueryBuilder();
$query->select($this->connection->getDatabasePlatform()->getMaxExpression($columnName) . ' AS ' . $columnName)
->from($conditions['table']);
$this->applyConditions($query, $conditions['conditions']);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0][$columnName] ?? -1) + 1;
} | php | public function getNextPosition(array $conditions): int
{
$columnName = $conditions['column'];
$query = $this->connection->createQueryBuilder();
$query->select($this->connection->getDatabasePlatform()->getMaxExpression($columnName) . ' AS ' . $columnName)
->from($conditions['table']);
$this->applyConditions($query, $conditions['conditions']);
$data = $query->execute()->fetchAll(PDO::FETCH_ASSOC);
return (int) ($data[0][$columnName] ?? -1) + 1;
} | [
"public",
"function",
"getNextPosition",
"(",
"array",
"$",
"conditions",
")",
":",
"int",
"{",
"$",
"columnName",
"=",
"$",
"conditions",
"[",
"'column'",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"select",
"(",
"$",
"this",
"->",
"connection",
"->",
"getDatabasePlatform",
"(",
")",
"->",
"getMaxExpression",
"(",
"$",
"columnName",
")",
".",
"' AS '",
".",
"$",
"columnName",
")",
"->",
"from",
"(",
"$",
"conditions",
"[",
"'table'",
"]",
")",
";",
"$",
"this",
"->",
"applyConditions",
"(",
"$",
"query",
",",
"$",
"conditions",
"[",
"'conditions'",
"]",
")",
";",
"$",
"data",
"=",
"$",
"query",
"->",
"execute",
"(",
")",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"return",
"(",
"int",
")",
"(",
"$",
"data",
"[",
"0",
"]",
"[",
"$",
"columnName",
"]",
"??",
"-",
"1",
")",
"+",
"1",
";",
"}"
]
| Returns the next available position in the table. | [
"Returns",
"the",
"next",
"available",
"position",
"in",
"the",
"table",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Helper/PositionHelper.php#L109-L122 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Helper/PositionHelper.php | PositionHelper.incrementPositions | private function incrementPositions(array $conditions, ?int $startPosition = null, ?int $endPosition = null): void
{
$columnName = $conditions['column'];
$query = $this->connection->createQueryBuilder();
$query
->update($conditions['table'])
->set($columnName, $columnName . ' + 1');
if ($startPosition !== null) {
$query->andWhere($query->expr()->gte($columnName, ':start_position'));
$query->setParameter('start_position', $startPosition, Type::INTEGER);
}
if ($endPosition !== null) {
$query->andWhere($query->expr()->lte($columnName, ':end_position'));
$query->setParameter('end_position', $endPosition, Type::INTEGER);
}
$this->applyConditions($query, $conditions['conditions']);
$query->execute();
} | php | private function incrementPositions(array $conditions, ?int $startPosition = null, ?int $endPosition = null): void
{
$columnName = $conditions['column'];
$query = $this->connection->createQueryBuilder();
$query
->update($conditions['table'])
->set($columnName, $columnName . ' + 1');
if ($startPosition !== null) {
$query->andWhere($query->expr()->gte($columnName, ':start_position'));
$query->setParameter('start_position', $startPosition, Type::INTEGER);
}
if ($endPosition !== null) {
$query->andWhere($query->expr()->lte($columnName, ':end_position'));
$query->setParameter('end_position', $endPosition, Type::INTEGER);
}
$this->applyConditions($query, $conditions['conditions']);
$query->execute();
} | [
"private",
"function",
"incrementPositions",
"(",
"array",
"$",
"conditions",
",",
"?",
"int",
"$",
"startPosition",
"=",
"null",
",",
"?",
"int",
"$",
"endPosition",
"=",
"null",
")",
":",
"void",
"{",
"$",
"columnName",
"=",
"$",
"conditions",
"[",
"'column'",
"]",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"query",
"->",
"update",
"(",
"$",
"conditions",
"[",
"'table'",
"]",
")",
"->",
"set",
"(",
"$",
"columnName",
",",
"$",
"columnName",
".",
"' + 1'",
")",
";",
"if",
"(",
"$",
"startPosition",
"!==",
"null",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"$",
"query",
"->",
"expr",
"(",
")",
"->",
"gte",
"(",
"$",
"columnName",
",",
"':start_position'",
")",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'start_position'",
",",
"$",
"startPosition",
",",
"Type",
"::",
"INTEGER",
")",
";",
"}",
"if",
"(",
"$",
"endPosition",
"!==",
"null",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"$",
"query",
"->",
"expr",
"(",
")",
"->",
"lte",
"(",
"$",
"columnName",
",",
"':end_position'",
")",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"'end_position'",
",",
"$",
"endPosition",
",",
"Type",
"::",
"INTEGER",
")",
";",
"}",
"$",
"this",
"->",
"applyConditions",
"(",
"$",
"query",
",",
"$",
"conditions",
"[",
"'conditions'",
"]",
")",
";",
"$",
"query",
"->",
"execute",
"(",
")",
";",
"}"
]
| Increments all positions in a table starting from provided position. | [
"Increments",
"all",
"positions",
"in",
"a",
"table",
"starting",
"from",
"provided",
"position",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Helper/PositionHelper.php#L127-L150 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Helper/PositionHelper.php | PositionHelper.applyConditions | private function applyConditions(QueryBuilder $query, array $conditions): void
{
foreach ($conditions as $identifier => $value) {
$query->andWhere(
$query->expr()->eq($identifier, ':' . $identifier)
);
$query->setParameter($identifier, $value, is_int($value) ? Type::INTEGER : Type::STRING);
}
} | php | private function applyConditions(QueryBuilder $query, array $conditions): void
{
foreach ($conditions as $identifier => $value) {
$query->andWhere(
$query->expr()->eq($identifier, ':' . $identifier)
);
$query->setParameter($identifier, $value, is_int($value) ? Type::INTEGER : Type::STRING);
}
} | [
"private",
"function",
"applyConditions",
"(",
"QueryBuilder",
"$",
"query",
",",
"array",
"$",
"conditions",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"conditions",
"as",
"$",
"identifier",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
"->",
"andWhere",
"(",
"$",
"query",
"->",
"expr",
"(",
")",
"->",
"eq",
"(",
"$",
"identifier",
",",
"':'",
".",
"$",
"identifier",
")",
")",
";",
"$",
"query",
"->",
"setParameter",
"(",
"$",
"identifier",
",",
"$",
"value",
",",
"is_int",
"(",
"$",
"value",
")",
"?",
"Type",
"::",
"INTEGER",
":",
"Type",
"::",
"STRING",
")",
";",
"}",
"}"
]
| Applies the provided conditions to the query. | [
"Applies",
"the",
"provided",
"conditions",
"to",
"the",
"query",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Helper/PositionHelper.php#L183-L192 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/Controller/Controller.php | Controller.buildView | protected function buildView(
$value,
string $context = ViewInterface::CONTEXT_DEFAULT,
array $parameters = [],
?Response $response = null
): ViewInterface {
/** @var \Netgen\BlockManager\View\ViewBuilderInterface $viewBuilder */
$viewBuilder = $this->get('netgen_block_manager.view.view_builder');
$view = $viewBuilder->buildView($value, $context, $parameters);
$view->setResponse($response instanceof Response ? $response : new Response());
return $view;
} | php | protected function buildView(
$value,
string $context = ViewInterface::CONTEXT_DEFAULT,
array $parameters = [],
?Response $response = null
): ViewInterface {
/** @var \Netgen\BlockManager\View\ViewBuilderInterface $viewBuilder */
$viewBuilder = $this->get('netgen_block_manager.view.view_builder');
$view = $viewBuilder->buildView($value, $context, $parameters);
$view->setResponse($response instanceof Response ? $response : new Response());
return $view;
} | [
"protected",
"function",
"buildView",
"(",
"$",
"value",
",",
"string",
"$",
"context",
"=",
"ViewInterface",
"::",
"CONTEXT_DEFAULT",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
",",
"?",
"Response",
"$",
"response",
"=",
"null",
")",
":",
"ViewInterface",
"{",
"/** @var \\Netgen\\BlockManager\\View\\ViewBuilderInterface $viewBuilder */",
"$",
"viewBuilder",
"=",
"$",
"this",
"->",
"get",
"(",
"'netgen_block_manager.view.view_builder'",
")",
";",
"$",
"view",
"=",
"$",
"viewBuilder",
"->",
"buildView",
"(",
"$",
"value",
",",
"$",
"context",
",",
"$",
"parameters",
")",
";",
"$",
"view",
"->",
"setResponse",
"(",
"$",
"response",
"instanceof",
"Response",
"?",
"$",
"response",
":",
"new",
"Response",
"(",
")",
")",
";",
"return",
"$",
"view",
";",
"}"
]
| Builds the view from provided value.
@param mixed $value
@param string $context
@param array<string, mixed> $parameters
@param \Symfony\Component\HttpFoundation\Response $response
@return \Netgen\BlockManager\View\ViewInterface | [
"Builds",
"the",
"view",
"from",
"provided",
"value",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/Controller/Controller.php#L32-L45 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/DependencyInjection/CompilerPass/Layout/LayoutTypePass.php | LayoutTypePass.buildLayoutTypes | private function buildLayoutTypes(ContainerBuilder $container, array $layoutTypes): Generator
{
foreach ($layoutTypes as $identifier => $layoutType) {
$serviceIdentifier = sprintf('netgen_block_manager.layout.layout_type.%s', $identifier);
$container->register($serviceIdentifier, LayoutType::class)
->setArguments([$identifier, $layoutType])
->setLazy(true)
->setPublic(true)
->setFactory([LayoutTypeFactory::class, 'buildLayoutType']);
yield $identifier => new Reference($serviceIdentifier);
}
} | php | private function buildLayoutTypes(ContainerBuilder $container, array $layoutTypes): Generator
{
foreach ($layoutTypes as $identifier => $layoutType) {
$serviceIdentifier = sprintf('netgen_block_manager.layout.layout_type.%s', $identifier);
$container->register($serviceIdentifier, LayoutType::class)
->setArguments([$identifier, $layoutType])
->setLazy(true)
->setPublic(true)
->setFactory([LayoutTypeFactory::class, 'buildLayoutType']);
yield $identifier => new Reference($serviceIdentifier);
}
} | [
"private",
"function",
"buildLayoutTypes",
"(",
"ContainerBuilder",
"$",
"container",
",",
"array",
"$",
"layoutTypes",
")",
":",
"Generator",
"{",
"foreach",
"(",
"$",
"layoutTypes",
"as",
"$",
"identifier",
"=>",
"$",
"layoutType",
")",
"{",
"$",
"serviceIdentifier",
"=",
"sprintf",
"(",
"'netgen_block_manager.layout.layout_type.%s'",
",",
"$",
"identifier",
")",
";",
"$",
"container",
"->",
"register",
"(",
"$",
"serviceIdentifier",
",",
"LayoutType",
"::",
"class",
")",
"->",
"setArguments",
"(",
"[",
"$",
"identifier",
",",
"$",
"layoutType",
"]",
")",
"->",
"setLazy",
"(",
"true",
")",
"->",
"setPublic",
"(",
"true",
")",
"->",
"setFactory",
"(",
"[",
"LayoutTypeFactory",
"::",
"class",
",",
"'buildLayoutType'",
"]",
")",
";",
"yield",
"$",
"identifier",
"=>",
"new",
"Reference",
"(",
"$",
"serviceIdentifier",
")",
";",
"}",
"}"
]
| Builds the layout type objects from provided configuration. | [
"Builds",
"the",
"layout",
"type",
"objects",
"from",
"provided",
"configuration",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/DependencyInjection/CompilerPass/Layout/LayoutTypePass.php#L39-L52 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/DependencyInjection/CompilerPass/Layout/LayoutTypePass.php | LayoutTypePass.validateLayoutTypes | private function validateLayoutTypes(array $layoutTypes, array $blockDefinitions): void
{
foreach ($layoutTypes as $layoutType => $layoutTypeConfig) {
foreach ($layoutTypeConfig['zones'] as $zoneConfig) {
foreach ($zoneConfig['allowed_block_definitions'] as $blockDefinition) {
if (!isset($blockDefinitions[$blockDefinition])) {
throw new RuntimeException(
sprintf(
'Block definition "%s" used in "%s" layout type does not exist.',
$blockDefinition,
$layoutType
)
);
}
}
}
}
} | php | private function validateLayoutTypes(array $layoutTypes, array $blockDefinitions): void
{
foreach ($layoutTypes as $layoutType => $layoutTypeConfig) {
foreach ($layoutTypeConfig['zones'] as $zoneConfig) {
foreach ($zoneConfig['allowed_block_definitions'] as $blockDefinition) {
if (!isset($blockDefinitions[$blockDefinition])) {
throw new RuntimeException(
sprintf(
'Block definition "%s" used in "%s" layout type does not exist.',
$blockDefinition,
$layoutType
)
);
}
}
}
}
} | [
"private",
"function",
"validateLayoutTypes",
"(",
"array",
"$",
"layoutTypes",
",",
"array",
"$",
"blockDefinitions",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"layoutTypes",
"as",
"$",
"layoutType",
"=>",
"$",
"layoutTypeConfig",
")",
"{",
"foreach",
"(",
"$",
"layoutTypeConfig",
"[",
"'zones'",
"]",
"as",
"$",
"zoneConfig",
")",
"{",
"foreach",
"(",
"$",
"zoneConfig",
"[",
"'allowed_block_definitions'",
"]",
"as",
"$",
"blockDefinition",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"blockDefinitions",
"[",
"$",
"blockDefinition",
"]",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"sprintf",
"(",
"'Block definition \"%s\" used in \"%s\" layout type does not exist.'",
",",
"$",
"blockDefinition",
",",
"$",
"layoutType",
")",
")",
";",
"}",
"}",
"}",
"}",
"}"
]
| Validates layout type config.
@throws \Netgen\BlockManager\Exception\RuntimeException If validation failed | [
"Validates",
"layout",
"type",
"config",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/DependencyInjection/CompilerPass/Layout/LayoutTypePass.php#L59-L76 | train |
netgen-layouts/layouts-core | bundles/BlockManagerBundle/Templating/Twig/Runtime/ItemRuntime.php | ItemRuntime.getItemPath | public function getItemPath($value, ?string $valueType = null): string
{
try {
$item = null;
if (is_string($value) && $valueType === null) {
$itemUri = parse_url($value);
if (!is_array($itemUri) || ($itemUri['scheme'] ?? '') === '' || !isset($itemUri['host'])) {
throw ItemException::invalidValue($value);
}
$item = $this->cmsItemLoader->load(
$itemUri['host'],
str_replace('-', '_', $itemUri['scheme'])
);
} elseif ((is_int($value) || is_string($value)) && is_string($valueType)) {
$item = $this->cmsItemLoader->load($value, $valueType);
} elseif ($value instanceof CmsItemInterface) {
$item = $value;
}
if (!$item instanceof CmsItemInterface) {
throw ItemException::canNotLoadItem();
}
return $this->urlGenerator->generate($item);
} catch (Throwable $t) {
$this->errorHandler->handleError($t);
}
return '';
} | php | public function getItemPath($value, ?string $valueType = null): string
{
try {
$item = null;
if (is_string($value) && $valueType === null) {
$itemUri = parse_url($value);
if (!is_array($itemUri) || ($itemUri['scheme'] ?? '') === '' || !isset($itemUri['host'])) {
throw ItemException::invalidValue($value);
}
$item = $this->cmsItemLoader->load(
$itemUri['host'],
str_replace('-', '_', $itemUri['scheme'])
);
} elseif ((is_int($value) || is_string($value)) && is_string($valueType)) {
$item = $this->cmsItemLoader->load($value, $valueType);
} elseif ($value instanceof CmsItemInterface) {
$item = $value;
}
if (!$item instanceof CmsItemInterface) {
throw ItemException::canNotLoadItem();
}
return $this->urlGenerator->generate($item);
} catch (Throwable $t) {
$this->errorHandler->handleError($t);
}
return '';
} | [
"public",
"function",
"getItemPath",
"(",
"$",
"value",
",",
"?",
"string",
"$",
"valueType",
"=",
"null",
")",
":",
"string",
"{",
"try",
"{",
"$",
"item",
"=",
"null",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"$",
"valueType",
"===",
"null",
")",
"{",
"$",
"itemUri",
"=",
"parse_url",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"itemUri",
")",
"||",
"(",
"$",
"itemUri",
"[",
"'scheme'",
"]",
"??",
"''",
")",
"===",
"''",
"||",
"!",
"isset",
"(",
"$",
"itemUri",
"[",
"'host'",
"]",
")",
")",
"{",
"throw",
"ItemException",
"::",
"invalidValue",
"(",
"$",
"value",
")",
";",
"}",
"$",
"item",
"=",
"$",
"this",
"->",
"cmsItemLoader",
"->",
"load",
"(",
"$",
"itemUri",
"[",
"'host'",
"]",
",",
"str_replace",
"(",
"'-'",
",",
"'_'",
",",
"$",
"itemUri",
"[",
"'scheme'",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"(",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_string",
"(",
"$",
"value",
")",
")",
"&&",
"is_string",
"(",
"$",
"valueType",
")",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"cmsItemLoader",
"->",
"load",
"(",
"$",
"value",
",",
"$",
"valueType",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"CmsItemInterface",
")",
"{",
"$",
"item",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"!",
"$",
"item",
"instanceof",
"CmsItemInterface",
")",
"{",
"throw",
"ItemException",
"::",
"canNotLoadItem",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"$",
"item",
")",
";",
"}",
"catch",
"(",
"Throwable",
"$",
"t",
")",
"{",
"$",
"this",
"->",
"errorHandler",
"->",
"handleError",
"(",
"$",
"t",
")",
";",
"}",
"return",
"''",
";",
"}"
]
| The method returns the full path of provided item.
It accepts three kinds of references to the item:
1) URI with value_type://value format, e.g. type://42
2) ID and value type as separate arguments
3) \Netgen\BlockManager\Item\CmsItemInterface object
@param mixed $value
@param string|null $valueType
@throws \Netgen\BlockManager\Exception\Item\ItemException If provided item or item reference is not valid
@return string | [
"The",
"method",
"returns",
"the",
"full",
"path",
"of",
"provided",
"item",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerBundle/Templating/Twig/Runtime/ItemRuntime.php#L57-L88 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/CollectionMapper.php | CollectionMapper.mapCollections | public function mapCollections(array $data): array
{
$collections = [];
foreach ($data as $dataItem) {
$collectionId = (int) $dataItem['id'];
$locale = $dataItem['locale'];
if (!isset($collections[$collectionId])) {
$collections[$collectionId] = [
'id' => $collectionId,
'status' => (int) $dataItem['status'],
'offset' => (int) $dataItem['start'],
'limit' => $dataItem['length'] !== null ? (int) $dataItem['length'] : null,
'isTranslatable' => (bool) $dataItem['translatable'],
'mainLocale' => $dataItem['main_locale'],
'alwaysAvailable' => (bool) $dataItem['always_available'],
];
}
$collections[$collectionId]['availableLocales'][] = $locale;
}
return array_values(
array_map(
static function (array $collectionData): Collection {
sort($collectionData['availableLocales']);
return Collection::fromArray($collectionData);
},
$collections
)
);
} | php | public function mapCollections(array $data): array
{
$collections = [];
foreach ($data as $dataItem) {
$collectionId = (int) $dataItem['id'];
$locale = $dataItem['locale'];
if (!isset($collections[$collectionId])) {
$collections[$collectionId] = [
'id' => $collectionId,
'status' => (int) $dataItem['status'],
'offset' => (int) $dataItem['start'],
'limit' => $dataItem['length'] !== null ? (int) $dataItem['length'] : null,
'isTranslatable' => (bool) $dataItem['translatable'],
'mainLocale' => $dataItem['main_locale'],
'alwaysAvailable' => (bool) $dataItem['always_available'],
];
}
$collections[$collectionId]['availableLocales'][] = $locale;
}
return array_values(
array_map(
static function (array $collectionData): Collection {
sort($collectionData['availableLocales']);
return Collection::fromArray($collectionData);
},
$collections
)
);
} | [
"public",
"function",
"mapCollections",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"collections",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataItem",
")",
"{",
"$",
"collectionId",
"=",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'id'",
"]",
";",
"$",
"locale",
"=",
"$",
"dataItem",
"[",
"'locale'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"collections",
"[",
"$",
"collectionId",
"]",
")",
")",
"{",
"$",
"collections",
"[",
"$",
"collectionId",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"collectionId",
",",
"'status'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'status'",
"]",
",",
"'offset'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'start'",
"]",
",",
"'limit'",
"=>",
"$",
"dataItem",
"[",
"'length'",
"]",
"!==",
"null",
"?",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'length'",
"]",
":",
"null",
",",
"'isTranslatable'",
"=>",
"(",
"bool",
")",
"$",
"dataItem",
"[",
"'translatable'",
"]",
",",
"'mainLocale'",
"=>",
"$",
"dataItem",
"[",
"'main_locale'",
"]",
",",
"'alwaysAvailable'",
"=>",
"(",
"bool",
")",
"$",
"dataItem",
"[",
"'always_available'",
"]",
",",
"]",
";",
"}",
"$",
"collections",
"[",
"$",
"collectionId",
"]",
"[",
"'availableLocales'",
"]",
"[",
"]",
"=",
"$",
"locale",
";",
"}",
"return",
"array_values",
"(",
"array_map",
"(",
"static",
"function",
"(",
"array",
"$",
"collectionData",
")",
":",
"Collection",
"{",
"sort",
"(",
"$",
"collectionData",
"[",
"'availableLocales'",
"]",
")",
";",
"return",
"Collection",
"::",
"fromArray",
"(",
"$",
"collectionData",
")",
";",
"}",
",",
"$",
"collections",
")",
")",
";",
"}"
]
| Maps data from database to collection values.
@return \Netgen\BlockManager\Persistence\Values\Collection\Collection[] | [
"Maps",
"data",
"from",
"database",
"to",
"collection",
"values",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/CollectionMapper.php#L18-L51 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/CollectionMapper.php | CollectionMapper.mapItems | public function mapItems(array $data): array
{
$items = [];
foreach ($data as $dataItem) {
$items[] = Item::fromArray(
[
'id' => (int) $dataItem['id'],
'collectionId' => (int) $dataItem['collection_id'],
'position' => (int) $dataItem['position'],
'value' => $dataItem['value'],
'valueType' => $dataItem['value_type'],
'status' => (int) $dataItem['status'],
'config' => $this->buildParameters((string) $dataItem['config']),
]
);
}
return $items;
} | php | public function mapItems(array $data): array
{
$items = [];
foreach ($data as $dataItem) {
$items[] = Item::fromArray(
[
'id' => (int) $dataItem['id'],
'collectionId' => (int) $dataItem['collection_id'],
'position' => (int) $dataItem['position'],
'value' => $dataItem['value'],
'valueType' => $dataItem['value_type'],
'status' => (int) $dataItem['status'],
'config' => $this->buildParameters((string) $dataItem['config']),
]
);
}
return $items;
} | [
"public",
"function",
"mapItems",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataItem",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"Item",
"::",
"fromArray",
"(",
"[",
"'id'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'id'",
"]",
",",
"'collectionId'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'collection_id'",
"]",
",",
"'position'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'position'",
"]",
",",
"'value'",
"=>",
"$",
"dataItem",
"[",
"'value'",
"]",
",",
"'valueType'",
"=>",
"$",
"dataItem",
"[",
"'value_type'",
"]",
",",
"'status'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'status'",
"]",
",",
"'config'",
"=>",
"$",
"this",
"->",
"buildParameters",
"(",
"(",
"string",
")",
"$",
"dataItem",
"[",
"'config'",
"]",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"items",
";",
"}"
]
| Maps data from database to item values.
@return \Netgen\BlockManager\Persistence\Values\Collection\Item[] | [
"Maps",
"data",
"from",
"database",
"to",
"item",
"values",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/CollectionMapper.php#L58-L77 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/CollectionMapper.php | CollectionMapper.mapQueries | public function mapQueries(array $data): array
{
$queries = [];
foreach ($data as $dataItem) {
$queryId = (int) $dataItem['id'];
$locale = $dataItem['locale'];
if (!isset($queries[$queryId])) {
$queries[$queryId] = [
'id' => $queryId,
'collectionId' => (int) $dataItem['collection_id'],
'type' => $dataItem['type'],
'status' => (int) $dataItem['status'],
];
}
$queries[$queryId]['parameters'][$locale] = $this->buildParameters((string) $dataItem['parameters']);
$queries[$queryId]['availableLocales'][] = $locale;
}
$queries = array_values(
array_map(
static function (array $queryData): Query {
ksort($queryData['parameters']);
sort($queryData['availableLocales']);
return Query::fromArray($queryData);
},
$queries
)
);
return $queries;
} | php | public function mapQueries(array $data): array
{
$queries = [];
foreach ($data as $dataItem) {
$queryId = (int) $dataItem['id'];
$locale = $dataItem['locale'];
if (!isset($queries[$queryId])) {
$queries[$queryId] = [
'id' => $queryId,
'collectionId' => (int) $dataItem['collection_id'],
'type' => $dataItem['type'],
'status' => (int) $dataItem['status'],
];
}
$queries[$queryId]['parameters'][$locale] = $this->buildParameters((string) $dataItem['parameters']);
$queries[$queryId]['availableLocales'][] = $locale;
}
$queries = array_values(
array_map(
static function (array $queryData): Query {
ksort($queryData['parameters']);
sort($queryData['availableLocales']);
return Query::fromArray($queryData);
},
$queries
)
);
return $queries;
} | [
"public",
"function",
"mapQueries",
"(",
"array",
"$",
"data",
")",
":",
"array",
"{",
"$",
"queries",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"dataItem",
")",
"{",
"$",
"queryId",
"=",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'id'",
"]",
";",
"$",
"locale",
"=",
"$",
"dataItem",
"[",
"'locale'",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"queries",
"[",
"$",
"queryId",
"]",
")",
")",
"{",
"$",
"queries",
"[",
"$",
"queryId",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"queryId",
",",
"'collectionId'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'collection_id'",
"]",
",",
"'type'",
"=>",
"$",
"dataItem",
"[",
"'type'",
"]",
",",
"'status'",
"=>",
"(",
"int",
")",
"$",
"dataItem",
"[",
"'status'",
"]",
",",
"]",
";",
"}",
"$",
"queries",
"[",
"$",
"queryId",
"]",
"[",
"'parameters'",
"]",
"[",
"$",
"locale",
"]",
"=",
"$",
"this",
"->",
"buildParameters",
"(",
"(",
"string",
")",
"$",
"dataItem",
"[",
"'parameters'",
"]",
")",
";",
"$",
"queries",
"[",
"$",
"queryId",
"]",
"[",
"'availableLocales'",
"]",
"[",
"]",
"=",
"$",
"locale",
";",
"}",
"$",
"queries",
"=",
"array_values",
"(",
"array_map",
"(",
"static",
"function",
"(",
"array",
"$",
"queryData",
")",
":",
"Query",
"{",
"ksort",
"(",
"$",
"queryData",
"[",
"'parameters'",
"]",
")",
";",
"sort",
"(",
"$",
"queryData",
"[",
"'availableLocales'",
"]",
")",
";",
"return",
"Query",
"::",
"fromArray",
"(",
"$",
"queryData",
")",
";",
"}",
",",
"$",
"queries",
")",
")",
";",
"return",
"$",
"queries",
";",
"}"
]
| Maps data from database to query values. | [
"Maps",
"data",
"from",
"database",
"to",
"query",
"values",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/CollectionMapper.php#L82-L116 | train |
netgen-layouts/layouts-core | lib/Persistence/Doctrine/Mapper/CollectionMapper.php | CollectionMapper.buildParameters | private function buildParameters(string $parameters): array
{
$decodedParameters = json_decode($parameters, true);
return is_array($decodedParameters) ? $decodedParameters : [];
} | php | private function buildParameters(string $parameters): array
{
$decodedParameters = json_decode($parameters, true);
return is_array($decodedParameters) ? $decodedParameters : [];
} | [
"private",
"function",
"buildParameters",
"(",
"string",
"$",
"parameters",
")",
":",
"array",
"{",
"$",
"decodedParameters",
"=",
"json_decode",
"(",
"$",
"parameters",
",",
"true",
")",
";",
"return",
"is_array",
"(",
"$",
"decodedParameters",
")",
"?",
"$",
"decodedParameters",
":",
"[",
"]",
";",
"}"
]
| Builds the array of parameters from provided JSON string. | [
"Builds",
"the",
"array",
"of",
"parameters",
"from",
"provided",
"JSON",
"string",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/lib/Persistence/Doctrine/Mapper/CollectionMapper.php#L121-L126 | train |
netgen-layouts/layouts-core | bundles/BlockManagerAdminBundle/Controller/Admin/LayoutResolver/UpdateRulePriorities.php | UpdateRulePriorities.validatePriorities | private function validatePriorities(Request $request): void
{
$this->validate(
$request->request->get('rule_ids'),
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'array']),
new Constraints\All(
[
'constraints' => [
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'scalar']),
],
]
),
],
'rule_ids'
);
} | php | private function validatePriorities(Request $request): void
{
$this->validate(
$request->request->get('rule_ids'),
[
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'array']),
new Constraints\All(
[
'constraints' => [
new Constraints\NotBlank(),
new Constraints\Type(['type' => 'scalar']),
],
]
),
],
'rule_ids'
);
} | [
"private",
"function",
"validatePriorities",
"(",
"Request",
"$",
"request",
")",
":",
"void",
"{",
"$",
"this",
"->",
"validate",
"(",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'rule_ids'",
")",
",",
"[",
"new",
"Constraints",
"\\",
"NotBlank",
"(",
")",
",",
"new",
"Constraints",
"\\",
"Type",
"(",
"[",
"'type'",
"=>",
"'array'",
"]",
")",
",",
"new",
"Constraints",
"\\",
"All",
"(",
"[",
"'constraints'",
"=>",
"[",
"new",
"Constraints",
"\\",
"NotBlank",
"(",
")",
",",
"new",
"Constraints",
"\\",
"Type",
"(",
"[",
"'type'",
"=>",
"'scalar'",
"]",
")",
",",
"]",
",",
"]",
")",
",",
"]",
",",
"'rule_ids'",
")",
";",
"}"
]
| Validates list of rules from the request when updating priorities.
@throws \Netgen\BlockManager\Exception\Validation\ValidationException If validation failed | [
"Validates",
"list",
"of",
"rules",
"from",
"the",
"request",
"when",
"updating",
"priorities",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerAdminBundle/Controller/Admin/LayoutResolver/UpdateRulePriorities.php#L87-L105 | train |
netgen-layouts/layouts-core | bundles/BlockManagerDebugBundle/DataCollector/BlockManagerDataCollector.php | BlockManagerDataCollector.collectLayout | public function collectLayout(LayoutViewInterface $layoutView): void
{
$layout = $layoutView->getLayout();
$this->data['layout'] = [
'id' => $layout->getId(),
'name' => $layout->getName(),
'type' => $layout->getLayoutType()->getName(),
'context' => $layoutView->getContext(),
'template' => null,
'template_path' => null,
];
if ($layoutView->getTemplate() !== null) {
$templateSource = $this->getTemplateSource($layoutView->getTemplate());
$this->data['layout']['template'] = $templateSource->getName();
$this->data['layout']['template_path'] = $templateSource->getPath();
}
} | php | public function collectLayout(LayoutViewInterface $layoutView): void
{
$layout = $layoutView->getLayout();
$this->data['layout'] = [
'id' => $layout->getId(),
'name' => $layout->getName(),
'type' => $layout->getLayoutType()->getName(),
'context' => $layoutView->getContext(),
'template' => null,
'template_path' => null,
];
if ($layoutView->getTemplate() !== null) {
$templateSource = $this->getTemplateSource($layoutView->getTemplate());
$this->data['layout']['template'] = $templateSource->getName();
$this->data['layout']['template_path'] = $templateSource->getPath();
}
} | [
"public",
"function",
"collectLayout",
"(",
"LayoutViewInterface",
"$",
"layoutView",
")",
":",
"void",
"{",
"$",
"layout",
"=",
"$",
"layoutView",
"->",
"getLayout",
"(",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'layout'",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"layout",
"->",
"getId",
"(",
")",
",",
"'name'",
"=>",
"$",
"layout",
"->",
"getName",
"(",
")",
",",
"'type'",
"=>",
"$",
"layout",
"->",
"getLayoutType",
"(",
")",
"->",
"getName",
"(",
")",
",",
"'context'",
"=>",
"$",
"layoutView",
"->",
"getContext",
"(",
")",
",",
"'template'",
"=>",
"null",
",",
"'template_path'",
"=>",
"null",
",",
"]",
";",
"if",
"(",
"$",
"layoutView",
"->",
"getTemplate",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"templateSource",
"=",
"$",
"this",
"->",
"getTemplateSource",
"(",
"$",
"layoutView",
"->",
"getTemplate",
"(",
")",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'layout'",
"]",
"[",
"'template'",
"]",
"=",
"$",
"templateSource",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"data",
"[",
"'layout'",
"]",
"[",
"'template_path'",
"]",
"=",
"$",
"templateSource",
"->",
"getPath",
"(",
")",
";",
"}",
"}"
]
| Collects the layout data. | [
"Collects",
"the",
"layout",
"data",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerDebugBundle/DataCollector/BlockManagerDataCollector.php#L77-L96 | train |
netgen-layouts/layouts-core | bundles/BlockManagerDebugBundle/DataCollector/BlockManagerDataCollector.php | BlockManagerDataCollector.collectRule | public function collectRule(Rule $rule): void
{
$this->data['rule'] = [
'id' => $rule->getId(),
];
foreach ($rule->getTargets() as $target) {
$this->data['rule']['targets'][] = [
'type' => $target->getTargetType()::getType(),
'value' => $this->formatVar($target->getValue()),
];
}
foreach ($rule->getConditions() as $condition) {
$this->data['rule']['conditions'][] = [
'type' => $condition->getConditionType()::getType(),
'value' => $this->formatVar($condition->getValue()),
];
}
} | php | public function collectRule(Rule $rule): void
{
$this->data['rule'] = [
'id' => $rule->getId(),
];
foreach ($rule->getTargets() as $target) {
$this->data['rule']['targets'][] = [
'type' => $target->getTargetType()::getType(),
'value' => $this->formatVar($target->getValue()),
];
}
foreach ($rule->getConditions() as $condition) {
$this->data['rule']['conditions'][] = [
'type' => $condition->getConditionType()::getType(),
'value' => $this->formatVar($condition->getValue()),
];
}
} | [
"public",
"function",
"collectRule",
"(",
"Rule",
"$",
"rule",
")",
":",
"void",
"{",
"$",
"this",
"->",
"data",
"[",
"'rule'",
"]",
"=",
"[",
"'id'",
"=>",
"$",
"rule",
"->",
"getId",
"(",
")",
",",
"]",
";",
"foreach",
"(",
"$",
"rule",
"->",
"getTargets",
"(",
")",
"as",
"$",
"target",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'rule'",
"]",
"[",
"'targets'",
"]",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"target",
"->",
"getTargetType",
"(",
")",
"::",
"getType",
"(",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"formatVar",
"(",
"$",
"target",
"->",
"getValue",
"(",
")",
")",
",",
"]",
";",
"}",
"foreach",
"(",
"$",
"rule",
"->",
"getConditions",
"(",
")",
"as",
"$",
"condition",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'rule'",
"]",
"[",
"'conditions'",
"]",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"condition",
"->",
"getConditionType",
"(",
")",
"::",
"getType",
"(",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"formatVar",
"(",
"$",
"condition",
"->",
"getValue",
"(",
")",
")",
",",
"]",
";",
"}",
"}"
]
| Collects the rule data. | [
"Collects",
"the",
"rule",
"data",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerDebugBundle/DataCollector/BlockManagerDataCollector.php#L101-L120 | train |
netgen-layouts/layouts-core | bundles/BlockManagerDebugBundle/DataCollector/BlockManagerDataCollector.php | BlockManagerDataCollector.collectBlockView | public function collectBlockView(BlockViewInterface $blockView): void
{
$block = $blockView->getBlock();
$blockDefinition = $block->getDefinition();
$blockData = [
'id' => $block->getId(),
'layout_id' => $block->getLayoutId(),
'definition' => $blockDefinition->getName(),
'view_type' => $blockDefinition->hasViewType($block->getViewType()) ?
$blockDefinition->getViewType($block->getViewType())->getName() :
'Invalid view type',
'locale' => $block->getLocale(),
'template' => null,
'template_path' => null,
];
if ($blockView->getTemplate() !== null) {
$templateSource = $this->getTemplateSource($blockView->getTemplate());
$blockData['template'] = $templateSource->getName();
$blockData['template_path'] = $templateSource->getPath();
}
$this->data['blocks'][] = $blockData;
} | php | public function collectBlockView(BlockViewInterface $blockView): void
{
$block = $blockView->getBlock();
$blockDefinition = $block->getDefinition();
$blockData = [
'id' => $block->getId(),
'layout_id' => $block->getLayoutId(),
'definition' => $blockDefinition->getName(),
'view_type' => $blockDefinition->hasViewType($block->getViewType()) ?
$blockDefinition->getViewType($block->getViewType())->getName() :
'Invalid view type',
'locale' => $block->getLocale(),
'template' => null,
'template_path' => null,
];
if ($blockView->getTemplate() !== null) {
$templateSource = $this->getTemplateSource($blockView->getTemplate());
$blockData['template'] = $templateSource->getName();
$blockData['template_path'] = $templateSource->getPath();
}
$this->data['blocks'][] = $blockData;
} | [
"public",
"function",
"collectBlockView",
"(",
"BlockViewInterface",
"$",
"blockView",
")",
":",
"void",
"{",
"$",
"block",
"=",
"$",
"blockView",
"->",
"getBlock",
"(",
")",
";",
"$",
"blockDefinition",
"=",
"$",
"block",
"->",
"getDefinition",
"(",
")",
";",
"$",
"blockData",
"=",
"[",
"'id'",
"=>",
"$",
"block",
"->",
"getId",
"(",
")",
",",
"'layout_id'",
"=>",
"$",
"block",
"->",
"getLayoutId",
"(",
")",
",",
"'definition'",
"=>",
"$",
"blockDefinition",
"->",
"getName",
"(",
")",
",",
"'view_type'",
"=>",
"$",
"blockDefinition",
"->",
"hasViewType",
"(",
"$",
"block",
"->",
"getViewType",
"(",
")",
")",
"?",
"$",
"blockDefinition",
"->",
"getViewType",
"(",
"$",
"block",
"->",
"getViewType",
"(",
")",
")",
"->",
"getName",
"(",
")",
":",
"'Invalid view type'",
",",
"'locale'",
"=>",
"$",
"block",
"->",
"getLocale",
"(",
")",
",",
"'template'",
"=>",
"null",
",",
"'template_path'",
"=>",
"null",
",",
"]",
";",
"if",
"(",
"$",
"blockView",
"->",
"getTemplate",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"templateSource",
"=",
"$",
"this",
"->",
"getTemplateSource",
"(",
"$",
"blockView",
"->",
"getTemplate",
"(",
")",
")",
";",
"$",
"blockData",
"[",
"'template'",
"]",
"=",
"$",
"templateSource",
"->",
"getName",
"(",
")",
";",
"$",
"blockData",
"[",
"'template_path'",
"]",
"=",
"$",
"templateSource",
"->",
"getPath",
"(",
")",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"'blocks'",
"]",
"[",
"]",
"=",
"$",
"blockData",
";",
"}"
]
| Collects the block view data. | [
"Collects",
"the",
"block",
"view",
"data",
"."
]
| 81b4dd0d3043b926286f9a4890e1d8deebb103e9 | https://github.com/netgen-layouts/layouts-core/blob/81b4dd0d3043b926286f9a4890e1d8deebb103e9/bundles/BlockManagerDebugBundle/DataCollector/BlockManagerDataCollector.php#L125-L150 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.