repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
drupalwxt/wxt | src/Composer/ReleaseVersion.php | ReleaseVersion.updateMakeFile | protected static function updateMakeFile($version) {
$encoder = new IniEncoder();
$finder = (new Finder())
->name('build-wxt.make')
->in('.');
/** @var \Symfony\Component\Finder\SplFileInfo $make_file */
foreach ($finder as $make_file) {
$make = $encoder->parse($make_file->getContent... | php | protected static function updateMakeFile($version) {
$encoder = new IniEncoder();
$finder = (new Finder())
->name('build-wxt.make')
->in('.');
/** @var \Symfony\Component\Finder\SplFileInfo $make_file */
foreach ($finder as $make_file) {
$make = $encoder->parse($make_file->getContent... | [
"protected",
"static",
"function",
"updateMakeFile",
"(",
"$",
"version",
")",
"{",
"$",
"encoder",
"=",
"new",
"IniEncoder",
"(",
")",
";",
"$",
"finder",
"=",
"(",
"new",
"Finder",
"(",
")",
")",
"->",
"name",
"(",
"'build-wxt.make'",
")",
"->",
"in"... | Updates the legacy Drush make file(s).
@param string $version
The target version. | [
"Updates",
"the",
"legacy",
"Drush",
"make",
"file",
"(",
"s",
")",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/src/Composer/ReleaseVersion.php#L56-L69 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_breadcrumb/src/Breadcrumb/BlogBreadcrumbBuilder.php | BlogBreadcrumbBuilder.build | public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$links = [];
// Add the url.path.parent cache context. This code ignores the last path
// part so the result only depends on the path parents.
$breadcrumb->addCacheContexts(['url.path.parent']);
$links[] ... | php | public function build(RouteMatchInterface $route_match) {
$breadcrumb = new Breadcrumb();
$links = [];
// Add the url.path.parent cache context. This code ignores the last path
// part so the result only depends on the path parents.
$breadcrumb->addCacheContexts(['url.path.parent']);
$links[] ... | [
"public",
"function",
"build",
"(",
"RouteMatchInterface",
"$",
"route_match",
")",
"{",
"$",
"breadcrumb",
"=",
"new",
"Breadcrumb",
"(",
")",
";",
"$",
"links",
"=",
"[",
"]",
";",
"// Add the url.path.parent cache context. This code ignores the last path",
"// part... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_breadcrumb/src/Breadcrumb/BlogBreadcrumbBuilder.php#L169-L213 |
drupalwxt/wxt | modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php | Lightbox.settingsForm | public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$image_styles = image_style_options(FALSE);
$form['thumb_image_style'] = [
'#title' => $this->t('Thumbnail Image Style'),
'#type' => 'select',
'#default_value' => ... | php | public function settingsForm(array $form, FormStateInterface $form_state) {
$form = parent::settingsForm($form, $form_state);
$image_styles = image_style_options(FALSE);
$form['thumb_image_style'] = [
'#title' => $this->t('Thumbnail Image Style'),
'#type' => 'select',
'#default_value' => ... | [
"public",
"function",
"settingsForm",
"(",
"array",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"form",
"=",
"parent",
"::",
"settingsForm",
"(",
"$",
"form",
",",
"$",
"form_state",
")",
";",
"$",
"image_styles",
"=",
"image_... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php#L39-L67 |
drupalwxt/wxt | modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php | Lightbox.settingsSummary | public function settingsSummary() {
$image_styles = image_style_options(FALSE);
$thumb_image_style = $this->getSetting('thumb_image_style');
$lbx_image_style = $this->getSetting('lbx_image_style');
$summary[] = $this->t('Thumbnail image style: @thumb_style. Lightbox image style: @lbx_style', [
'@... | php | public function settingsSummary() {
$image_styles = image_style_options(FALSE);
$thumb_image_style = $this->getSetting('thumb_image_style');
$lbx_image_style = $this->getSetting('lbx_image_style');
$summary[] = $this->t('Thumbnail image style: @thumb_style. Lightbox image style: @lbx_style', [
'@... | [
"public",
"function",
"settingsSummary",
"(",
")",
"{",
"$",
"image_styles",
"=",
"image_style_options",
"(",
"FALSE",
")",
";",
"$",
"thumb_image_style",
"=",
"$",
"this",
"->",
"getSetting",
"(",
"'thumb_image_style'",
")",
";",
"$",
"lbx_image_style",
"=",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php#L72-L83 |
drupalwxt/wxt | modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php | Lightbox.viewElements | public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
$thumb_image_style = $this->getSetting('thumb_image_style');
$lbx_image_style = $this->getSetting('lbx_image_style');
$lbx_gal = $this->getSetting('lbx_gal');
$files = $this->getEntitiesToView($items, $langcode)... | php | public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
$thumb_image_style = $this->getSetting('thumb_image_style');
$lbx_image_style = $this->getSetting('lbx_image_style');
$lbx_gal = $this->getSetting('lbx_gal');
$files = $this->getEntitiesToView($items, $langcode)... | [
"public",
"function",
"viewElements",
"(",
"FieldItemListInterface",
"$",
"items",
",",
"$",
"langcode",
")",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"$",
"thumb_image_style",
"=",
"$",
"this",
"->",
"getSetting",
"(",
"'thumb_image_style'",
")",
";",
"$",... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php#L88-L120 |
drupalwxt/wxt | modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php | Lightbox.view | public function view(FieldItemListInterface $items, $langcode = NULL) {
$elements = parent::view($items, $langcode);
$lbx_gal = $this->getSetting('lbx_gal');
$elements['#attributes']['class'][] = 'wb-lbx';
$elements['#attributes']['class'][] = 'lbx-gal';
$elements['#attributes']['class'][] = 'wxt-' ... | php | public function view(FieldItemListInterface $items, $langcode = NULL) {
$elements = parent::view($items, $langcode);
$lbx_gal = $this->getSetting('lbx_gal');
$elements['#attributes']['class'][] = 'wb-lbx';
$elements['#attributes']['class'][] = 'lbx-gal';
$elements['#attributes']['class'][] = 'wxt-' ... | [
"public",
"function",
"view",
"(",
"FieldItemListInterface",
"$",
"items",
",",
"$",
"langcode",
"=",
"NULL",
")",
"{",
"$",
"elements",
"=",
"parent",
"::",
"view",
"(",
"$",
"items",
",",
"$",
"langcode",
")",
";",
"$",
"lbx_gal",
"=",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_core/src/Plugin/Field/FieldFormatter/Lightbox.php#L125-L132 |
drupalwxt/wxt | modules/custom/wxt_admin/src/EventSubscriber/MenuRouterRebuildSubscriber.php | MenuRouterRebuildSubscriber.onKernelRequestMenuRouterRebuild | public function onKernelRequestMenuRouterRebuild(GetResponseEvent $event) {
if (file_exists("public://rebuild.dat")) {
$site_path = preg_replace('/^sites\//', '', $this->sitePath);
if (!file_exists('public://.drushrc') && file_exists('public://') && is_writable('public://') && file_put_contents('public:... | php | public function onKernelRequestMenuRouterRebuild(GetResponseEvent $event) {
if (file_exists("public://rebuild.dat")) {
$site_path = preg_replace('/^sites\//', '', $this->sitePath);
if (!file_exists('public://.drushrc') && file_exists('public://') && is_writable('public://') && file_put_contents('public:... | [
"public",
"function",
"onKernelRequestMenuRouterRebuild",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"if",
"(",
"file_exists",
"(",
"\"public://rebuild.dat\"",
")",
")",
"{",
"$",
"site_path",
"=",
"preg_replace",
"(",
"'/^sites\\//'",
",",
"''",
",",
"$",
... | Rebuilds the menu router if the rebuild.dat file is found.
@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
The Event to process. | [
"Rebuilds",
"the",
"menu",
"router",
"if",
"the",
"rebuild",
".",
"dat",
"file",
"is",
"found",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_admin/src/EventSubscriber/MenuRouterRebuildSubscriber.php#L48-L59 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php | MigrationSubscriber.onMigrationPostRowSave | public function onMigrationPostRowSave(MigratePostRowSaveEvent $event) {
// Landing Page logic.
if ($event->getMigration()->id() == 'gcweb_node_landing_page' ||
$event->getMigration()->id() == 'gcweb_node_landing_page_translation') {
// Set front page to panelized "homepage".
$name = $event-... | php | public function onMigrationPostRowSave(MigratePostRowSaveEvent $event) {
// Landing Page logic.
if ($event->getMigration()->id() == 'gcweb_node_landing_page' ||
$event->getMigration()->id() == 'gcweb_node_landing_page_translation') {
// Set front page to panelized "homepage".
$name = $event-... | [
"public",
"function",
"onMigrationPostRowSave",
"(",
"MigratePostRowSaveEvent",
"$",
"event",
")",
"{",
"// Landing Page logic.",
"if",
"(",
"$",
"event",
"->",
"getMigration",
"(",
")",
"->",
"id",
"(",
")",
"==",
"'gcweb_node_landing_page'",
"||",
"$",
"event",
... | Code to run after a migration row has been saved. | [
"Code",
"to",
"run",
"after",
"a",
"migration",
"row",
"has",
"been",
"saved",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php#L181-L211 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php | MigrationSubscriber.getSubscribedEvents | public static function getSubscribedEvents() {
$events[MigrateEvents::PRE_ROW_SAVE] = 'onMigrationPreRowSave';
$events[MigrateEvents::POST_ROW_SAVE] = 'onMigrationPostRowSave';
$events[MigrateEvents::POST_IMPORT] = 'onMigrationPostImport';
return $events;
} | php | public static function getSubscribedEvents() {
$events[MigrateEvents::PRE_ROW_SAVE] = 'onMigrationPreRowSave';
$events[MigrateEvents::POST_ROW_SAVE] = 'onMigrationPostRowSave';
$events[MigrateEvents::POST_IMPORT] = 'onMigrationPostImport';
return $events;
} | [
"public",
"static",
"function",
"getSubscribedEvents",
"(",
")",
"{",
"$",
"events",
"[",
"MigrateEvents",
"::",
"PRE_ROW_SAVE",
"]",
"=",
"'onMigrationPreRowSave'",
";",
"$",
"events",
"[",
"MigrateEvents",
"::",
"POST_ROW_SAVE",
"]",
"=",
"'onMigrationPostRowSave'... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php#L216-L221 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php | MigrationSubscriber.entityQueueCreate | public function entityQueueCreate($queue, $destBid) {
$entity_subqueue = $this->entityManager->getStorage('entity_subqueue')->load($queue);
$items = $entity_subqueue->get('items')->getValue();
$items[] = ['target_id' => $destBid[0]];
$entity_subqueue->set('items', $items);
$entity_subqueue->save();
... | php | public function entityQueueCreate($queue, $destBid) {
$entity_subqueue = $this->entityManager->getStorage('entity_subqueue')->load($queue);
$items = $entity_subqueue->get('items')->getValue();
$items[] = ['target_id' => $destBid[0]];
$entity_subqueue->set('items', $items);
$entity_subqueue->save();
... | [
"public",
"function",
"entityQueueCreate",
"(",
"$",
"queue",
",",
"$",
"destBid",
")",
"{",
"$",
"entity_subqueue",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getStorage",
"(",
"'entity_subqueue'",
")",
"->",
"load",
"(",
"$",
"queue",
")",
";",
"$",... | Add a specific entityqueue. | [
"Add",
"a",
"specific",
"entityqueue",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php#L226-L232 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php | MigrationSubscriber.menuLinkDependency | public function menuLinkDependency($title, $link, $translations, $destBid, $weight = 0, $menu = 'main') {
$menu_link_content = $this->entityManager->getStorage('menu_link_content')->create([
'title' => $title,
'link' => ['uri' => 'internal:/node/' . $destBid[0]],
'menu_name' => (!empty($translatio... | php | public function menuLinkDependency($title, $link, $translations, $destBid, $weight = 0, $menu = 'main') {
$menu_link_content = $this->entityManager->getStorage('menu_link_content')->create([
'title' => $title,
'link' => ['uri' => 'internal:/node/' . $destBid[0]],
'menu_name' => (!empty($translatio... | [
"public",
"function",
"menuLinkDependency",
"(",
"$",
"title",
",",
"$",
"link",
",",
"$",
"translations",
",",
"$",
"destBid",
",",
"$",
"weight",
"=",
"0",
",",
"$",
"menu",
"=",
"'main'",
")",
"{",
"$",
"menu_link_content",
"=",
"$",
"this",
"->",
... | Add a menu link with dependency support. | [
"Add",
"a",
"menu",
"link",
"with",
"dependency",
"support",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/EventSubscriber/MigrationSubscriber.php#L237-L252 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/TextToTerm.php | TextToTerm.transform | public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$field = empty($this->configuration['field']) ? 'value' : $this->configuration['field'];
$termName = FALSE;
/*
* Depending on the context (whether the plugin is called
* as a part ... | php | public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$field = empty($this->configuration['field']) ? 'value' : $this->configuration['field'];
$termName = FALSE;
/*
* Depending on the context (whether the plugin is called
* as a part ... | [
"public",
"function",
"transform",
"(",
"$",
"value",
",",
"MigrateExecutableInterface",
"$",
"migrate_executable",
",",
"Row",
"$",
"row",
",",
"$",
"destination_property",
")",
"{",
"$",
"field",
"=",
"empty",
"(",
"$",
"this",
"->",
"configuration",
"[",
... | The main function for the plugin, actually doing the data conversion. | [
"The",
"main",
"function",
"for",
"the",
"plugin",
"actually",
"doing",
"the",
"data",
"conversion",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/TextToTerm.php#L23-L51 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/TextToTerm.php | TextToTerm.getTerm | protected function getTerm($name, Row $row, $vocabulary) {
// Attempt to fetch an existing term.
$properties = [];
if (!empty($name)) {
$properties['name'] = $name;
}
$vocabularies = taxonomy_vocabulary_get_names();
if (isset($vocabularies[$vocabulary])) {
$properties['vid'] = $vocab... | php | protected function getTerm($name, Row $row, $vocabulary) {
// Attempt to fetch an existing term.
$properties = [];
if (!empty($name)) {
$properties['name'] = $name;
}
$vocabularies = taxonomy_vocabulary_get_names();
if (isset($vocabularies[$vocabulary])) {
$properties['vid'] = $vocab... | [
"protected",
"function",
"getTerm",
"(",
"$",
"name",
",",
"Row",
"$",
"row",
",",
"$",
"vocabulary",
")",
"{",
"// Attempt to fetch an existing term.",
"$",
"properties",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"$... | Creates a new or returns an existing term for the target vocabulary. | [
"Creates",
"a",
"new",
"or",
"returns",
"an",
"existing",
"term",
"for",
"the",
"target",
"vocabulary",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/TextToTerm.php#L56-L88 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php | ReportProblemBlock.blockForm | public function blockForm($form, FormStateInterface $form_state) {
$form['webform_id'] = [
'#title' => $this->t('Webform'),
'#type' => 'entity_autocomplete',
'#target_type' => 'webform',
'#required' => TRUE,
'#default_value' => $this->getWebform(),
];
return $form;
} | php | public function blockForm($form, FormStateInterface $form_state) {
$form['webform_id'] = [
'#title' => $this->t('Webform'),
'#type' => 'entity_autocomplete',
'#target_type' => 'webform',
'#required' => TRUE,
'#default_value' => $this->getWebform(),
];
return $form;
} | [
"public",
"function",
"blockForm",
"(",
"$",
"form",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"form",
"[",
"'webform_id'",
"]",
"=",
"[",
"'#title'",
"=>",
"$",
"this",
"->",
"t",
"(",
"'Webform'",
")",
",",
"'#type'",
"=>",
"'entity_... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php#L97-L108 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php | ReportProblemBlock.build | public function build() {
$url = $this->getWebform()->toUrl()
->setOption('query', $this->requestStack->getCurrentRequest()->query->all())
->toString();
$markup = '<a class="btn btn-default" href="' . $url . '">';
$markup .= '<span class="glyphicon glyphicon-play"> </span>';
$markup .=... | php | public function build() {
$url = $this->getWebform()->toUrl()
->setOption('query', $this->requestStack->getCurrentRequest()->query->all())
->toString();
$markup = '<a class="btn btn-default" href="' . $url . '">';
$markup .= '<span class="glyphicon glyphicon-play"> </span>';
$markup .=... | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getWebform",
"(",
")",
"->",
"toUrl",
"(",
")",
"->",
"setOption",
"(",
"'query'",
",",
"$",
"this",
"->",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
"->",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php#L120-L131 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php | ReportProblemBlock.blockAccess | protected function blockAccess(AccountInterface $account) {
$webform = $this->getWebform();
if (!$webform) {
return AccessResult::forbidden();
}
$access_result = $webform->access('submission_create', $account, TRUE);
if ($access_result->isAllowed()) {
return $access_result;
}
$... | php | protected function blockAccess(AccountInterface $account) {
$webform = $this->getWebform();
if (!$webform) {
return AccessResult::forbidden();
}
$access_result = $webform->access('submission_create', $account, TRUE);
if ($access_result->isAllowed()) {
return $access_result;
}
$... | [
"protected",
"function",
"blockAccess",
"(",
"AccountInterface",
"$",
"account",
")",
"{",
"$",
"webform",
"=",
"$",
"this",
"->",
"getWebform",
"(",
")",
";",
"if",
"(",
"!",
"$",
"webform",
")",
"{",
"return",
"AccessResult",
"::",
"forbidden",
"(",
")... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php#L136-L150 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php | ReportProblemBlock.calculateDependencies | public function calculateDependencies() {
$dependencies = parent::calculateDependencies();
$webform = $this->getWebform();
$dependencies[$webform->getConfigDependencyKey()][] = $webform->getConfigDependencyName();
return $dependencies;
} | php | public function calculateDependencies() {
$dependencies = parent::calculateDependencies();
$webform = $this->getWebform();
$dependencies[$webform->getConfigDependencyKey()][] = $webform->getConfigDependencyName();
return $dependencies;
} | [
"public",
"function",
"calculateDependencies",
"(",
")",
"{",
"$",
"dependencies",
"=",
"parent",
"::",
"calculateDependencies",
"(",
")",
";",
"$",
"webform",
"=",
"$",
"this",
"->",
"getWebform",
"(",
")",
";",
"$",
"dependencies",
"[",
"$",
"webform",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_webform/src/Plugin/Block/ReportProblemBlock.php#L155-L162 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/MediaTags.php | MediaTags.replaceToken | private function replaceToken($match, $migrate_executable, $row, $destination_property) {
$settings = [];
$match = str_replace("[[", "", $match);
$match = str_replace("]]", "", $match);
$tag = $match[0];
$classes = '';
try {
if (!is_string($tag)) {
throw new MigrateException('Unab... | php | private function replaceToken($match, $migrate_executable, $row, $destination_property) {
$settings = [];
$match = str_replace("[[", "", $match);
$match = str_replace("]]", "", $match);
$tag = $match[0];
$classes = '';
try {
if (!is_string($tag)) {
throw new MigrateException('Unab... | [
"private",
"function",
"replaceToken",
"(",
"$",
"match",
",",
"$",
"migrate_executable",
",",
"$",
"row",
",",
"$",
"destination_property",
")",
"{",
"$",
"settings",
"=",
"[",
"]",
";",
"$",
"match",
"=",
"str_replace",
"(",
"\"[[\"",
",",
"\"\"",
",",... | Replace callback to convert a media file tag into HTML markup.
Partially copied from 7.x media module media.filter.inc (media_filter).
@param string $match
Takes a match of tag code
@param \Drupal\migrate\MigrateExecutableInterface $migrate_executable
The migrate executable helper class.
@param \Drupal\migrate\Row $r... | [
"Replace",
"callback",
"to",
"convert",
"a",
"media",
"file",
"tag",
"into",
"HTML",
"markup",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/MediaTags.php#L105-L186 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/MediaTags.php | MediaTags.mediaParseCssDeclarations | private function mediaParseCssDeclarations($declarations) {
$properties = [];
foreach (array_map('trim', explode(";", $declarations)) as $declaration) {
if ($declaration != '') {
list($name, $value) = array_map('trim', explode(':', $declaration, 2));
$properties[strtolower($name)] = $value... | php | private function mediaParseCssDeclarations($declarations) {
$properties = [];
foreach (array_map('trim', explode(";", $declarations)) as $declaration) {
if ($declaration != '') {
list($name, $value) = array_map('trim', explode(':', $declaration, 2));
$properties[strtolower($name)] = $value... | [
"private",
"function",
"mediaParseCssDeclarations",
"(",
"$",
"declarations",
")",
"{",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"array_map",
"(",
"'trim'",
",",
"explode",
"(",
"\";\"",
",",
"$",
"declarations",
")",
")",
"as",
"$",
"declara... | Copied from 7.x media @ media.filter.inc (media_parse_css_declarations).
Parses the contents of a CSS declaration block and returns a keyed array
of property names and values.
@param $declarations
One or more CSS declarations delimited by a semicolon. The same as a CSS
declaration block (http://www.w3.org/TR/CSS21/sy... | [
"Copied",
"from",
"7",
".",
"x",
"media",
"@",
"media",
".",
"filter",
".",
"inc",
"(",
"media_parse_css_declarations",
")",
"."
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/MediaTags.php#L204-L213 |
drupalwxt/wxt | modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/PrivPath.php | PrivPath.transform | public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!$value) {
throw new MigrateSkipProcessException();
}
return $this->getPrivPath($value);
} | php | public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
if (!$value) {
throw new MigrateSkipProcessException();
}
return $this->getPrivPath($value);
} | [
"public",
"function",
"transform",
"(",
"$",
"value",
",",
"MigrateExecutableInterface",
"$",
"migrate_executable",
",",
"Row",
"$",
"row",
",",
"$",
"destination_property",
")",
"{",
"if",
"(",
"!",
"$",
"value",
")",
"{",
"throw",
"new",
"MigrateSkipProcessE... | {@inheritdoc} | [
"{"
] | train | https://github.com/drupalwxt/wxt/blob/f0a3730065d9dba1ffb68237e329bf575da410d4/modules/custom/wxt_ext/wxt_ext_migration/src/Plugin/migrate/process/PrivPath.php#L23-L28 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.validateContentTypeHeader | public function validateContentTypeHeader(): void
{
if ($this->isValidMediaTypeHeader("content-type") === false) {
throw $this->exceptionFactory->createMediaTypeUnsupportedException(
$this,
$this->getHeaderLine("content-type")
);
}
} | php | public function validateContentTypeHeader(): void
{
if ($this->isValidMediaTypeHeader("content-type") === false) {
throw $this->exceptionFactory->createMediaTypeUnsupportedException(
$this,
$this->getHeaderLine("content-type")
);
}
} | [
"public",
"function",
"validateContentTypeHeader",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidMediaTypeHeader",
"(",
"\"content-type\"",
")",
"===",
"false",
")",
"{",
"throw",
"$",
"this",
"->",
"exceptionFactory",
"->",
"createMediaTypeU... | Validates if the current request's Content-Type header conforms to the JSON:API schema.
@throws MediaTypeUnsupported|JsonApiExceptionInterface | [
"Validates",
"if",
"the",
"current",
"request",
"s",
"Content",
"-",
"Type",
"header",
"conforms",
"to",
"the",
"JSON",
":",
"API",
"schema",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L83-L91 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.validateAcceptHeader | public function validateAcceptHeader(): void
{
if ($this->isValidMediaTypeHeader("accept") === false) {
throw $this->exceptionFactory->createMediaTypeUnacceptableException($this, $this->getHeaderLine("accept"));
}
} | php | public function validateAcceptHeader(): void
{
if ($this->isValidMediaTypeHeader("accept") === false) {
throw $this->exceptionFactory->createMediaTypeUnacceptableException($this, $this->getHeaderLine("accept"));
}
} | [
"public",
"function",
"validateAcceptHeader",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidMediaTypeHeader",
"(",
"\"accept\"",
")",
"===",
"false",
")",
"{",
"throw",
"$",
"this",
"->",
"exceptionFactory",
"->",
"createMediaTypeUnacceptable... | Validates if the current request's Accept header conforms to the JSON:API schema.
@throws MediaTypeUnacceptable|JsonApiExceptionInterface | [
"Validates",
"if",
"the",
"current",
"request",
"s",
"Accept",
"header",
"conforms",
"to",
"the",
"JSON",
":",
"API",
"schema",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L98-L103 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.validateQueryParams | public function validateQueryParams(): void
{
foreach ($this->getQueryParams() as $queryParamName => $queryParamValue) {
if (preg_match("/^([a-z]+)$/", $queryParamName) === 1 &&
in_array($queryParamName, ["fields", "include", "sort", "page", "filter", "profile"], true) === false
... | php | public function validateQueryParams(): void
{
foreach ($this->getQueryParams() as $queryParamName => $queryParamValue) {
if (preg_match("/^([a-z]+)$/", $queryParamName) === 1 &&
in_array($queryParamName, ["fields", "include", "sort", "page", "filter", "profile"], true) === false
... | [
"public",
"function",
"validateQueryParams",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getQueryParams",
"(",
")",
"as",
"$",
"queryParamName",
"=>",
"$",
"queryParamValue",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^([a-z]+)$/\"",
","... | Validates if the current request's query parameters conform to the JSON:API schema.
According to the JSON:API specification "Implementation specific query parameters MUST
adhere to the same constraints as member names with the additional requirement that they
MUST contain at least one non a-z character (U+0061 to U+00... | [
"Validates",
"if",
"the",
"current",
"request",
"s",
"query",
"parameters",
"conform",
"to",
"the",
"JSON",
":",
"API",
"schema",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L114-L123 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getIncludedFields | public function getIncludedFields(string $resourceType): array
{
if ($this->includedFields === null) {
$this->includedFields = $this->setIncludedFields();
}
return isset($this->includedFields[$resourceType]) ? array_keys($this->includedFields[$resourceType]) : [];
} | php | public function getIncludedFields(string $resourceType): array
{
if ($this->includedFields === null) {
$this->includedFields = $this->setIncludedFields();
}
return isset($this->includedFields[$resourceType]) ? array_keys($this->includedFields[$resourceType]) : [];
} | [
"public",
"function",
"getIncludedFields",
"(",
"string",
"$",
"resourceType",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"includedFields",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"includedFields",
"=",
"$",
"this",
"->",
"setIncludedFields",
... | Returns a list of field names for the given resource type which should be present in the response. | [
"Returns",
"a",
"list",
"of",
"field",
"names",
"for",
"the",
"given",
"resource",
"type",
"which",
"should",
"be",
"present",
"in",
"the",
"response",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L269-L276 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.isIncludedField | public function isIncludedField(string $resourceType, string $field): bool
{
if ($this->includedFields === null) {
$this->includedFields = $this->setIncludedFields();
}
if (array_key_exists($resourceType, $this->includedFields) === false) {
return true;
}
... | php | public function isIncludedField(string $resourceType, string $field): bool
{
if ($this->includedFields === null) {
$this->includedFields = $this->setIncludedFields();
}
if (array_key_exists($resourceType, $this->includedFields) === false) {
return true;
}
... | [
"public",
"function",
"isIncludedField",
"(",
"string",
"$",
"resourceType",
",",
"string",
"$",
"field",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"includedFields",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"includedFields",
"=",
"$",
"this... | Determines if a given field for a given resource type should be present in the response or not. | [
"Determines",
"if",
"a",
"given",
"field",
"for",
"a",
"given",
"resource",
"type",
"should",
"be",
"present",
"in",
"the",
"response",
"or",
"not",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L281-L296 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.hasIncludedRelationships | public function hasIncludedRelationships(): bool
{
if ($this->includedRelationships === null) {
$this->setIncludedRelationships();
}
return empty($this->includedRelationships) === false;
} | php | public function hasIncludedRelationships(): bool
{
if ($this->includedRelationships === null) {
$this->setIncludedRelationships();
}
return empty($this->includedRelationships) === false;
} | [
"public",
"function",
"hasIncludedRelationships",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"includedRelationships",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setIncludedRelationships",
"(",
")",
";",
"}",
"return",
"empty",
"(",
"$",
"t... | Determines if any relationship needs to be included. | [
"Determines",
"if",
"any",
"relationship",
"needs",
"to",
"be",
"included",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L337-L344 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getIncludedRelationships | public function getIncludedRelationships(string $baseRelationshipPath): array
{
if ($this->includedRelationships === null) {
$this->setIncludedRelationships();
}
if (isset($this->includedRelationships[$baseRelationshipPath])) {
return array_values($this->includedRela... | php | public function getIncludedRelationships(string $baseRelationshipPath): array
{
if ($this->includedRelationships === null) {
$this->setIncludedRelationships();
}
if (isset($this->includedRelationships[$baseRelationshipPath])) {
return array_values($this->includedRela... | [
"public",
"function",
"getIncludedRelationships",
"(",
"string",
"$",
"baseRelationshipPath",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"includedRelationships",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"setIncludedRelationships",
"(",
")",
";",
... | Returns a list of relationship paths for a given parent path which should be included in the response. | [
"Returns",
"a",
"list",
"of",
"relationship",
"paths",
"for",
"a",
"given",
"parent",
"path",
"which",
"should",
"be",
"included",
"in",
"the",
"response",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L349-L360 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.isIncludedRelationship | public function isIncludedRelationship(
string $baseRelationshipPath,
string $relationshipName,
array $defaultRelationships
): bool {
if ($this->includedRelationships === null) {
$this->setIncludedRelationships();
}
if ($this->getQueryParam("include") ===... | php | public function isIncludedRelationship(
string $baseRelationshipPath,
string $relationshipName,
array $defaultRelationships
): bool {
if ($this->includedRelationships === null) {
$this->setIncludedRelationships();
}
if ($this->getQueryParam("include") ===... | [
"public",
"function",
"isIncludedRelationship",
"(",
"string",
"$",
"baseRelationshipPath",
",",
"string",
"$",
"relationshipName",
",",
"array",
"$",
"defaultRelationships",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"includedRelationships",
"===",
"nul... | Determines if a given relationship name that is a child of the $baseRelationshipPath should be included
in the response. | [
"Determines",
"if",
"a",
"given",
"relationship",
"name",
"that",
"is",
"a",
"child",
"of",
"the",
"$baseRelationshipPath",
"should",
"be",
"included",
"in",
"the",
"response",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L366-L384 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getSorting | public function getSorting(): array
{
if ($this->sorting === null) {
$this->sorting = $this->setSorting();
}
return $this->sorting;
} | php | public function getSorting(): array
{
if ($this->sorting === null) {
$this->sorting = $this->setSorting();
}
return $this->sorting;
} | [
"public",
"function",
"getSorting",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"sorting",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"sorting",
"=",
"$",
"this",
"->",
"setSorting",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
... | Returns the "sort[]" query parameters. | [
"Returns",
"the",
"sort",
"[]",
"query",
"parameters",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L389-L396 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getPagination | public function getPagination(): array
{
if ($this->pagination === null) {
$this->pagination = $this->setPagination();
}
return $this->pagination;
} | php | public function getPagination(): array
{
if ($this->pagination === null) {
$this->pagination = $this->setPagination();
}
return $this->pagination;
} | [
"public",
"function",
"getPagination",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"pagination",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"pagination",
"=",
"$",
"this",
"->",
"setPagination",
"(",
")",
";",
"}",
"return",
"$",
"thi... | Returns the "page[]" query parameters. | [
"Returns",
"the",
"page",
"[]",
"query",
"parameters",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L415-L422 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getFiltering | public function getFiltering(): array
{
if ($this->filtering === null) {
$this->filtering = $this->setFiltering();
}
return $this->filtering;
} | php | public function getFiltering(): array
{
if ($this->filtering === null) {
$this->filtering = $this->setFiltering();
}
return $this->filtering;
} | [
"public",
"function",
"getFiltering",
"(",
")",
":",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"filtering",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"filtering",
"=",
"$",
"this",
"->",
"setFiltering",
"(",
")",
";",
"}",
"return",
"$",
"this",
... | Returns the "filter[]" query parameters. | [
"Returns",
"the",
"filter",
"[]",
"query",
"parameters",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L438-L445 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getToOneRelationship | public function getToOneRelationship(string $relationship): ToOneRelationship
{
$data = $this->getResource();
// The relationship has to exist in the request and have a data attribute to be valid
if (isset($data["relationships"][$relationship]) && array_key_exists("data", $data["relationshi... | php | public function getToOneRelationship(string $relationship): ToOneRelationship
{
$data = $this->getResource();
// The relationship has to exist in the request and have a data attribute to be valid
if (isset($data["relationships"][$relationship]) && array_key_exists("data", $data["relationshi... | [
"public",
"function",
"getToOneRelationship",
"(",
"string",
"$",
"relationship",
")",
":",
"ToOneRelationship",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
";",
"// The relationship has to exist in the request and have a data attribute to be valid",
... | Returns the $relationship to-one relationship of the primary resource if it is present, or null otherwise. | [
"Returns",
"the",
"$relationship",
"to",
"-",
"one",
"relationship",
"of",
"the",
"primary",
"resource",
"if",
"it",
"is",
"present",
"or",
"null",
"otherwise",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L541-L558 |
woohoolabs/yin | src/JsonApi/Request/JsonApiRequest.php | JsonApiRequest.getToManyRelationship | public function getToManyRelationship(string $relationship): ToManyRelationship
{
$data = $this->getResource();
if (isset($data["relationships"][$relationship]["data"]) === false) {
throw $this->exceptionFactory->createRelationshipNotExistsException($relationship);
}
$r... | php | public function getToManyRelationship(string $relationship): ToManyRelationship
{
$data = $this->getResource();
if (isset($data["relationships"][$relationship]["data"]) === false) {
throw $this->exceptionFactory->createRelationshipNotExistsException($relationship);
}
$r... | [
"public",
"function",
"getToManyRelationship",
"(",
"string",
"$",
"relationship",
")",
":",
"ToManyRelationship",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"\"relationships\"",
"]",
... | Returns the $relationship to-many relationship of the primary resource if it is present, or null otherwise. | [
"Returns",
"the",
"$relationship",
"to",
"-",
"many",
"relationship",
"of",
"the",
"primary",
"resource",
"if",
"it",
"is",
"present",
"or",
"null",
"otherwise",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/JsonApiRequest.php#L570-L584 |
woohoolabs/yin | examples/Book/JsonApi/Hydrator/BookHydator.php | BookHydator.validateClientGeneratedId | protected function validateClientGeneratedId(
string $clientGeneratedId,
JsonApiRequestInterface $request,
ExceptionFactoryInterface $exceptionFactory
) {
if ($clientGeneratedId !== null) {
throw $exceptionFactory->createClientGeneratedIdNotSupportedException($request, $c... | php | protected function validateClientGeneratedId(
string $clientGeneratedId,
JsonApiRequestInterface $request,
ExceptionFactoryInterface $exceptionFactory
) {
if ($clientGeneratedId !== null) {
throw $exceptionFactory->createClientGeneratedIdNotSupportedException($request, $c... | [
"protected",
"function",
"validateClientGeneratedId",
"(",
"string",
"$",
"clientGeneratedId",
",",
"JsonApiRequestInterface",
"$",
"request",
",",
"ExceptionFactoryInterface",
"$",
"exceptionFactory",
")",
"{",
"if",
"(",
"$",
"clientGeneratedId",
"!==",
"null",
")",
... | Validates a client-generated ID.
If the $clientGeneratedId is not a valid ID for the domain object, then
the appropriate exception should be thrown: if it is not well-formed then
a ClientGeneratedIdNotSupported exception can be raised, if the ID already
exists then a ClientGeneratedIdAlreadyExists exception can be thr... | [
"Validates",
"a",
"client",
"-",
"generated",
"ID",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/Book/JsonApi/Hydrator/BookHydator.php#L45-L53 |
woohoolabs/yin | examples/Book/JsonApi/Hydrator/BookHydator.php | BookHydator.getAttributeHydrator | protected function getAttributeHydrator($book): array
{
return [
"title" => function (array $book, $attribute, $data) {
$book["title"] = $attribute;
return $book;
},
"pages" => function (array &$book, $attribute, $data) {
$b... | php | protected function getAttributeHydrator($book): array
{
return [
"title" => function (array $book, $attribute, $data) {
$book["title"] = $attribute;
return $book;
},
"pages" => function (array &$book, $attribute, $data) {
$b... | [
"protected",
"function",
"getAttributeHydrator",
"(",
"$",
"book",
")",
":",
"array",
"{",
"return",
"[",
"\"title\"",
"=>",
"function",
"(",
"array",
"$",
"book",
",",
"$",
"attribute",
",",
"$",
"data",
")",
"{",
"$",
"book",
"[",
"\"title\"",
"]",
"... | Provides the attribute hydrators.
The method returns an array of attribute hydrators, where a hydrator is a key-value pair:
the key is the specific attribute name which comes from the request and the value is a
callable which hydrates the given attribute.
These callables receive the domain object (which will be hydrat... | [
"Provides",
"the",
"attribute",
"hydrators",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/Book/JsonApi/Hydrator/BookHydator.php#L110-L121 |
woohoolabs/yin | examples/Book/JsonApi/Hydrator/BookHydator.php | BookHydator.getRelationshipHydrator | protected function getRelationshipHydrator($book): array
{
return [
"authors" => function (array $book, ToManyRelationship $authors, $data, $relationshipName) {
if ($authors->isEmpty()) {
$book["authors"] = [];
} else {
$boo... | php | protected function getRelationshipHydrator($book): array
{
return [
"authors" => function (array $book, ToManyRelationship $authors, $data, $relationshipName) {
if ($authors->isEmpty()) {
$book["authors"] = [];
} else {
$boo... | [
"protected",
"function",
"getRelationshipHydrator",
"(",
"$",
"book",
")",
":",
"array",
"{",
"return",
"[",
"\"authors\"",
"=>",
"function",
"(",
"array",
"$",
"book",
",",
"ToManyRelationship",
"$",
"authors",
",",
"$",
"data",
",",
"$",
"relationshipName",
... | Provides the relationship hydrators.
The method returns an array of relationship hydrators, where a hydrator is a key-value pair:
the key is the specific relationship name which comes from the request and the value is a
callable which hydrate the previous relationship.
These callables receive the domain object (which ... | [
"Provides",
"the",
"relationship",
"hydrators",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/Book/JsonApi/Hydrator/BookHydator.php#L139-L159 |
woohoolabs/yin | examples/User/JsonApi/Document/UsersDocument.php | UsersDocument.getLinks | public function getLinks(): ?DocumentLinks
{
return DocumentLinks::createWithoutBaseUri()
->setPagination("/users", $this->object, $this->request->getUri()->getQuery());
} | php | public function getLinks(): ?DocumentLinks
{
return DocumentLinks::createWithoutBaseUri()
->setPagination("/users", $this->object, $this->request->getUri()->getQuery());
} | [
"public",
"function",
"getLinks",
"(",
")",
":",
"?",
"DocumentLinks",
"{",
"return",
"DocumentLinks",
"::",
"createWithoutBaseUri",
"(",
")",
"->",
"setPagination",
"(",
"\"/users\"",
",",
"$",
"this",
"->",
"object",
",",
"$",
"this",
"->",
"request",
"->"... | Provides information about the "links" member of the current document.
The method returns a new DocumentLinks object if you want to provide linkage data
for the document or null if the section should be omitted from the response. | [
"Provides",
"information",
"about",
"the",
"links",
"member",
"of",
"the",
"current",
"document",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/User/JsonApi/Document/UsersDocument.php#L46-L50 |
woohoolabs/yin | src/JsonApi/JsonApi.php | JsonApi.disableIncludes | public function disableIncludes(): void
{
if ($this->request->getQueryParam("include") !== null) {
throw $this->exceptionFactory->createInclusionUnsupportedException($this->request);
}
} | php | public function disableIncludes(): void
{
if ($this->request->getQueryParam("include") !== null) {
throw $this->exceptionFactory->createInclusionUnsupportedException($this->request);
}
} | [
"public",
"function",
"disableIncludes",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"getQueryParam",
"(",
"\"include\"",
")",
"!==",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"exceptionFactory",
"->",
"createInclusionUnsup... | Disables inclusion of related resources.
If the current request asks for inclusion of related resources, it throws an InclusionNotSupported exception.
@throws InclusionUnsupported|JsonApiExceptionInterface | [
"Disables",
"inclusion",
"of",
"related",
"resources",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/JsonApi.php#L122-L127 |
woohoolabs/yin | src/JsonApi/JsonApi.php | JsonApi.disableSorting | public function disableSorting(): void
{
if ($this->request->getQueryParam("sort") !== null) {
throw $this->exceptionFactory->createSortingUnsupportedException($this->request);
}
} | php | public function disableSorting(): void
{
if ($this->request->getQueryParam("sort") !== null) {
throw $this->exceptionFactory->createSortingUnsupportedException($this->request);
}
} | [
"public",
"function",
"disableSorting",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"getQueryParam",
"(",
"\"sort\"",
")",
"!==",
"null",
")",
"{",
"throw",
"$",
"this",
"->",
"exceptionFactory",
"->",
"createSortingUnsupported... | Disables sorting.
If the current request contains sorting criteria, it throws a SortingNotSupported exception.
@throws SortingUnsupported|JsonApiExceptionInterface | [
"Disables",
"sorting",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/JsonApi.php#L136-L141 |
woohoolabs/yin | src/JsonApi/Request/Pagination/PaginationFactory.php | PaginationFactory.createFixedPageBasedPagination | public function createFixedPageBasedPagination(int $defaultPage = 0): FixedPageBasedPagination
{
return FixedPageBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultPage);
} | php | public function createFixedPageBasedPagination(int $defaultPage = 0): FixedPageBasedPagination
{
return FixedPageBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultPage);
} | [
"public",
"function",
"createFixedPageBasedPagination",
"(",
"int",
"$",
"defaultPage",
"=",
"0",
")",
":",
"FixedPageBasedPagination",
"{",
"return",
"FixedPageBasedPagination",
"::",
"fromPaginationQueryParams",
"(",
"$",
"this",
"->",
"request",
"->",
"getPagination"... | Returns a FixedPageBasedPagination class in order to be used for fixed page-based pagination.
The FixedPageBasedPagination class stores the value of the "page[number]" query parameter if present
or the $defaultPage otherwise. | [
"Returns",
"a",
"FixedPageBasedPagination",
"class",
"in",
"order",
"to",
"be",
"used",
"for",
"fixed",
"page",
"-",
"based",
"pagination",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/Pagination/PaginationFactory.php#L26-L29 |
woohoolabs/yin | src/JsonApi/Request/Pagination/PaginationFactory.php | PaginationFactory.createPageBasedPagination | public function createPageBasedPagination(int $defaultPage = 0, int $defaultSize = 0): PageBasedPagination
{
return PageBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultPage, $defaultSize);
} | php | public function createPageBasedPagination(int $defaultPage = 0, int $defaultSize = 0): PageBasedPagination
{
return PageBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultPage, $defaultSize);
} | [
"public",
"function",
"createPageBasedPagination",
"(",
"int",
"$",
"defaultPage",
"=",
"0",
",",
"int",
"$",
"defaultSize",
"=",
"0",
")",
":",
"PageBasedPagination",
"{",
"return",
"PageBasedPagination",
"::",
"fromPaginationQueryParams",
"(",
"$",
"this",
"->",... | Returns a PageBasedPagination class in order to be used for page-based pagination.
The PageBasedPagination class stores the value of the "page[number]" and "page[size]" query parameters
if present or the $defaultPage and $defaultSize otherwise. | [
"Returns",
"a",
"PageBasedPagination",
"class",
"in",
"order",
"to",
"be",
"used",
"for",
"page",
"-",
"based",
"pagination",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/Pagination/PaginationFactory.php#L37-L40 |
woohoolabs/yin | src/JsonApi/Request/Pagination/PaginationFactory.php | PaginationFactory.createOffsetBasedPagination | public function createOffsetBasedPagination(int $defaultOffset = 0, int $defaultLimit = 0): OffsetBasedPagination
{
return OffsetBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultOffset, $defaultLimit);
} | php | public function createOffsetBasedPagination(int $defaultOffset = 0, int $defaultLimit = 0): OffsetBasedPagination
{
return OffsetBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultOffset, $defaultLimit);
} | [
"public",
"function",
"createOffsetBasedPagination",
"(",
"int",
"$",
"defaultOffset",
"=",
"0",
",",
"int",
"$",
"defaultLimit",
"=",
"0",
")",
":",
"OffsetBasedPagination",
"{",
"return",
"OffsetBasedPagination",
"::",
"fromPaginationQueryParams",
"(",
"$",
"this"... | Returns a OffsetBasedPagination class in order to be used for offset-based pagination.
The OffsetBasedPagination class stores the value of the "page[offset]" and "page[limit]" query parameters
if present or the $defaultOffset and $defaultLimit otherwise. | [
"Returns",
"a",
"OffsetBasedPagination",
"class",
"in",
"order",
"to",
"be",
"used",
"for",
"offset",
"-",
"based",
"pagination",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/Pagination/PaginationFactory.php#L48-L51 |
woohoolabs/yin | src/JsonApi/Request/Pagination/PaginationFactory.php | PaginationFactory.createFixedCursorBasedPagination | public function createFixedCursorBasedPagination($defaultCursor = null): FixedCursorBasedPagination
{
return FixedCursorBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultCursor);
} | php | public function createFixedCursorBasedPagination($defaultCursor = null): FixedCursorBasedPagination
{
return FixedCursorBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultCursor);
} | [
"public",
"function",
"createFixedCursorBasedPagination",
"(",
"$",
"defaultCursor",
"=",
"null",
")",
":",
"FixedCursorBasedPagination",
"{",
"return",
"FixedCursorBasedPagination",
"::",
"fromPaginationQueryParams",
"(",
"$",
"this",
"->",
"request",
"->",
"getPaginatio... | Returns a FixedCursorBasedPagination class in order to be used for cursor-based pagination.
The FixedCursorBasedPagination class stores the value of the "page[cursor]" query parameter if present
or the $defaultCursor otherwise.
@param mixed $defaultCursor | [
"Returns",
"a",
"FixedCursorBasedPagination",
"class",
"in",
"order",
"to",
"be",
"used",
"for",
"cursor",
"-",
"based",
"pagination",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/Pagination/PaginationFactory.php#L60-L63 |
woohoolabs/yin | src/JsonApi/Request/Pagination/PaginationFactory.php | PaginationFactory.createCursorBasedPagination | public function createCursorBasedPagination($defaultCursor = null, int $defaultSize = 0): CursorBasedPagination
{
return CursorBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultCursor, $defaultSize);
} | php | public function createCursorBasedPagination($defaultCursor = null, int $defaultSize = 0): CursorBasedPagination
{
return CursorBasedPagination::fromPaginationQueryParams($this->request->getPagination(), $defaultCursor, $defaultSize);
} | [
"public",
"function",
"createCursorBasedPagination",
"(",
"$",
"defaultCursor",
"=",
"null",
",",
"int",
"$",
"defaultSize",
"=",
"0",
")",
":",
"CursorBasedPagination",
"{",
"return",
"CursorBasedPagination",
"::",
"fromPaginationQueryParams",
"(",
"$",
"this",
"->... | Returns a CursorBasedPagination class in order to be used for cursor-based pagination.
The CursorBasedPagination class stores the value of the "page[cursor]" and "page[size]" query parameters if present
or the $defaultCursor and $defaultSize otherwise.
@param mixed $defaultCursor | [
"Returns",
"a",
"CursorBasedPagination",
"class",
"in",
"order",
"to",
"be",
"used",
"for",
"cursor",
"-",
"based",
"pagination",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Request/Pagination/PaginationFactory.php#L72-L75 |
woohoolabs/yin | examples/User/JsonApi/Resource/UserResource.php | UserResource.getRelationships | public function getRelationships($user): array
{
return [
"contacts" => function (array $user) {
return
ToManyRelationship::create()
->setLinks(
RelationshipLinks::createWithoutBaseUri(
... | php | public function getRelationships($user): array
{
return [
"contacts" => function (array $user) {
return
ToManyRelationship::create()
->setLinks(
RelationshipLinks::createWithoutBaseUri(
... | [
"public",
"function",
"getRelationships",
"(",
"$",
"user",
")",
":",
"array",
"{",
"return",
"[",
"\"contacts\"",
"=>",
"function",
"(",
"array",
"$",
"user",
")",
"{",
"return",
"ToManyRelationship",
"::",
"create",
"(",
")",
"->",
"setLinks",
"(",
"Rela... | Provides information about the "relationships" member of the current resource.
The method returns an array where the keys signify the relationship names,
while the values are callables receiving the domain object as an argument,
and they should return a new relationship instance (to-one or to-many).
@param array $use... | [
"Provides",
"information",
"about",
"the",
"relationships",
"member",
"of",
"the",
"current",
"resource",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/User/JsonApi/Resource/UserResource.php#L116-L135 |
woohoolabs/yin | src/JsonApi/Hydrator/UpdateHydratorTrait.php | UpdateHydratorTrait.hydrateForUpdate | public function hydrateForUpdate(
JsonApiRequestInterface $request,
ExceptionFactoryInterface $exceptionFactory,
$domainObject
) {
$data = $request->getResource();
if ($data === null) {
throw $exceptionFactory->createDataMemberMissingException($request);
}... | php | public function hydrateForUpdate(
JsonApiRequestInterface $request,
ExceptionFactoryInterface $exceptionFactory,
$domainObject
) {
$data = $request->getResource();
if ($data === null) {
throw $exceptionFactory->createDataMemberMissingException($request);
}... | [
"public",
"function",
"hydrateForUpdate",
"(",
"JsonApiRequestInterface",
"$",
"request",
",",
"ExceptionFactoryInterface",
"$",
"exceptionFactory",
",",
"$",
"domainObject",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"getResource",
"(",
")",
";",
"if",
"... | Hydrates the domain object from the updating request.
The domain object's attributes and relationships are hydrated
according to the JSON:API specification.
@param mixed $domainObject
@return mixed
@throws JsonApiExceptionInterface | [
"Hydrates",
"the",
"domain",
"object",
"from",
"the",
"updating",
"request",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Hydrator/UpdateHydratorTrait.php#L94-L111 |
woohoolabs/yin | src/JsonApi/Response/Responder.php | Responder.ok | public function ok(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
return $this->getResourceResponse($document, $object, 200, $additionalMeta);
} | php | public function ok(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
return $this->getResourceResponse($document, $object, 200, $additionalMeta);
} | [
"public",
"function",
"ok",
"(",
"ResourceDocumentInterface",
"$",
"document",
",",
"$",
"object",
",",
"array",
"$",
"additionalMeta",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"getResourceResponse",
"(",
"$",
"document",... | Returns a "200 Ok" response, containing a document in the body with the resource.
@param mixed $object | [
"Returns",
"a",
"200",
"Ok",
"response",
"containing",
"a",
"document",
"in",
"the",
"body",
"with",
"the",
"resource",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Response/Responder.php#L42-L45 |
woohoolabs/yin | src/JsonApi/Response/Responder.php | Responder.okWithMeta | public function okWithMeta(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
return $this->getMetaResponse($document, $object, 200, $additionalMeta);
} | php | public function okWithMeta(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
return $this->getMetaResponse($document, $object, 200, $additionalMeta);
} | [
"public",
"function",
"okWithMeta",
"(",
"ResourceDocumentInterface",
"$",
"document",
",",
"$",
"object",
",",
"array",
"$",
"additionalMeta",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"getMetaResponse",
"(",
"$",
"docume... | Returns a "200 Ok" response, containing a document in the body with the resource metadata.
@param mixed $object | [
"Returns",
"a",
"200",
"Ok",
"response",
"containing",
"a",
"document",
"in",
"the",
"body",
"with",
"the",
"resource",
"metadata",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Response/Responder.php#L51-L54 |
woohoolabs/yin | src/JsonApi/Response/Responder.php | Responder.created | public function created(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
$response = $this->getResourceResponse($document, $object, 201, $additionalMeta);
return $this->getResponseWithLocationHeader($document, $response);
} | php | public function created(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
$response = $this->getResourceResponse($document, $object, 201, $additionalMeta);
return $this->getResponseWithLocationHeader($document, $response);
} | [
"public",
"function",
"created",
"(",
"ResourceDocumentInterface",
"$",
"document",
",",
"$",
"object",
",",
"array",
"$",
"additionalMeta",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getResourceResponse",
"(",... | Returns a "201 Created" response, containing a document in the body with the newly created resource. You can also
pass additional meta information for the document in the $additionalMeta argument.
@param mixed $object | [
"Returns",
"a",
"201",
"Created",
"response",
"containing",
"a",
"document",
"in",
"the",
"body",
"with",
"the",
"newly",
"created",
"resource",
".",
"You",
"can",
"also",
"pass",
"additional",
"meta",
"information",
"for",
"the",
"document",
"in",
"the",
"$... | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Response/Responder.php#L81-L86 |
woohoolabs/yin | src/JsonApi/Response/Responder.php | Responder.createdWithMeta | public function createdWithMeta(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
$response = $this->getMetaResponse($document, $object, 201, $additionalMeta);
return $this->getResponseWithLocationHeader($document, $response);
} | php | public function createdWithMeta(ResourceDocumentInterface $document, $object, array $additionalMeta = []): ResponseInterface
{
$response = $this->getMetaResponse($document, $object, 201, $additionalMeta);
return $this->getResponseWithLocationHeader($document, $response);
} | [
"public",
"function",
"createdWithMeta",
"(",
"ResourceDocumentInterface",
"$",
"document",
",",
"$",
"object",
",",
"array",
"$",
"additionalMeta",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getMetaResponse",
... | Returns a "201 Created" response, containing a document in the body with the newly created resource metadata.
You can also pass additional meta information for the document in the $additionalMeta argument.
@param mixed $object | [
"Returns",
"a",
"201",
"Created",
"response",
"containing",
"a",
"document",
"in",
"the",
"body",
"with",
"the",
"newly",
"created",
"resource",
"metadata",
".",
"You",
"can",
"also",
"pass",
"additional",
"meta",
"information",
"for",
"the",
"document",
"in",... | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Response/Responder.php#L93-L98 |
woohoolabs/yin | src/JsonApi/Response/Responder.php | Responder.createdWithRelationship | public function createdWithRelationship(
string $relationshipName,
ResourceDocumentInterface $document,
$object,
array $additionalMeta = []
): ResponseInterface {
return $this->getRelationshipResponse(
$relationshipName,
$document,
$object,... | php | public function createdWithRelationship(
string $relationshipName,
ResourceDocumentInterface $document,
$object,
array $additionalMeta = []
): ResponseInterface {
return $this->getRelationshipResponse(
$relationshipName,
$document,
$object,... | [
"public",
"function",
"createdWithRelationship",
"(",
"string",
"$",
"relationshipName",
",",
"ResourceDocumentInterface",
"$",
"document",
",",
"$",
"object",
",",
"array",
"$",
"additionalMeta",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
... | Returns a "200 Ok" response, containing a document in the body with the relationship. You can also
pass additional meta information for the document in the $additionalMeta argument.
@param mixed $object | [
"Returns",
"a",
"200",
"Ok",
"response",
"containing",
"a",
"document",
"in",
"the",
"body",
"with",
"the",
"relationship",
".",
"You",
"can",
"also",
"pass",
"additional",
"meta",
"information",
"for",
"the",
"document",
"in",
"the",
"$additionalMeta",
"argum... | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Response/Responder.php#L105-L118 |
woohoolabs/yin | src/JsonApi/Response/Responder.php | Responder.genericError | public function genericError(ErrorDocumentInterface $document, ?int $statusCode = null, array $additionalMeta = []): ResponseInterface
{
return $this->getErrorResponse($document, $statusCode, $additionalMeta);
} | php | public function genericError(ErrorDocumentInterface $document, ?int $statusCode = null, array $additionalMeta = []): ResponseInterface
{
return $this->getErrorResponse($document, $statusCode, $additionalMeta);
} | [
"public",
"function",
"genericError",
"(",
"ErrorDocumentInterface",
"$",
"document",
",",
"?",
"int",
"$",
"statusCode",
"=",
"null",
",",
"array",
"$",
"additionalMeta",
"=",
"[",
"]",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"this",
"->",
"getEr... | Returns an error response, containing a document in the body with the errors. You can also pass additional
meta information to the document in the $additionalMeta argument. | [
"Returns",
"an",
"error",
"response",
"containing",
"a",
"document",
"in",
"the",
"body",
"with",
"the",
"errors",
".",
"You",
"can",
"also",
"pass",
"additional",
"meta",
"information",
"to",
"the",
"document",
"in",
"the",
"$additionalMeta",
"argument",
"."
... | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Response/Responder.php#L175-L178 |
woohoolabs/yin | src/JsonApi/Hydrator/CreateHydratorTrait.php | CreateHydratorTrait.hydrateForCreate | public function hydrateForCreate(
JsonApiRequestInterface $request,
ExceptionFactoryInterface $exceptionFactory,
$domainObject
) {
$data = $request->getResource();
if ($data === null) {
throw $exceptionFactory->createDataMemberMissingException($request);
}... | php | public function hydrateForCreate(
JsonApiRequestInterface $request,
ExceptionFactoryInterface $exceptionFactory,
$domainObject
) {
$data = $request->getResource();
if ($data === null) {
throw $exceptionFactory->createDataMemberMissingException($request);
}... | [
"public",
"function",
"hydrateForCreate",
"(",
"JsonApiRequestInterface",
"$",
"request",
",",
"ExceptionFactoryInterface",
"$",
"exceptionFactory",
",",
"$",
"domainObject",
")",
"{",
"$",
"data",
"=",
"$",
"request",
"->",
"getResource",
"(",
")",
";",
"if",
"... | Hydrates the domain object from the creating request.
The domain object's attributes and relationships are hydrated
according to the JSON:API specification.
@param mixed $domainObject
@return mixed
@throws JsonApiExceptionInterface | [
"Hydrates",
"the",
"domain",
"object",
"from",
"the",
"creating",
"request",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Hydrator/CreateHydratorTrait.php#L86-L103 |
woohoolabs/yin | examples/Book/JsonApi/Resource/BookResource.php | BookResource.getAttributes | public function getAttributes($book): array
{
return [
"title" => function (array $book) {
return $book["title"];
},
"isbn13" => function (array $book) {
return $book["isbn13"];
},
"releaseDate" => function (array $b... | php | public function getAttributes($book): array
{
return [
"title" => function (array $book) {
return $book["title"];
},
"isbn13" => function (array $book) {
return $book["isbn13"];
},
"releaseDate" => function (array $b... | [
"public",
"function",
"getAttributes",
"(",
"$",
"book",
")",
":",
"array",
"{",
"return",
"[",
"\"title\"",
"=>",
"function",
"(",
"array",
"$",
"book",
")",
"{",
"return",
"$",
"book",
"[",
"\"title\"",
"]",
";",
"}",
",",
"\"isbn13\"",
"=>",
"functi... | Provides information about the "attributes" member of the current resource.
The method returns an array of attributes if you want the section to
appear in the response or null if it should be omitted. In the returned array,
the keys signify the attribute names, while the values are callables receiving the
domain objec... | [
"Provides",
"information",
"about",
"the",
"attributes",
"member",
"of",
"the",
"current",
"resource",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/Book/JsonApi/Resource/BookResource.php#L100-L119 |
woohoolabs/yin | examples/Book/JsonApi/Resource/BookResource.php | BookResource.getRelationships | public function getRelationships($book): array
{
return [
"authors" => function (array $book) {
return
ToManyRelationship::create()
->setLinks(
new RelationshipLinks($this->getSelfLinkHref($book), new Link("/... | php | public function getRelationships($book): array
{
return [
"authors" => function (array $book) {
return
ToManyRelationship::create()
->setLinks(
new RelationshipLinks($this->getSelfLinkHref($book), new Link("/... | [
"public",
"function",
"getRelationships",
"(",
"$",
"book",
")",
":",
"array",
"{",
"return",
"[",
"\"authors\"",
"=>",
"function",
"(",
"array",
"$",
"book",
")",
"{",
"return",
"ToManyRelationship",
"::",
"create",
"(",
")",
"->",
"setLinks",
"(",
"new",... | Provides information about the "relationships" member of the current resource.
The method returns an array where the keys signify the relationship names,
while the values are callables receiving the domain object as an argument,
and they should return a new relationship instance (to-one or to-many).
@param array $boo... | [
"Provides",
"information",
"about",
"the",
"relationships",
"member",
"of",
"the",
"current",
"resource",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/examples/Book/JsonApi/Resource/BookResource.php#L141-L166 |
woohoolabs/yin | src/JsonApi/Hydrator/AbstractUpdateHydrator.php | AbstractUpdateHydrator.hydrate | public function hydrate(JsonApiRequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject)
{
return $this->hydrateForUpdate($request, $exceptionFactory, $domainObject);
} | php | public function hydrate(JsonApiRequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject)
{
return $this->hydrateForUpdate($request, $exceptionFactory, $domainObject);
} | [
"public",
"function",
"hydrate",
"(",
"JsonApiRequestInterface",
"$",
"request",
",",
"ExceptionFactoryInterface",
"$",
"exceptionFactory",
",",
"$",
"domainObject",
")",
"{",
"return",
"$",
"this",
"->",
"hydrateForUpdate",
"(",
"$",
"request",
",",
"$",
"excepti... | Alias for UpdateHydratorTrait::hydrateForUpdate()
@see UpdateHydratorTrait::hydrateForUpdate()
@param mixed $domainObject
@return mixed
@throws ResourceTypeMissing|JsonApiExceptionInterface | [
"Alias",
"for",
"UpdateHydratorTrait",
"::",
"hydrateForUpdate",
"()"
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Hydrator/AbstractUpdateHydrator.php#L24-L27 |
woohoolabs/yin | src/JsonApi/Transformer/ResourceTransformer.php | ResourceTransformer.transformToResourceObject | public function transformToResourceObject(ResourceTransformation $transformation, DataInterface $data): ?array
{
if ($transformation->object === null || $transformation->resource === null) {
return null;
}
$transformation->resource->initializeTransformation(
$transfo... | php | public function transformToResourceObject(ResourceTransformation $transformation, DataInterface $data): ?array
{
if ($transformation->object === null || $transformation->resource === null) {
return null;
}
$transformation->resource->initializeTransformation(
$transfo... | [
"public",
"function",
"transformToResourceObject",
"(",
"ResourceTransformation",
"$",
"transformation",
",",
"DataInterface",
"$",
"data",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"transformation",
"->",
"object",
"===",
"null",
"||",
"$",
"transformation",
... | Transforms the original resource to a JSON:API resource object. | [
"Transforms",
"the",
"original",
"resource",
"to",
"a",
"JSON",
":",
"API",
"resource",
"object",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Transformer/ResourceTransformer.php#L20-L40 |
woohoolabs/yin | src/JsonApi/Transformer/ResourceTransformer.php | ResourceTransformer.transformToResourceIdentifier | public function transformToResourceIdentifier(ResourceTransformation $transformation): ?array
{
if ($transformation->object === null || $transformation->resource === null) {
return null;
}
$transformation->resource->initializeTransformation(
$transformation->request,... | php | public function transformToResourceIdentifier(ResourceTransformation $transformation): ?array
{
if ($transformation->object === null || $transformation->resource === null) {
return null;
}
$transformation->resource->initializeTransformation(
$transformation->request,... | [
"public",
"function",
"transformToResourceIdentifier",
"(",
"ResourceTransformation",
"$",
"transformation",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"transformation",
"->",
"object",
"===",
"null",
"||",
"$",
"transformation",
"->",
"resource",
"===",
"null",... | Transforms the original resource to a JSON:API resource identifier. | [
"Transforms",
"the",
"original",
"resource",
"to",
"a",
"JSON",
":",
"API",
"resource",
"identifier",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Transformer/ResourceTransformer.php#L45-L62 |
woohoolabs/yin | src/JsonApi/Transformer/ResourceTransformer.php | ResourceTransformer.transformToRelationshipObject | public function transformToRelationshipObject(ResourceTransformation $transformation, DataInterface $data): ?array
{
if ($transformation->object === null || $transformation->resource === null) {
return null;
}
$relationships = $transformation->resource->getRelationships($transfo... | php | public function transformToRelationshipObject(ResourceTransformation $transformation, DataInterface $data): ?array
{
if ($transformation->object === null || $transformation->resource === null) {
return null;
}
$relationships = $transformation->resource->getRelationships($transfo... | [
"public",
"function",
"transformToRelationshipObject",
"(",
"ResourceTransformation",
"$",
"transformation",
",",
"DataInterface",
"$",
"data",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"transformation",
"->",
"object",
"===",
"null",
"||",
"$",
"transformation... | Transforms a relationship of the original resource to a JSON:API relationship. | [
"Transforms",
"a",
"relationship",
"of",
"the",
"original",
"resource",
"to",
"a",
"JSON",
":",
"API",
"relationship",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Transformer/ResourceTransformer.php#L67-L88 |
woohoolabs/yin | src/TransformerTrait.php | TransformerTrait.toDecimal | public function toDecimal($value, int $precision = 12): float
{
if (is_numeric($value) === false) {
return 0.0;
}
return round((float) $value, $precision);
} | php | public function toDecimal($value, int $precision = 12): float
{
if (is_numeric($value) === false) {
return 0.0;
}
return round((float) $value, $precision);
} | [
"public",
"function",
"toDecimal",
"(",
"$",
"value",
",",
"int",
"$",
"precision",
"=",
"12",
")",
":",
"float",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"return",
"0.0",
";",
"}",
"return",
"round",
"(",
"("... | Transforms a value to a decimal with a precision of $precision.
@param mixed $value | [
"Transforms",
"a",
"value",
"to",
"a",
"decimal",
"with",
"a",
"precision",
"of",
"$precision",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/TransformerTrait.php#L19-L26 |
woohoolabs/yin | src/TransformerTrait.php | TransformerTrait.toIso8601Date | public function toIso8601Date(DateTimeInterface $dateTime, ?DateTimeZone $displayedTimeZone = null): string
{
if ($displayedTimeZone !== null && ($dateTime instanceof DateTime || $dateTime instanceof DateTimeImmutable)) {
$dateTime = $dateTime->setTimezone($displayedTimeZone);
}
... | php | public function toIso8601Date(DateTimeInterface $dateTime, ?DateTimeZone $displayedTimeZone = null): string
{
if ($displayedTimeZone !== null && ($dateTime instanceof DateTime || $dateTime instanceof DateTimeImmutable)) {
$dateTime = $dateTime->setTimezone($displayedTimeZone);
}
... | [
"public",
"function",
"toIso8601Date",
"(",
"DateTimeInterface",
"$",
"dateTime",
",",
"?",
"DateTimeZone",
"$",
"displayedTimeZone",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"displayedTimeZone",
"!==",
"null",
"&&",
"(",
"$",
"dateTime",
"instanc... | Transforms a DateTime object to an ISO 8601 compatible date-time string.
If the $displayedTimeZone parameter is present then $dateTime will be converted to that time zone. | [
"Transforms",
"a",
"DateTime",
"object",
"to",
"an",
"ISO",
"8601",
"compatible",
"date",
"-",
"time",
"string",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/TransformerTrait.php#L33-L40 |
woohoolabs/yin | src/TransformerTrait.php | TransformerTrait.toIso8601DateTime | public function toIso8601DateTime(DateTimeInterface $dateTime, ?DateTimeZone $displayedTimeZone = null): string
{
if ($displayedTimeZone !== null && ($dateTime instanceof DateTime || $dateTime instanceof DateTimeImmutable)) {
$dateTime = $dateTime->setTimezone($displayedTimeZone);
}
... | php | public function toIso8601DateTime(DateTimeInterface $dateTime, ?DateTimeZone $displayedTimeZone = null): string
{
if ($displayedTimeZone !== null && ($dateTime instanceof DateTime || $dateTime instanceof DateTimeImmutable)) {
$dateTime = $dateTime->setTimezone($displayedTimeZone);
}
... | [
"public",
"function",
"toIso8601DateTime",
"(",
"DateTimeInterface",
"$",
"dateTime",
",",
"?",
"DateTimeZone",
"$",
"displayedTimeZone",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"displayedTimeZone",
"!==",
"null",
"&&",
"(",
"$",
"dateTime",
"ins... | Transforms a DateTime object to an ISO 8601 compatible date-time string.
If the $displayedTimeZone parameter is present then $dateTime will be converted to that time zone. | [
"Transforms",
"a",
"DateTime",
"object",
"to",
"an",
"ISO",
"8601",
"compatible",
"date",
"-",
"time",
"string",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/TransformerTrait.php#L47-L54 |
woohoolabs/yin | src/TransformerTrait.php | TransformerTrait.fromSqlToIso8601Time | public function fromSqlToIso8601Time(string $string, ?DateTimeZone $displayedTimeZone = null): string
{
$dateTime = DateTime::createFromFormat(
"Y-m-d H:i:s",
$string,
$displayedTimeZone
);
if ($dateTime === false) {
return "";
}
... | php | public function fromSqlToIso8601Time(string $string, ?DateTimeZone $displayedTimeZone = null): string
{
$dateTime = DateTime::createFromFormat(
"Y-m-d H:i:s",
$string,
$displayedTimeZone
);
if ($dateTime === false) {
return "";
}
... | [
"public",
"function",
"fromSqlToIso8601Time",
"(",
"string",
"$",
"string",
",",
"?",
"DateTimeZone",
"$",
"displayedTimeZone",
"=",
"null",
")",
":",
"string",
"{",
"$",
"dateTime",
"=",
"DateTime",
"::",
"createFromFormat",
"(",
"\"Y-m-d H:i:s\"",
",",
"$",
... | Transforms an SQL compatible date-time string to an ISO 8601 compatible date-time string. | [
"Transforms",
"an",
"SQL",
"compatible",
"date",
"-",
"time",
"string",
"to",
"an",
"ISO",
"8601",
"compatible",
"date",
"-",
"time",
"string",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/TransformerTrait.php#L59-L72 |
woohoolabs/yin | src/JsonApi/Hydrator/AbstractHydrator.php | AbstractHydrator.hydrate | public function hydrate(JsonApiRequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject)
{
if ($request->getMethod() === "POST") {
$domainObject = $this->hydrateForCreate($request, $exceptionFactory, $domainObject);
} elseif ($request->getMethod() === "PATCH"... | php | public function hydrate(JsonApiRequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject)
{
if ($request->getMethod() === "POST") {
$domainObject = $this->hydrateForCreate($request, $exceptionFactory, $domainObject);
} elseif ($request->getMethod() === "PATCH"... | [
"public",
"function",
"hydrate",
"(",
"JsonApiRequestInterface",
"$",
"request",
",",
"ExceptionFactoryInterface",
"$",
"exceptionFactory",
",",
"$",
"domainObject",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
"===",
"\"POST\"",
")",
"{",
... | Hydrates the domain object from the request based on the request method.
If the request method is POST then the domain object is hydrated
as a create. If it is a PATCH request then the domain object is
hydrated as an update.
@param mixed $domainObject
@return mixed
@throws ResourceTypeMissing|JsonApiExceptionInterface | [
"Hydrates",
"the",
"domain",
"object",
"from",
"the",
"request",
"based",
"on",
"the",
"request",
"method",
"."
] | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Hydrator/AbstractHydrator.php#L28-L37 |
woohoolabs/yin | src/JsonApi/Transformer/DocumentTransformer.php | DocumentTransformer.transformErrors | private function transformErrors(ErrorDocumentTransformation $transformation): void
{
foreach ($transformation->document->getErrors() as $error) {
$transformation->result["errors"][] = $error->transform();
}
} | php | private function transformErrors(ErrorDocumentTransformation $transformation): void
{
foreach ($transformation->document->getErrors() as $error) {
$transformation->result["errors"][] = $error->transform();
}
} | [
"private",
"function",
"transformErrors",
"(",
"ErrorDocumentTransformation",
"$",
"transformation",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"transformation",
"->",
"document",
"->",
"getErrors",
"(",
")",
"as",
"$",
"error",
")",
"{",
"$",
"transformation",... | Returns the content as an array with all the provided members of the error document. You can also pass
additional meta information for the document in the $additionalMeta argument. | [
"Returns",
"the",
"content",
"as",
"an",
"array",
"with",
"all",
"the",
"provided",
"members",
"of",
"the",
"error",
"document",
".",
"You",
"can",
"also",
"pass",
"additional",
"meta",
"information",
"for",
"the",
"document",
"in",
"the",
"$additionalMeta",
... | train | https://github.com/woohoolabs/yin/blob/e445fa999c7e8676f6cc3c7ee8e5c139315ab242/src/JsonApi/Transformer/DocumentTransformer.php#L115-L120 |
phly/keep-a-changelog | src/AddEntry.php | AddEntry.locateInjectionIndex | private function locateInjectionIndex(array $contents, string $type) : stdClass
{
$action = (object) [
'index' => null,
'type' => self::ACTION_NOT_FOUND,
];
foreach ($contents as $index => $line) {
if (! preg_match('/^### ' . $type . '/i', $line)) {
... | php | private function locateInjectionIndex(array $contents, string $type) : stdClass
{
$action = (object) [
'index' => null,
'type' => self::ACTION_NOT_FOUND,
];
foreach ($contents as $index => $line) {
if (! preg_match('/^### ' . $type . '/i', $line)) {
... | [
"private",
"function",
"locateInjectionIndex",
"(",
"array",
"$",
"contents",
",",
"string",
"$",
"type",
")",
":",
"stdClass",
"{",
"$",
"action",
"=",
"(",
"object",
")",
"[",
"'index'",
"=>",
"null",
",",
"'type'",
"=>",
"self",
"::",
"ACTION_NOT_FOUND"... | Locates the location within the changelog where the injection should occur.
Also determines if the injection is a replacement or an addition. | [
"Locates",
"the",
"location",
"within",
"the",
"changelog",
"where",
"the",
"injection",
"should",
"occur",
".",
"Also",
"determines",
"if",
"the",
"injection",
"is",
"a",
"replacement",
"or",
"an",
"addition",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/AddEntry.php#L76-L96 |
phly/keep-a-changelog | src/AddEntry.php | AddEntry.injectEntry | private function injectEntry(array $contents, stdClass $action, string $entry) : array
{
switch ($action->type) {
case self::ACTION_REPLACE:
array_splice($contents, $action->index, 1, $this->formatEntry($entry));
break;
case self::ACTION_INJECT:
... | php | private function injectEntry(array $contents, stdClass $action, string $entry) : array
{
switch ($action->type) {
case self::ACTION_REPLACE:
array_splice($contents, $action->index, 1, $this->formatEntry($entry));
break;
case self::ACTION_INJECT:
... | [
"private",
"function",
"injectEntry",
"(",
"array",
"$",
"contents",
",",
"stdClass",
"$",
"action",
",",
"string",
"$",
"entry",
")",
":",
"array",
"{",
"switch",
"(",
"$",
"action",
"->",
"type",
")",
"{",
"case",
"self",
"::",
"ACTION_REPLACE",
":",
... | Injects the new entry at the detected index, replacing the line if required. | [
"Injects",
"the",
"new",
"entry",
"at",
"the",
"detected",
"index",
"replacing",
"the",
"line",
"if",
"required",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/AddEntry.php#L101-L114 |
phly/keep-a-changelog | src/AddEntry.php | AddEntry.formatEntry | private function formatEntry(string $entry, bool $withExtraLine = false) : string
{
$entry = sprintf('- %s', $entry);
$entry = preg_replace("/\n(?!\s{2}|$)/s", "\n ", $entry);
if ("\n" !== $entry[-1]) {
// All entries need to end with a new line.
$entry .= "\n";
... | php | private function formatEntry(string $entry, bool $withExtraLine = false) : string
{
$entry = sprintf('- %s', $entry);
$entry = preg_replace("/\n(?!\s{2}|$)/s", "\n ", $entry);
if ("\n" !== $entry[-1]) {
// All entries need to end with a new line.
$entry .= "\n";
... | [
"private",
"function",
"formatEntry",
"(",
"string",
"$",
"entry",
",",
"bool",
"$",
"withExtraLine",
"=",
"false",
")",
":",
"string",
"{",
"$",
"entry",
"=",
"sprintf",
"(",
"'- %s'",
",",
"$",
"entry",
")",
";",
"$",
"entry",
"=",
"preg_replace",
"(... | Formats the entry for use in the changelog.
Prepends the string '- ', and appends a newline if none is present.
If $withExtraLine is true, an extra newline is appended.
If the string spans multiple lines, it ensures all additional lines are
indented two characters. | [
"Formats",
"the",
"entry",
"for",
"use",
"in",
"the",
"changelog",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/AddEntry.php#L126-L139 |
phly/keep-a-changelog | src/ConfigFileTrait.php | ConfigFileTrait.createNewConfig | private function createNewConfig() : Config
{
$globalPath = $this->globalPath ?: getenv('HOME');
$tokenFile = sprintf('%s/.keep-a-changelog/token', $globalPath);
$token = is_readable($tokenFile)
? trim(file_get_contents($tokenFile))
: '';
return new Config($t... | php | private function createNewConfig() : Config
{
$globalPath = $this->globalPath ?: getenv('HOME');
$tokenFile = sprintf('%s/.keep-a-changelog/token', $globalPath);
$token = is_readable($tokenFile)
? trim(file_get_contents($tokenFile))
: '';
return new Config($t... | [
"private",
"function",
"createNewConfig",
"(",
")",
":",
"Config",
"{",
"$",
"globalPath",
"=",
"$",
"this",
"->",
"globalPath",
"?",
":",
"getenv",
"(",
"'HOME'",
")",
";",
"$",
"tokenFile",
"=",
"sprintf",
"(",
"'%s/.keep-a-changelog/token'",
",",
"$",
"... | Create a new Config instance.
If the config file does not exist, this creates empty configuration,
optionally using an existing tokenfile ($HOME/.keep-a-changelog/token)
if it exists. | [
"Create",
"a",
"new",
"Config",
"instance",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/ConfigFileTrait.php#L70-L78 |
phly/keep-a-changelog | src/ConfigFileTrait.php | ConfigFileTrait.createConfigFromFile | private function createConfigFromFile(string $configFile) : Config
{
$ini = parse_ini_file($configFile);
return new Config($ini['token'] ?? '', $ini['provider'] ?? Config::PROVIDER_GITHUB);
} | php | private function createConfigFromFile(string $configFile) : Config
{
$ini = parse_ini_file($configFile);
return new Config($ini['token'] ?? '', $ini['provider'] ?? Config::PROVIDER_GITHUB);
} | [
"private",
"function",
"createConfigFromFile",
"(",
"string",
"$",
"configFile",
")",
":",
"Config",
"{",
"$",
"ini",
"=",
"parse_ini_file",
"(",
"$",
"configFile",
")",
";",
"return",
"new",
"Config",
"(",
"$",
"ini",
"[",
"'token'",
"]",
"??",
"''",
",... | Parses the config file and returns a populated Config instance. | [
"Parses",
"the",
"config",
"file",
"and",
"returns",
"a",
"populated",
"Config",
"instance",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/ConfigFileTrait.php#L83-L87 |
phly/keep-a-changelog | src/ChangelogBump.php | ChangelogBump.updateChangelog | public function updateChangelog(string $version)
{
$changelog = sprintf(self::TEMPLATE, $version);
$contents = file_get_contents($this->changelogFile);
$contents = preg_replace(
"/^(\# Changelog\n\n.*?)(\n\n\#\# )/s",
'$1' . $changelog . '## ',
$contents
... | php | public function updateChangelog(string $version)
{
$changelog = sprintf(self::TEMPLATE, $version);
$contents = file_get_contents($this->changelogFile);
$contents = preg_replace(
"/^(\# Changelog\n\n.*?)(\n\n\#\# )/s",
'$1' . $changelog . '## ',
$contents
... | [
"public",
"function",
"updateChangelog",
"(",
"string",
"$",
"version",
")",
"{",
"$",
"changelog",
"=",
"sprintf",
"(",
"self",
"::",
"TEMPLATE",
",",
"$",
"version",
")",
";",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"changelogF... | Update the CHANGELOG with the new version information.
@param string $version | [
"Update",
"the",
"CHANGELOG",
"with",
"the",
"new",
"version",
"information",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/ChangelogBump.php#L97-L107 |
phly/keep-a-changelog | src/Edit.php | Edit.getChangelogEntry | private function getChangelogEntry($filename) : ?stdClass
{
$contents = file($filename);
if (false === $contents) {
throw Exception\ChangelogFileNotFoundException::at($filename);
}
$data = (object) [
'contents' => '',
'index' => null,
... | php | private function getChangelogEntry($filename) : ?stdClass
{
$contents = file($filename);
if (false === $contents) {
throw Exception\ChangelogFileNotFoundException::at($filename);
}
$data = (object) [
'contents' => '',
'index' => null,
... | [
"private",
"function",
"getChangelogEntry",
"(",
"$",
"filename",
")",
":",
"?",
"stdClass",
"{",
"$",
"contents",
"=",
"file",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"false",
"===",
"$",
"contents",
")",
"{",
"throw",
"Exception",
"\\",
"ChangelogFi... | Retrieves the first changelog entry in the file.
If no changelog entry is found, returns null. Otherwise, returns an
anonymous object with the keys:
- index, indicating the line number where the contents began
- length, the number of lines in the contents
- contents, a string representing the changelog entry found in... | [
"Retrieves",
"the",
"first",
"changelog",
"entry",
"in",
"the",
"file",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/Edit.php#L59-L92 |
phly/keep-a-changelog | src/Edit.php | Edit.createTempFileWithContents | private function createTempFileWithContents(string $contents) : string
{
$filename = sprintf('%s.md', uniqid('KAC', true));
$path = sprintf('%s/%s', sys_get_temp_dir(), $filename);
file_put_contents($path, $contents);
return $path;
} | php | private function createTempFileWithContents(string $contents) : string
{
$filename = sprintf('%s.md', uniqid('KAC', true));
$path = sprintf('%s/%s', sys_get_temp_dir(), $filename);
file_put_contents($path, $contents);
return $path;
} | [
"private",
"function",
"createTempFileWithContents",
"(",
"string",
"$",
"contents",
")",
":",
"string",
"{",
"$",
"filename",
"=",
"sprintf",
"(",
"'%s.md'",
",",
"uniqid",
"(",
"'KAC'",
",",
"true",
")",
")",
";",
"$",
"path",
"=",
"sprintf",
"(",
"'%s... | Creates a temporary file with the changelog contents. | [
"Creates",
"a",
"temporary",
"file",
"with",
"the",
"changelog",
"contents",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/Edit.php#L97-L103 |
phly/keep-a-changelog | src/Edit.php | Edit.discoverEditor | private function discoverEditor() : string
{
$editor = getenv('EDITOR');
if ($editor) {
return $editor;
}
return isset($_SERVER['OS']) && false !== strpos($_SERVER['OS'], 'indows')
? 'notepad'
: 'vi';
} | php | private function discoverEditor() : string
{
$editor = getenv('EDITOR');
if ($editor) {
return $editor;
}
return isset($_SERVER['OS']) && false !== strpos($_SERVER['OS'], 'indows')
? 'notepad'
: 'vi';
} | [
"private",
"function",
"discoverEditor",
"(",
")",
":",
"string",
"{",
"$",
"editor",
"=",
"getenv",
"(",
"'EDITOR'",
")",
";",
"if",
"(",
"$",
"editor",
")",
"{",
"return",
"$",
"editor",
";",
"}",
"return",
"isset",
"(",
"$",
"_SERVER",
"[",
"'OS'"... | Determines the system editor command and returns it.
Checks for the $EDITOR env variable, returning its value if present.
If not, it checks to see if we are on a Windows or other type of system,
returning "notepad" or "vi", respecively. | [
"Determines",
"the",
"system",
"editor",
"command",
"and",
"returns",
"it",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/Edit.php#L113-L124 |
phly/keep-a-changelog | src/Edit.php | Edit.spawnEditor | public function spawnEditor(OutputInterface $output, string $editor, string $filename) : int
{
$descriptorspec = [STDIN, STDOUT, STDERR];
$command = sprintf('%s %s', $editor, escapeshellarg($filename));
$output->writeln(sprintf('<info>Executing "%s"</info>', $command));
$process = ... | php | public function spawnEditor(OutputInterface $output, string $editor, string $filename) : int
{
$descriptorspec = [STDIN, STDOUT, STDERR];
$command = sprintf('%s %s', $editor, escapeshellarg($filename));
$output->writeln(sprintf('<info>Executing "%s"</info>', $command));
$process = ... | [
"public",
"function",
"spawnEditor",
"(",
"OutputInterface",
"$",
"output",
",",
"string",
"$",
"editor",
",",
"string",
"$",
"filename",
")",
":",
"int",
"{",
"$",
"descriptorspec",
"=",
"[",
"STDIN",
",",
"STDOUT",
",",
"STDERR",
"]",
";",
"$",
"comman... | Spawn an editor to edit the given filename. | [
"Spawn",
"an",
"editor",
"to",
"edit",
"the",
"given",
"filename",
"."
] | train | https://github.com/phly/keep-a-changelog/blob/8585813060576fc939772a7b1e37b8b6a7ff438d/src/Edit.php#L129-L138 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php | PatchEditor.openBuffer | public function openBuffer(File $file)
{
if ( ! isset($this->builders[$file->getRelativePath()])) {
$this->builders[$file->getRelativePath()] = new PatchBuilder(
$file->getCode(), $file->getRelativePath()
);
}
return new PatchBuffer($this->builders[$f... | php | public function openBuffer(File $file)
{
if ( ! isset($this->builders[$file->getRelativePath()])) {
$this->builders[$file->getRelativePath()] = new PatchBuilder(
$file->getCode(), $file->getRelativePath()
);
}
return new PatchBuffer($this->builders[$f... | [
"public",
"function",
"openBuffer",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"builders",
"[",
"$",
"file",
"->",
"getRelativePath",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"builders",
"[",
"$",
... | {@inheritDoc} | [
"{"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php#L37-L46 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php | PatchEditor.save | public function save()
{
foreach ($this->builders as $builder) {
$this->command->apply($builder->generateUnifiedDiff());
}
} | php | public function save()
{
foreach ($this->builders as $builder) {
$this->command->apply($builder->generateUnifiedDiff());
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"builders",
"as",
"$",
"builder",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"apply",
"(",
"$",
"builder",
"->",
"generateUnifiedDiff",
"(",
")",
")",
";",
"}",
"}"
] | {@inheritDoc} | [
"{"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchEditor.php#L51-L56 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Model/File.php | File.createFromPath | public static function createFromPath($path, $workingDirectory)
{
if ( ! file_exists($path) || ! is_file($path)) {
throw new \InvalidArgumentException("Not a valid file: " . $path);
}
$code = file_get_contents($path);
$workingDirectory = rtrim($workingDirectory, '/\\');
... | php | public static function createFromPath($path, $workingDirectory)
{
if ( ! file_exists($path) || ! is_file($path)) {
throw new \InvalidArgumentException("Not a valid file: " . $path);
}
$code = file_get_contents($path);
$workingDirectory = rtrim($workingDirectory, '/\\');
... | [
"public",
"static",
"function",
"createFromPath",
"(",
"$",
"path",
",",
"$",
"workingDirectory",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"path",
")",
"||",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgum... | @param string $path
@param string $workingDirectory
@return File | [
"@param",
"string",
"$path",
"@param",
"string",
"$workingDirectory"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Model/File.php#L30-L46 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Model/File.php | File.extractPsr0ClassName | public function extractPsr0ClassName()
{
$shortName = $this->parseFileForPsr0ClassShortName();
return new PhpName(
ltrim($this->parseFileForPsr0NamespaceName() . '\\' . $shortName, '\\'),
$shortName
);
} | php | public function extractPsr0ClassName()
{
$shortName = $this->parseFileForPsr0ClassShortName();
return new PhpName(
ltrim($this->parseFileForPsr0NamespaceName() . '\\' . $shortName, '\\'),
$shortName
);
} | [
"public",
"function",
"extractPsr0ClassName",
"(",
")",
"{",
"$",
"shortName",
"=",
"$",
"this",
"->",
"parseFileForPsr0ClassShortName",
"(",
")",
";",
"return",
"new",
"PhpName",
"(",
"ltrim",
"(",
"$",
"this",
"->",
"parseFileForPsr0NamespaceName",
"(",
")",
... | Extract the PhpName for the class contained in this file assuming PSR-0 naming.
@return PhpName | [
"Extract",
"the",
"PhpName",
"for",
"the",
"class",
"contained",
"in",
"this",
"file",
"assuming",
"PSR",
"-",
"0",
"naming",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Model/File.php#L83-L91 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php | PatchBuilder.changeToken | public function changeToken($originalLine, $oldToken, $newToken)
{
$newLine = $this->buffer->getLine($this->createLineNumber($originalLine));
$newLine = preg_replace(
'!(^|[^a-z0-9])(' . preg_quote($oldToken) . ')([^a-z0-9]|$)!',
'\1' . $newToken . '\3',
$newLine... | php | public function changeToken($originalLine, $oldToken, $newToken)
{
$newLine = $this->buffer->getLine($this->createLineNumber($originalLine));
$newLine = preg_replace(
'!(^|[^a-z0-9])(' . preg_quote($oldToken) . ')([^a-z0-9]|$)!',
'\1' . $newToken . '\3',
$newLine... | [
"public",
"function",
"changeToken",
"(",
"$",
"originalLine",
",",
"$",
"oldToken",
",",
"$",
"newToken",
")",
"{",
"$",
"newLine",
"=",
"$",
"this",
"->",
"buffer",
"->",
"getLine",
"(",
"$",
"this",
"->",
"createLineNumber",
"(",
"$",
"originalLine",
... | Change Token in given line from old to new.
@param int $originalLine
@param string $oldToken
@param string $newToken
@return void | [
"Change",
"Token",
"in",
"given",
"line",
"from",
"old",
"to",
"new",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php#L71-L85 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php | PatchBuilder.appendToLine | public function appendToLine($originalLine, array $lines)
{
// Why is this one method different to the rest?
$originalLine++;
$this->buffer->insert($this->createLineNumber($originalLine), $lines);
} | php | public function appendToLine($originalLine, array $lines)
{
// Why is this one method different to the rest?
$originalLine++;
$this->buffer->insert($this->createLineNumber($originalLine), $lines);
} | [
"public",
"function",
"appendToLine",
"(",
"$",
"originalLine",
",",
"array",
"$",
"lines",
")",
"{",
"// Why is this one method different to the rest?",
"$",
"originalLine",
"++",
";",
"$",
"this",
"->",
"buffer",
"->",
"insert",
"(",
"$",
"this",
"->",
"create... | Append new lines to an original line of the file.
@param int $originalLine
@param array $lines
@return void | [
"Append",
"new",
"lines",
"to",
"an",
"original",
"line",
"of",
"the",
"file",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php#L95-L101 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php | PatchBuilder.changeLines | public function changeLines($originalLine, array $newLines)
{
$this->buffer->replace($this->createSingleLineRange($originalLine), $newLines);
} | php | public function changeLines($originalLine, array $newLines)
{
$this->buffer->replace($this->createSingleLineRange($originalLine), $newLines);
} | [
"public",
"function",
"changeLines",
"(",
"$",
"originalLine",
",",
"array",
"$",
"newLines",
")",
"{",
"$",
"this",
"->",
"buffer",
"->",
"replace",
"(",
"$",
"this",
"->",
"createSingleLineRange",
"(",
"$",
"originalLine",
")",
",",
"$",
"newLines",
")",... | Change one line by replacing it with one or many new lines.
@param int $originalLine
@param array $newLines
@return void | [
"Change",
"one",
"line",
"by",
"replacing",
"it",
"with",
"one",
"or",
"many",
"new",
"lines",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php#L111-L114 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php | PatchBuilder.replaceLines | public function replaceLines($startOriginalLine, $endOriginalLine, array $newLines)
{
$this->buffer->replace($this->createLineRange($startOriginalLine, $endOriginalLine), $newLines);
} | php | public function replaceLines($startOriginalLine, $endOriginalLine, array $newLines)
{
$this->buffer->replace($this->createLineRange($startOriginalLine, $endOriginalLine), $newLines);
} | [
"public",
"function",
"replaceLines",
"(",
"$",
"startOriginalLine",
",",
"$",
"endOriginalLine",
",",
"array",
"$",
"newLines",
")",
"{",
"$",
"this",
"->",
"buffer",
"->",
"replace",
"(",
"$",
"this",
"->",
"createLineRange",
"(",
"$",
"startOriginalLine",
... | Replace a range of lines with a set of new lines.
@param int $startOriginalLine
@param int $endOriginalLine
@param array $newLines
@return void | [
"Replace",
"a",
"range",
"of",
"lines",
"with",
"a",
"set",
"of",
"new",
"lines",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php#L137-L140 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php | PatchBuilder.generateUnifiedDiff | public function generateUnifiedDiff()
{
$builder = new PhpDiffBuilder();
return $builder->buildPatch(
'a/' . $this->path,
'b/' . $this->path,
$this->buffer
);
} | php | public function generateUnifiedDiff()
{
$builder = new PhpDiffBuilder();
return $builder->buildPatch(
'a/' . $this->path,
'b/' . $this->path,
$this->buffer
);
} | [
"public",
"function",
"generateUnifiedDiff",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"PhpDiffBuilder",
"(",
")",
";",
"return",
"$",
"builder",
"->",
"buildPatch",
"(",
"'a/'",
".",
"$",
"this",
"->",
"path",
",",
"'b/'",
".",
"$",
"this",
"->",
"pa... | Generate a unified diff of all operations performed on the current file.
@return string | [
"Generate",
"a",
"unified",
"diff",
"of",
"all",
"operations",
"performed",
"on",
"the",
"current",
"file",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/PatchBuilder/PatchBuilder.php#L147-L156 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Adapters/Symfony/Compiler.php | Compiler.compile | public function compile()
{
$pharFile = 'refactor.phar';
if (file_exists($pharFile)) {
unlink($pharFile);
}
$process = new Process('git log --pretty="%H" -n1 HEAD', $this->directory);
if ($process->run() != 0) {
throw new \RuntimeException('Can\'t ru... | php | public function compile()
{
$pharFile = 'refactor.phar';
if (file_exists($pharFile)) {
unlink($pharFile);
}
$process = new Process('git log --pretty="%H" -n1 HEAD', $this->directory);
if ($process->run() != 0) {
throw new \RuntimeException('Can\'t ru... | [
"public",
"function",
"compile",
"(",
")",
"{",
"$",
"pharFile",
"=",
"'refactor.phar'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"pharFile",
")",
")",
"{",
"unlink",
"(",
"$",
"pharFile",
")",
";",
"}",
"$",
"process",
"=",
"new",
"Process",
"(",
"'... | Compiles composer into a single phar file
@throws \RuntimeException | [
"Compiles",
"composer",
"into",
"a",
"single",
"phar",
"file"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Adapters/Symfony/Compiler.php#L42-L99 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/ReplaceWithMethodCall.php | ReplaceWithMethodCall.getIndent | private function getIndent(array $lines)
{
$detector = new IndentationDetector(
LineCollection::createFromArray($lines)
);
return str_repeat(' ', $detector->getFirstLineIndentation());
} | php | private function getIndent(array $lines)
{
$detector = new IndentationDetector(
LineCollection::createFromArray($lines)
);
return str_repeat(' ', $detector->getFirstLineIndentation());
} | [
"private",
"function",
"getIndent",
"(",
"array",
"$",
"lines",
")",
"{",
"$",
"detector",
"=",
"new",
"IndentationDetector",
"(",
"LineCollection",
"::",
"createFromArray",
"(",
"$",
"lines",
")",
")",
";",
"return",
"str_repeat",
"(",
"' '",
",",
"$",
"d... | @param string[] $lines
@return string | [
"@param",
"string",
"[]",
"$lines"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Model/EditingAction/ReplaceWithMethodCall.php#L42-L49 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Model/DefinedVariables.php | DefinedVariables.contains | public function contains(Variable $variable)
{
return (
isset($this->readAccess[$variable->getName()]) ||
isset($this->changeAccess[$variable->getName()])
);
} | php | public function contains(Variable $variable)
{
return (
isset($this->readAccess[$variable->getName()]) ||
isset($this->changeAccess[$variable->getName()])
);
} | [
"public",
"function",
"contains",
"(",
"Variable",
"$",
"variable",
")",
"{",
"return",
"(",
"isset",
"(",
"$",
"this",
"->",
"readAccess",
"[",
"$",
"variable",
"->",
"getName",
"(",
")",
"]",
")",
"||",
"isset",
"(",
"$",
"this",
"->",
"changeAccess"... | Does list contain the given variable?
@return bool | [
"Does",
"list",
"contain",
"the",
"given",
"variable?"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Model/DefinedVariables.php#L76-L82 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Model/PhpNames/NoImportedUsagesFilter.php | NoImportedUsagesFilter.filter | public function filter(array $phpNames)
{
$fileUseOccurances = array_flip(
array_map(
function ($useOccurance) {
return $useOccurance->name()->fullyQualifiedName();
},
array_filter(
$phpNames,
... | php | public function filter(array $phpNames)
{
$fileUseOccurances = array_flip(
array_map(
function ($useOccurance) {
return $useOccurance->name()->fullyQualifiedName();
},
array_filter(
$phpNames,
... | [
"public",
"function",
"filter",
"(",
"array",
"$",
"phpNames",
")",
"{",
"$",
"fileUseOccurances",
"=",
"array_flip",
"(",
"array_map",
"(",
"function",
"(",
"$",
"useOccurance",
")",
"{",
"return",
"$",
"useOccurance",
"->",
"name",
"(",
")",
"->",
"fully... | @param array<PhpNameOccurance>
@return array<PhpNameOccurance> | [
"@param",
"array<PhpNameOccurance",
">"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Model/PhpNames/NoImportedUsagesFilter.php#L17-L42 |
QafooLabs/php-refactoring-browser | features/bootstrap/FeatureContext.php | FeatureContext.formatExpectedPatch | protected function formatExpectedPatch($patch)
{
if ('\\' === DIRECTORY_SEPARATOR) {
$formatLine = function ($line) {
// replace lines for diff-path-files starting with --- or +++
$line = preg_replace_callback('~^((?:---|\+\+\+)\s*(?:a|b)/)(.*)~', function ($match... | php | protected function formatExpectedPatch($patch)
{
if ('\\' === DIRECTORY_SEPARATOR) {
$formatLine = function ($line) {
// replace lines for diff-path-files starting with --- or +++
$line = preg_replace_callback('~^((?:---|\+\+\+)\s*(?:a|b)/)(.*)~', function ($match... | [
"protected",
"function",
"formatExpectedPatch",
"(",
"$",
"patch",
")",
"{",
"if",
"(",
"'\\\\'",
"===",
"DIRECTORY_SEPARATOR",
")",
"{",
"$",
"formatLine",
"=",
"function",
"(",
"$",
"line",
")",
"{",
"// replace lines for diff-path-files starting with --- or +++",
... | converts / paths in expectedPatch text to \ paths
leaves the a/ b/ slashes untouched
returns an array of lines
@return array | [
"converts",
"/",
"paths",
"in",
"expectedPatch",
"text",
"to",
"\\",
"paths"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/features/bootstrap/FeatureContext.php#L119-L146 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php | PhpName.isAffectedByChangesTo | public function isAffectedByChangesTo(PhpName $other)
{
return
$this->fullyQualifiedName === $other->fullyQualifiedName ||
$this->overlaps($other)
;
} | php | public function isAffectedByChangesTo(PhpName $other)
{
return
$this->fullyQualifiedName === $other->fullyQualifiedName ||
$this->overlaps($other)
;
} | [
"public",
"function",
"isAffectedByChangesTo",
"(",
"PhpName",
"$",
"other",
")",
"{",
"return",
"$",
"this",
"->",
"fullyQualifiedName",
"===",
"$",
"other",
"->",
"fullyQualifiedName",
"||",
"$",
"this",
"->",
"overlaps",
"(",
"$",
"other",
")",
";",
"}"
] | Would this name be affected by a change to the given name?
@param PhpName $other
@return bool | [
"Would",
"this",
"name",
"be",
"affected",
"by",
"a",
"change",
"to",
"the",
"given",
"name?"
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Model/PhpName.php#L56-L62 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Collections/Set.php | Set.add | public function add($item)
{
if ($item instanceof Hashable) {
$this->items[$item->hashCode()] = $item;
return;
}
$this->items[(string)$item] = $item;
} | php | public function add($item)
{
if ($item instanceof Hashable) {
$this->items[$item->hashCode()] = $item;
return;
}
$this->items[(string)$item] = $item;
} | [
"public",
"function",
"add",
"(",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"instanceof",
"Hashable",
")",
"{",
"$",
"this",
"->",
"items",
"[",
"$",
"item",
"->",
"hashCode",
"(",
")",
"]",
"=",
"$",
"item",
";",
"return",
";",
"}",
"$",
... | Add a new item to the set.
Overrides values that were previously set that have the same value
or hashCode. If you pass an object make sure it implements either
{__toString()} or the {@see Hashable} interface.
@param mixed $item
@return void | [
"Add",
"a",
"new",
"item",
"to",
"the",
"set",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Collections/Set.php#L26-L35 |
QafooLabs/php-refactoring-browser | src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php | CodeAnalysis.findMethodRange | public function findMethodRange(File $file, LineRange $range)
{
$methodStartLine = $this->getMethodStartLine($file, $range);
$methodEndLine = $this->getMethodEndLine($file, $range);
return LineRange::fromLines($methodStartLine, $methodEndLine);
} | php | public function findMethodRange(File $file, LineRange $range)
{
$methodStartLine = $this->getMethodStartLine($file, $range);
$methodEndLine = $this->getMethodEndLine($file, $range);
return LineRange::fromLines($methodStartLine, $methodEndLine);
} | [
"public",
"function",
"findMethodRange",
"(",
"File",
"$",
"file",
",",
"LineRange",
"$",
"range",
")",
"{",
"$",
"methodStartLine",
"=",
"$",
"this",
"->",
"getMethodStartLine",
"(",
"$",
"file",
",",
"$",
"range",
")",
";",
"$",
"methodEndLine",
"=",
"... | From a range within a method, find the start and end range of that method.
@param File $file
@param LineRange $range
@return LineRange | [
"From",
"a",
"range",
"within",
"a",
"method",
"find",
"the",
"start",
"and",
"end",
"range",
"of",
"that",
"method",
"."
] | train | https://github.com/QafooLabs/php-refactoring-browser/blob/3ff0f7bc955ec253ad7fa1bfaf44cc02604aaa1d/src/main/QafooLabs/Refactoring/Domain/Services/CodeAnalysis.php#L75-L81 |
lexxyungcarter/laravel-5-messenger | src/ChatMessengerServiceProvider.php | ChatMessengerServiceProvider.setMessengerModels | protected function setMessengerModels()
{
$config = $this->app->make('config');
Models::setMessageModel($config->get('chatmessenger.message_model', Message::class));
Models::setThreadModel($config->get('chatmessenger.thread_model', Thread::class));
Models::setParticipantModel($confi... | php | protected function setMessengerModels()
{
$config = $this->app->make('config');
Models::setMessageModel($config->get('chatmessenger.message_model', Message::class));
Models::setThreadModel($config->get('chatmessenger.thread_model', Thread::class));
Models::setParticipantModel($confi... | [
"protected",
"function",
"setMessengerModels",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"Models",
"::",
"setMessageModel",
"(",
"$",
"config",
"->",
"get",
"(",
"'chatmessenger.message_model'",
","... | Define Messenger's models in registry
@return void | [
"Define",
"Messenger",
"s",
"models",
"in",
"registry"
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/src/ChatMessengerServiceProvider.php#L74-L87 |
lexxyungcarter/laravel-5-messenger | src/ChatMessengerServiceProvider.php | ChatMessengerServiceProvider.setUserModel | protected function setUserModel()
{
$config = $this->app->make('config');
$model = $config->get('auth.providers.users.model', function () use ($config) {
return $config->get('auth.model', $config->get('chatmessenger.user_model'));
});
Models::setUserModel($model);
... | php | protected function setUserModel()
{
$config = $this->app->make('config');
$model = $config->get('auth.providers.users.model', function () use ($config) {
return $config->get('auth.model', $config->get('chatmessenger.user_model'));
});
Models::setUserModel($model);
... | [
"protected",
"function",
"setUserModel",
"(",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'config'",
")",
";",
"$",
"model",
"=",
"$",
"config",
"->",
"get",
"(",
"'auth.providers.users.model'",
",",
"function",
"(",
")",
... | Define User model in Messenger's model registry.
@return void | [
"Define",
"User",
"model",
"in",
"Messenger",
"s",
"model",
"registry",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/src/ChatMessengerServiceProvider.php#L94-L107 |
lexxyungcarter/laravel-5-messenger | migrations/2017_11_08_063801_create_threads_table.php | CreateThreadsTable.up | public function up()
{
Schema::create(Models::table('threads'), function (Blueprint $table) {
$table->increments('id');
$table->boolean('starred')->default(0);
$table->string('subject');
$table->string('slug')->nullable()->comment('Unique slug for social media... | php | public function up()
{
Schema::create(Models::table('threads'), function (Blueprint $table) {
$table->increments('id');
$table->boolean('starred')->default(0);
$table->string('subject');
$table->string('slug')->nullable()->comment('Unique slug for social media... | [
"public",
"function",
"up",
"(",
")",
"{",
"Schema",
"::",
"create",
"(",
"Models",
"::",
"table",
"(",
"'threads'",
")",
",",
"function",
"(",
"Blueprint",
"$",
"table",
")",
"{",
"$",
"table",
"->",
"increments",
"(",
"'id'",
")",
";",
"$",
"table"... | Run the migrations.
@return void | [
"Run",
"the",
"migrations",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/migrations/2017_11_08_063801_create_threads_table.php#L15-L28 |
lexxyungcarter/laravel-5-messenger | src/Models/Thread.php | Thread.participantsUserIds | public function participantsUserIds($userId = null)
{
$users = $this->participants()->select('user_id')->get()->map(function ($participant) {
return $participant->user_id;
});
if ($userId) {
$users->push($userId);
}
return $users->toArray();
} | php | public function participantsUserIds($userId = null)
{
$users = $this->participants()->select('user_id')->get()->map(function ($participant) {
return $participant->user_id;
});
if ($userId) {
$users->push($userId);
}
return $users->toArray();
} | [
"public",
"function",
"participantsUserIds",
"(",
"$",
"userId",
"=",
"null",
")",
"{",
"$",
"users",
"=",
"$",
"this",
"->",
"participants",
"(",
")",
"->",
"select",
"(",
"'user_id'",
")",
"->",
"get",
"(",
")",
"->",
"map",
"(",
"function",
"(",
"... | Returns an array of user ids that are associated with the thread.
Deleted participants from a thread will not be returned
@param null $userId
@return array | [
"Returns",
"an",
"array",
"of",
"user",
"ids",
"that",
"are",
"associated",
"with",
"the",
"thread",
".",
"Deleted",
"participants",
"from",
"a",
"thread",
"will",
"not",
"be",
"returned"
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/src/Models/Thread.php#L143-L154 |
lexxyungcarter/laravel-5-messenger | src/Models/Thread.php | Thread.hasMaxParticipants | public function hasMaxParticipants()
{
$participants = $this->participants();
if ($participants->count() > $this->max_participants) {
// max number of participants reached
return true;
}
return false;
} | php | public function hasMaxParticipants()
{
$participants = $this->participants();
if ($participants->count() > $this->max_participants) {
// max number of participants reached
return true;
}
return false;
} | [
"public",
"function",
"hasMaxParticipants",
"(",
")",
"{",
"$",
"participants",
"=",
"$",
"this",
"->",
"participants",
"(",
")",
";",
"if",
"(",
"$",
"participants",
"->",
"count",
"(",
")",
">",
"$",
"this",
"->",
"max_participants",
")",
"{",
"// max ... | Checks if the max number of participants in a thread has been reached.
@return boolean | [
"Checks",
"if",
"the",
"max",
"number",
"of",
"participants",
"in",
"a",
"thread",
"has",
"been",
"reached",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/src/Models/Thread.php#L466-L474 |
lexxyungcarter/laravel-5-messenger | examples/MessagesController.php | MessagesController.store | public function store()
{
$input = Input::all();
$thread = Thread::create([
'subject' => $input['subject'],
]);
// Message
$message = Message::create([
'thread_id' => $thread->id,
'user_id' => Auth::id(),
'body' => $input['mes... | php | public function store()
{
$input = Input::all();
$thread = Thread::create([
'subject' => $input['subject'],
]);
// Message
$message = Message::create([
'thread_id' => $thread->id,
'user_id' => Auth::id(),
'body' => $input['mes... | [
"public",
"function",
"store",
"(",
")",
"{",
"$",
"input",
"=",
"Input",
"::",
"all",
"(",
")",
";",
"$",
"thread",
"=",
"Thread",
"::",
"create",
"(",
"[",
"'subject'",
"=>",
"$",
"input",
"[",
"'subject'",
"]",
",",
"]",
")",
";",
"// Message",
... | Stores a new message thread.
@return mixed | [
"Stores",
"a",
"new",
"message",
"thread",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/examples/MessagesController.php#L90-L134 |
lexxyungcarter/laravel-5-messenger | examples/MessagesController.php | MessagesController.update | public function update($id)
{
try {
$thread = Thread::findOrFail($id);
} catch (ModelNotFoundException $e) {
Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
return redirect()->route('messages');
}
// Restore all... | php | public function update($id)
{
try {
$thread = Thread::findOrFail($id);
} catch (ModelNotFoundException $e) {
Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.');
return redirect()->route('messages');
}
// Restore all... | [
"public",
"function",
"update",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"thread",
"=",
"Thread",
"::",
"findOrFail",
"(",
"$",
"id",
")",
";",
"}",
"catch",
"(",
"ModelNotFoundException",
"$",
"e",
")",
"{",
"Session",
"::",
"flash",
"(",
"'error_... | Adds a new message to a current thread.
@param $id
@return mixed | [
"Adds",
"a",
"new",
"message",
"to",
"a",
"current",
"thread",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/examples/MessagesController.php#L142-L197 |
lexxyungcarter/laravel-5-messenger | examples/MessagesController.php | MessagesController.oooPushIt | protected function oooPushIt(Message $message, $html = '')
{
$thread = $message->thread;
$sender = $message->user;
$data = [
'thread_id' => $thread->id,
'div_id' => 'thread_' . $thread->id,
'sender_name' => $sender->name,
'thread_url' => route... | php | protected function oooPushIt(Message $message, $html = '')
{
$thread = $message->thread;
$sender = $message->user;
$data = [
'thread_id' => $thread->id,
'div_id' => 'thread_' . $thread->id,
'sender_name' => $sender->name,
'thread_url' => route... | [
"protected",
"function",
"oooPushIt",
"(",
"Message",
"$",
"message",
",",
"$",
"html",
"=",
"''",
")",
"{",
"$",
"thread",
"=",
"$",
"message",
"->",
"thread",
";",
"$",
"sender",
"=",
"$",
"message",
"->",
"user",
";",
"$",
"data",
"=",
"[",
"'th... | Send the new message to Pusher in order to notify users.
@param Message $message | [
"Send",
"the",
"new",
"message",
"to",
"Pusher",
"in",
"order",
"to",
"notify",
"users",
"."
] | train | https://github.com/lexxyungcarter/laravel-5-messenger/blob/d98d00b1e9e70b82748beb06f0470b6609ebc9ca/examples/MessagesController.php#L204-L233 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.