repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.withShortName | public function withShortName(string $shortName): self
{
$metadata = clone $this;
$metadata->shortName = $shortName;
return $metadata;
} | php | public function withShortName(string $shortName): self
{
$metadata = clone $this;
$metadata->shortName = $shortName;
return $metadata;
} | [
"public",
"function",
"withShortName",
"(",
"string",
"$",
"shortName",
")",
":",
"self",
"{",
"$",
"metadata",
"=",
"clone",
"$",
"this",
";",
"$",
"metadata",
"->",
"shortName",
"=",
"$",
"shortName",
";",
"return",
"$",
"metadata",
";",
"}"
]
| Returns a new instance with the given short name. | [
"Returns",
"a",
"new",
"instance",
"with",
"the",
"given",
"short",
"name",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L57-L63 | train |
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.withIri | public function withIri(string $iri): self
{
$metadata = clone $this;
$metadata->iri = $iri;
return $metadata;
} | php | public function withIri(string $iri): self
{
$metadata = clone $this;
$metadata->iri = $iri;
return $metadata;
} | [
"public",
"function",
"withIri",
"(",
"string",
"$",
"iri",
")",
":",
"self",
"{",
"$",
"metadata",
"=",
"clone",
"$",
"this",
";",
"$",
"metadata",
"->",
"iri",
"=",
"$",
"iri",
";",
"return",
"$",
"metadata",
";",
"}"
]
| Returns a new instance with the given IRI. | [
"Returns",
"a",
"new",
"instance",
"with",
"the",
"given",
"IRI",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L95-L101 | train |
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.getCollectionOperationAttribute | public function getCollectionOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
return $this->findOperationAttribute($this->collectionOperations, $operationName, $key, $defaultValue, $resourceFallback);
} | php | public function getCollectionOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
return $this->findOperationAttribute($this->collectionOperations, $operationName, $key, $defaultValue, $resourceFallback);
} | [
"public",
"function",
"getCollectionOperationAttribute",
"(",
"?",
"string",
"$",
"operationName",
",",
"string",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"bool",
"$",
"resourceFallback",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"findOperationAttribute",
"(",
"$",
"this",
"->",
"collectionOperations",
",",
"$",
"operationName",
",",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"resourceFallback",
")",
";",
"}"
]
| Gets a collection operation attribute, optionally fallback to a resource attribute.
@param mixed|null $defaultValue | [
"Gets",
"a",
"collection",
"operation",
"attribute",
"optionally",
"fallback",
"to",
"a",
"resource",
"attribute",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L165-L168 | train |
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.getItemOperationAttribute | public function getItemOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
return $this->findOperationAttribute($this->itemOperations, $operationName, $key, $defaultValue, $resourceFallback);
} | php | public function getItemOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
return $this->findOperationAttribute($this->itemOperations, $operationName, $key, $defaultValue, $resourceFallback);
} | [
"public",
"function",
"getItemOperationAttribute",
"(",
"?",
"string",
"$",
"operationName",
",",
"string",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"bool",
"$",
"resourceFallback",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"findOperationAttribute",
"(",
"$",
"this",
"->",
"itemOperations",
",",
"$",
"operationName",
",",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"resourceFallback",
")",
";",
"}"
]
| Gets an item operation attribute, optionally fallback to a resource attribute.
@param mixed|null $defaultValue | [
"Gets",
"an",
"item",
"operation",
"attribute",
"optionally",
"fallback",
"to",
"a",
"resource",
"attribute",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L175-L178 | train |
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.getSubresourceOperationAttribute | public function getSubresourceOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
return $this->findOperationAttribute($this->subresourceOperations, $operationName, $key, $defaultValue, $resourceFallback);
} | php | public function getSubresourceOperationAttribute(?string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
return $this->findOperationAttribute($this->subresourceOperations, $operationName, $key, $defaultValue, $resourceFallback);
} | [
"public",
"function",
"getSubresourceOperationAttribute",
"(",
"?",
"string",
"$",
"operationName",
",",
"string",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"bool",
"$",
"resourceFallback",
"=",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"findOperationAttribute",
"(",
"$",
"this",
"->",
"subresourceOperations",
",",
"$",
"operationName",
",",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"resourceFallback",
")",
";",
"}"
]
| Gets a subresource operation attribute, optionally fallback to a resource attribute.
@param mixed|null $defaultValue | [
"Gets",
"a",
"subresource",
"operation",
"attribute",
"optionally",
"fallback",
"to",
"a",
"resource",
"attribute",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L185-L188 | train |
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.getTypedOperationAttribute | public function getTypedOperationAttribute(string $operationType, string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
switch ($operationType) {
case OperationType::COLLECTION:
return $this->getCollectionOperationAttribute($operationName, $key, $defaultValue, $resourceFallback);
case OperationType::ITEM:
return $this->getItemOperationAttribute($operationName, $key, $defaultValue, $resourceFallback);
default:
return $this->getSubresourceOperationAttribute($operationName, $key, $defaultValue, $resourceFallback);
}
} | php | public function getTypedOperationAttribute(string $operationType, string $operationName, string $key, $defaultValue = null, bool $resourceFallback = false)
{
switch ($operationType) {
case OperationType::COLLECTION:
return $this->getCollectionOperationAttribute($operationName, $key, $defaultValue, $resourceFallback);
case OperationType::ITEM:
return $this->getItemOperationAttribute($operationName, $key, $defaultValue, $resourceFallback);
default:
return $this->getSubresourceOperationAttribute($operationName, $key, $defaultValue, $resourceFallback);
}
} | [
"public",
"function",
"getTypedOperationAttribute",
"(",
"string",
"$",
"operationType",
",",
"string",
"$",
"operationName",
",",
"string",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"bool",
"$",
"resourceFallback",
"=",
"false",
")",
"{",
"switch",
"(",
"$",
"operationType",
")",
"{",
"case",
"OperationType",
"::",
"COLLECTION",
":",
"return",
"$",
"this",
"->",
"getCollectionOperationAttribute",
"(",
"$",
"operationName",
",",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"resourceFallback",
")",
";",
"case",
"OperationType",
"::",
"ITEM",
":",
"return",
"$",
"this",
"->",
"getItemOperationAttribute",
"(",
"$",
"operationName",
",",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"resourceFallback",
")",
";",
"default",
":",
"return",
"$",
"this",
"->",
"getSubresourceOperationAttribute",
"(",
"$",
"operationName",
",",
"$",
"key",
",",
"$",
"defaultValue",
",",
"$",
"resourceFallback",
")",
";",
"}",
"}"
]
| Gets an attribute for a given operation type and operation name.
@param mixed|null $defaultValue | [
"Gets",
"an",
"attribute",
"for",
"a",
"given",
"operation",
"type",
"and",
"operation",
"name",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L234-L244 | train |
api-platform/core | src/Metadata/Resource/ResourceMetadata.php | ResourceMetadata.findOperationAttribute | private function findOperationAttribute(?array $operations, ?string $operationName, string $key, $defaultValue, bool $resourceFallback)
{
if (null !== $operationName && isset($operations[$operationName][$key])) {
return $operations[$operationName][$key];
}
if ($resourceFallback && isset($this->attributes[$key])) {
return $this->attributes[$key];
}
return $defaultValue;
} | php | private function findOperationAttribute(?array $operations, ?string $operationName, string $key, $defaultValue, bool $resourceFallback)
{
if (null !== $operationName && isset($operations[$operationName][$key])) {
return $operations[$operationName][$key];
}
if ($resourceFallback && isset($this->attributes[$key])) {
return $this->attributes[$key];
}
return $defaultValue;
} | [
"private",
"function",
"findOperationAttribute",
"(",
"?",
"array",
"$",
"operations",
",",
"?",
"string",
"$",
"operationName",
",",
"string",
"$",
"key",
",",
"$",
"defaultValue",
",",
"bool",
"$",
"resourceFallback",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"operationName",
"&&",
"isset",
"(",
"$",
"operations",
"[",
"$",
"operationName",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"operations",
"[",
"$",
"operationName",
"]",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"$",
"resourceFallback",
"&&",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"attributes",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"defaultValue",
";",
"}"
]
| Gets an operation attribute, optionally fallback to a resource attribute.
@param mixed|null $defaultValue | [
"Gets",
"an",
"operation",
"attribute",
"optionally",
"fallback",
"to",
"a",
"resource",
"attribute",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Metadata/Resource/ResourceMetadata.php#L299-L310 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.populateEntrypointProperties | private function populateEntrypointProperties(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array &$entrypointProperties)
{
$hydraCollectionOperations = $this->getHydraOperations($resourceClass, $resourceMetadata, $prefixedShortName, true);
if (empty($hydraCollectionOperations)) {
return;
}
$entrypointProperty = [
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => sprintf('#Entrypoint/%s', lcfirst($shortName)),
'@type' => 'hydra:Link',
'domain' => '#Entrypoint',
'rdfs:label' => "The collection of $shortName resources",
'rdfs:range' => [
['@id' => 'hydra:Collection'],
[
'owl:equivalentClass' => [
'owl:onProperty' => ['@id' => 'hydra:member'],
'owl:allValuesFrom' => ['@id' => $prefixedShortName],
],
],
],
'hydra:supportedOperation' => $hydraCollectionOperations,
],
'hydra:title' => "The collection of $shortName resources",
'hydra:readable' => true,
'hydra:writable' => false,
];
if ($resourceMetadata->getCollectionOperationAttribute('GET', 'deprecation_reason', null, true)) {
$entrypointProperty['owl:deprecated'] = true;
}
$entrypointProperties[] = $entrypointProperty;
} | php | private function populateEntrypointProperties(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array &$entrypointProperties)
{
$hydraCollectionOperations = $this->getHydraOperations($resourceClass, $resourceMetadata, $prefixedShortName, true);
if (empty($hydraCollectionOperations)) {
return;
}
$entrypointProperty = [
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => sprintf('#Entrypoint/%s', lcfirst($shortName)),
'@type' => 'hydra:Link',
'domain' => '#Entrypoint',
'rdfs:label' => "The collection of $shortName resources",
'rdfs:range' => [
['@id' => 'hydra:Collection'],
[
'owl:equivalentClass' => [
'owl:onProperty' => ['@id' => 'hydra:member'],
'owl:allValuesFrom' => ['@id' => $prefixedShortName],
],
],
],
'hydra:supportedOperation' => $hydraCollectionOperations,
],
'hydra:title' => "The collection of $shortName resources",
'hydra:readable' => true,
'hydra:writable' => false,
];
if ($resourceMetadata->getCollectionOperationAttribute('GET', 'deprecation_reason', null, true)) {
$entrypointProperty['owl:deprecated'] = true;
}
$entrypointProperties[] = $entrypointProperty;
} | [
"private",
"function",
"populateEntrypointProperties",
"(",
"string",
"$",
"resourceClass",
",",
"ResourceMetadata",
"$",
"resourceMetadata",
",",
"string",
"$",
"shortName",
",",
"string",
"$",
"prefixedShortName",
",",
"array",
"&",
"$",
"entrypointProperties",
")",
"{",
"$",
"hydraCollectionOperations",
"=",
"$",
"this",
"->",
"getHydraOperations",
"(",
"$",
"resourceClass",
",",
"$",
"resourceMetadata",
",",
"$",
"prefixedShortName",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"hydraCollectionOperations",
")",
")",
"{",
"return",
";",
"}",
"$",
"entrypointProperty",
"=",
"[",
"'@type'",
"=>",
"'hydra:SupportedProperty'",
",",
"'hydra:property'",
"=>",
"[",
"'@id'",
"=>",
"sprintf",
"(",
"'#Entrypoint/%s'",
",",
"lcfirst",
"(",
"$",
"shortName",
")",
")",
",",
"'@type'",
"=>",
"'hydra:Link'",
",",
"'domain'",
"=>",
"'#Entrypoint'",
",",
"'rdfs:label'",
"=>",
"\"The collection of $shortName resources\"",
",",
"'rdfs:range'",
"=>",
"[",
"[",
"'@id'",
"=>",
"'hydra:Collection'",
"]",
",",
"[",
"'owl:equivalentClass'",
"=>",
"[",
"'owl:onProperty'",
"=>",
"[",
"'@id'",
"=>",
"'hydra:member'",
"]",
",",
"'owl:allValuesFrom'",
"=>",
"[",
"'@id'",
"=>",
"$",
"prefixedShortName",
"]",
",",
"]",
",",
"]",
",",
"]",
",",
"'hydra:supportedOperation'",
"=>",
"$",
"hydraCollectionOperations",
",",
"]",
",",
"'hydra:title'",
"=>",
"\"The collection of $shortName resources\"",
",",
"'hydra:readable'",
"=>",
"true",
",",
"'hydra:writable'",
"=>",
"false",
",",
"]",
";",
"if",
"(",
"$",
"resourceMetadata",
"->",
"getCollectionOperationAttribute",
"(",
"'GET'",
",",
"'deprecation_reason'",
",",
"null",
",",
"true",
")",
")",
"{",
"$",
"entrypointProperty",
"[",
"'owl:deprecated'",
"]",
"=",
"true",
";",
"}",
"$",
"entrypointProperties",
"[",
"]",
"=",
"$",
"entrypointProperty",
";",
"}"
]
| Populates entrypoint properties. | [
"Populates",
"entrypoint",
"properties",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L88-L123 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getClass | private function getClass(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array $context): array
{
$class = [
'@id' => $prefixedShortName,
'@type' => 'hydra:Class',
'rdfs:label' => $shortName,
'hydra:title' => $shortName,
'hydra:supportedProperty' => $this->getHydraProperties($resourceClass, $resourceMetadata, $shortName, $prefixedShortName, $context),
'hydra:supportedOperation' => $this->getHydraOperations($resourceClass, $resourceMetadata, $prefixedShortName, false),
];
if (null !== $description = $resourceMetadata->getDescription()) {
$class['hydra:description'] = $description;
}
if ($resourceMetadata->getAttribute('deprecation_reason')) {
$class['owl:deprecated'] = true;
}
return $class;
} | php | private function getClass(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array $context): array
{
$class = [
'@id' => $prefixedShortName,
'@type' => 'hydra:Class',
'rdfs:label' => $shortName,
'hydra:title' => $shortName,
'hydra:supportedProperty' => $this->getHydraProperties($resourceClass, $resourceMetadata, $shortName, $prefixedShortName, $context),
'hydra:supportedOperation' => $this->getHydraOperations($resourceClass, $resourceMetadata, $prefixedShortName, false),
];
if (null !== $description = $resourceMetadata->getDescription()) {
$class['hydra:description'] = $description;
}
if ($resourceMetadata->getAttribute('deprecation_reason')) {
$class['owl:deprecated'] = true;
}
return $class;
} | [
"private",
"function",
"getClass",
"(",
"string",
"$",
"resourceClass",
",",
"ResourceMetadata",
"$",
"resourceMetadata",
",",
"string",
"$",
"shortName",
",",
"string",
"$",
"prefixedShortName",
",",
"array",
"$",
"context",
")",
":",
"array",
"{",
"$",
"class",
"=",
"[",
"'@id'",
"=>",
"$",
"prefixedShortName",
",",
"'@type'",
"=>",
"'hydra:Class'",
",",
"'rdfs:label'",
"=>",
"$",
"shortName",
",",
"'hydra:title'",
"=>",
"$",
"shortName",
",",
"'hydra:supportedProperty'",
"=>",
"$",
"this",
"->",
"getHydraProperties",
"(",
"$",
"resourceClass",
",",
"$",
"resourceMetadata",
",",
"$",
"shortName",
",",
"$",
"prefixedShortName",
",",
"$",
"context",
")",
",",
"'hydra:supportedOperation'",
"=>",
"$",
"this",
"->",
"getHydraOperations",
"(",
"$",
"resourceClass",
",",
"$",
"resourceMetadata",
",",
"$",
"prefixedShortName",
",",
"false",
")",
",",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"description",
"=",
"$",
"resourceMetadata",
"->",
"getDescription",
"(",
")",
")",
"{",
"$",
"class",
"[",
"'hydra:description'",
"]",
"=",
"$",
"description",
";",
"}",
"if",
"(",
"$",
"resourceMetadata",
"->",
"getAttribute",
"(",
"'deprecation_reason'",
")",
")",
"{",
"$",
"class",
"[",
"'owl:deprecated'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"class",
";",
"}"
]
| Gets a Hydra class. | [
"Gets",
"a",
"Hydra",
"class",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L128-L148 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getPropertyNameCollectionFactoryContext | private function getPropertyNameCollectionFactoryContext(ResourceMetadata $resourceMetadata): array
{
$attributes = $resourceMetadata->getAttributes();
$context = [];
if (isset($attributes['normalization_context'][AbstractNormalizer::GROUPS])) {
$context['serializer_groups'] = (array) $attributes['normalization_context'][AbstractNormalizer::GROUPS];
}
if (!isset($attributes['denormalization_context'][AbstractNormalizer::GROUPS])) {
return $context;
}
if (isset($context['serializer_groups'])) {
foreach ((array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS] as $groupName) {
$context['serializer_groups'][] = $groupName;
}
return $context;
}
$context['serializer_groups'] = (array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
return $context;
} | php | private function getPropertyNameCollectionFactoryContext(ResourceMetadata $resourceMetadata): array
{
$attributes = $resourceMetadata->getAttributes();
$context = [];
if (isset($attributes['normalization_context'][AbstractNormalizer::GROUPS])) {
$context['serializer_groups'] = (array) $attributes['normalization_context'][AbstractNormalizer::GROUPS];
}
if (!isset($attributes['denormalization_context'][AbstractNormalizer::GROUPS])) {
return $context;
}
if (isset($context['serializer_groups'])) {
foreach ((array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS] as $groupName) {
$context['serializer_groups'][] = $groupName;
}
return $context;
}
$context['serializer_groups'] = (array) $attributes['denormalization_context'][AbstractNormalizer::GROUPS];
return $context;
} | [
"private",
"function",
"getPropertyNameCollectionFactoryContext",
"(",
"ResourceMetadata",
"$",
"resourceMetadata",
")",
":",
"array",
"{",
"$",
"attributes",
"=",
"$",
"resourceMetadata",
"->",
"getAttributes",
"(",
")",
";",
"$",
"context",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'normalization_context'",
"]",
"[",
"AbstractNormalizer",
"::",
"GROUPS",
"]",
")",
")",
"{",
"$",
"context",
"[",
"'serializer_groups'",
"]",
"=",
"(",
"array",
")",
"$",
"attributes",
"[",
"'normalization_context'",
"]",
"[",
"AbstractNormalizer",
"::",
"GROUPS",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'denormalization_context'",
"]",
"[",
"AbstractNormalizer",
"::",
"GROUPS",
"]",
")",
")",
"{",
"return",
"$",
"context",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"'serializer_groups'",
"]",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"attributes",
"[",
"'denormalization_context'",
"]",
"[",
"AbstractNormalizer",
"::",
"GROUPS",
"]",
"as",
"$",
"groupName",
")",
"{",
"$",
"context",
"[",
"'serializer_groups'",
"]",
"[",
"]",
"=",
"$",
"groupName",
";",
"}",
"return",
"$",
"context",
";",
"}",
"$",
"context",
"[",
"'serializer_groups'",
"]",
"=",
"(",
"array",
")",
"$",
"attributes",
"[",
"'denormalization_context'",
"]",
"[",
"AbstractNormalizer",
"::",
"GROUPS",
"]",
";",
"return",
"$",
"context",
";",
"}"
]
| Gets the context for the property name factory. | [
"Gets",
"the",
"context",
"for",
"the",
"property",
"name",
"factory",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L153-L177 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getHydraProperties | private function getHydraProperties(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array $context): array
{
$classes = [];
foreach ($resourceMetadata->getCollectionOperations() as $operationName => $operation) {
$inputMetadata = $resourceMetadata->getTypedOperationAttribute(OperationType::COLLECTION, $operationName, 'input', ['class' => $resourceClass], true);
if (null !== $inputClass = $inputMetadata['class'] ?? null) {
$classes[$inputClass] = true;
}
$outputMetadata = $resourceMetadata->getTypedOperationAttribute(OperationType::COLLECTION, $operationName, 'output', ['class' => $resourceClass], true);
if (null !== $outputClass = $outputMetadata['class'] ?? null) {
$classes[$outputClass] = true;
}
}
$properties = [];
foreach ($classes as $class => $v) {
foreach ($this->propertyNameCollectionFactory->create($class, $this->getPropertyNameCollectionFactoryContext($resourceMetadata)) as $propertyName) {
$propertyMetadata = $this->propertyMetadataFactory->create($class, $propertyName);
if (true === $propertyMetadata->isIdentifier() && false === $propertyMetadata->isWritable()) {
continue;
}
if ($this->nameConverter) {
$propertyName = $this->nameConverter->normalize($propertyName, $class, self::FORMAT, $context);
}
$properties[] = $this->getProperty($propertyMetadata, $propertyName, $prefixedShortName, $shortName);
}
}
return $properties;
} | php | private function getHydraProperties(string $resourceClass, ResourceMetadata $resourceMetadata, string $shortName, string $prefixedShortName, array $context): array
{
$classes = [];
foreach ($resourceMetadata->getCollectionOperations() as $operationName => $operation) {
$inputMetadata = $resourceMetadata->getTypedOperationAttribute(OperationType::COLLECTION, $operationName, 'input', ['class' => $resourceClass], true);
if (null !== $inputClass = $inputMetadata['class'] ?? null) {
$classes[$inputClass] = true;
}
$outputMetadata = $resourceMetadata->getTypedOperationAttribute(OperationType::COLLECTION, $operationName, 'output', ['class' => $resourceClass], true);
if (null !== $outputClass = $outputMetadata['class'] ?? null) {
$classes[$outputClass] = true;
}
}
$properties = [];
foreach ($classes as $class => $v) {
foreach ($this->propertyNameCollectionFactory->create($class, $this->getPropertyNameCollectionFactoryContext($resourceMetadata)) as $propertyName) {
$propertyMetadata = $this->propertyMetadataFactory->create($class, $propertyName);
if (true === $propertyMetadata->isIdentifier() && false === $propertyMetadata->isWritable()) {
continue;
}
if ($this->nameConverter) {
$propertyName = $this->nameConverter->normalize($propertyName, $class, self::FORMAT, $context);
}
$properties[] = $this->getProperty($propertyMetadata, $propertyName, $prefixedShortName, $shortName);
}
}
return $properties;
} | [
"private",
"function",
"getHydraProperties",
"(",
"string",
"$",
"resourceClass",
",",
"ResourceMetadata",
"$",
"resourceMetadata",
",",
"string",
"$",
"shortName",
",",
"string",
"$",
"prefixedShortName",
",",
"array",
"$",
"context",
")",
":",
"array",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"resourceMetadata",
"->",
"getCollectionOperations",
"(",
")",
"as",
"$",
"operationName",
"=>",
"$",
"operation",
")",
"{",
"$",
"inputMetadata",
"=",
"$",
"resourceMetadata",
"->",
"getTypedOperationAttribute",
"(",
"OperationType",
"::",
"COLLECTION",
",",
"$",
"operationName",
",",
"'input'",
",",
"[",
"'class'",
"=>",
"$",
"resourceClass",
"]",
",",
"true",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"inputClass",
"=",
"$",
"inputMetadata",
"[",
"'class'",
"]",
"??",
"null",
")",
"{",
"$",
"classes",
"[",
"$",
"inputClass",
"]",
"=",
"true",
";",
"}",
"$",
"outputMetadata",
"=",
"$",
"resourceMetadata",
"->",
"getTypedOperationAttribute",
"(",
"OperationType",
"::",
"COLLECTION",
",",
"$",
"operationName",
",",
"'output'",
",",
"[",
"'class'",
"=>",
"$",
"resourceClass",
"]",
",",
"true",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"outputClass",
"=",
"$",
"outputMetadata",
"[",
"'class'",
"]",
"??",
"null",
")",
"{",
"$",
"classes",
"[",
"$",
"outputClass",
"]",
"=",
"true",
";",
"}",
"}",
"$",
"properties",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
"=>",
"$",
"v",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"propertyNameCollectionFactory",
"->",
"create",
"(",
"$",
"class",
",",
"$",
"this",
"->",
"getPropertyNameCollectionFactoryContext",
"(",
"$",
"resourceMetadata",
")",
")",
"as",
"$",
"propertyName",
")",
"{",
"$",
"propertyMetadata",
"=",
"$",
"this",
"->",
"propertyMetadataFactory",
"->",
"create",
"(",
"$",
"class",
",",
"$",
"propertyName",
")",
";",
"if",
"(",
"true",
"===",
"$",
"propertyMetadata",
"->",
"isIdentifier",
"(",
")",
"&&",
"false",
"===",
"$",
"propertyMetadata",
"->",
"isWritable",
"(",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"nameConverter",
")",
"{",
"$",
"propertyName",
"=",
"$",
"this",
"->",
"nameConverter",
"->",
"normalize",
"(",
"$",
"propertyName",
",",
"$",
"class",
",",
"self",
"::",
"FORMAT",
",",
"$",
"context",
")",
";",
"}",
"$",
"properties",
"[",
"]",
"=",
"$",
"this",
"->",
"getProperty",
"(",
"$",
"propertyMetadata",
",",
"$",
"propertyName",
",",
"$",
"prefixedShortName",
",",
"$",
"shortName",
")",
";",
"}",
"}",
"return",
"$",
"properties",
";",
"}"
]
| Gets Hydra properties. | [
"Gets",
"Hydra",
"properties",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L182-L214 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getHydraOperations | private function getHydraOperations(string $resourceClass, ResourceMetadata $resourceMetadata, string $prefixedShortName, bool $collection): array
{
if (null === $operations = $collection ? $resourceMetadata->getCollectionOperations() : $resourceMetadata->getItemOperations()) {
return [];
}
$hydraOperations = [];
foreach ($operations as $operationName => $operation) {
$hydraOperations[] = $this->getHydraOperation($resourceClass, $resourceMetadata, $operationName, $operation, $prefixedShortName, $collection ? OperationType::COLLECTION : OperationType::ITEM);
}
if (null !== $this->subresourceOperationFactory) {
foreach ($this->subresourceOperationFactory->create($resourceClass) as $operationId => $operation) {
$subresourceMetadata = $this->resourceMetadataFactory->create($operation['resource_class']);
$propertyMetadata = $this->propertyMetadataFactory->create(end($operation['identifiers'])[1], $operation['property']);
$hydraOperations[] = $this->getHydraOperation($resourceClass, $subresourceMetadata, $operation['route_name'], $operation, "#{$subresourceMetadata->getShortName()}", OperationType::SUBRESOURCE, $propertyMetadata->getSubresource());
}
}
return $hydraOperations;
} | php | private function getHydraOperations(string $resourceClass, ResourceMetadata $resourceMetadata, string $prefixedShortName, bool $collection): array
{
if (null === $operations = $collection ? $resourceMetadata->getCollectionOperations() : $resourceMetadata->getItemOperations()) {
return [];
}
$hydraOperations = [];
foreach ($operations as $operationName => $operation) {
$hydraOperations[] = $this->getHydraOperation($resourceClass, $resourceMetadata, $operationName, $operation, $prefixedShortName, $collection ? OperationType::COLLECTION : OperationType::ITEM);
}
if (null !== $this->subresourceOperationFactory) {
foreach ($this->subresourceOperationFactory->create($resourceClass) as $operationId => $operation) {
$subresourceMetadata = $this->resourceMetadataFactory->create($operation['resource_class']);
$propertyMetadata = $this->propertyMetadataFactory->create(end($operation['identifiers'])[1], $operation['property']);
$hydraOperations[] = $this->getHydraOperation($resourceClass, $subresourceMetadata, $operation['route_name'], $operation, "#{$subresourceMetadata->getShortName()}", OperationType::SUBRESOURCE, $propertyMetadata->getSubresource());
}
}
return $hydraOperations;
} | [
"private",
"function",
"getHydraOperations",
"(",
"string",
"$",
"resourceClass",
",",
"ResourceMetadata",
"$",
"resourceMetadata",
",",
"string",
"$",
"prefixedShortName",
",",
"bool",
"$",
"collection",
")",
":",
"array",
"{",
"if",
"(",
"null",
"===",
"$",
"operations",
"=",
"$",
"collection",
"?",
"$",
"resourceMetadata",
"->",
"getCollectionOperations",
"(",
")",
":",
"$",
"resourceMetadata",
"->",
"getItemOperations",
"(",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"hydraOperations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"operations",
"as",
"$",
"operationName",
"=>",
"$",
"operation",
")",
"{",
"$",
"hydraOperations",
"[",
"]",
"=",
"$",
"this",
"->",
"getHydraOperation",
"(",
"$",
"resourceClass",
",",
"$",
"resourceMetadata",
",",
"$",
"operationName",
",",
"$",
"operation",
",",
"$",
"prefixedShortName",
",",
"$",
"collection",
"?",
"OperationType",
"::",
"COLLECTION",
":",
"OperationType",
"::",
"ITEM",
")",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"subresourceOperationFactory",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"subresourceOperationFactory",
"->",
"create",
"(",
"$",
"resourceClass",
")",
"as",
"$",
"operationId",
"=>",
"$",
"operation",
")",
"{",
"$",
"subresourceMetadata",
"=",
"$",
"this",
"->",
"resourceMetadataFactory",
"->",
"create",
"(",
"$",
"operation",
"[",
"'resource_class'",
"]",
")",
";",
"$",
"propertyMetadata",
"=",
"$",
"this",
"->",
"propertyMetadataFactory",
"->",
"create",
"(",
"end",
"(",
"$",
"operation",
"[",
"'identifiers'",
"]",
")",
"[",
"1",
"]",
",",
"$",
"operation",
"[",
"'property'",
"]",
")",
";",
"$",
"hydraOperations",
"[",
"]",
"=",
"$",
"this",
"->",
"getHydraOperation",
"(",
"$",
"resourceClass",
",",
"$",
"subresourceMetadata",
",",
"$",
"operation",
"[",
"'route_name'",
"]",
",",
"$",
"operation",
",",
"\"#{$subresourceMetadata->getShortName()}\"",
",",
"OperationType",
"::",
"SUBRESOURCE",
",",
"$",
"propertyMetadata",
"->",
"getSubresource",
"(",
")",
")",
";",
"}",
"}",
"return",
"$",
"hydraOperations",
";",
"}"
]
| Gets Hydra operations. | [
"Gets",
"Hydra",
"operations",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L219-L239 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getRange | private function getRange(PropertyMetadata $propertyMetadata): ?string
{
$jsonldContext = $propertyMetadata->getAttributes()['jsonld_context'] ?? [];
if (isset($jsonldContext['@type'])) {
return $jsonldContext['@type'];
}
if (null === $type = $propertyMetadata->getType()) {
return null;
}
if ($type->isCollection() && null !== $collectionType = $type->getCollectionValueType()) {
$type = $collectionType;
}
switch ($type->getBuiltinType()) {
case Type::BUILTIN_TYPE_STRING:
return 'xmls:string';
case Type::BUILTIN_TYPE_INT:
return 'xmls:integer';
case Type::BUILTIN_TYPE_FLOAT:
return 'xmls:decimal';
case Type::BUILTIN_TYPE_BOOL:
return 'xmls:boolean';
case Type::BUILTIN_TYPE_OBJECT:
if (null === $className = $type->getClassName()) {
return null;
}
if (is_a($className, \DateTimeInterface::class, true)) {
return 'xmls:dateTime';
}
if ($this->resourceClassResolver->isResourceClass($className)) {
$resourceMetadata = $this->resourceMetadataFactory->create($className);
return $resourceMetadata->getIri() ?? "#{$resourceMetadata->getShortName()}";
}
break;
}
return null;
} | php | private function getRange(PropertyMetadata $propertyMetadata): ?string
{
$jsonldContext = $propertyMetadata->getAttributes()['jsonld_context'] ?? [];
if (isset($jsonldContext['@type'])) {
return $jsonldContext['@type'];
}
if (null === $type = $propertyMetadata->getType()) {
return null;
}
if ($type->isCollection() && null !== $collectionType = $type->getCollectionValueType()) {
$type = $collectionType;
}
switch ($type->getBuiltinType()) {
case Type::BUILTIN_TYPE_STRING:
return 'xmls:string';
case Type::BUILTIN_TYPE_INT:
return 'xmls:integer';
case Type::BUILTIN_TYPE_FLOAT:
return 'xmls:decimal';
case Type::BUILTIN_TYPE_BOOL:
return 'xmls:boolean';
case Type::BUILTIN_TYPE_OBJECT:
if (null === $className = $type->getClassName()) {
return null;
}
if (is_a($className, \DateTimeInterface::class, true)) {
return 'xmls:dateTime';
}
if ($this->resourceClassResolver->isResourceClass($className)) {
$resourceMetadata = $this->resourceMetadataFactory->create($className);
return $resourceMetadata->getIri() ?? "#{$resourceMetadata->getShortName()}";
}
break;
}
return null;
} | [
"private",
"function",
"getRange",
"(",
"PropertyMetadata",
"$",
"propertyMetadata",
")",
":",
"?",
"string",
"{",
"$",
"jsonldContext",
"=",
"$",
"propertyMetadata",
"->",
"getAttributes",
"(",
")",
"[",
"'jsonld_context'",
"]",
"??",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"jsonldContext",
"[",
"'@type'",
"]",
")",
")",
"{",
"return",
"$",
"jsonldContext",
"[",
"'@type'",
"]",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"type",
"=",
"$",
"propertyMetadata",
"->",
"getType",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"type",
"->",
"isCollection",
"(",
")",
"&&",
"null",
"!==",
"$",
"collectionType",
"=",
"$",
"type",
"->",
"getCollectionValueType",
"(",
")",
")",
"{",
"$",
"type",
"=",
"$",
"collectionType",
";",
"}",
"switch",
"(",
"$",
"type",
"->",
"getBuiltinType",
"(",
")",
")",
"{",
"case",
"Type",
"::",
"BUILTIN_TYPE_STRING",
":",
"return",
"'xmls:string'",
";",
"case",
"Type",
"::",
"BUILTIN_TYPE_INT",
":",
"return",
"'xmls:integer'",
";",
"case",
"Type",
"::",
"BUILTIN_TYPE_FLOAT",
":",
"return",
"'xmls:decimal'",
";",
"case",
"Type",
"::",
"BUILTIN_TYPE_BOOL",
":",
"return",
"'xmls:boolean'",
";",
"case",
"Type",
"::",
"BUILTIN_TYPE_OBJECT",
":",
"if",
"(",
"null",
"===",
"$",
"className",
"=",
"$",
"type",
"->",
"getClassName",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"is_a",
"(",
"$",
"className",
",",
"\\",
"DateTimeInterface",
"::",
"class",
",",
"true",
")",
")",
"{",
"return",
"'xmls:dateTime'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resourceClassResolver",
"->",
"isResourceClass",
"(",
"$",
"className",
")",
")",
"{",
"$",
"resourceMetadata",
"=",
"$",
"this",
"->",
"resourceMetadataFactory",
"->",
"create",
"(",
"$",
"className",
")",
";",
"return",
"$",
"resourceMetadata",
"->",
"getIri",
"(",
")",
"??",
"\"#{$resourceMetadata->getShortName()}\"",
";",
"}",
"break",
";",
"}",
"return",
"null",
";",
"}"
]
| Gets the range of the property. | [
"Gets",
"the",
"range",
"of",
"the",
"property",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L328-L371 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getClasses | private function getClasses(array $entrypointProperties, array $classes): array
{
$classes[] = [
'@id' => '#Entrypoint',
'@type' => 'hydra:Class',
'hydra:title' => 'The API entrypoint',
'hydra:supportedProperty' => $entrypointProperties,
'hydra:supportedOperation' => [
'@type' => 'hydra:Operation',
'hydra:method' => 'GET',
'rdfs:label' => 'The API entrypoint.',
'returns' => '#EntryPoint',
],
];
// Constraint violation
$classes[] = [
'@id' => '#ConstraintViolation',
'@type' => 'hydra:Class',
'hydra:title' => 'A constraint violation',
'hydra:supportedProperty' => [
[
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => '#ConstraintViolation/propertyPath',
'@type' => 'rdf:Property',
'rdfs:label' => 'propertyPath',
'domain' => '#ConstraintViolation',
'range' => 'xmls:string',
],
'hydra:title' => 'propertyPath',
'hydra:description' => 'The property path of the violation',
'hydra:readable' => true,
'hydra:writable' => false,
],
[
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => '#ConstraintViolation/message',
'@type' => 'rdf:Property',
'rdfs:label' => 'message',
'domain' => '#ConstraintViolation',
'range' => 'xmls:string',
],
'hydra:title' => 'message',
'hydra:description' => 'The message associated with the violation',
'hydra:readable' => true,
'hydra:writable' => false,
],
],
];
// Constraint violation list
$classes[] = [
'@id' => '#ConstraintViolationList',
'@type' => 'hydra:Class',
'subClassOf' => 'hydra:Error',
'hydra:title' => 'A constraint violation list',
'hydra:supportedProperty' => [
[
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => '#ConstraintViolationList/violations',
'@type' => 'rdf:Property',
'rdfs:label' => 'violations',
'domain' => '#ConstraintViolationList',
'range' => '#ConstraintViolation',
],
'hydra:title' => 'violations',
'hydra:description' => 'The violations',
'hydra:readable' => true,
'hydra:writable' => false,
],
],
];
return $classes;
} | php | private function getClasses(array $entrypointProperties, array $classes): array
{
$classes[] = [
'@id' => '#Entrypoint',
'@type' => 'hydra:Class',
'hydra:title' => 'The API entrypoint',
'hydra:supportedProperty' => $entrypointProperties,
'hydra:supportedOperation' => [
'@type' => 'hydra:Operation',
'hydra:method' => 'GET',
'rdfs:label' => 'The API entrypoint.',
'returns' => '#EntryPoint',
],
];
// Constraint violation
$classes[] = [
'@id' => '#ConstraintViolation',
'@type' => 'hydra:Class',
'hydra:title' => 'A constraint violation',
'hydra:supportedProperty' => [
[
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => '#ConstraintViolation/propertyPath',
'@type' => 'rdf:Property',
'rdfs:label' => 'propertyPath',
'domain' => '#ConstraintViolation',
'range' => 'xmls:string',
],
'hydra:title' => 'propertyPath',
'hydra:description' => 'The property path of the violation',
'hydra:readable' => true,
'hydra:writable' => false,
],
[
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => '#ConstraintViolation/message',
'@type' => 'rdf:Property',
'rdfs:label' => 'message',
'domain' => '#ConstraintViolation',
'range' => 'xmls:string',
],
'hydra:title' => 'message',
'hydra:description' => 'The message associated with the violation',
'hydra:readable' => true,
'hydra:writable' => false,
],
],
];
// Constraint violation list
$classes[] = [
'@id' => '#ConstraintViolationList',
'@type' => 'hydra:Class',
'subClassOf' => 'hydra:Error',
'hydra:title' => 'A constraint violation list',
'hydra:supportedProperty' => [
[
'@type' => 'hydra:SupportedProperty',
'hydra:property' => [
'@id' => '#ConstraintViolationList/violations',
'@type' => 'rdf:Property',
'rdfs:label' => 'violations',
'domain' => '#ConstraintViolationList',
'range' => '#ConstraintViolation',
],
'hydra:title' => 'violations',
'hydra:description' => 'The violations',
'hydra:readable' => true,
'hydra:writable' => false,
],
],
];
return $classes;
} | [
"private",
"function",
"getClasses",
"(",
"array",
"$",
"entrypointProperties",
",",
"array",
"$",
"classes",
")",
":",
"array",
"{",
"$",
"classes",
"[",
"]",
"=",
"[",
"'@id'",
"=>",
"'#Entrypoint'",
",",
"'@type'",
"=>",
"'hydra:Class'",
",",
"'hydra:title'",
"=>",
"'The API entrypoint'",
",",
"'hydra:supportedProperty'",
"=>",
"$",
"entrypointProperties",
",",
"'hydra:supportedOperation'",
"=>",
"[",
"'@type'",
"=>",
"'hydra:Operation'",
",",
"'hydra:method'",
"=>",
"'GET'",
",",
"'rdfs:label'",
"=>",
"'The API entrypoint.'",
",",
"'returns'",
"=>",
"'#EntryPoint'",
",",
"]",
",",
"]",
";",
"// Constraint violation",
"$",
"classes",
"[",
"]",
"=",
"[",
"'@id'",
"=>",
"'#ConstraintViolation'",
",",
"'@type'",
"=>",
"'hydra:Class'",
",",
"'hydra:title'",
"=>",
"'A constraint violation'",
",",
"'hydra:supportedProperty'",
"=>",
"[",
"[",
"'@type'",
"=>",
"'hydra:SupportedProperty'",
",",
"'hydra:property'",
"=>",
"[",
"'@id'",
"=>",
"'#ConstraintViolation/propertyPath'",
",",
"'@type'",
"=>",
"'rdf:Property'",
",",
"'rdfs:label'",
"=>",
"'propertyPath'",
",",
"'domain'",
"=>",
"'#ConstraintViolation'",
",",
"'range'",
"=>",
"'xmls:string'",
",",
"]",
",",
"'hydra:title'",
"=>",
"'propertyPath'",
",",
"'hydra:description'",
"=>",
"'The property path of the violation'",
",",
"'hydra:readable'",
"=>",
"true",
",",
"'hydra:writable'",
"=>",
"false",
",",
"]",
",",
"[",
"'@type'",
"=>",
"'hydra:SupportedProperty'",
",",
"'hydra:property'",
"=>",
"[",
"'@id'",
"=>",
"'#ConstraintViolation/message'",
",",
"'@type'",
"=>",
"'rdf:Property'",
",",
"'rdfs:label'",
"=>",
"'message'",
",",
"'domain'",
"=>",
"'#ConstraintViolation'",
",",
"'range'",
"=>",
"'xmls:string'",
",",
"]",
",",
"'hydra:title'",
"=>",
"'message'",
",",
"'hydra:description'",
"=>",
"'The message associated with the violation'",
",",
"'hydra:readable'",
"=>",
"true",
",",
"'hydra:writable'",
"=>",
"false",
",",
"]",
",",
"]",
",",
"]",
";",
"// Constraint violation list",
"$",
"classes",
"[",
"]",
"=",
"[",
"'@id'",
"=>",
"'#ConstraintViolationList'",
",",
"'@type'",
"=>",
"'hydra:Class'",
",",
"'subClassOf'",
"=>",
"'hydra:Error'",
",",
"'hydra:title'",
"=>",
"'A constraint violation list'",
",",
"'hydra:supportedProperty'",
"=>",
"[",
"[",
"'@type'",
"=>",
"'hydra:SupportedProperty'",
",",
"'hydra:property'",
"=>",
"[",
"'@id'",
"=>",
"'#ConstraintViolationList/violations'",
",",
"'@type'",
"=>",
"'rdf:Property'",
",",
"'rdfs:label'",
"=>",
"'violations'",
",",
"'domain'",
"=>",
"'#ConstraintViolationList'",
",",
"'range'",
"=>",
"'#ConstraintViolation'",
",",
"]",
",",
"'hydra:title'",
"=>",
"'violations'",
",",
"'hydra:description'",
"=>",
"'The violations'",
",",
"'hydra:readable'",
"=>",
"true",
",",
"'hydra:writable'",
"=>",
"false",
",",
"]",
",",
"]",
",",
"]",
";",
"return",
"$",
"classes",
";",
"}"
]
| Builds the classes array. | [
"Builds",
"the",
"classes",
"array",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L376-L453 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getProperty | private function getProperty(PropertyMetadata $propertyMetadata, string $propertyName, string $prefixedShortName, string $shortName): array
{
$propertyData = [
'@id' => $propertyMetadata->getIri() ?? "#$shortName/$propertyName",
'@type' => $propertyMetadata->isReadableLink() ? 'rdf:Property' : 'hydra:Link',
'rdfs:label' => $propertyName,
'domain' => $prefixedShortName,
];
$type = $propertyMetadata->getType();
if (null !== $type && !$type->isCollection() && (null !== $className = $type->getClassName()) && $this->resourceClassResolver->isResourceClass($className)) {
$propertyData['owl:maxCardinality'] = 1;
}
$property = [
'@type' => 'hydra:SupportedProperty',
'hydra:property' => $propertyData,
'hydra:title' => $propertyName,
'hydra:required' => $propertyMetadata->isRequired(),
'hydra:readable' => $propertyMetadata->isReadable(),
'hydra:writable' => $propertyMetadata->isWritable() || $propertyMetadata->isInitializable(),
];
if (null !== $range = $this->getRange($propertyMetadata)) {
$property['hydra:property']['range'] = $range;
}
if (null !== $description = $propertyMetadata->getDescription()) {
$property['hydra:description'] = $description;
}
if ($propertyMetadata->getAttribute('deprecation_reason')) {
$property['owl:deprecated'] = true;
}
return $property;
} | php | private function getProperty(PropertyMetadata $propertyMetadata, string $propertyName, string $prefixedShortName, string $shortName): array
{
$propertyData = [
'@id' => $propertyMetadata->getIri() ?? "#$shortName/$propertyName",
'@type' => $propertyMetadata->isReadableLink() ? 'rdf:Property' : 'hydra:Link',
'rdfs:label' => $propertyName,
'domain' => $prefixedShortName,
];
$type = $propertyMetadata->getType();
if (null !== $type && !$type->isCollection() && (null !== $className = $type->getClassName()) && $this->resourceClassResolver->isResourceClass($className)) {
$propertyData['owl:maxCardinality'] = 1;
}
$property = [
'@type' => 'hydra:SupportedProperty',
'hydra:property' => $propertyData,
'hydra:title' => $propertyName,
'hydra:required' => $propertyMetadata->isRequired(),
'hydra:readable' => $propertyMetadata->isReadable(),
'hydra:writable' => $propertyMetadata->isWritable() || $propertyMetadata->isInitializable(),
];
if (null !== $range = $this->getRange($propertyMetadata)) {
$property['hydra:property']['range'] = $range;
}
if (null !== $description = $propertyMetadata->getDescription()) {
$property['hydra:description'] = $description;
}
if ($propertyMetadata->getAttribute('deprecation_reason')) {
$property['owl:deprecated'] = true;
}
return $property;
} | [
"private",
"function",
"getProperty",
"(",
"PropertyMetadata",
"$",
"propertyMetadata",
",",
"string",
"$",
"propertyName",
",",
"string",
"$",
"prefixedShortName",
",",
"string",
"$",
"shortName",
")",
":",
"array",
"{",
"$",
"propertyData",
"=",
"[",
"'@id'",
"=>",
"$",
"propertyMetadata",
"->",
"getIri",
"(",
")",
"??",
"\"#$shortName/$propertyName\"",
",",
"'@type'",
"=>",
"$",
"propertyMetadata",
"->",
"isReadableLink",
"(",
")",
"?",
"'rdf:Property'",
":",
"'hydra:Link'",
",",
"'rdfs:label'",
"=>",
"$",
"propertyName",
",",
"'domain'",
"=>",
"$",
"prefixedShortName",
",",
"]",
";",
"$",
"type",
"=",
"$",
"propertyMetadata",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"type",
"&&",
"!",
"$",
"type",
"->",
"isCollection",
"(",
")",
"&&",
"(",
"null",
"!==",
"$",
"className",
"=",
"$",
"type",
"->",
"getClassName",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"resourceClassResolver",
"->",
"isResourceClass",
"(",
"$",
"className",
")",
")",
"{",
"$",
"propertyData",
"[",
"'owl:maxCardinality'",
"]",
"=",
"1",
";",
"}",
"$",
"property",
"=",
"[",
"'@type'",
"=>",
"'hydra:SupportedProperty'",
",",
"'hydra:property'",
"=>",
"$",
"propertyData",
",",
"'hydra:title'",
"=>",
"$",
"propertyName",
",",
"'hydra:required'",
"=>",
"$",
"propertyMetadata",
"->",
"isRequired",
"(",
")",
",",
"'hydra:readable'",
"=>",
"$",
"propertyMetadata",
"->",
"isReadable",
"(",
")",
",",
"'hydra:writable'",
"=>",
"$",
"propertyMetadata",
"->",
"isWritable",
"(",
")",
"||",
"$",
"propertyMetadata",
"->",
"isInitializable",
"(",
")",
",",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"range",
"=",
"$",
"this",
"->",
"getRange",
"(",
"$",
"propertyMetadata",
")",
")",
"{",
"$",
"property",
"[",
"'hydra:property'",
"]",
"[",
"'range'",
"]",
"=",
"$",
"range",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"description",
"=",
"$",
"propertyMetadata",
"->",
"getDescription",
"(",
")",
")",
"{",
"$",
"property",
"[",
"'hydra:description'",
"]",
"=",
"$",
"description",
";",
"}",
"if",
"(",
"$",
"propertyMetadata",
"->",
"getAttribute",
"(",
"'deprecation_reason'",
")",
")",
"{",
"$",
"property",
"[",
"'owl:deprecated'",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"property",
";",
"}"
]
| Gets a property definition. | [
"Gets",
"a",
"property",
"definition",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L458-L495 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.computeDoc | private function computeDoc(Documentation $object, array $classes): array
{
$doc = ['@context' => $this->getContext(), '@id' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT]), '@type' => 'hydra:ApiDocumentation'];
if ('' !== $object->getTitle()) {
$doc['hydra:title'] = $object->getTitle();
}
if ('' !== $object->getDescription()) {
$doc['hydra:description'] = $object->getDescription();
}
$doc['hydra:entrypoint'] = $this->urlGenerator->generate('api_entrypoint');
$doc['hydra:supportedClass'] = $classes;
return $doc;
} | php | private function computeDoc(Documentation $object, array $classes): array
{
$doc = ['@context' => $this->getContext(), '@id' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT]), '@type' => 'hydra:ApiDocumentation'];
if ('' !== $object->getTitle()) {
$doc['hydra:title'] = $object->getTitle();
}
if ('' !== $object->getDescription()) {
$doc['hydra:description'] = $object->getDescription();
}
$doc['hydra:entrypoint'] = $this->urlGenerator->generate('api_entrypoint');
$doc['hydra:supportedClass'] = $classes;
return $doc;
} | [
"private",
"function",
"computeDoc",
"(",
"Documentation",
"$",
"object",
",",
"array",
"$",
"classes",
")",
":",
"array",
"{",
"$",
"doc",
"=",
"[",
"'@context'",
"=>",
"$",
"this",
"->",
"getContext",
"(",
")",
",",
"'@id'",
"=>",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"'api_doc'",
",",
"[",
"'_format'",
"=>",
"self",
"::",
"FORMAT",
"]",
")",
",",
"'@type'",
"=>",
"'hydra:ApiDocumentation'",
"]",
";",
"if",
"(",
"''",
"!==",
"$",
"object",
"->",
"getTitle",
"(",
")",
")",
"{",
"$",
"doc",
"[",
"'hydra:title'",
"]",
"=",
"$",
"object",
"->",
"getTitle",
"(",
")",
";",
"}",
"if",
"(",
"''",
"!==",
"$",
"object",
"->",
"getDescription",
"(",
")",
")",
"{",
"$",
"doc",
"[",
"'hydra:description'",
"]",
"=",
"$",
"object",
"->",
"getDescription",
"(",
")",
";",
"}",
"$",
"doc",
"[",
"'hydra:entrypoint'",
"]",
"=",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"'api_entrypoint'",
")",
";",
"$",
"doc",
"[",
"'hydra:supportedClass'",
"]",
"=",
"$",
"classes",
";",
"return",
"$",
"doc",
";",
"}"
]
| Computes the documentation. | [
"Computes",
"the",
"documentation",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L500-L516 | train |
api-platform/core | src/Hydra/Serializer/DocumentationNormalizer.php | DocumentationNormalizer.getContext | private function getContext(): array
{
return [
'@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#',
'hydra' => ContextBuilderInterface::HYDRA_NS,
'rdf' => ContextBuilderInterface::RDF_NS,
'rdfs' => ContextBuilderInterface::RDFS_NS,
'xmls' => ContextBuilderInterface::XML_NS,
'owl' => ContextBuilderInterface::OWL_NS,
'schema' => ContextBuilderInterface::SCHEMA_ORG_NS,
'domain' => ['@id' => 'rdfs:domain', '@type' => '@id'],
'range' => ['@id' => 'rdfs:range', '@type' => '@id'],
'subClassOf' => ['@id' => 'rdfs:subClassOf', '@type' => '@id'],
'expects' => ['@id' => 'hydra:expects', '@type' => '@id'],
'returns' => ['@id' => 'hydra:returns', '@type' => '@id'],
];
} | php | private function getContext(): array
{
return [
'@vocab' => $this->urlGenerator->generate('api_doc', ['_format' => self::FORMAT], UrlGeneratorInterface::ABS_URL).'#',
'hydra' => ContextBuilderInterface::HYDRA_NS,
'rdf' => ContextBuilderInterface::RDF_NS,
'rdfs' => ContextBuilderInterface::RDFS_NS,
'xmls' => ContextBuilderInterface::XML_NS,
'owl' => ContextBuilderInterface::OWL_NS,
'schema' => ContextBuilderInterface::SCHEMA_ORG_NS,
'domain' => ['@id' => 'rdfs:domain', '@type' => '@id'],
'range' => ['@id' => 'rdfs:range', '@type' => '@id'],
'subClassOf' => ['@id' => 'rdfs:subClassOf', '@type' => '@id'],
'expects' => ['@id' => 'hydra:expects', '@type' => '@id'],
'returns' => ['@id' => 'hydra:returns', '@type' => '@id'],
];
} | [
"private",
"function",
"getContext",
"(",
")",
":",
"array",
"{",
"return",
"[",
"'@vocab'",
"=>",
"$",
"this",
"->",
"urlGenerator",
"->",
"generate",
"(",
"'api_doc'",
",",
"[",
"'_format'",
"=>",
"self",
"::",
"FORMAT",
"]",
",",
"UrlGeneratorInterface",
"::",
"ABS_URL",
")",
".",
"'#'",
",",
"'hydra'",
"=>",
"ContextBuilderInterface",
"::",
"HYDRA_NS",
",",
"'rdf'",
"=>",
"ContextBuilderInterface",
"::",
"RDF_NS",
",",
"'rdfs'",
"=>",
"ContextBuilderInterface",
"::",
"RDFS_NS",
",",
"'xmls'",
"=>",
"ContextBuilderInterface",
"::",
"XML_NS",
",",
"'owl'",
"=>",
"ContextBuilderInterface",
"::",
"OWL_NS",
",",
"'schema'",
"=>",
"ContextBuilderInterface",
"::",
"SCHEMA_ORG_NS",
",",
"'domain'",
"=>",
"[",
"'@id'",
"=>",
"'rdfs:domain'",
",",
"'@type'",
"=>",
"'@id'",
"]",
",",
"'range'",
"=>",
"[",
"'@id'",
"=>",
"'rdfs:range'",
",",
"'@type'",
"=>",
"'@id'",
"]",
",",
"'subClassOf'",
"=>",
"[",
"'@id'",
"=>",
"'rdfs:subClassOf'",
",",
"'@type'",
"=>",
"'@id'",
"]",
",",
"'expects'",
"=>",
"[",
"'@id'",
"=>",
"'hydra:expects'",
",",
"'@type'",
"=>",
"'@id'",
"]",
",",
"'returns'",
"=>",
"[",
"'@id'",
"=>",
"'hydra:returns'",
",",
"'@type'",
"=>",
"'@id'",
"]",
",",
"]",
";",
"}"
]
| Builds the JSON-LD context for the API documentation. | [
"Builds",
"the",
"JSON",
"-",
"LD",
"context",
"for",
"the",
"API",
"documentation",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Hydra/Serializer/DocumentationNormalizer.php#L521-L537 | train |
api-platform/core | src/Bridge/Elasticsearch/DataProvider/Filter/AbstractSearchFilter.php | AbstractSearchFilter.isIdentifier | protected function isIdentifier(string $resourceClass, string $property): bool
{
return $property === $this->identifierExtractor->getIdentifierFromResourceClass($resourceClass);
} | php | protected function isIdentifier(string $resourceClass, string $property): bool
{
return $property === $this->identifierExtractor->getIdentifierFromResourceClass($resourceClass);
} | [
"protected",
"function",
"isIdentifier",
"(",
"string",
"$",
"resourceClass",
",",
"string",
"$",
"property",
")",
":",
"bool",
"{",
"return",
"$",
"property",
"===",
"$",
"this",
"->",
"identifierExtractor",
"->",
"getIdentifierFromResourceClass",
"(",
"$",
"resourceClass",
")",
";",
"}"
]
| Is the given property of the given resource class an identifier? | [
"Is",
"the",
"given",
"property",
"of",
"the",
"given",
"resource",
"class",
"an",
"identifier?"
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Elasticsearch/DataProvider/Filter/AbstractSearchFilter.php#L150-L153 | train |
api-platform/core | src/Bridge/Doctrine/Common/DataPersister.php | DataPersister.getManager | private function getManager($data): ?DoctrineObjectManager
{
return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null;
} | php | private function getManager($data): ?DoctrineObjectManager
{
return \is_object($data) ? $this->managerRegistry->getManagerForClass($this->getObjectClass($data)) : null;
} | [
"private",
"function",
"getManager",
"(",
"$",
"data",
")",
":",
"?",
"DoctrineObjectManager",
"{",
"return",
"\\",
"is_object",
"(",
"$",
"data",
")",
"?",
"$",
"this",
"->",
"managerRegistry",
"->",
"getManagerForClass",
"(",
"$",
"this",
"->",
"getObjectClass",
"(",
"$",
"data",
")",
")",
":",
"null",
";",
"}"
]
| Gets the Doctrine object manager associated with given data. | [
"Gets",
"the",
"Doctrine",
"object",
"manager",
"associated",
"with",
"given",
"data",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Common/DataPersister.php#L81-L84 | train |
api-platform/core | src/Bridge/Doctrine/Common/DataPersister.php | DataPersister.isDeferredExplicit | private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool
{
$classMetadata = $manager->getClassMetadata($this->getObjectClass($data));
if ($classMetadata instanceof ClassMetadataInfo && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) {
return $classMetadata->isChangeTrackingDeferredExplicit();
}
return false;
} | php | private function isDeferredExplicit(DoctrineObjectManager $manager, $data): bool
{
$classMetadata = $manager->getClassMetadata($this->getObjectClass($data));
if ($classMetadata instanceof ClassMetadataInfo && method_exists($classMetadata, 'isChangeTrackingDeferredExplicit')) {
return $classMetadata->isChangeTrackingDeferredExplicit();
}
return false;
} | [
"private",
"function",
"isDeferredExplicit",
"(",
"DoctrineObjectManager",
"$",
"manager",
",",
"$",
"data",
")",
":",
"bool",
"{",
"$",
"classMetadata",
"=",
"$",
"manager",
"->",
"getClassMetadata",
"(",
"$",
"this",
"->",
"getObjectClass",
"(",
"$",
"data",
")",
")",
";",
"if",
"(",
"$",
"classMetadata",
"instanceof",
"ClassMetadataInfo",
"&&",
"method_exists",
"(",
"$",
"classMetadata",
",",
"'isChangeTrackingDeferredExplicit'",
")",
")",
"{",
"return",
"$",
"classMetadata",
"->",
"isChangeTrackingDeferredExplicit",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
]
| Checks if doctrine does not manage data automatically. | [
"Checks",
"if",
"doctrine",
"does",
"not",
"manage",
"data",
"automatically",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Common/DataPersister.php#L89-L97 | train |
api-platform/core | src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php | PurgeHttpCacheListener.preUpdate | public function preUpdate(PreUpdateEventArgs $eventArgs): void
{
$object = $eventArgs->getObject();
$this->gatherResourceAndItemTags($object, true);
$changeSet = $eventArgs->getEntityChangeSet();
$associationMappings = $eventArgs->getEntityManager()->getClassMetadata(ClassUtils::getClass($eventArgs->getObject()))->getAssociationMappings();
foreach ($changeSet as $key => $value) {
if (!isset($associationMappings[$key])) {
continue;
}
$this->addTagsFor($value[0]);
$this->addTagsFor($value[1]);
}
} | php | public function preUpdate(PreUpdateEventArgs $eventArgs): void
{
$object = $eventArgs->getObject();
$this->gatherResourceAndItemTags($object, true);
$changeSet = $eventArgs->getEntityChangeSet();
$associationMappings = $eventArgs->getEntityManager()->getClassMetadata(ClassUtils::getClass($eventArgs->getObject()))->getAssociationMappings();
foreach ($changeSet as $key => $value) {
if (!isset($associationMappings[$key])) {
continue;
}
$this->addTagsFor($value[0]);
$this->addTagsFor($value[1]);
}
} | [
"public",
"function",
"preUpdate",
"(",
"PreUpdateEventArgs",
"$",
"eventArgs",
")",
":",
"void",
"{",
"$",
"object",
"=",
"$",
"eventArgs",
"->",
"getObject",
"(",
")",
";",
"$",
"this",
"->",
"gatherResourceAndItemTags",
"(",
"$",
"object",
",",
"true",
")",
";",
"$",
"changeSet",
"=",
"$",
"eventArgs",
"->",
"getEntityChangeSet",
"(",
")",
";",
"$",
"associationMappings",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
"->",
"getClassMetadata",
"(",
"ClassUtils",
"::",
"getClass",
"(",
"$",
"eventArgs",
"->",
"getObject",
"(",
")",
")",
")",
"->",
"getAssociationMappings",
"(",
")",
";",
"foreach",
"(",
"$",
"changeSet",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"associationMappings",
"[",
"$",
"key",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"addTagsFor",
"(",
"$",
"value",
"[",
"0",
"]",
")",
";",
"$",
"this",
"->",
"addTagsFor",
"(",
"$",
"value",
"[",
"1",
"]",
")",
";",
"}",
"}"
]
| Collects tags from the previous and the current version of the updated entities to purge related documents. | [
"Collects",
"tags",
"from",
"the",
"previous",
"and",
"the",
"current",
"version",
"of",
"the",
"updated",
"entities",
"to",
"purge",
"related",
"documents",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php#L55-L71 | train |
api-platform/core | src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php | PurgeHttpCacheListener.onFlush | public function onFlush(OnFlushEventArgs $eventArgs): void
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
$this->gatherResourceAndItemTags($entity, false);
$this->gatherRelationTags($em, $entity);
}
foreach ($uow->getScheduledEntityUpdates() as $entity) {
$this->gatherResourceAndItemTags($entity, true);
$this->gatherRelationTags($em, $entity);
}
foreach ($uow->getScheduledEntityDeletions() as $entity) {
$this->gatherResourceAndItemTags($entity, true);
$this->gatherRelationTags($em, $entity);
}
} | php | public function onFlush(OnFlushEventArgs $eventArgs): void
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
$this->gatherResourceAndItemTags($entity, false);
$this->gatherRelationTags($em, $entity);
}
foreach ($uow->getScheduledEntityUpdates() as $entity) {
$this->gatherResourceAndItemTags($entity, true);
$this->gatherRelationTags($em, $entity);
}
foreach ($uow->getScheduledEntityDeletions() as $entity) {
$this->gatherResourceAndItemTags($entity, true);
$this->gatherRelationTags($em, $entity);
}
} | [
"public",
"function",
"onFlush",
"(",
"OnFlushEventArgs",
"$",
"eventArgs",
")",
":",
"void",
"{",
"$",
"em",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"uow",
"=",
"$",
"em",
"->",
"getUnitOfWork",
"(",
")",
";",
"foreach",
"(",
"$",
"uow",
"->",
"getScheduledEntityInsertions",
"(",
")",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"gatherResourceAndItemTags",
"(",
"$",
"entity",
",",
"false",
")",
";",
"$",
"this",
"->",
"gatherRelationTags",
"(",
"$",
"em",
",",
"$",
"entity",
")",
";",
"}",
"foreach",
"(",
"$",
"uow",
"->",
"getScheduledEntityUpdates",
"(",
")",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"gatherResourceAndItemTags",
"(",
"$",
"entity",
",",
"true",
")",
";",
"$",
"this",
"->",
"gatherRelationTags",
"(",
"$",
"em",
",",
"$",
"entity",
")",
";",
"}",
"foreach",
"(",
"$",
"uow",
"->",
"getScheduledEntityDeletions",
"(",
")",
"as",
"$",
"entity",
")",
"{",
"$",
"this",
"->",
"gatherResourceAndItemTags",
"(",
"$",
"entity",
",",
"true",
")",
";",
"$",
"this",
"->",
"gatherRelationTags",
"(",
"$",
"em",
",",
"$",
"entity",
")",
";",
"}",
"}"
]
| Collects tags from inserted and deleted entities, including relations. | [
"Collects",
"tags",
"from",
"inserted",
"and",
"deleted",
"entities",
"including",
"relations",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php#L76-L95 | train |
api-platform/core | src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php | PurgeHttpCacheListener.postFlush | public function postFlush(): void
{
if (empty($this->tags)) {
return;
}
$this->purger->purge($this->tags);
$this->tags = [];
} | php | public function postFlush(): void
{
if (empty($this->tags)) {
return;
}
$this->purger->purge($this->tags);
$this->tags = [];
} | [
"public",
"function",
"postFlush",
"(",
")",
":",
"void",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"tags",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"purger",
"->",
"purge",
"(",
"$",
"this",
"->",
"tags",
")",
";",
"$",
"this",
"->",
"tags",
"=",
"[",
"]",
";",
"}"
]
| Purges tags collected during this request, and clears the tag list. | [
"Purges",
"tags",
"collected",
"during",
"this",
"request",
"and",
"clears",
"the",
"tag",
"list",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/EventListener/PurgeHttpCacheListener.php#L100-L108 | train |
api-platform/core | src/HttpCache/EventListener/AddTagsListener.php | AddTagsListener.onKernelResponse | public function onKernelResponse(FilterResponseEvent $event): void
{
$request = $event->getRequest();
$response = $event->getResponse();
if (
!$request->isMethodCacheable()
|| !$response->isCacheable()
|| (!$attributes = RequestAttributesExtractor::extractAttributes($request))
) {
return;
}
$resources = $request->attributes->get('_resources');
if (isset($attributes['collection_operation_name']) || ($attributes['subresource_context']['collection'] ?? false)) {
// Allows to purge collections
$iri = $this->iriConverter->getIriFromResourceClass($attributes['resource_class']);
$resources[$iri] = $iri;
}
if (!$resources) {
return;
}
$response->headers->set('Cache-Tags', implode(',', $resources));
} | php | public function onKernelResponse(FilterResponseEvent $event): void
{
$request = $event->getRequest();
$response = $event->getResponse();
if (
!$request->isMethodCacheable()
|| !$response->isCacheable()
|| (!$attributes = RequestAttributesExtractor::extractAttributes($request))
) {
return;
}
$resources = $request->attributes->get('_resources');
if (isset($attributes['collection_operation_name']) || ($attributes['subresource_context']['collection'] ?? false)) {
// Allows to purge collections
$iri = $this->iriConverter->getIriFromResourceClass($attributes['resource_class']);
$resources[$iri] = $iri;
}
if (!$resources) {
return;
}
$response->headers->set('Cache-Tags', implode(',', $resources));
} | [
"public",
"function",
"onKernelResponse",
"(",
"FilterResponseEvent",
"$",
"event",
")",
":",
"void",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"$",
"response",
"=",
"$",
"event",
"->",
"getResponse",
"(",
")",
";",
"if",
"(",
"!",
"$",
"request",
"->",
"isMethodCacheable",
"(",
")",
"||",
"!",
"$",
"response",
"->",
"isCacheable",
"(",
")",
"||",
"(",
"!",
"$",
"attributes",
"=",
"RequestAttributesExtractor",
"::",
"extractAttributes",
"(",
"$",
"request",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"resources",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_resources'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"'collection_operation_name'",
"]",
")",
"||",
"(",
"$",
"attributes",
"[",
"'subresource_context'",
"]",
"[",
"'collection'",
"]",
"??",
"false",
")",
")",
"{",
"// Allows to purge collections",
"$",
"iri",
"=",
"$",
"this",
"->",
"iriConverter",
"->",
"getIriFromResourceClass",
"(",
"$",
"attributes",
"[",
"'resource_class'",
"]",
")",
";",
"$",
"resources",
"[",
"$",
"iri",
"]",
"=",
"$",
"iri",
";",
"}",
"if",
"(",
"!",
"$",
"resources",
")",
"{",
"return",
";",
"}",
"$",
"response",
"->",
"headers",
"->",
"set",
"(",
"'Cache-Tags'",
",",
"implode",
"(",
"','",
",",
"$",
"resources",
")",
")",
";",
"}"
]
| Adds the "Cache-Tags" header. | [
"Adds",
"the",
"Cache",
"-",
"Tags",
"header",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/HttpCache/EventListener/AddTagsListener.php#L43-L68 | train |
api-platform/core | src/Bridge/Doctrine/MongoDbOdm/Filter/RangeFilter.php | RangeFilter.addMatch | protected function addMatch(Builder $aggregationBuilder, string $field, string $matchField, string $operator, string $value)
{
switch ($operator) {
case self::PARAMETER_BETWEEN:
$rangeValue = explode('..', $value);
$rangeValue = $this->normalizeBetweenValues($rangeValue);
if (null === $rangeValue) {
return;
}
$aggregationBuilder->match()->field($matchField)->gte($rangeValue[0])->lte($rangeValue[1]);
break;
case self::PARAMETER_GREATER_THAN:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->gt($value);
break;
case self::PARAMETER_GREATER_THAN_OR_EQUAL:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->gte($value);
break;
case self::PARAMETER_LESS_THAN:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->lt($value);
break;
case self::PARAMETER_LESS_THAN_OR_EQUAL:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->lte($value);
break;
}
} | php | protected function addMatch(Builder $aggregationBuilder, string $field, string $matchField, string $operator, string $value)
{
switch ($operator) {
case self::PARAMETER_BETWEEN:
$rangeValue = explode('..', $value);
$rangeValue = $this->normalizeBetweenValues($rangeValue);
if (null === $rangeValue) {
return;
}
$aggregationBuilder->match()->field($matchField)->gte($rangeValue[0])->lte($rangeValue[1]);
break;
case self::PARAMETER_GREATER_THAN:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->gt($value);
break;
case self::PARAMETER_GREATER_THAN_OR_EQUAL:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->gte($value);
break;
case self::PARAMETER_LESS_THAN:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->lt($value);
break;
case self::PARAMETER_LESS_THAN_OR_EQUAL:
$value = $this->normalizeValue($value, $operator);
if (null === $value) {
return;
}
$aggregationBuilder->match()->field($matchField)->lte($value);
break;
}
} | [
"protected",
"function",
"addMatch",
"(",
"Builder",
"$",
"aggregationBuilder",
",",
"string",
"$",
"field",
",",
"string",
"$",
"matchField",
",",
"string",
"$",
"operator",
",",
"string",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"operator",
")",
"{",
"case",
"self",
"::",
"PARAMETER_BETWEEN",
":",
"$",
"rangeValue",
"=",
"explode",
"(",
"'..'",
",",
"$",
"value",
")",
";",
"$",
"rangeValue",
"=",
"$",
"this",
"->",
"normalizeBetweenValues",
"(",
"$",
"rangeValue",
")",
";",
"if",
"(",
"null",
"===",
"$",
"rangeValue",
")",
"{",
"return",
";",
"}",
"$",
"aggregationBuilder",
"->",
"match",
"(",
")",
"->",
"field",
"(",
"$",
"matchField",
")",
"->",
"gte",
"(",
"$",
"rangeValue",
"[",
"0",
"]",
")",
"->",
"lte",
"(",
"$",
"rangeValue",
"[",
"1",
"]",
")",
";",
"break",
";",
"case",
"self",
"::",
"PARAMETER_GREATER_THAN",
":",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeValue",
"(",
"$",
"value",
",",
"$",
"operator",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
";",
"}",
"$",
"aggregationBuilder",
"->",
"match",
"(",
")",
"->",
"field",
"(",
"$",
"matchField",
")",
"->",
"gt",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"self",
"::",
"PARAMETER_GREATER_THAN_OR_EQUAL",
":",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeValue",
"(",
"$",
"value",
",",
"$",
"operator",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
";",
"}",
"$",
"aggregationBuilder",
"->",
"match",
"(",
")",
"->",
"field",
"(",
"$",
"matchField",
")",
"->",
"gte",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"self",
"::",
"PARAMETER_LESS_THAN",
":",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeValue",
"(",
"$",
"value",
",",
"$",
"operator",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
";",
"}",
"$",
"aggregationBuilder",
"->",
"match",
"(",
")",
"->",
"field",
"(",
"$",
"matchField",
")",
"->",
"lt",
"(",
"$",
"value",
")",
";",
"break",
";",
"case",
"self",
"::",
"PARAMETER_LESS_THAN_OR_EQUAL",
":",
"$",
"value",
"=",
"$",
"this",
"->",
"normalizeValue",
"(",
"$",
"value",
",",
"$",
"operator",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
";",
"}",
"$",
"aggregationBuilder",
"->",
"match",
"(",
")",
"->",
"field",
"(",
"$",
"matchField",
")",
"->",
"lte",
"(",
"$",
"value",
")",
";",
"break",
";",
"}",
"}"
]
| Adds the match stage according to the operator. | [
"Adds",
"the",
"match",
"stage",
"according",
"to",
"the",
"operator",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/MongoDbOdm/Filter/RangeFilter.php#L70-L121 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Filter/DateFilter.php | DateFilter.addWhere | protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, string $operator, string $value, string $nullManagement = null, $type = null)
{
$type = (string) $type;
try {
$value = false === strpos($type, '_immutable') ? new \DateTime($value) : new \DateTimeImmutable($value);
} catch (\Exception $e) {
// Silently ignore this filter if it can not be transformed to a \DateTime
$this->logger->notice('Invalid filter ignored', [
'exception' => new InvalidArgumentException(sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)),
]);
return;
}
$valueParameter = $queryNameGenerator->generateParameterName($field);
$operatorValue = [
self::PARAMETER_BEFORE => '<=',
self::PARAMETER_STRICTLY_BEFORE => '<',
self::PARAMETER_AFTER => '>=',
self::PARAMETER_STRICTLY_AFTER => '>',
];
$baseWhere = sprintf('%s.%s %s :%s', $alias, $field, $operatorValue[$operator], $valueParameter);
if (null === $nullManagement || self::EXCLUDE_NULL === $nullManagement) {
$queryBuilder->andWhere($baseWhere);
} elseif (
(self::INCLUDE_NULL_BEFORE === $nullManagement && \in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true)) ||
(self::INCLUDE_NULL_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true)) ||
(self::INCLUDE_NULL_BEFORE_AND_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER, self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true))
) {
$queryBuilder->andWhere($queryBuilder->expr()->orX(
$baseWhere,
$queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $field))
));
} else {
$queryBuilder->andWhere($queryBuilder->expr()->andX(
$baseWhere,
$queryBuilder->expr()->isNotNull(sprintf('%s.%s', $alias, $field))
));
}
$queryBuilder->setParameter($valueParameter, $value, $type);
} | php | protected function addWhere(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $field, string $operator, string $value, string $nullManagement = null, $type = null)
{
$type = (string) $type;
try {
$value = false === strpos($type, '_immutable') ? new \DateTime($value) : new \DateTimeImmutable($value);
} catch (\Exception $e) {
// Silently ignore this filter if it can not be transformed to a \DateTime
$this->logger->notice('Invalid filter ignored', [
'exception' => new InvalidArgumentException(sprintf('The field "%s" has a wrong date format. Use one accepted by the \DateTime constructor', $field)),
]);
return;
}
$valueParameter = $queryNameGenerator->generateParameterName($field);
$operatorValue = [
self::PARAMETER_BEFORE => '<=',
self::PARAMETER_STRICTLY_BEFORE => '<',
self::PARAMETER_AFTER => '>=',
self::PARAMETER_STRICTLY_AFTER => '>',
];
$baseWhere = sprintf('%s.%s %s :%s', $alias, $field, $operatorValue[$operator], $valueParameter);
if (null === $nullManagement || self::EXCLUDE_NULL === $nullManagement) {
$queryBuilder->andWhere($baseWhere);
} elseif (
(self::INCLUDE_NULL_BEFORE === $nullManagement && \in_array($operator, [self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true)) ||
(self::INCLUDE_NULL_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER], true)) ||
(self::INCLUDE_NULL_BEFORE_AND_AFTER === $nullManagement && \in_array($operator, [self::PARAMETER_AFTER, self::PARAMETER_STRICTLY_AFTER, self::PARAMETER_BEFORE, self::PARAMETER_STRICTLY_BEFORE], true))
) {
$queryBuilder->andWhere($queryBuilder->expr()->orX(
$baseWhere,
$queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $field))
));
} else {
$queryBuilder->andWhere($queryBuilder->expr()->andX(
$baseWhere,
$queryBuilder->expr()->isNotNull(sprintf('%s.%s', $alias, $field))
));
}
$queryBuilder->setParameter($valueParameter, $value, $type);
} | [
"protected",
"function",
"addWhere",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"QueryNameGeneratorInterface",
"$",
"queryNameGenerator",
",",
"string",
"$",
"alias",
",",
"string",
"$",
"field",
",",
"string",
"$",
"operator",
",",
"string",
"$",
"value",
",",
"string",
"$",
"nullManagement",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"(",
"string",
")",
"$",
"type",
";",
"try",
"{",
"$",
"value",
"=",
"false",
"===",
"strpos",
"(",
"$",
"type",
",",
"'_immutable'",
")",
"?",
"new",
"\\",
"DateTime",
"(",
"$",
"value",
")",
":",
"new",
"\\",
"DateTimeImmutable",
"(",
"$",
"value",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// Silently ignore this filter if it can not be transformed to a \\DateTime",
"$",
"this",
"->",
"logger",
"->",
"notice",
"(",
"'Invalid filter ignored'",
",",
"[",
"'exception'",
"=>",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The field \"%s\" has a wrong date format. Use one accepted by the \\DateTime constructor'",
",",
"$",
"field",
")",
")",
",",
"]",
")",
";",
"return",
";",
"}",
"$",
"valueParameter",
"=",
"$",
"queryNameGenerator",
"->",
"generateParameterName",
"(",
"$",
"field",
")",
";",
"$",
"operatorValue",
"=",
"[",
"self",
"::",
"PARAMETER_BEFORE",
"=>",
"'<='",
",",
"self",
"::",
"PARAMETER_STRICTLY_BEFORE",
"=>",
"'<'",
",",
"self",
"::",
"PARAMETER_AFTER",
"=>",
"'>='",
",",
"self",
"::",
"PARAMETER_STRICTLY_AFTER",
"=>",
"'>'",
",",
"]",
";",
"$",
"baseWhere",
"=",
"sprintf",
"(",
"'%s.%s %s :%s'",
",",
"$",
"alias",
",",
"$",
"field",
",",
"$",
"operatorValue",
"[",
"$",
"operator",
"]",
",",
"$",
"valueParameter",
")",
";",
"if",
"(",
"null",
"===",
"$",
"nullManagement",
"||",
"self",
"::",
"EXCLUDE_NULL",
"===",
"$",
"nullManagement",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"baseWhere",
")",
";",
"}",
"elseif",
"(",
"(",
"self",
"::",
"INCLUDE_NULL_BEFORE",
"===",
"$",
"nullManagement",
"&&",
"\\",
"in_array",
"(",
"$",
"operator",
",",
"[",
"self",
"::",
"PARAMETER_BEFORE",
",",
"self",
"::",
"PARAMETER_STRICTLY_BEFORE",
"]",
",",
"true",
")",
")",
"||",
"(",
"self",
"::",
"INCLUDE_NULL_AFTER",
"===",
"$",
"nullManagement",
"&&",
"\\",
"in_array",
"(",
"$",
"operator",
",",
"[",
"self",
"::",
"PARAMETER_AFTER",
",",
"self",
"::",
"PARAMETER_STRICTLY_AFTER",
"]",
",",
"true",
")",
")",
"||",
"(",
"self",
"::",
"INCLUDE_NULL_BEFORE_AND_AFTER",
"===",
"$",
"nullManagement",
"&&",
"\\",
"in_array",
"(",
"$",
"operator",
",",
"[",
"self",
"::",
"PARAMETER_AFTER",
",",
"self",
"::",
"PARAMETER_STRICTLY_AFTER",
",",
"self",
"::",
"PARAMETER_BEFORE",
",",
"self",
"::",
"PARAMETER_STRICTLY_BEFORE",
"]",
",",
"true",
")",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
"$",
"baseWhere",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"isNull",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"field",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
"$",
"baseWhere",
",",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"isNotNull",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"field",
")",
")",
")",
")",
";",
"}",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"$",
"valueParameter",
",",
"$",
"value",
",",
"$",
"type",
")",
";",
"}"
]
| Adds the where clause according to the chosen null management.
@param string|DBALType $type | [
"Adds",
"the",
"where",
"clause",
"according",
"to",
"the",
"chosen",
"null",
"management",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Filter/DateFilter.php#L131-L173 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.addJoinOnce | public static function addJoinOnce(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $association, string $joinType = null, string $conditionType = null, string $condition = null, string $originAlias = null): string
{
$join = self::getExistingJoin($queryBuilder, $alias, $association, $originAlias);
if (null !== $join) {
return $join->getAlias();
}
$associationAlias = $queryNameGenerator->generateJoinAlias($association);
$query = "$alias.$association";
if (Join::LEFT_JOIN === $joinType || QueryChecker::hasLeftJoin($queryBuilder)) {
$queryBuilder->leftJoin($query, $associationAlias, $conditionType, $condition);
} else {
$queryBuilder->innerJoin($query, $associationAlias, $conditionType, $condition);
}
return $associationAlias;
} | php | public static function addJoinOnce(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $alias, string $association, string $joinType = null, string $conditionType = null, string $condition = null, string $originAlias = null): string
{
$join = self::getExistingJoin($queryBuilder, $alias, $association, $originAlias);
if (null !== $join) {
return $join->getAlias();
}
$associationAlias = $queryNameGenerator->generateJoinAlias($association);
$query = "$alias.$association";
if (Join::LEFT_JOIN === $joinType || QueryChecker::hasLeftJoin($queryBuilder)) {
$queryBuilder->leftJoin($query, $associationAlias, $conditionType, $condition);
} else {
$queryBuilder->innerJoin($query, $associationAlias, $conditionType, $condition);
}
return $associationAlias;
} | [
"public",
"static",
"function",
"addJoinOnce",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"QueryNameGeneratorInterface",
"$",
"queryNameGenerator",
",",
"string",
"$",
"alias",
",",
"string",
"$",
"association",
",",
"string",
"$",
"joinType",
"=",
"null",
",",
"string",
"$",
"conditionType",
"=",
"null",
",",
"string",
"$",
"condition",
"=",
"null",
",",
"string",
"$",
"originAlias",
"=",
"null",
")",
":",
"string",
"{",
"$",
"join",
"=",
"self",
"::",
"getExistingJoin",
"(",
"$",
"queryBuilder",
",",
"$",
"alias",
",",
"$",
"association",
",",
"$",
"originAlias",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"join",
")",
"{",
"return",
"$",
"join",
"->",
"getAlias",
"(",
")",
";",
"}",
"$",
"associationAlias",
"=",
"$",
"queryNameGenerator",
"->",
"generateJoinAlias",
"(",
"$",
"association",
")",
";",
"$",
"query",
"=",
"\"$alias.$association\"",
";",
"if",
"(",
"Join",
"::",
"LEFT_JOIN",
"===",
"$",
"joinType",
"||",
"QueryChecker",
"::",
"hasLeftJoin",
"(",
"$",
"queryBuilder",
")",
")",
"{",
"$",
"queryBuilder",
"->",
"leftJoin",
"(",
"$",
"query",
",",
"$",
"associationAlias",
",",
"$",
"conditionType",
",",
"$",
"condition",
")",
";",
"}",
"else",
"{",
"$",
"queryBuilder",
"->",
"innerJoin",
"(",
"$",
"query",
",",
"$",
"associationAlias",
",",
"$",
"conditionType",
",",
"$",
"condition",
")",
";",
"}",
"return",
"$",
"associationAlias",
";",
"}"
]
| Adds a join to the QueryBuilder if none exists. | [
"Adds",
"a",
"join",
"to",
"the",
"QueryBuilder",
"if",
"none",
"exists",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L34-L52 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.getEntityClassByAlias | public static function getEntityClassByAlias(string $alias, QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): string
{
if (!\in_array($alias, $queryBuilder->getAllAliases(), true)) {
throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
}
$rootAliasMap = self::mapRootAliases($queryBuilder->getRootAliases(), $queryBuilder->getRootEntities());
if (isset($rootAliasMap[$alias])) {
return $rootAliasMap[$alias];
}
$metadata = null;
foreach (self::traverseJoins($alias, $queryBuilder, $managerRegistry) as [$currentMetadata]) {
$metadata = $currentMetadata;
}
if (null === $metadata) {
throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
}
return $metadata->getName();
} | php | public static function getEntityClassByAlias(string $alias, QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): string
{
if (!\in_array($alias, $queryBuilder->getAllAliases(), true)) {
throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
}
$rootAliasMap = self::mapRootAliases($queryBuilder->getRootAliases(), $queryBuilder->getRootEntities());
if (isset($rootAliasMap[$alias])) {
return $rootAliasMap[$alias];
}
$metadata = null;
foreach (self::traverseJoins($alias, $queryBuilder, $managerRegistry) as [$currentMetadata]) {
$metadata = $currentMetadata;
}
if (null === $metadata) {
throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
}
return $metadata->getName();
} | [
"public",
"static",
"function",
"getEntityClassByAlias",
"(",
"string",
"$",
"alias",
",",
"QueryBuilder",
"$",
"queryBuilder",
",",
"ManagerRegistry",
"$",
"managerRegistry",
")",
":",
"string",
"{",
"if",
"(",
"!",
"\\",
"in_array",
"(",
"$",
"alias",
",",
"$",
"queryBuilder",
"->",
"getAllAliases",
"(",
")",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The alias \"%s\" does not exist in the QueryBuilder.'",
",",
"$",
"alias",
")",
")",
";",
"}",
"$",
"rootAliasMap",
"=",
"self",
"::",
"mapRootAliases",
"(",
"$",
"queryBuilder",
"->",
"getRootAliases",
"(",
")",
",",
"$",
"queryBuilder",
"->",
"getRootEntities",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"rootAliasMap",
"[",
"$",
"alias",
"]",
")",
")",
"{",
"return",
"$",
"rootAliasMap",
"[",
"$",
"alias",
"]",
";",
"}",
"$",
"metadata",
"=",
"null",
";",
"foreach",
"(",
"self",
"::",
"traverseJoins",
"(",
"$",
"alias",
",",
"$",
"queryBuilder",
",",
"$",
"managerRegistry",
")",
"as",
"[",
"$",
"currentMetadata",
"]",
")",
"{",
"$",
"metadata",
"=",
"$",
"currentMetadata",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"metadata",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The alias \"%s\" does not exist in the QueryBuilder.'",
",",
"$",
"alias",
")",
")",
";",
"}",
"return",
"$",
"metadata",
"->",
"getName",
"(",
")",
";",
"}"
]
| Gets the entity class name by an alias used in the QueryBuilder. | [
"Gets",
"the",
"entity",
"class",
"name",
"by",
"an",
"alias",
"used",
"in",
"the",
"QueryBuilder",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L57-L80 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.findRootAlias | public static function findRootAlias(string $alias, QueryBuilder $queryBuilder): string
{
if (\in_array($alias, $queryBuilder->getRootAliases(), true)) {
return $alias;
}
foreach ($queryBuilder->getDQLPart('join') as $rootAlias => $joins) {
foreach ($joins as $join) {
if ($alias === $join->getAlias()) {
return $rootAlias;
}
}
}
throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
} | php | public static function findRootAlias(string $alias, QueryBuilder $queryBuilder): string
{
if (\in_array($alias, $queryBuilder->getRootAliases(), true)) {
return $alias;
}
foreach ($queryBuilder->getDQLPart('join') as $rootAlias => $joins) {
foreach ($joins as $join) {
if ($alias === $join->getAlias()) {
return $rootAlias;
}
}
}
throw new \LogicException(sprintf('The alias "%s" does not exist in the QueryBuilder.', $alias));
} | [
"public",
"static",
"function",
"findRootAlias",
"(",
"string",
"$",
"alias",
",",
"QueryBuilder",
"$",
"queryBuilder",
")",
":",
"string",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"alias",
",",
"$",
"queryBuilder",
"->",
"getRootAliases",
"(",
")",
",",
"true",
")",
")",
"{",
"return",
"$",
"alias",
";",
"}",
"foreach",
"(",
"$",
"queryBuilder",
"->",
"getDQLPart",
"(",
"'join'",
")",
"as",
"$",
"rootAlias",
"=>",
"$",
"joins",
")",
"{",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"join",
")",
"{",
"if",
"(",
"$",
"alias",
"===",
"$",
"join",
"->",
"getAlias",
"(",
")",
")",
"{",
"return",
"$",
"rootAlias",
";",
"}",
"}",
"}",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The alias \"%s\" does not exist in the QueryBuilder.'",
",",
"$",
"alias",
")",
")",
";",
"}"
]
| Finds the root alias for an alias used in the QueryBuilder. | [
"Finds",
"the",
"root",
"alias",
"for",
"an",
"alias",
"used",
"in",
"the",
"QueryBuilder",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L85-L100 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.traverseJoins | public static function traverseJoins(string $alias, QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): \Generator
{
$rootAliasMap = self::mapRootAliases($queryBuilder->getRootAliases(), $queryBuilder->getRootEntities());
$joinParts = $queryBuilder->getDQLPart('join');
$rootAlias = self::findRootAlias($alias, $queryBuilder);
$joinAliasMap = self::mapJoinAliases($joinParts[$rootAlias]);
$aliasMap = array_merge($rootAliasMap, $joinAliasMap);
$apexEntityClass = null;
$associationStack = [];
$aliasStack = [];
$currentAlias = $alias;
while (null === $apexEntityClass) {
if (!isset($aliasMap[$currentAlias])) {
throw new \LogicException(sprintf('Unknown alias "%s".', $currentAlias));
}
if (\is_string($aliasMap[$currentAlias])) {
$aliasStack[] = $currentAlias;
$apexEntityClass = $aliasMap[$currentAlias];
} else {
[$parentAlias, $association] = $aliasMap[$currentAlias];
$associationStack[] = $association;
$aliasStack[] = $currentAlias;
$currentAlias = $parentAlias;
}
}
$entityClass = $apexEntityClass;
while (null !== ($alias = array_pop($aliasStack))) {
$metadata = $managerRegistry
->getManagerForClass($entityClass)
->getClassMetadata($entityClass);
$association = array_pop($associationStack);
yield $alias => [
$metadata,
$association,
];
if (null !== $association) {
$entityClass = $metadata->getAssociationTargetClass($association);
}
}
} | php | public static function traverseJoins(string $alias, QueryBuilder $queryBuilder, ManagerRegistry $managerRegistry): \Generator
{
$rootAliasMap = self::mapRootAliases($queryBuilder->getRootAliases(), $queryBuilder->getRootEntities());
$joinParts = $queryBuilder->getDQLPart('join');
$rootAlias = self::findRootAlias($alias, $queryBuilder);
$joinAliasMap = self::mapJoinAliases($joinParts[$rootAlias]);
$aliasMap = array_merge($rootAliasMap, $joinAliasMap);
$apexEntityClass = null;
$associationStack = [];
$aliasStack = [];
$currentAlias = $alias;
while (null === $apexEntityClass) {
if (!isset($aliasMap[$currentAlias])) {
throw new \LogicException(sprintf('Unknown alias "%s".', $currentAlias));
}
if (\is_string($aliasMap[$currentAlias])) {
$aliasStack[] = $currentAlias;
$apexEntityClass = $aliasMap[$currentAlias];
} else {
[$parentAlias, $association] = $aliasMap[$currentAlias];
$associationStack[] = $association;
$aliasStack[] = $currentAlias;
$currentAlias = $parentAlias;
}
}
$entityClass = $apexEntityClass;
while (null !== ($alias = array_pop($aliasStack))) {
$metadata = $managerRegistry
->getManagerForClass($entityClass)
->getClassMetadata($entityClass);
$association = array_pop($associationStack);
yield $alias => [
$metadata,
$association,
];
if (null !== $association) {
$entityClass = $metadata->getAssociationTargetClass($association);
}
}
} | [
"public",
"static",
"function",
"traverseJoins",
"(",
"string",
"$",
"alias",
",",
"QueryBuilder",
"$",
"queryBuilder",
",",
"ManagerRegistry",
"$",
"managerRegistry",
")",
":",
"\\",
"Generator",
"{",
"$",
"rootAliasMap",
"=",
"self",
"::",
"mapRootAliases",
"(",
"$",
"queryBuilder",
"->",
"getRootAliases",
"(",
")",
",",
"$",
"queryBuilder",
"->",
"getRootEntities",
"(",
")",
")",
";",
"$",
"joinParts",
"=",
"$",
"queryBuilder",
"->",
"getDQLPart",
"(",
"'join'",
")",
";",
"$",
"rootAlias",
"=",
"self",
"::",
"findRootAlias",
"(",
"$",
"alias",
",",
"$",
"queryBuilder",
")",
";",
"$",
"joinAliasMap",
"=",
"self",
"::",
"mapJoinAliases",
"(",
"$",
"joinParts",
"[",
"$",
"rootAlias",
"]",
")",
";",
"$",
"aliasMap",
"=",
"array_merge",
"(",
"$",
"rootAliasMap",
",",
"$",
"joinAliasMap",
")",
";",
"$",
"apexEntityClass",
"=",
"null",
";",
"$",
"associationStack",
"=",
"[",
"]",
";",
"$",
"aliasStack",
"=",
"[",
"]",
";",
"$",
"currentAlias",
"=",
"$",
"alias",
";",
"while",
"(",
"null",
"===",
"$",
"apexEntityClass",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"aliasMap",
"[",
"$",
"currentAlias",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'Unknown alias \"%s\".'",
",",
"$",
"currentAlias",
")",
")",
";",
"}",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"aliasMap",
"[",
"$",
"currentAlias",
"]",
")",
")",
"{",
"$",
"aliasStack",
"[",
"]",
"=",
"$",
"currentAlias",
";",
"$",
"apexEntityClass",
"=",
"$",
"aliasMap",
"[",
"$",
"currentAlias",
"]",
";",
"}",
"else",
"{",
"[",
"$",
"parentAlias",
",",
"$",
"association",
"]",
"=",
"$",
"aliasMap",
"[",
"$",
"currentAlias",
"]",
";",
"$",
"associationStack",
"[",
"]",
"=",
"$",
"association",
";",
"$",
"aliasStack",
"[",
"]",
"=",
"$",
"currentAlias",
";",
"$",
"currentAlias",
"=",
"$",
"parentAlias",
";",
"}",
"}",
"$",
"entityClass",
"=",
"$",
"apexEntityClass",
";",
"while",
"(",
"null",
"!==",
"(",
"$",
"alias",
"=",
"array_pop",
"(",
"$",
"aliasStack",
")",
")",
")",
"{",
"$",
"metadata",
"=",
"$",
"managerRegistry",
"->",
"getManagerForClass",
"(",
"$",
"entityClass",
")",
"->",
"getClassMetadata",
"(",
"$",
"entityClass",
")",
";",
"$",
"association",
"=",
"array_pop",
"(",
"$",
"associationStack",
")",
";",
"yield",
"$",
"alias",
"=>",
"[",
"$",
"metadata",
",",
"$",
"association",
",",
"]",
";",
"if",
"(",
"null",
"!==",
"$",
"association",
")",
"{",
"$",
"entityClass",
"=",
"$",
"metadata",
"->",
"getAssociationTargetClass",
"(",
"$",
"association",
")",
";",
"}",
"}",
"}"
]
| Traverses through the joins for an alias used in the QueryBuilder.
@return \Generator<string, array> | [
"Traverses",
"through",
"the",
"joins",
"for",
"an",
"alias",
"used",
"in",
"the",
"QueryBuilder",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L107-L158 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.getExistingJoin | private static function getExistingJoin(QueryBuilder $queryBuilder, string $alias, string $association, string $originAlias = null): ?Join
{
$parts = $queryBuilder->getDQLPart('join');
$rootAlias = $originAlias ?? $queryBuilder->getRootAliases()[0];
if (!isset($parts[$rootAlias])) {
return null;
}
foreach ($parts[$rootAlias] as $join) {
/** @var Join $join */
if (sprintf('%s.%s', $alias, $association) === $join->getJoin()) {
return $join;
}
}
return null;
} | php | private static function getExistingJoin(QueryBuilder $queryBuilder, string $alias, string $association, string $originAlias = null): ?Join
{
$parts = $queryBuilder->getDQLPart('join');
$rootAlias = $originAlias ?? $queryBuilder->getRootAliases()[0];
if (!isset($parts[$rootAlias])) {
return null;
}
foreach ($parts[$rootAlias] as $join) {
/** @var Join $join */
if (sprintf('%s.%s', $alias, $association) === $join->getJoin()) {
return $join;
}
}
return null;
} | [
"private",
"static",
"function",
"getExistingJoin",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"string",
"$",
"alias",
",",
"string",
"$",
"association",
",",
"string",
"$",
"originAlias",
"=",
"null",
")",
":",
"?",
"Join",
"{",
"$",
"parts",
"=",
"$",
"queryBuilder",
"->",
"getDQLPart",
"(",
"'join'",
")",
";",
"$",
"rootAlias",
"=",
"$",
"originAlias",
"??",
"$",
"queryBuilder",
"->",
"getRootAliases",
"(",
")",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"parts",
"[",
"$",
"rootAlias",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"parts",
"[",
"$",
"rootAlias",
"]",
"as",
"$",
"join",
")",
"{",
"/** @var Join $join */",
"if",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"association",
")",
"===",
"$",
"join",
"->",
"getJoin",
"(",
")",
")",
"{",
"return",
"$",
"join",
";",
"}",
"}",
"return",
"null",
";",
"}"
]
| Gets the existing join from QueryBuilder DQL parts. | [
"Gets",
"the",
"existing",
"join",
"from",
"QueryBuilder",
"DQL",
"parts",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L163-L180 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.mapRootAliases | private static function mapRootAliases(array $rootAliases, array $rootEntities): array
{
$aliasMap = array_combine($rootAliases, $rootEntities);
if (false === $aliasMap) {
throw new \LogicException('Number of root aliases and root entities do not match.');
}
return $aliasMap;
} | php | private static function mapRootAliases(array $rootAliases, array $rootEntities): array
{
$aliasMap = array_combine($rootAliases, $rootEntities);
if (false === $aliasMap) {
throw new \LogicException('Number of root aliases and root entities do not match.');
}
return $aliasMap;
} | [
"private",
"static",
"function",
"mapRootAliases",
"(",
"array",
"$",
"rootAliases",
",",
"array",
"$",
"rootEntities",
")",
":",
"array",
"{",
"$",
"aliasMap",
"=",
"array_combine",
"(",
"$",
"rootAliases",
",",
"$",
"rootEntities",
")",
";",
"if",
"(",
"false",
"===",
"$",
"aliasMap",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"'Number of root aliases and root entities do not match.'",
")",
";",
"}",
"return",
"$",
"aliasMap",
";",
"}"
]
| Maps the root aliases to root entity classes.
@return array<string, string> | [
"Maps",
"the",
"root",
"aliases",
"to",
"root",
"entity",
"classes",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L187-L195 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php | QueryBuilderHelper.mapJoinAliases | private static function mapJoinAliases(iterable $joins): array
{
$aliasMap = [];
foreach ($joins as $join) {
$alias = $join->getAlias();
$relationship = $join->getJoin();
if (false !== strpos($relationship, '.')) {
$aliasMap[$alias] = explode('.', $relationship);
} else {
$aliasMap[$alias] = $relationship;
}
}
return $aliasMap;
} | php | private static function mapJoinAliases(iterable $joins): array
{
$aliasMap = [];
foreach ($joins as $join) {
$alias = $join->getAlias();
$relationship = $join->getJoin();
if (false !== strpos($relationship, '.')) {
$aliasMap[$alias] = explode('.', $relationship);
} else {
$aliasMap[$alias] = $relationship;
}
}
return $aliasMap;
} | [
"private",
"static",
"function",
"mapJoinAliases",
"(",
"iterable",
"$",
"joins",
")",
":",
"array",
"{",
"$",
"aliasMap",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"join",
")",
"{",
"$",
"alias",
"=",
"$",
"join",
"->",
"getAlias",
"(",
")",
";",
"$",
"relationship",
"=",
"$",
"join",
"->",
"getJoin",
"(",
")",
";",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"relationship",
",",
"'.'",
")",
")",
"{",
"$",
"aliasMap",
"[",
"$",
"alias",
"]",
"=",
"explode",
"(",
"'.'",
",",
"$",
"relationship",
")",
";",
"}",
"else",
"{",
"$",
"aliasMap",
"[",
"$",
"alias",
"]",
"=",
"$",
"relationship",
";",
"}",
"}",
"return",
"$",
"aliasMap",
";",
"}"
]
| Maps the join aliases to the parent alias and association, or the entity class.
@return array<string, string[]|string> | [
"Maps",
"the",
"join",
"aliases",
"to",
"the",
"parent",
"alias",
"and",
"association",
"or",
"the",
"entity",
"class",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/QueryBuilderHelper.php#L202-L218 | train |
api-platform/core | src/Api/FormatsProvider.php | FormatsProvider.getOperationFormats | private function getOperationFormats(array $annotationFormats): array
{
$resourceFormats = [];
foreach ($annotationFormats as $format => $value) {
if (!is_numeric($format)) {
$resourceFormats[$format] = (array) $value;
continue;
}
if (!\is_string($value)) {
throw new InvalidArgumentException(sprintf("The 'formats' attributes value must be a string when trying to include an already configured format, %s given.", \gettype($value)));
}
if (\array_key_exists($value, $this->configuredFormats)) {
$resourceFormats[$value] = $this->configuredFormats[$value];
continue;
}
throw new InvalidArgumentException(sprintf("You either need to add the format '%s' to your project configuration or declare a mime type for it in your annotation.", $value));
}
return $resourceFormats;
} | php | private function getOperationFormats(array $annotationFormats): array
{
$resourceFormats = [];
foreach ($annotationFormats as $format => $value) {
if (!is_numeric($format)) {
$resourceFormats[$format] = (array) $value;
continue;
}
if (!\is_string($value)) {
throw new InvalidArgumentException(sprintf("The 'formats' attributes value must be a string when trying to include an already configured format, %s given.", \gettype($value)));
}
if (\array_key_exists($value, $this->configuredFormats)) {
$resourceFormats[$value] = $this->configuredFormats[$value];
continue;
}
throw new InvalidArgumentException(sprintf("You either need to add the format '%s' to your project configuration or declare a mime type for it in your annotation.", $value));
}
return $resourceFormats;
} | [
"private",
"function",
"getOperationFormats",
"(",
"array",
"$",
"annotationFormats",
")",
":",
"array",
"{",
"$",
"resourceFormats",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"annotationFormats",
"as",
"$",
"format",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"format",
")",
")",
"{",
"$",
"resourceFormats",
"[",
"$",
"format",
"]",
"=",
"(",
"array",
")",
"$",
"value",
";",
"continue",
";",
"}",
"if",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"The 'formats' attributes value must be a string when trying to include an already configured format, %s given.\"",
",",
"\\",
"gettype",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"if",
"(",
"\\",
"array_key_exists",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"configuredFormats",
")",
")",
"{",
"$",
"resourceFormats",
"[",
"$",
"value",
"]",
"=",
"$",
"this",
"->",
"configuredFormats",
"[",
"$",
"value",
"]",
";",
"continue",
";",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"You either need to add the format '%s' to your project configuration or declare a mime type for it in your annotation.\"",
",",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"resourceFormats",
";",
"}"
]
| Filter and populate the acceptable formats.
@throws InvalidArgumentException | [
"Filter",
"and",
"populate",
"the",
"acceptable",
"formats",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Api/FormatsProvider.php#L84-L104 | train |
api-platform/core | src/Bridge/Elasticsearch/Util/FieldDatatypeTrait.php | FieldDatatypeTrait.isNestedField | private function isNestedField(string $resourceClass, string $property): bool
{
return null !== $this->getNestedFieldPath($resourceClass, $property);
} | php | private function isNestedField(string $resourceClass, string $property): bool
{
return null !== $this->getNestedFieldPath($resourceClass, $property);
} | [
"private",
"function",
"isNestedField",
"(",
"string",
"$",
"resourceClass",
",",
"string",
"$",
"property",
")",
":",
"bool",
"{",
"return",
"null",
"!==",
"$",
"this",
"->",
"getNestedFieldPath",
"(",
"$",
"resourceClass",
",",
"$",
"property",
")",
";",
"}"
]
| Is the decomposed given property of the given resource class potentially mapped as a nested field in Elasticsearch? | [
"Is",
"the",
"decomposed",
"given",
"property",
"of",
"the",
"given",
"resource",
"class",
"potentially",
"mapped",
"as",
"a",
"nested",
"field",
"in",
"Elasticsearch?"
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Elasticsearch/Util/FieldDatatypeTrait.php#L45-L48 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php | EagerLoadingTrait.shouldOperationForceEager | private function shouldOperationForceEager(string $resourceClass, array $options): bool
{
return $this->getBooleanOperationAttribute($resourceClass, $options, 'force_eager', $this->forceEager);
} | php | private function shouldOperationForceEager(string $resourceClass, array $options): bool
{
return $this->getBooleanOperationAttribute($resourceClass, $options, 'force_eager', $this->forceEager);
} | [
"private",
"function",
"shouldOperationForceEager",
"(",
"string",
"$",
"resourceClass",
",",
"array",
"$",
"options",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getBooleanOperationAttribute",
"(",
"$",
"resourceClass",
",",
"$",
"options",
",",
"'force_eager'",
",",
"$",
"this",
"->",
"forceEager",
")",
";",
"}"
]
| Checks if an operation has a `force_eager` attribute. | [
"Checks",
"if",
"an",
"operation",
"has",
"a",
"force_eager",
"attribute",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php#L33-L36 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php | EagerLoadingTrait.shouldOperationFetchPartial | private function shouldOperationFetchPartial(string $resourceClass, array $options): bool
{
return $this->getBooleanOperationAttribute($resourceClass, $options, 'fetch_partial', $this->fetchPartial);
} | php | private function shouldOperationFetchPartial(string $resourceClass, array $options): bool
{
return $this->getBooleanOperationAttribute($resourceClass, $options, 'fetch_partial', $this->fetchPartial);
} | [
"private",
"function",
"shouldOperationFetchPartial",
"(",
"string",
"$",
"resourceClass",
",",
"array",
"$",
"options",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getBooleanOperationAttribute",
"(",
"$",
"resourceClass",
",",
"$",
"options",
",",
"'fetch_partial'",
",",
"$",
"this",
"->",
"fetchPartial",
")",
";",
"}"
]
| Checks if an operation has a `fetch_partial` attribute. | [
"Checks",
"if",
"an",
"operation",
"has",
"a",
"fetch_partial",
"attribute",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php#L41-L44 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php | EagerLoadingTrait.getBooleanOperationAttribute | private function getBooleanOperationAttribute(string $resourceClass, array $options, string $attributeName, bool $default): bool
{
$resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
if (isset($options['collection_operation_name'])) {
$attribute = $resourceMetadata->getCollectionOperationAttribute($options['collection_operation_name'], $attributeName, null, true);
} elseif (isset($options['item_operation_name'])) {
$attribute = $resourceMetadata->getItemOperationAttribute($options['item_operation_name'], $attributeName, null, true);
} else {
$attribute = $resourceMetadata->getAttribute($attributeName);
}
return \is_bool($attribute) ? $attribute : $default;
} | php | private function getBooleanOperationAttribute(string $resourceClass, array $options, string $attributeName, bool $default): bool
{
$resourceMetadata = $this->resourceMetadataFactory->create($resourceClass);
if (isset($options['collection_operation_name'])) {
$attribute = $resourceMetadata->getCollectionOperationAttribute($options['collection_operation_name'], $attributeName, null, true);
} elseif (isset($options['item_operation_name'])) {
$attribute = $resourceMetadata->getItemOperationAttribute($options['item_operation_name'], $attributeName, null, true);
} else {
$attribute = $resourceMetadata->getAttribute($attributeName);
}
return \is_bool($attribute) ? $attribute : $default;
} | [
"private",
"function",
"getBooleanOperationAttribute",
"(",
"string",
"$",
"resourceClass",
",",
"array",
"$",
"options",
",",
"string",
"$",
"attributeName",
",",
"bool",
"$",
"default",
")",
":",
"bool",
"{",
"$",
"resourceMetadata",
"=",
"$",
"this",
"->",
"resourceMetadataFactory",
"->",
"create",
"(",
"$",
"resourceClass",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'collection_operation_name'",
"]",
")",
")",
"{",
"$",
"attribute",
"=",
"$",
"resourceMetadata",
"->",
"getCollectionOperationAttribute",
"(",
"$",
"options",
"[",
"'collection_operation_name'",
"]",
",",
"$",
"attributeName",
",",
"null",
",",
"true",
")",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"options",
"[",
"'item_operation_name'",
"]",
")",
")",
"{",
"$",
"attribute",
"=",
"$",
"resourceMetadata",
"->",
"getItemOperationAttribute",
"(",
"$",
"options",
"[",
"'item_operation_name'",
"]",
",",
"$",
"attributeName",
",",
"null",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"attribute",
"=",
"$",
"resourceMetadata",
"->",
"getAttribute",
"(",
"$",
"attributeName",
")",
";",
"}",
"return",
"\\",
"is_bool",
"(",
"$",
"attribute",
")",
"?",
"$",
"attribute",
":",
"$",
"default",
";",
"}"
]
| Get the boolean attribute of an operation or the resource metadata. | [
"Get",
"the",
"boolean",
"attribute",
"of",
"an",
"operation",
"or",
"the",
"resource",
"metadata",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php#L49-L62 | train |
api-platform/core | src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php | EagerLoadingTrait.hasFetchEagerAssociation | private function hasFetchEagerAssociation(EntityManager $em, ClassMetadataInfo $classMetadata, array &$checked = []): bool
{
$checked[] = $classMetadata->name;
foreach ($classMetadata->getAssociationMappings() as $mapping) {
if (ClassMetadataInfo::FETCH_EAGER === $mapping['fetch']) {
return true;
}
$related = $em->getClassMetadata($mapping['targetEntity']);
if (\in_array($related->name, $checked, true)) {
continue;
}
if (true === $this->hasFetchEagerAssociation($em, $related, $checked)) {
return true;
}
}
return false;
} | php | private function hasFetchEagerAssociation(EntityManager $em, ClassMetadataInfo $classMetadata, array &$checked = []): bool
{
$checked[] = $classMetadata->name;
foreach ($classMetadata->getAssociationMappings() as $mapping) {
if (ClassMetadataInfo::FETCH_EAGER === $mapping['fetch']) {
return true;
}
$related = $em->getClassMetadata($mapping['targetEntity']);
if (\in_array($related->name, $checked, true)) {
continue;
}
if (true === $this->hasFetchEagerAssociation($em, $related, $checked)) {
return true;
}
}
return false;
} | [
"private",
"function",
"hasFetchEagerAssociation",
"(",
"EntityManager",
"$",
"em",
",",
"ClassMetadataInfo",
"$",
"classMetadata",
",",
"array",
"&",
"$",
"checked",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"checked",
"[",
"]",
"=",
"$",
"classMetadata",
"->",
"name",
";",
"foreach",
"(",
"$",
"classMetadata",
"->",
"getAssociationMappings",
"(",
")",
"as",
"$",
"mapping",
")",
"{",
"if",
"(",
"ClassMetadataInfo",
"::",
"FETCH_EAGER",
"===",
"$",
"mapping",
"[",
"'fetch'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"$",
"related",
"=",
"$",
"em",
"->",
"getClassMetadata",
"(",
"$",
"mapping",
"[",
"'targetEntity'",
"]",
")",
";",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"related",
"->",
"name",
",",
"$",
"checked",
",",
"true",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"this",
"->",
"hasFetchEagerAssociation",
"(",
"$",
"em",
",",
"$",
"related",
",",
"$",
"checked",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Checks if the class has an associationMapping with FETCH=EAGER.
@param array $checked array cache of tested metadata classes | [
"Checks",
"if",
"the",
"class",
"has",
"an",
"associationMapping",
"with",
"FETCH",
"=",
"EAGER",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Orm/Util/EagerLoadingTrait.php#L69-L90 | train |
api-platform/core | src/Bridge/Doctrine/Common/Util/IdentifierManagerTrait.php | IdentifierManagerTrait.normalizeIdentifiers | private function normalizeIdentifiers($id, ObjectManager $manager, string $resourceClass): array
{
$identifierValues = [$id];
$doctrineClassMetadata = $manager->getClassMetadata($resourceClass);
$doctrineIdentifierFields = $doctrineClassMetadata->getIdentifier();
$isOrm = $manager instanceof EntityManagerInterface;
$isOdm = $manager instanceof DocumentManager;
$platform = $isOrm ? $manager->getConnection()->getDatabasePlatform() : null;
$identifiersMap = null;
if (\count($doctrineIdentifierFields) > 1) {
$identifiersMap = [];
// first transform identifiers to a proper key/value array
foreach (explode(';', (string) $id) as $identifier) {
if (!$identifier) {
continue;
}
$identifierPair = explode('=', $identifier);
$identifiersMap[$identifierPair[0]] = $identifierPair[1];
}
}
$identifiers = [];
$i = 0;
foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) {
$propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName);
if (!$propertyMetadata->isIdentifier()) {
continue;
}
$identifier = null === $identifiersMap ? $identifierValues[$i] ?? null : $identifiersMap[$propertyName] ?? null;
if (null === $identifier) {
throw new PropertyNotFoundException(sprintf('Invalid identifier "%s", "%s" was not found.', $id, $propertyName));
}
$doctrineTypeName = $doctrineClassMetadata->getTypeOfField($propertyName);
if ($isOrm && null !== $doctrineTypeName && DBALType::hasType($doctrineTypeName)) {
$identifier = DBALType::getType($doctrineTypeName)->convertToPHPValue($identifier, $platform);
}
if ($isOdm && null !== $doctrineTypeName && MongoDbType::hasType($doctrineTypeName)) {
$identifier = MongoDbType::getType($doctrineTypeName)->convertToPHPValue($identifier);
}
$identifiers[$propertyName] = $identifier;
++$i;
}
return $identifiers;
} | php | private function normalizeIdentifiers($id, ObjectManager $manager, string $resourceClass): array
{
$identifierValues = [$id];
$doctrineClassMetadata = $manager->getClassMetadata($resourceClass);
$doctrineIdentifierFields = $doctrineClassMetadata->getIdentifier();
$isOrm = $manager instanceof EntityManagerInterface;
$isOdm = $manager instanceof DocumentManager;
$platform = $isOrm ? $manager->getConnection()->getDatabasePlatform() : null;
$identifiersMap = null;
if (\count($doctrineIdentifierFields) > 1) {
$identifiersMap = [];
// first transform identifiers to a proper key/value array
foreach (explode(';', (string) $id) as $identifier) {
if (!$identifier) {
continue;
}
$identifierPair = explode('=', $identifier);
$identifiersMap[$identifierPair[0]] = $identifierPair[1];
}
}
$identifiers = [];
$i = 0;
foreach ($this->propertyNameCollectionFactory->create($resourceClass) as $propertyName) {
$propertyMetadata = $this->propertyMetadataFactory->create($resourceClass, $propertyName);
if (!$propertyMetadata->isIdentifier()) {
continue;
}
$identifier = null === $identifiersMap ? $identifierValues[$i] ?? null : $identifiersMap[$propertyName] ?? null;
if (null === $identifier) {
throw new PropertyNotFoundException(sprintf('Invalid identifier "%s", "%s" was not found.', $id, $propertyName));
}
$doctrineTypeName = $doctrineClassMetadata->getTypeOfField($propertyName);
if ($isOrm && null !== $doctrineTypeName && DBALType::hasType($doctrineTypeName)) {
$identifier = DBALType::getType($doctrineTypeName)->convertToPHPValue($identifier, $platform);
}
if ($isOdm && null !== $doctrineTypeName && MongoDbType::hasType($doctrineTypeName)) {
$identifier = MongoDbType::getType($doctrineTypeName)->convertToPHPValue($identifier);
}
$identifiers[$propertyName] = $identifier;
++$i;
}
return $identifiers;
} | [
"private",
"function",
"normalizeIdentifiers",
"(",
"$",
"id",
",",
"ObjectManager",
"$",
"manager",
",",
"string",
"$",
"resourceClass",
")",
":",
"array",
"{",
"$",
"identifierValues",
"=",
"[",
"$",
"id",
"]",
";",
"$",
"doctrineClassMetadata",
"=",
"$",
"manager",
"->",
"getClassMetadata",
"(",
"$",
"resourceClass",
")",
";",
"$",
"doctrineIdentifierFields",
"=",
"$",
"doctrineClassMetadata",
"->",
"getIdentifier",
"(",
")",
";",
"$",
"isOrm",
"=",
"$",
"manager",
"instanceof",
"EntityManagerInterface",
";",
"$",
"isOdm",
"=",
"$",
"manager",
"instanceof",
"DocumentManager",
";",
"$",
"platform",
"=",
"$",
"isOrm",
"?",
"$",
"manager",
"->",
"getConnection",
"(",
")",
"->",
"getDatabasePlatform",
"(",
")",
":",
"null",
";",
"$",
"identifiersMap",
"=",
"null",
";",
"if",
"(",
"\\",
"count",
"(",
"$",
"doctrineIdentifierFields",
")",
">",
"1",
")",
"{",
"$",
"identifiersMap",
"=",
"[",
"]",
";",
"// first transform identifiers to a proper key/value array",
"foreach",
"(",
"explode",
"(",
"';'",
",",
"(",
"string",
")",
"$",
"id",
")",
"as",
"$",
"identifier",
")",
"{",
"if",
"(",
"!",
"$",
"identifier",
")",
"{",
"continue",
";",
"}",
"$",
"identifierPair",
"=",
"explode",
"(",
"'='",
",",
"$",
"identifier",
")",
";",
"$",
"identifiersMap",
"[",
"$",
"identifierPair",
"[",
"0",
"]",
"]",
"=",
"$",
"identifierPair",
"[",
"1",
"]",
";",
"}",
"}",
"$",
"identifiers",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"propertyNameCollectionFactory",
"->",
"create",
"(",
"$",
"resourceClass",
")",
"as",
"$",
"propertyName",
")",
"{",
"$",
"propertyMetadata",
"=",
"$",
"this",
"->",
"propertyMetadataFactory",
"->",
"create",
"(",
"$",
"resourceClass",
",",
"$",
"propertyName",
")",
";",
"if",
"(",
"!",
"$",
"propertyMetadata",
"->",
"isIdentifier",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"identifier",
"=",
"null",
"===",
"$",
"identifiersMap",
"?",
"$",
"identifierValues",
"[",
"$",
"i",
"]",
"??",
"null",
":",
"$",
"identifiersMap",
"[",
"$",
"propertyName",
"]",
"??",
"null",
";",
"if",
"(",
"null",
"===",
"$",
"identifier",
")",
"{",
"throw",
"new",
"PropertyNotFoundException",
"(",
"sprintf",
"(",
"'Invalid identifier \"%s\", \"%s\" was not found.'",
",",
"$",
"id",
",",
"$",
"propertyName",
")",
")",
";",
"}",
"$",
"doctrineTypeName",
"=",
"$",
"doctrineClassMetadata",
"->",
"getTypeOfField",
"(",
"$",
"propertyName",
")",
";",
"if",
"(",
"$",
"isOrm",
"&&",
"null",
"!==",
"$",
"doctrineTypeName",
"&&",
"DBALType",
"::",
"hasType",
"(",
"$",
"doctrineTypeName",
")",
")",
"{",
"$",
"identifier",
"=",
"DBALType",
"::",
"getType",
"(",
"$",
"doctrineTypeName",
")",
"->",
"convertToPHPValue",
"(",
"$",
"identifier",
",",
"$",
"platform",
")",
";",
"}",
"if",
"(",
"$",
"isOdm",
"&&",
"null",
"!==",
"$",
"doctrineTypeName",
"&&",
"MongoDbType",
"::",
"hasType",
"(",
"$",
"doctrineTypeName",
")",
")",
"{",
"$",
"identifier",
"=",
"MongoDbType",
"::",
"getType",
"(",
"$",
"doctrineTypeName",
")",
"->",
"convertToPHPValue",
"(",
"$",
"identifier",
")",
";",
"}",
"$",
"identifiers",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"identifier",
";",
"++",
"$",
"i",
";",
"}",
"return",
"$",
"identifiers",
";",
"}"
]
| Transform and check the identifier, composite or not.
@param int|string $id
@throws PropertyNotFoundException | [
"Transform",
"and",
"check",
"the",
"identifier",
"composite",
"or",
"not",
"."
]
| 0888bf33429a37d031345bf7c720f23010a50de4 | https://github.com/api-platform/core/blob/0888bf33429a37d031345bf7c720f23010a50de4/src/Bridge/Doctrine/Common/Util/IdentifierManagerTrait.php#L38-L91 | train |
line/line-bot-sdk-php | src/LINEBot/Event/BaseEvent.php | BaseEvent.getGroupId | public function getGroupId()
{
if (!$this->isGroupEvent()) {
throw new InvalidEventSourceException('This event source is not a group type');
}
return isset($this->event['source']['groupId'])
? $this->event['source']['groupId']
: null;
} | php | public function getGroupId()
{
if (!$this->isGroupEvent()) {
throw new InvalidEventSourceException('This event source is not a group type');
}
return isset($this->event['source']['groupId'])
? $this->event['source']['groupId']
: null;
} | [
"public",
"function",
"getGroupId",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isGroupEvent",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidEventSourceException",
"(",
"'This event source is not a group type'",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"event",
"[",
"'source'",
"]",
"[",
"'groupId'",
"]",
")",
"?",
"$",
"this",
"->",
"event",
"[",
"'source'",
"]",
"[",
"'groupId'",
"]",
":",
"null",
";",
"}"
]
| Returns group ID of the event.
@return string|null
@throws InvalidEventSourceException Raise when called with non group type event. | [
"Returns",
"group",
"ID",
"of",
"the",
"event",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/Event/BaseEvent.php#L134-L142 | train |
line/line-bot-sdk-php | src/LINEBot/Event/BaseEvent.php | BaseEvent.getRoomId | public function getRoomId()
{
if (!$this->isRoomEvent()) {
throw new InvalidEventSourceException('This event source is not a room type');
}
return isset($this->event['source']['roomId'])
? $this->event['source']['roomId']
: null;
} | php | public function getRoomId()
{
if (!$this->isRoomEvent()) {
throw new InvalidEventSourceException('This event source is not a room type');
}
return isset($this->event['source']['roomId'])
? $this->event['source']['roomId']
: null;
} | [
"public",
"function",
"getRoomId",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isRoomEvent",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidEventSourceException",
"(",
"'This event source is not a room type'",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"event",
"[",
"'source'",
"]",
"[",
"'roomId'",
"]",
")",
"?",
"$",
"this",
"->",
"event",
"[",
"'source'",
"]",
"[",
"'roomId'",
"]",
":",
"null",
";",
"}"
]
| Returns room ID of the event.
@return string|null
@throws InvalidEventSourceException Raise when called with non room type event. | [
"Returns",
"room",
"ID",
"of",
"the",
"event",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/Event/BaseEvent.php#L150-L158 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/LocationMessageBuilder.php | LocationMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$locationMessage = [
'type' => MessageType::LOCATION,
'title' => $this->title,
'address' => $this->address,
'latitude' => $this->latitude,
'longitude' => $this->longitude,
];
if ($this->quickReply) {
$locationMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $locationMessage;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$locationMessage = [
'type' => MessageType::LOCATION,
'title' => $this->title,
'address' => $this->address,
'latitude' => $this->latitude,
'longitude' => $this->longitude,
];
if ($this->quickReply) {
$locationMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $locationMessage;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"locationMessage",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"LOCATION",
",",
"'title'",
"=>",
"$",
"this",
"->",
"title",
",",
"'address'",
"=>",
"$",
"this",
"->",
"address",
",",
"'latitude'",
"=>",
"$",
"this",
"->",
"latitude",
",",
"'longitude'",
"=>",
"$",
"this",
"->",
"longitude",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"locationMessage",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"locationMessage",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds location message structure.
@return array | [
"Builds",
"location",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/LocationMessageBuilder.php#L73-L94 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.replyMessage | public function replyMessage($replyToken, MessageBuilder $messageBuilder)
{
return $this->httpClient->post($this->endpointBase . '/v2/bot/message/reply', [
'replyToken' => $replyToken,
'messages' => $messageBuilder->buildMessage(),
]);
} | php | public function replyMessage($replyToken, MessageBuilder $messageBuilder)
{
return $this->httpClient->post($this->endpointBase . '/v2/bot/message/reply', [
'replyToken' => $replyToken,
'messages' => $messageBuilder->buildMessage(),
]);
} | [
"public",
"function",
"replyMessage",
"(",
"$",
"replyToken",
",",
"MessageBuilder",
"$",
"messageBuilder",
")",
"{",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"this",
"->",
"endpointBase",
".",
"'/v2/bot/message/reply'",
",",
"[",
"'replyToken'",
"=>",
"$",
"replyToken",
",",
"'messages'",
"=>",
"$",
"messageBuilder",
"->",
"buildMessage",
"(",
")",
",",
"]",
")",
";",
"}"
]
| Replies arbitrary message to destination which is associated with reply token.
@param string $replyToken Identifier of destination.
@param MessageBuilder $messageBuilder Message builder to send.
@return Response | [
"Replies",
"arbitrary",
"message",
"to",
"destination",
"which",
"is",
"associated",
"with",
"reply",
"token",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L95-L101 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.pushMessage | public function pushMessage($to, MessageBuilder $messageBuilder)
{
return $this->httpClient->post($this->endpointBase . '/v2/bot/message/push', [
'to' => $to,
'messages' => $messageBuilder->buildMessage(),
]);
} | php | public function pushMessage($to, MessageBuilder $messageBuilder)
{
return $this->httpClient->post($this->endpointBase . '/v2/bot/message/push', [
'to' => $to,
'messages' => $messageBuilder->buildMessage(),
]);
} | [
"public",
"function",
"pushMessage",
"(",
"$",
"to",
",",
"MessageBuilder",
"$",
"messageBuilder",
")",
"{",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"this",
"->",
"endpointBase",
".",
"'/v2/bot/message/push'",
",",
"[",
"'to'",
"=>",
"$",
"to",
",",
"'messages'",
"=>",
"$",
"messageBuilder",
"->",
"buildMessage",
"(",
")",
",",
"]",
")",
";",
"}"
]
| Sends arbitrary message to destination.
@param string $to Identifier of destination.
@param MessageBuilder $messageBuilder Message builder to send.
@return Response | [
"Sends",
"arbitrary",
"message",
"to",
"destination",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L144-L150 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.multicast | public function multicast(array $tos, MessageBuilder $messageBuilder)
{
return $this->httpClient->post($this->endpointBase . '/v2/bot/message/multicast', [
'to' => $tos,
'messages' => $messageBuilder->buildMessage(),
]);
} | php | public function multicast(array $tos, MessageBuilder $messageBuilder)
{
return $this->httpClient->post($this->endpointBase . '/v2/bot/message/multicast', [
'to' => $tos,
'messages' => $messageBuilder->buildMessage(),
]);
} | [
"public",
"function",
"multicast",
"(",
"array",
"$",
"tos",
",",
"MessageBuilder",
"$",
"messageBuilder",
")",
"{",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"this",
"->",
"endpointBase",
".",
"'/v2/bot/message/multicast'",
",",
"[",
"'to'",
"=>",
"$",
"tos",
",",
"'messages'",
"=>",
"$",
"messageBuilder",
"->",
"buildMessage",
"(",
")",
",",
"]",
")",
";",
"}"
]
| Sends arbitrary message to multi destinations.
@param array $tos Identifiers of destination.
@param MessageBuilder $messageBuilder Message builder to send.
@return Response | [
"Sends",
"arbitrary",
"message",
"to",
"multi",
"destinations",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L159-L165 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.parseEventRequest | public function parseEventRequest($body, $signature, $eventOnly = true)
{
return EventRequestParser::parseEventRequest($body, $this->channelSecret, $signature, $eventOnly);
} | php | public function parseEventRequest($body, $signature, $eventOnly = true)
{
return EventRequestParser::parseEventRequest($body, $this->channelSecret, $signature, $eventOnly);
} | [
"public",
"function",
"parseEventRequest",
"(",
"$",
"body",
",",
"$",
"signature",
",",
"$",
"eventOnly",
"=",
"true",
")",
"{",
"return",
"EventRequestParser",
"::",
"parseEventRequest",
"(",
"$",
"body",
",",
"$",
"this",
"->",
"channelSecret",
",",
"$",
"signature",
",",
"$",
"eventOnly",
")",
";",
"}"
]
| Parse event request to Event objects.
@param string $body Request body.
@param string $signature Signature of request.
@param bool $eventOnly if this flag on, get events only.
@return mixed
@throws LINEBot\Exception\InvalidEventRequestException
@throws LINEBot\Exception\InvalidSignatureException | [
"Parse",
"event",
"request",
"to",
"Event",
"objects",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L199-L202 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.getGroupMemberProfile | public function getGroupMemberProfile($groupId, $userId)
{
$url = sprintf('%s/v2/bot/group/%s/member/%s', $this->endpointBase, urlencode($groupId), urlencode($userId));
return $this->httpClient->get($url, []);
} | php | public function getGroupMemberProfile($groupId, $userId)
{
$url = sprintf('%s/v2/bot/group/%s/member/%s', $this->endpointBase, urlencode($groupId), urlencode($userId));
return $this->httpClient->get($url, []);
} | [
"public",
"function",
"getGroupMemberProfile",
"(",
"$",
"groupId",
",",
"$",
"userId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/group/%s/member/%s'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"groupId",
")",
",",
"urlencode",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"]",
")",
";",
"}"
]
| Gets the user profile of a member of a group that the bot is in.
This can be the user ID of a user who has not added the bot as a friend or has blocked the bot.
@param string $groupId Identifier of the group
@param string $userId Identifier of the user
@return Response | [
"Gets",
"the",
"user",
"profile",
"of",
"a",
"member",
"of",
"a",
"group",
"that",
"the",
"bot",
"is",
"in",
".",
"This",
"can",
"be",
"the",
"user",
"ID",
"of",
"a",
"user",
"who",
"has",
"not",
"added",
"the",
"bot",
"as",
"a",
"friend",
"or",
"has",
"blocked",
"the",
"bot",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L225-L229 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.getRoomMemberProfile | public function getRoomMemberProfile($roomId, $userId)
{
$url = sprintf('%s/v2/bot/room/%s/member/%s', $this->endpointBase, urlencode($roomId), urlencode($userId));
return $this->httpClient->get($url, []);
} | php | public function getRoomMemberProfile($roomId, $userId)
{
$url = sprintf('%s/v2/bot/room/%s/member/%s', $this->endpointBase, urlencode($roomId), urlencode($userId));
return $this->httpClient->get($url, []);
} | [
"public",
"function",
"getRoomMemberProfile",
"(",
"$",
"roomId",
",",
"$",
"userId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/room/%s/member/%s'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"roomId",
")",
",",
"urlencode",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"]",
")",
";",
"}"
]
| Gets the user profile of a member of a room that the bot is in.
This can be the user ID of a user who has not added the bot as a friend or has blocked the bot.
@param string $roomId Identifier of the room
@param string $userId Identifier of the user
@return Response | [
"Gets",
"the",
"user",
"profile",
"of",
"a",
"member",
"of",
"a",
"room",
"that",
"the",
"bot",
"is",
"in",
".",
"This",
"can",
"be",
"the",
"user",
"ID",
"of",
"a",
"user",
"who",
"has",
"not",
"added",
"the",
"bot",
"as",
"a",
"friend",
"or",
"has",
"blocked",
"the",
"bot",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L239-L243 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.getGroupMemberIds | public function getGroupMemberIds($groupId, $start = null)
{
$url = sprintf('%s/v2/bot/group/%s/members/ids', $this->endpointBase, urlencode($groupId));
$params = is_null($start) ? [] : ['start' => $start];
return $this->httpClient->get($url, $params);
} | php | public function getGroupMemberIds($groupId, $start = null)
{
$url = sprintf('%s/v2/bot/group/%s/members/ids', $this->endpointBase, urlencode($groupId));
$params = is_null($start) ? [] : ['start' => $start];
return $this->httpClient->get($url, $params);
} | [
"public",
"function",
"getGroupMemberIds",
"(",
"$",
"groupId",
",",
"$",
"start",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/group/%s/members/ids'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"groupId",
")",
")",
";",
"$",
"params",
"=",
"is_null",
"(",
"$",
"start",
")",
"?",
"[",
"]",
":",
"[",
"'start'",
"=>",
"$",
"start",
"]",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}"
]
| Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.
This feature is only available for LINE@ Approved accounts or official accounts.
@param string $groupId Identifier of the group
@param string $start continuationToken
@return Response | [
"Gets",
"the",
"user",
"IDs",
"of",
"the",
"members",
"of",
"a",
"group",
"that",
"the",
"bot",
"is",
"in",
".",
"This",
"includes",
"the",
"user",
"IDs",
"of",
"users",
"who",
"have",
"not",
"added",
"the",
"bot",
"as",
"a",
"friend",
"or",
"has",
"blocked",
"the",
"bot",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L255-L260 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.getRoomMemberIds | public function getRoomMemberIds($roomId, $start = null)
{
$url = sprintf('%s/v2/bot/room/%s/members/ids', $this->endpointBase, urlencode($roomId));
$params = is_null($start) ? [] : ['start' => $start];
return $this->httpClient->get($url, $params);
} | php | public function getRoomMemberIds($roomId, $start = null)
{
$url = sprintf('%s/v2/bot/room/%s/members/ids', $this->endpointBase, urlencode($roomId));
$params = is_null($start) ? [] : ['start' => $start];
return $this->httpClient->get($url, $params);
} | [
"public",
"function",
"getRoomMemberIds",
"(",
"$",
"roomId",
",",
"$",
"start",
"=",
"null",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/room/%s/members/ids'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"roomId",
")",
")",
";",
"$",
"params",
"=",
"is_null",
"(",
"$",
"start",
")",
"?",
"[",
"]",
":",
"[",
"'start'",
"=>",
"$",
"start",
"]",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}"
]
| Gets the user IDs of the members of a room that the bot is in.
This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.
This feature is only available for LINE@ Approved accounts or official accounts.
@param string $roomId Identifier of the room
@param string $start continuationToken
@return Response | [
"Gets",
"the",
"user",
"IDs",
"of",
"the",
"members",
"of",
"a",
"room",
"that",
"the",
"bot",
"is",
"in",
".",
"This",
"includes",
"the",
"user",
"IDs",
"of",
"users",
"who",
"have",
"not",
"added",
"the",
"bot",
"as",
"a",
"friend",
"or",
"has",
"blocked",
"the",
"bot",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L272-L277 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.createLinkToken | public function createLinkToken($userId)
{
$url = sprintf('%s/v2/bot/user/%s/linkToken', $this->endpointBase, urlencode($userId));
return $this->httpClient->post($url, []);
} | php | public function createLinkToken($userId)
{
$url = sprintf('%s/v2/bot/user/%s/linkToken', $this->endpointBase, urlencode($userId));
return $this->httpClient->post($url, []);
} | [
"public",
"function",
"createLinkToken",
"(",
"$",
"userId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/user/%s/linkToken'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"url",
",",
"[",
"]",
")",
";",
"}"
]
| Issues a link token used for the account link feature.
@param string $userId User ID for the LINE account to be linked.
@return Response | [
"Issues",
"a",
"link",
"token",
"used",
"for",
"the",
"account",
"link",
"feature",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L335-L339 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.deleteRichMenu | public function deleteRichMenu($richMenuId)
{
$url = sprintf('%s/v2/bot/richmenu/%s', $this->endpointBase, urlencode($richMenuId));
return $this->httpClient->delete($url);
} | php | public function deleteRichMenu($richMenuId)
{
$url = sprintf('%s/v2/bot/richmenu/%s', $this->endpointBase, urlencode($richMenuId));
return $this->httpClient->delete($url);
} | [
"public",
"function",
"deleteRichMenu",
"(",
"$",
"richMenuId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/richmenu/%s'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"richMenuId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"delete",
"(",
"$",
"url",
")",
";",
"}"
]
| Deletes a rich menu.
@param string $richMenuId ID of an uploaded rich menu
@return Response | [
"Deletes",
"a",
"rich",
"menu",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L372-L376 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.getRichMenuId | public function getRichMenuId($userId)
{
$url = sprintf('%s/v2/bot/user/%s/richmenu', $this->endpointBase, urlencode($userId));
return $this->httpClient->get($url, []);
} | php | public function getRichMenuId($userId)
{
$url = sprintf('%s/v2/bot/user/%s/richmenu', $this->endpointBase, urlencode($userId));
return $this->httpClient->get($url, []);
} | [
"public",
"function",
"getRichMenuId",
"(",
"$",
"userId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/user/%s/richmenu'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"]",
")",
";",
"}"
]
| Gets the ID of the rich menu linked to a user.
@param string $userId User ID. Found in the source object of webhook event objects.
@return Response | [
"Gets",
"the",
"ID",
"of",
"the",
"rich",
"menu",
"linked",
"to",
"a",
"user",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L384-L388 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.linkRichMenu | public function linkRichMenu($userId, $richMenuId)
{
$url = sprintf(
'%s/v2/bot/user/%s/richmenu/%s',
$this->endpointBase,
urlencode($userId),
urlencode($richMenuId)
);
return $this->httpClient->post($url, []);
} | php | public function linkRichMenu($userId, $richMenuId)
{
$url = sprintf(
'%s/v2/bot/user/%s/richmenu/%s',
$this->endpointBase,
urlencode($userId),
urlencode($richMenuId)
);
return $this->httpClient->post($url, []);
} | [
"public",
"function",
"linkRichMenu",
"(",
"$",
"userId",
",",
"$",
"richMenuId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/user/%s/richmenu/%s'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"userId",
")",
",",
"urlencode",
"(",
"$",
"richMenuId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"url",
",",
"[",
"]",
")",
";",
"}"
]
| Links a rich menu to a user. Only one rich menu can be linked to a user at one time.
@param string $userId User ID. Found in the source object of webhook event objects.
@param string $richMenuId ID of an uploaded rich menu
@return Response | [
"Links",
"a",
"rich",
"menu",
"to",
"a",
"user",
".",
"Only",
"one",
"rich",
"menu",
"can",
"be",
"linked",
"to",
"a",
"user",
"at",
"one",
"time",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L397-L406 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.bulkLinkRichMenu | public function bulkLinkRichMenu($userIds, $richMenuId)
{
$url = $this->endpointBase . '/v2/bot/richmenu/bulk/link';
return $this->httpClient->post($url, [
'richMenuId' => $richMenuId,
'userIds' => $userIds
]);
} | php | public function bulkLinkRichMenu($userIds, $richMenuId)
{
$url = $this->endpointBase . '/v2/bot/richmenu/bulk/link';
return $this->httpClient->post($url, [
'richMenuId' => $richMenuId,
'userIds' => $userIds
]);
} | [
"public",
"function",
"bulkLinkRichMenu",
"(",
"$",
"userIds",
",",
"$",
"richMenuId",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"endpointBase",
".",
"'/v2/bot/richmenu/bulk/link'",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"url",
",",
"[",
"'richMenuId'",
"=>",
"$",
"richMenuId",
",",
"'userIds'",
"=>",
"$",
"userIds",
"]",
")",
";",
"}"
]
| Links a rich menu to multiple users.
@param string[] $userIds Found in the source object of webhook event objects. Max: 150 user IDs.
@param string $richMenuId ID of an uploaded rich menu
@return Response | [
"Links",
"a",
"rich",
"menu",
"to",
"multiple",
"users",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L415-L422 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.unlinkRichMenu | public function unlinkRichMenu($userId)
{
$url = sprintf('%s/v2/bot/user/%s/richmenu', $this->endpointBase, urlencode($userId));
return $this->httpClient->delete($url);
} | php | public function unlinkRichMenu($userId)
{
$url = sprintf('%s/v2/bot/user/%s/richmenu', $this->endpointBase, urlencode($userId));
return $this->httpClient->delete($url);
} | [
"public",
"function",
"unlinkRichMenu",
"(",
"$",
"userId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/user/%s/richmenu'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"userId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"delete",
"(",
"$",
"url",
")",
";",
"}"
]
| Unlinks a rich menu from multiple user.
@param string $userId User ID. Found in the source object of webhook event objects.
@return Response | [
"Unlinks",
"a",
"rich",
"menu",
"from",
"multiple",
"user",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L430-L434 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.bulkUnlinkRichMenu | public function bulkUnlinkRichMenu($userIds)
{
$url = $this->endpointBase . '/v2/bot/richmenu/bulk/unlink';
return $this->httpClient->post($url, [
'userIds' => $userIds
]);
} | php | public function bulkUnlinkRichMenu($userIds)
{
$url = $this->endpointBase . '/v2/bot/richmenu/bulk/unlink';
return $this->httpClient->post($url, [
'userIds' => $userIds
]);
} | [
"public",
"function",
"bulkUnlinkRichMenu",
"(",
"$",
"userIds",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"endpointBase",
".",
"'/v2/bot/richmenu/bulk/unlink'",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"url",
",",
"[",
"'userIds'",
"=>",
"$",
"userIds",
"]",
")",
";",
"}"
]
| Unlinks rich menus from multiple users.
@param string[] $userIds Found in the source object of webhook event objects. Max: 150 user IDs.
@return Response | [
"Unlinks",
"rich",
"menus",
"from",
"multiple",
"users",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L442-L448 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.downloadRichMenuImage | public function downloadRichMenuImage($richMenuId)
{
$url = sprintf('%s/v2/bot/richmenu/%s/content', $this->endpointBase, urlencode($richMenuId));
return $this->httpClient->get($url);
} | php | public function downloadRichMenuImage($richMenuId)
{
$url = sprintf('%s/v2/bot/richmenu/%s/content', $this->endpointBase, urlencode($richMenuId));
return $this->httpClient->get($url);
} | [
"public",
"function",
"downloadRichMenuImage",
"(",
"$",
"richMenuId",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/richmenu/%s/content'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"richMenuId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
")",
";",
"}"
]
| Downloads an image associated with a rich menu.
@param string $richMenuId ID of an uploaded rich menu
@return Response | [
"Downloads",
"an",
"image",
"associated",
"with",
"a",
"rich",
"menu",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L456-L460 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.uploadRichMenuImage | public function uploadRichMenuImage($richMenuId, $imagePath, $contentType)
{
$url = sprintf('%s/v2/bot/richmenu/%s/content', $this->endpointBase, urlencode($richMenuId));
return $this->httpClient->post(
$url,
[
'__file' => $imagePath,
'__type' => $contentType,
],
[ "Content-Type: $contentType" ]
);
} | php | public function uploadRichMenuImage($richMenuId, $imagePath, $contentType)
{
$url = sprintf('%s/v2/bot/richmenu/%s/content', $this->endpointBase, urlencode($richMenuId));
return $this->httpClient->post(
$url,
[
'__file' => $imagePath,
'__type' => $contentType,
],
[ "Content-Type: $contentType" ]
);
} | [
"public",
"function",
"uploadRichMenuImage",
"(",
"$",
"richMenuId",
",",
"$",
"imagePath",
",",
"$",
"contentType",
")",
"{",
"$",
"url",
"=",
"sprintf",
"(",
"'%s/v2/bot/richmenu/%s/content'",
",",
"$",
"this",
"->",
"endpointBase",
",",
"urlencode",
"(",
"$",
"richMenuId",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"post",
"(",
"$",
"url",
",",
"[",
"'__file'",
"=>",
"$",
"imagePath",
",",
"'__type'",
"=>",
"$",
"contentType",
",",
"]",
",",
"[",
"\"Content-Type: $contentType\"",
"]",
")",
";",
"}"
]
| Uploads and attaches an image to a rich menu.
Notes:
<ul><li>Images must have one of the following resolutions: 2500x1686 or 2500x843 pixels.</li>
<li>You cannot replace an image attached to a rich menu. To update your rich menu image,
create a new rich menu object and upload another image.</li></ul>
@param string $richMenuId ID of an uploaded rich menu
@param string $imagePath Path to the image
@param string $contentType image/jpeg or image/png
@return Response | [
"Uploads",
"and",
"attaches",
"an",
"image",
"to",
"a",
"rich",
"menu",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L475-L486 | train |
line/line-bot-sdk-php | src/LINEBot.php | LINEBot.getNumberOfSentReplyMessages | public function getNumberOfSentReplyMessages(DateTime $datetime)
{
$url = $this->endpointBase . '/v2/bot/message/delivery/reply';
$datetime->setTimezone(new DateTimeZone('Asia/Tokyo'));
return $this->httpClient->get($url, ['date' => $datetime->format('Ymd')]);
} | php | public function getNumberOfSentReplyMessages(DateTime $datetime)
{
$url = $this->endpointBase . '/v2/bot/message/delivery/reply';
$datetime->setTimezone(new DateTimeZone('Asia/Tokyo'));
return $this->httpClient->get($url, ['date' => $datetime->format('Ymd')]);
} | [
"public",
"function",
"getNumberOfSentReplyMessages",
"(",
"DateTime",
"$",
"datetime",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"endpointBase",
".",
"'/v2/bot/message/delivery/reply'",
";",
"$",
"datetime",
"->",
"setTimezone",
"(",
"new",
"DateTimeZone",
"(",
"'Asia/Tokyo'",
")",
")",
";",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"get",
"(",
"$",
"url",
",",
"[",
"'date'",
"=>",
"$",
"datetime",
"->",
"format",
"(",
"'Ymd'",
")",
"]",
")",
";",
"}"
]
| Get number of sent reply messages
@param DateTime $datetime Date the messages were sent.
@return Response | [
"Get",
"number",
"of",
"sent",
"reply",
"messages"
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot.php#L504-L509 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/BlockStyleBuilder.php | BlockStyleBuilder.build | public function build()
{
if (isset($this->style)) {
return $this->style;
}
$this->style = BuildUtil::removeNullElements([
'backgroundColor' => $this->backgroundColor,
'separator' => $this->separator,
'separatorColor' => $this->separatorColor,
]);
return $this->style;
} | php | public function build()
{
if (isset($this->style)) {
return $this->style;
}
$this->style = BuildUtil::removeNullElements([
'backgroundColor' => $this->backgroundColor,
'separator' => $this->separator,
'separatorColor' => $this->separatorColor,
]);
return $this->style;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"style",
")",
")",
"{",
"return",
"$",
"this",
"->",
"style",
";",
"}",
"$",
"this",
"->",
"style",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'backgroundColor'",
"=>",
"$",
"this",
"->",
"backgroundColor",
",",
"'separator'",
"=>",
"$",
"this",
"->",
"separator",
",",
"'separatorColor'",
"=>",
"$",
"this",
"->",
"separatorColor",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"style",
";",
"}"
]
| Builds block style structure.
@return array | [
"Builds",
"block",
"style",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/BlockStyleBuilder.php#L105-L118 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/ImageComponentBuilder.php | ImageComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::IMAGE,
'url' => $this->url,
'flex' => $this->flex,
'margin' => $this->margin,
'align' => $this->align,
'gravity' => $this->gravity,
'size' => $this->size,
'aspectRatio' => $this->aspectRatio,
'aspectMode' => $this->aspectMode,
'backgroundColor' => $this->backgroundColor,
'action' => BuildUtil::build($this->actionBuilder, 'buildTemplateAction'),
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::IMAGE,
'url' => $this->url,
'flex' => $this->flex,
'margin' => $this->margin,
'align' => $this->align,
'gravity' => $this->gravity,
'size' => $this->size,
'aspectRatio' => $this->aspectRatio,
'aspectMode' => $this->aspectMode,
'backgroundColor' => $this->backgroundColor,
'action' => BuildUtil::build($this->actionBuilder, 'buildTemplateAction'),
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"IMAGE",
",",
"'url'",
"=>",
"$",
"this",
"->",
"url",
",",
"'flex'",
"=>",
"$",
"this",
"->",
"flex",
",",
"'margin'",
"=>",
"$",
"this",
"->",
"margin",
",",
"'align'",
"=>",
"$",
"this",
"->",
"align",
",",
"'gravity'",
"=>",
"$",
"this",
"->",
"gravity",
",",
"'size'",
"=>",
"$",
"this",
"->",
"size",
",",
"'aspectRatio'",
"=>",
"$",
"this",
"->",
"aspectRatio",
",",
"'aspectMode'",
"=>",
"$",
"this",
"->",
"aspectMode",
",",
"'backgroundColor'",
"=>",
"$",
"this",
"->",
"backgroundColor",
",",
"'action'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"actionBuilder",
",",
"'buildTemplateAction'",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds image component structure.
@return array | [
"Builds",
"image",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/ImageComponentBuilder.php#L237-L258 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/TextComponentBuilder.php | TextComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::TEXT,
'text' => $this->text,
'flex' => $this->flex,
'margin' => $this->margin,
'size' => $this->size,
'align' => $this->align,
'gravity' => $this->gravity,
'wrap' => $this->wrap,
'maxLines' => $this->maxLines,
'weight' => $this->weight,
'color' => $this->color,
'action' => BuildUtil::build($this->actionBuilder, 'buildTemplateAction'),
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::TEXT,
'text' => $this->text,
'flex' => $this->flex,
'margin' => $this->margin,
'size' => $this->size,
'align' => $this->align,
'gravity' => $this->gravity,
'wrap' => $this->wrap,
'maxLines' => $this->maxLines,
'weight' => $this->weight,
'color' => $this->color,
'action' => BuildUtil::build($this->actionBuilder, 'buildTemplateAction'),
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"TEXT",
",",
"'text'",
"=>",
"$",
"this",
"->",
"text",
",",
"'flex'",
"=>",
"$",
"this",
"->",
"flex",
",",
"'margin'",
"=>",
"$",
"this",
"->",
"margin",
",",
"'size'",
"=>",
"$",
"this",
"->",
"size",
",",
"'align'",
"=>",
"$",
"this",
"->",
"align",
",",
"'gravity'",
"=>",
"$",
"this",
"->",
"gravity",
",",
"'wrap'",
"=>",
"$",
"this",
"->",
"wrap",
",",
"'maxLines'",
"=>",
"$",
"this",
"->",
"maxLines",
",",
"'weight'",
"=>",
"$",
"this",
"->",
"weight",
",",
"'color'",
"=>",
"$",
"this",
"->",
"color",
",",
"'action'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"actionBuilder",
",",
"'buildTemplateAction'",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds text component structure.
@return array | [
"Builds",
"text",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/TextComponentBuilder.php#L253-L275 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/TemplateBuilder/CarouselColumnTemplateBuilder.php | CarouselColumnTemplateBuilder.buildTemplate | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$actions = [];
foreach ($this->actionBuilders as $actionBuilder) {
$actions[] = $actionBuilder->buildTemplateAction();
}
$this->template = [
'thumbnailImageUrl' => $this->thumbnailImageUrl,
'title' => $this->title,
'text' => $this->text,
'actions' => $actions,
];
if ($this->imageBackgroundColor) {
$this->template['imageBackgroundColor'] = $this->imageBackgroundColor;
}
return $this->template;
} | php | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$actions = [];
foreach ($this->actionBuilders as $actionBuilder) {
$actions[] = $actionBuilder->buildTemplateAction();
}
$this->template = [
'thumbnailImageUrl' => $this->thumbnailImageUrl,
'title' => $this->title,
'text' => $this->text,
'actions' => $actions,
];
if ($this->imageBackgroundColor) {
$this->template['imageBackgroundColor'] = $this->imageBackgroundColor;
}
return $this->template;
} | [
"public",
"function",
"buildTemplate",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"template",
")",
")",
"{",
"return",
"$",
"this",
"->",
"template",
";",
"}",
"$",
"actions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"actionBuilders",
"as",
"$",
"actionBuilder",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"$",
"actionBuilder",
"->",
"buildTemplateAction",
"(",
")",
";",
"}",
"$",
"this",
"->",
"template",
"=",
"[",
"'thumbnailImageUrl'",
"=>",
"$",
"this",
"->",
"thumbnailImageUrl",
",",
"'title'",
"=>",
"$",
"this",
"->",
"title",
",",
"'text'",
"=>",
"$",
"this",
"->",
"text",
",",
"'actions'",
"=>",
"$",
"actions",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"imageBackgroundColor",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'imageBackgroundColor'",
"]",
"=",
"$",
"this",
"->",
"imageBackgroundColor",
";",
"}",
"return",
"$",
"this",
"->",
"template",
";",
"}"
]
| Builds column of carousel template structure.
@return array | [
"Builds",
"column",
"of",
"carousel",
"template",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/TemplateBuilder/CarouselColumnTemplateBuilder.php#L68-L91 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ContainerBuilder/BubbleContainerBuilder.php | BubbleContainerBuilder.build | public function build()
{
if (!empty($this->container)) {
return $this->container;
}
$this->container = BuildUtil::removeNullElements([
'type' => ContainerType::BUBBLE,
'direction' => $this->direction,
'header' => BuildUtil::build($this->headerComponentBuilder),
'hero' => BuildUtil::build($this->heroComponentBuilder),
'body' => BuildUtil::build($this->bodyComponentBuilder),
'footer' => BuildUtil::build($this->footerComponentBuilder),
'styles' => BuildUtil::build($this->stylesBuilder),
]);
return $this->container;
} | php | public function build()
{
if (!empty($this->container)) {
return $this->container;
}
$this->container = BuildUtil::removeNullElements([
'type' => ContainerType::BUBBLE,
'direction' => $this->direction,
'header' => BuildUtil::build($this->headerComponentBuilder),
'hero' => BuildUtil::build($this->heroComponentBuilder),
'body' => BuildUtil::build($this->bodyComponentBuilder),
'footer' => BuildUtil::build($this->footerComponentBuilder),
'styles' => BuildUtil::build($this->stylesBuilder),
]);
return $this->container;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"container",
")",
")",
"{",
"return",
"$",
"this",
"->",
"container",
";",
"}",
"$",
"this",
"->",
"container",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ContainerType",
"::",
"BUBBLE",
",",
"'direction'",
"=>",
"$",
"this",
"->",
"direction",
",",
"'header'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"headerComponentBuilder",
")",
",",
"'hero'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"heroComponentBuilder",
")",
",",
"'body'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"bodyComponentBuilder",
")",
",",
"'footer'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"footerComponentBuilder",
")",
",",
"'styles'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"stylesBuilder",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"container",
";",
"}"
]
| Builds bubble container structure.
@return array | [
"Builds",
"bubble",
"container",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ContainerBuilder/BubbleContainerBuilder.php#L165-L182 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/TemplateBuilder/ButtonTemplateBuilder.php | ButtonTemplateBuilder.buildTemplate | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$actions = [];
foreach ($this->actionBuilders as $actionBuilder) {
$actions[] = $actionBuilder->buildTemplateAction();
}
$this->template = [
'type' => TemplateType::BUTTONS,
'text' => $this->text,
'actions' => $actions,
];
if ($this->title) {
$this->template['title'] = $this->title;
}
if ($this->thumbnailImageUrl) {
$this->template['thumbnailImageUrl'] = $this->thumbnailImageUrl;
}
if ($this->imageAspectRatio) {
$this->template['imageAspectRatio'] = $this->imageAspectRatio;
}
if ($this->imageSize) {
$this->template['imageSize'] = $this->imageSize;
}
if ($this->imageBackgroundColor) {
$this->template['imageBackgroundColor'] = $this->imageBackgroundColor;
}
if ($this->defaultAction) {
$this->template['defaultAction'] = $this->defaultAction->buildTemplateAction();
}
return $this->template;
} | php | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$actions = [];
foreach ($this->actionBuilders as $actionBuilder) {
$actions[] = $actionBuilder->buildTemplateAction();
}
$this->template = [
'type' => TemplateType::BUTTONS,
'text' => $this->text,
'actions' => $actions,
];
if ($this->title) {
$this->template['title'] = $this->title;
}
if ($this->thumbnailImageUrl) {
$this->template['thumbnailImageUrl'] = $this->thumbnailImageUrl;
}
if ($this->imageAspectRatio) {
$this->template['imageAspectRatio'] = $this->imageAspectRatio;
}
if ($this->imageSize) {
$this->template['imageSize'] = $this->imageSize;
}
if ($this->imageBackgroundColor) {
$this->template['imageBackgroundColor'] = $this->imageBackgroundColor;
}
if ($this->defaultAction) {
$this->template['defaultAction'] = $this->defaultAction->buildTemplateAction();
}
return $this->template;
} | [
"public",
"function",
"buildTemplate",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"template",
")",
")",
"{",
"return",
"$",
"this",
"->",
"template",
";",
"}",
"$",
"actions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"actionBuilders",
"as",
"$",
"actionBuilder",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"$",
"actionBuilder",
"->",
"buildTemplateAction",
"(",
")",
";",
"}",
"$",
"this",
"->",
"template",
"=",
"[",
"'type'",
"=>",
"TemplateType",
"::",
"BUTTONS",
",",
"'text'",
"=>",
"$",
"this",
"->",
"text",
",",
"'actions'",
"=>",
"$",
"actions",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"title",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'title'",
"]",
"=",
"$",
"this",
"->",
"title",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"thumbnailImageUrl",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'thumbnailImageUrl'",
"]",
"=",
"$",
"this",
"->",
"thumbnailImageUrl",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"imageAspectRatio",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'imageAspectRatio'",
"]",
"=",
"$",
"this",
"->",
"imageAspectRatio",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"imageSize",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'imageSize'",
"]",
"=",
"$",
"this",
"->",
"imageSize",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"imageBackgroundColor",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'imageBackgroundColor'",
"]",
"=",
"$",
"this",
"->",
"imageBackgroundColor",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"defaultAction",
")",
"{",
"$",
"this",
"->",
"template",
"[",
"'defaultAction'",
"]",
"=",
"$",
"this",
"->",
"defaultAction",
"->",
"buildTemplateAction",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"template",
";",
"}"
]
| Builds button template message structure.
@return array | [
"Builds",
"button",
"template",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/TemplateBuilder/ButtonTemplateBuilder.php#L99-L141 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/SeparatorComponentBuilder.php | SeparatorComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::SEPARATOR,
'margin' => $this->margin,
'color' => $this->color,
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::SEPARATOR,
'margin' => $this->margin,
'color' => $this->color,
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"SEPARATOR",
",",
"'margin'",
"=>",
"$",
"this",
"->",
"margin",
",",
"'color'",
"=>",
"$",
"this",
"->",
"color",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds separator component structure.
@return array | [
"Builds",
"separator",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/SeparatorComponentBuilder.php#L92-L105 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/TextMessageBuilder.php | TextMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
foreach ($this->texts as $text) {
$this->message[] = [
'type' => MessageType::TEXT,
'text' => $text,
];
}
if ($this->quickReply) {
$lastKey = count($this->message) - 1;
// If the user receives multiple message objects.
// The quickReply property of the last message object is displayed.
$this->message[$lastKey]['quickReply'] = $this->quickReply->buildQuickReply();
}
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
foreach ($this->texts as $text) {
$this->message[] = [
'type' => MessageType::TEXT,
'text' => $text,
];
}
if ($this->quickReply) {
$lastKey = count($this->message) - 1;
// If the user receives multiple message objects.
// The quickReply property of the last message object is displayed.
$this->message[$lastKey]['quickReply'] = $this->quickReply->buildQuickReply();
}
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"texts",
"as",
"$",
"text",
")",
"{",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"TEXT",
",",
"'text'",
"=>",
"$",
"text",
",",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"lastKey",
"=",
"count",
"(",
"$",
"this",
"->",
"message",
")",
"-",
"1",
";",
"// If the user receives multiple message objects.",
"// The quickReply property of the last message object is displayed.",
"$",
"this",
"->",
"message",
"[",
"$",
"lastKey",
"]",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds text message structure.
@return array | [
"Builds",
"text",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/TextMessageBuilder.php#L79-L101 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/BubbleStylesBuilder.php | BubbleStylesBuilder.build | public function build()
{
if (isset($this->styles)) {
return $this->styles;
}
$this->styles = BuildUtil::removeNullElements([
'header' => BuildUtil::build($this->headerStyleBuilder),
'hero' => BuildUtil::build($this->heroStyleBuilder),
'body' => BuildUtil::build($this->bodyStyleBuilder),
'footer' => BuildUtil::build($this->footerStyleBuilder),
]);
return $this->styles;
} | php | public function build()
{
if (isset($this->styles)) {
return $this->styles;
}
$this->styles = BuildUtil::removeNullElements([
'header' => BuildUtil::build($this->headerStyleBuilder),
'hero' => BuildUtil::build($this->heroStyleBuilder),
'body' => BuildUtil::build($this->bodyStyleBuilder),
'footer' => BuildUtil::build($this->footerStyleBuilder),
]);
return $this->styles;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"styles",
")",
")",
"{",
"return",
"$",
"this",
"->",
"styles",
";",
"}",
"$",
"this",
"->",
"styles",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'header'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"headerStyleBuilder",
")",
",",
"'hero'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"heroStyleBuilder",
")",
",",
"'body'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"bodyStyleBuilder",
")",
",",
"'footer'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"footerStyleBuilder",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"styles",
";",
"}"
]
| Builds bubble styles structure.
@return array | [
"Builds",
"bubble",
"styles",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/BubbleStylesBuilder.php#L125-L139 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/StickerMessageBuilder.php | StickerMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$sticker = [
'type' => MessageType::STICKER,
'packageId' => $this->packageId,
'stickerId' => $this->stickerId,
];
if ($this->quickReply) {
$sticker['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $sticker;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$sticker = [
'type' => MessageType::STICKER,
'packageId' => $this->packageId,
'stickerId' => $this->stickerId,
];
if ($this->quickReply) {
$sticker['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $sticker;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"sticker",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"STICKER",
",",
"'packageId'",
"=>",
"$",
"this",
"->",
"packageId",
",",
"'stickerId'",
"=>",
"$",
"this",
"->",
"stickerId",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"sticker",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"sticker",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds sticker message structure.
@return array | [
"Builds",
"sticker",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/StickerMessageBuilder.php#L63-L82 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Imagemap/VideoBuilder.php | VideoBuilder.build | public function build()
{
$video = [
'originalContentUrl' => $this->originalContentUrl,
'previewImageUrl' => $this->previewImageUrl,
'area' => $this->areaBuilder->build()
];
if ($this->externalLinkBuilder) {
$video['externalLink'] = $this->externalLinkBuilder->build();
}
return $video;
} | php | public function build()
{
$video = [
'originalContentUrl' => $this->originalContentUrl,
'previewImageUrl' => $this->previewImageUrl,
'area' => $this->areaBuilder->build()
];
if ($this->externalLinkBuilder) {
$video['externalLink'] = $this->externalLinkBuilder->build();
}
return $video;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"video",
"=",
"[",
"'originalContentUrl'",
"=>",
"$",
"this",
"->",
"originalContentUrl",
",",
"'previewImageUrl'",
"=>",
"$",
"this",
"->",
"previewImageUrl",
",",
"'area'",
"=>",
"$",
"this",
"->",
"areaBuilder",
"->",
"build",
"(",
")",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"externalLinkBuilder",
")",
"{",
"$",
"video",
"[",
"'externalLink'",
"]",
"=",
"$",
"this",
"->",
"externalLinkBuilder",
"->",
"build",
"(",
")",
";",
"}",
"return",
"$",
"video",
";",
"}"
]
| Builds video of imagemap.
@return array | [
"Builds",
"video",
"of",
"imagemap",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Imagemap/VideoBuilder.php#L64-L75 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/AudioMessageBuilder.php | AudioMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$audioMessage = [
'type' => MessageType::AUDIO,
'originalContentUrl' => $this->originalContentUrl,
'duration' => $this->duration,
];
if ($this->quickReply) {
$audioMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $audioMessage;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$audioMessage = [
'type' => MessageType::AUDIO,
'originalContentUrl' => $this->originalContentUrl,
'duration' => $this->duration,
];
if ($this->quickReply) {
$audioMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $audioMessage;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"audioMessage",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"AUDIO",
",",
"'originalContentUrl'",
"=>",
"$",
"this",
"->",
"originalContentUrl",
",",
"'duration'",
"=>",
"$",
"this",
"->",
"duration",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"audioMessage",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"audioMessage",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Build audio message structure.
@return array | [
"Build",
"audio",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/AudioMessageBuilder.php#L63-L82 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/ImageMessageBuilder.php | ImageMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$imageMessage = [
'type' => MessageType::IMAGE,
'originalContentUrl' => $this->originalContentUrl,
'previewImageUrl' => $this->previewImageUrl,
];
if ($this->quickReply) {
$imageMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $imageMessage;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$imageMessage = [
'type' => MessageType::IMAGE,
'originalContentUrl' => $this->originalContentUrl,
'previewImageUrl' => $this->previewImageUrl,
];
if ($this->quickReply) {
$imageMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $imageMessage;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"imageMessage",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"IMAGE",
",",
"'originalContentUrl'",
"=>",
"$",
"this",
"->",
"originalContentUrl",
",",
"'previewImageUrl'",
"=>",
"$",
"this",
"->",
"previewImageUrl",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"imageMessage",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"imageMessage",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds image message structure.
@return array | [
"Builds",
"image",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/ImageMessageBuilder.php#L63-L82 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/TemplateBuilder/ConfirmTemplateBuilder.php | ConfirmTemplateBuilder.buildTemplate | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$actions = [];
foreach ($this->actionBuilders as $actionBuilder) {
$actions[] = $actionBuilder->buildTemplateAction();
}
$this->template = [
'type' => TemplateType::CONFIRM,
'text' => $this->text,
'actions' => $actions,
];
return $this->template;
} | php | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$actions = [];
foreach ($this->actionBuilders as $actionBuilder) {
$actions[] = $actionBuilder->buildTemplateAction();
}
$this->template = [
'type' => TemplateType::CONFIRM,
'text' => $this->text,
'actions' => $actions,
];
return $this->template;
} | [
"public",
"function",
"buildTemplate",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"template",
")",
")",
"{",
"return",
"$",
"this",
"->",
"template",
";",
"}",
"$",
"actions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"actionBuilders",
"as",
"$",
"actionBuilder",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"$",
"actionBuilder",
"->",
"buildTemplateAction",
"(",
")",
";",
"}",
"$",
"this",
"->",
"template",
"=",
"[",
"'type'",
"=>",
"TemplateType",
"::",
"CONFIRM",
",",
"'text'",
"=>",
"$",
"this",
"->",
"text",
",",
"'actions'",
"=>",
"$",
"actions",
",",
"]",
";",
"return",
"$",
"this",
"->",
"template",
";",
"}"
]
| Builds confirm template structure.
@return array | [
"Builds",
"confirm",
"template",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/TemplateBuilder/ConfirmTemplateBuilder.php#L57-L75 | train |
line/line-bot-sdk-php | src/LINEBot/HTTPClient/CurlHTTPClient.php | CurlHTTPClient.get | public function get($url, array $data = [], array $headers = [])
{
if ($data) {
$url .= '?' . http_build_query($data);
}
return $this->sendRequest('GET', $url, $headers);
} | php | public function get($url, array $data = [], array $headers = [])
{
if ($data) {
$url .= '?' . http_build_query($data);
}
return $this->sendRequest('GET', $url, $headers);
} | [
"public",
"function",
"get",
"(",
"$",
"url",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"url",
".=",
"'?'",
".",
"http_build_query",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'GET'",
",",
"$",
"url",
",",
"$",
"headers",
")",
";",
"}"
]
| Sends GET request to LINE Messaging API.
@param string $url Request URL.
@param array $data Request body
@param array $headers Request headers.
@return Response Response of API request.
@throws CurlExecutionException | [
"Sends",
"GET",
"request",
"to",
"LINE",
"Messaging",
"API",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/HTTPClient/CurlHTTPClient.php#L64-L70 | train |
line/line-bot-sdk-php | src/LINEBot/HTTPClient/CurlHTTPClient.php | CurlHTTPClient.post | public function post($url, array $data, array $headers = null)
{
$headers = is_null($headers) ? ['Content-Type: application/json; charset=utf-8'] : $headers;
return $this->sendRequest('POST', $url, $headers, $data);
} | php | public function post($url, array $data, array $headers = null)
{
$headers = is_null($headers) ? ['Content-Type: application/json; charset=utf-8'] : $headers;
return $this->sendRequest('POST', $url, $headers, $data);
} | [
"public",
"function",
"post",
"(",
"$",
"url",
",",
"array",
"$",
"data",
",",
"array",
"$",
"headers",
"=",
"null",
")",
"{",
"$",
"headers",
"=",
"is_null",
"(",
"$",
"headers",
")",
"?",
"[",
"'Content-Type: application/json; charset=utf-8'",
"]",
":",
"$",
"headers",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"headers",
",",
"$",
"data",
")",
";",
"}"
]
| Sends POST request to LINE Messaging API.
@param string $url Request URL.
@param array $data Request body or resource path.
@param array|null $headers Request headers.
@return Response Response of API request.
@throws CurlExecutionException | [
"Sends",
"POST",
"request",
"to",
"LINE",
"Messaging",
"API",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/HTTPClient/CurlHTTPClient.php#L81-L85 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/TemplateBuilder/ImageCarouselColumnTemplateBuilder.php | ImageCarouselColumnTemplateBuilder.buildTemplate | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$this->template = [
'imageUrl' => $this->imageUrl,
'action' => $this->actionBuilder->buildTemplateAction(),
];
return $this->template;
} | php | public function buildTemplate()
{
if (!empty($this->template)) {
return $this->template;
}
$this->template = [
'imageUrl' => $this->imageUrl,
'action' => $this->actionBuilder->buildTemplateAction(),
];
return $this->template;
} | [
"public",
"function",
"buildTemplate",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"template",
")",
")",
"{",
"return",
"$",
"this",
"->",
"template",
";",
"}",
"$",
"this",
"->",
"template",
"=",
"[",
"'imageUrl'",
"=>",
"$",
"this",
"->",
"imageUrl",
",",
"'action'",
"=>",
"$",
"this",
"->",
"actionBuilder",
"->",
"buildTemplateAction",
"(",
")",
",",
"]",
";",
"return",
"$",
"this",
"->",
"template",
";",
"}"
]
| Builds column of image carousel template structure.
@return array | [
"Builds",
"column",
"of",
"image",
"carousel",
"template",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/TemplateBuilder/ImageCarouselColumnTemplateBuilder.php#L56-L68 | train |
line/line-bot-sdk-php | src/LINEBot/TemplateActionBuilder/DatetimePickerTemplateActionBuilder.php | DatetimePickerTemplateActionBuilder.buildTemplateAction | public function buildTemplateAction()
{
return [
'type' => ActionType::DATETIME_PICKER,
'label' => $this->label,
'data' => $this->data,
'mode' => $this->mode,
'initial' => $this->initial,
'max' => $this->max,
'min' => $this->min,
];
} | php | public function buildTemplateAction()
{
return [
'type' => ActionType::DATETIME_PICKER,
'label' => $this->label,
'data' => $this->data,
'mode' => $this->mode,
'initial' => $this->initial,
'max' => $this->max,
'min' => $this->min,
];
} | [
"public",
"function",
"buildTemplateAction",
"(",
")",
"{",
"return",
"[",
"'type'",
"=>",
"ActionType",
"::",
"DATETIME_PICKER",
",",
"'label'",
"=>",
"$",
"this",
"->",
"label",
",",
"'data'",
"=>",
"$",
"this",
"->",
"data",
",",
"'mode'",
"=>",
"$",
"this",
"->",
"mode",
",",
"'initial'",
"=>",
"$",
"this",
"->",
"initial",
",",
"'max'",
"=>",
"$",
"this",
"->",
"max",
",",
"'min'",
"=>",
"$",
"this",
"->",
"min",
",",
"]",
";",
"}"
]
| Builds datetime picker action structure.
@return array Built datetime picker action structure. | [
"Builds",
"datetime",
"picker",
"action",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/TemplateActionBuilder/DatetimePickerTemplateActionBuilder.php#L80-L91 | train |
line/line-bot-sdk-php | src/LINEBot/TemplateActionBuilder/UriTemplateActionBuilder.php | UriTemplateActionBuilder.buildTemplateAction | public function buildTemplateAction()
{
$templateAction = BuildUtil::removeNullElements([
'type' => ActionType::URI,
'label' => $this->label,
'uri' => $this->uri,
]);
if ($this->altUri) {
$templateAction['altUri'] = $this->altUri->build();
}
return $templateAction;
} | php | public function buildTemplateAction()
{
$templateAction = BuildUtil::removeNullElements([
'type' => ActionType::URI,
'label' => $this->label,
'uri' => $this->uri,
]);
if ($this->altUri) {
$templateAction['altUri'] = $this->altUri->build();
}
return $templateAction;
} | [
"public",
"function",
"buildTemplateAction",
"(",
")",
"{",
"$",
"templateAction",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ActionType",
"::",
"URI",
",",
"'label'",
"=>",
"$",
"this",
"->",
"label",
",",
"'uri'",
"=>",
"$",
"this",
"->",
"uri",
",",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"altUri",
")",
"{",
"$",
"templateAction",
"[",
"'altUri'",
"]",
"=",
"$",
"this",
"->",
"altUri",
"->",
"build",
"(",
")",
";",
"}",
"return",
"$",
"templateAction",
";",
"}"
]
| Builds URI action structure.
@return array Built URI action structure. | [
"Builds",
"URI",
"action",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/TemplateActionBuilder/UriTemplateActionBuilder.php#L58-L71 | train |
line/line-bot-sdk-php | src/LINEBot/SignatureValidator.php | SignatureValidator.validateSignature | public static function validateSignature($body, $channelSecret, $signature)
{
if (!isset($signature)) {
throw new InvalidSignatureException('Signature must not be empty');
}
return hash_equals(base64_encode(hash_hmac('sha256', $body, $channelSecret, true)), $signature);
} | php | public static function validateSignature($body, $channelSecret, $signature)
{
if (!isset($signature)) {
throw new InvalidSignatureException('Signature must not be empty');
}
return hash_equals(base64_encode(hash_hmac('sha256', $body, $channelSecret, true)), $signature);
} | [
"public",
"static",
"function",
"validateSignature",
"(",
"$",
"body",
",",
"$",
"channelSecret",
",",
"$",
"signature",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"signature",
")",
")",
"{",
"throw",
"new",
"InvalidSignatureException",
"(",
"'Signature must not be empty'",
")",
";",
"}",
"return",
"hash_equals",
"(",
"base64_encode",
"(",
"hash_hmac",
"(",
"'sha256'",
",",
"$",
"body",
",",
"$",
"channelSecret",
",",
"true",
")",
")",
",",
"$",
"signature",
")",
";",
"}"
]
| Validate request with signature.
@param string $body Request body.
@param string $channelSecret Your channel secret.
@param string $signature Signature (probably retrieve from HTTP header).
@return bool Request is valid or not.
@throws InvalidSignatureException When empty signature is given. | [
"Validate",
"request",
"with",
"signature",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/SignatureValidator.php#L39-L46 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/IconComponentBuilder.php | IconComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::ICON,
'url' => $this->url,
'margin' => $this->margin,
'size' => $this->size,
'aspectRatio' => $this->aspectRatio,
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::ICON,
'url' => $this->url,
'margin' => $this->margin,
'size' => $this->size,
'aspectRatio' => $this->aspectRatio,
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"ICON",
",",
"'url'",
"=>",
"$",
"this",
"->",
"url",
",",
"'margin'",
"=>",
"$",
"this",
"->",
"margin",
",",
"'size'",
"=>",
"$",
"this",
"->",
"size",
",",
"'aspectRatio'",
"=>",
"$",
"this",
"->",
"aspectRatio",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds icon component structure.
@return array | [
"Builds",
"icon",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/IconComponentBuilder.php#L126-L141 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/SpacerComponentBuilder.php | SpacerComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::SPACER,
'size' => $this->size,
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::SPACER,
'size' => $this->size,
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"SPACER",
",",
"'size'",
"=>",
"$",
"this",
"->",
"size",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds spacer component structure.
@return array | [
"Builds",
"spacer",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/SpacerComponentBuilder.php#L76-L88 | train |
line/line-bot-sdk-php | examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleShopping.php | FlexSampleShopping.get | public static function get()
{
return FlexMessageBuilder::builder()
->setAltText('Shopping')
->setContents(new CarouselContainerBuilder([
self::createItemBubble(111),
self::createItemBubble(112),
self::createMoreBubble()
]));
} | php | public static function get()
{
return FlexMessageBuilder::builder()
->setAltText('Shopping')
->setContents(new CarouselContainerBuilder([
self::createItemBubble(111),
self::createItemBubble(112),
self::createMoreBubble()
]));
} | [
"public",
"static",
"function",
"get",
"(",
")",
"{",
"return",
"FlexMessageBuilder",
"::",
"builder",
"(",
")",
"->",
"setAltText",
"(",
"'Shopping'",
")",
"->",
"setContents",
"(",
"new",
"CarouselContainerBuilder",
"(",
"[",
"self",
"::",
"createItemBubble",
"(",
"111",
")",
",",
"self",
"::",
"createItemBubble",
"(",
"112",
")",
",",
"self",
"::",
"createMoreBubble",
"(",
")",
"]",
")",
")",
";",
"}"
]
| Create sample shopping flex message
@return \LINE\LINEBot\MessageBuilder\FlexMessageBuilder | [
"Create",
"sample",
"shopping",
"flex",
"message"
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleShopping.php#L66-L75 | train |
line/line-bot-sdk-php | src/LINEBot/QuickReplyBuilder/QuickReplyMessageBuilder.php | QuickReplyMessageBuilder.buildQuickReply | public function buildQuickReply()
{
if (!empty($this->quickReply)) {
return $this->quickReply;
}
$items = [];
foreach ($this->buttonBuilders as $buttonBuilder) {
$items[] = $buttonBuilder->buildQuickReplyButton();
}
$this->quickReply = ['items' => $items];
return $this->quickReply;
} | php | public function buildQuickReply()
{
if (!empty($this->quickReply)) {
return $this->quickReply;
}
$items = [];
foreach ($this->buttonBuilders as $buttonBuilder) {
$items[] = $buttonBuilder->buildQuickReplyButton();
}
$this->quickReply = ['items' => $items];
return $this->quickReply;
} | [
"public",
"function",
"buildQuickReply",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"quickReply",
")",
")",
"{",
"return",
"$",
"this",
"->",
"quickReply",
";",
"}",
"$",
"items",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"buttonBuilders",
"as",
"$",
"buttonBuilder",
")",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"buttonBuilder",
"->",
"buildQuickReplyButton",
"(",
")",
";",
"}",
"$",
"this",
"->",
"quickReply",
"=",
"[",
"'items'",
"=>",
"$",
"items",
"]",
";",
"return",
"$",
"this",
"->",
"quickReply",
";",
"}"
]
| Builds button of quick reply structure.
@return array | [
"Builds",
"button",
"of",
"quick",
"reply",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/QuickReplyBuilder/QuickReplyMessageBuilder.php#L51-L66 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/BoxComponentBuilder.php | BoxComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$contents = array_map(function ($componentBuilder) {
/** @var ComponentBuilder $componentBuilder */
return $componentBuilder->build();
}, $this->componentBuilders);
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::BOX,
'layout' => $this->layout,
'contents' => $contents,
'flex' => $this->flex,
'spacing' => $this->spacing,
'margin' => $this->margin,
'action' => BuildUtil::build($this->actionBuilder, 'buildTemplateAction'),
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$contents = array_map(function ($componentBuilder) {
/** @var ComponentBuilder $componentBuilder */
return $componentBuilder->build();
}, $this->componentBuilders);
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::BOX,
'layout' => $this->layout,
'contents' => $contents,
'flex' => $this->flex,
'spacing' => $this->spacing,
'margin' => $this->margin,
'action' => BuildUtil::build($this->actionBuilder, 'buildTemplateAction'),
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"contents",
"=",
"array_map",
"(",
"function",
"(",
"$",
"componentBuilder",
")",
"{",
"/** @var ComponentBuilder $componentBuilder */",
"return",
"$",
"componentBuilder",
"->",
"build",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"componentBuilders",
")",
";",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"BOX",
",",
"'layout'",
"=>",
"$",
"this",
"->",
"layout",
",",
"'contents'",
"=>",
"$",
"contents",
",",
"'flex'",
"=>",
"$",
"this",
"->",
"flex",
",",
"'spacing'",
"=>",
"$",
"this",
"->",
"spacing",
",",
"'margin'",
"=>",
"$",
"this",
"->",
"margin",
",",
"'action'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"actionBuilder",
",",
"'buildTemplateAction'",
")",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds box component structure.
@return array | [
"Builds",
"box",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/BoxComponentBuilder.php#L165-L187 | train |
line/line-bot-sdk-php | examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleRestaurant.php | FlexSampleRestaurant.get | public static function get()
{
return FlexMessageBuilder::builder()
->setAltText('Restaurant')
->setContents(
BubbleContainerBuilder::builder()
->setHero(self::createHeroBlock())
->setBody(self::createBodyBlock())
->setFooter(self::createFooterBlock())
);
} | php | public static function get()
{
return FlexMessageBuilder::builder()
->setAltText('Restaurant')
->setContents(
BubbleContainerBuilder::builder()
->setHero(self::createHeroBlock())
->setBody(self::createBodyBlock())
->setFooter(self::createFooterBlock())
);
} | [
"public",
"static",
"function",
"get",
"(",
")",
"{",
"return",
"FlexMessageBuilder",
"::",
"builder",
"(",
")",
"->",
"setAltText",
"(",
"'Restaurant'",
")",
"->",
"setContents",
"(",
"BubbleContainerBuilder",
"::",
"builder",
"(",
")",
"->",
"setHero",
"(",
"self",
"::",
"createHeroBlock",
"(",
")",
")",
"->",
"setBody",
"(",
"self",
"::",
"createBodyBlock",
"(",
")",
")",
"->",
"setFooter",
"(",
"self",
"::",
"createFooterBlock",
"(",
")",
")",
")",
";",
"}"
]
| Create sample restaurant flex message
@return \LINE\LINEBot\MessageBuilder\FlexMessageBuilder | [
"Create",
"sample",
"restaurant",
"flex",
"message"
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/examples/KitchenSink/src/LINEBot/KitchenSink/EventHandler/MessageHandler/Flex/FlexSampleRestaurant.php#L54-L64 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/ImagemapMessageBuilder.php | ImagemapMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$actions = [];
foreach ($this->imagemapActionBuilders as $builder) {
$actions[] = $builder->buildImagemapAction();
}
$imagemapMessage = [
'type' => MessageType::IMAGEMAP,
'baseUrl' => $this->baseUrl,
'altText' => $this->altText,
'baseSize' => $this->baseSizeBuilder->build(),
'actions' => $actions,
];
if ($this->quickReply) {
$imagemapMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
if ($this->videoBuilder) {
$imagemapMessage['video'] = $this->videoBuilder->build();
}
$this->message[] = $imagemapMessage;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$actions = [];
foreach ($this->imagemapActionBuilders as $builder) {
$actions[] = $builder->buildImagemapAction();
}
$imagemapMessage = [
'type' => MessageType::IMAGEMAP,
'baseUrl' => $this->baseUrl,
'altText' => $this->altText,
'baseSize' => $this->baseSizeBuilder->build(),
'actions' => $actions,
];
if ($this->quickReply) {
$imagemapMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
if ($this->videoBuilder) {
$imagemapMessage['video'] = $this->videoBuilder->build();
}
$this->message[] = $imagemapMessage;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"actions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"imagemapActionBuilders",
"as",
"$",
"builder",
")",
"{",
"$",
"actions",
"[",
"]",
"=",
"$",
"builder",
"->",
"buildImagemapAction",
"(",
")",
";",
"}",
"$",
"imagemapMessage",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"IMAGEMAP",
",",
"'baseUrl'",
"=>",
"$",
"this",
"->",
"baseUrl",
",",
"'altText'",
"=>",
"$",
"this",
"->",
"altText",
",",
"'baseSize'",
"=>",
"$",
"this",
"->",
"baseSizeBuilder",
"->",
"build",
"(",
")",
",",
"'actions'",
"=>",
"$",
"actions",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"imagemapMessage",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"videoBuilder",
")",
"{",
"$",
"imagemapMessage",
"[",
"'video'",
"]",
"=",
"$",
"this",
"->",
"videoBuilder",
"->",
"build",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"imagemapMessage",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds imagemap message strucutre.
@return array | [
"Builds",
"imagemap",
"message",
"strucutre",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/ImagemapMessageBuilder.php#L87-L117 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/TemplateMessageBuilder.php | TemplateMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$templateMessage = [
'type' => MessageType::TEMPLATE,
'altText' => $this->altText,
'template' => $this->templateBuilder->buildTemplate(),
];
if ($this->quickReply) {
$templateMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $templateMessage;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$templateMessage = [
'type' => MessageType::TEMPLATE,
'altText' => $this->altText,
'template' => $this->templateBuilder->buildTemplate(),
];
if ($this->quickReply) {
$templateMessage['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $templateMessage;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"templateMessage",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"TEMPLATE",
",",
"'altText'",
"=>",
"$",
"this",
"->",
"altText",
",",
"'template'",
"=>",
"$",
"this",
"->",
"templateBuilder",
"->",
"buildTemplate",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"templateMessage",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"templateMessage",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds template message structure.
@return array | [
"Builds",
"template",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/TemplateMessageBuilder.php#L65-L84 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/FlexMessageBuilder.php | FlexMessageBuilder.buildMessage | public function buildMessage()
{
if (isset($this->message)) {
return $this->message;
}
$this->message = [
BuildUtil::removeNullElements([
'type' => MessageType::FLEX,
'altText' => $this->altText,
'contents' => $this->containerBuilder->build(),
'quickReply' => BuildUtil::build($this->quickReply, 'buildQuickReply'),
])
];
return $this->message;
} | php | public function buildMessage()
{
if (isset($this->message)) {
return $this->message;
}
$this->message = [
BuildUtil::removeNullElements([
'type' => MessageType::FLEX,
'altText' => $this->altText,
'contents' => $this->containerBuilder->build(),
'quickReply' => BuildUtil::build($this->quickReply, 'buildQuickReply'),
])
];
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"this",
"->",
"message",
"=",
"[",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"MessageType",
"::",
"FLEX",
",",
"'altText'",
"=>",
"$",
"this",
"->",
"altText",
",",
"'contents'",
"=>",
"$",
"this",
"->",
"containerBuilder",
"->",
"build",
"(",
")",
",",
"'quickReply'",
"=>",
"BuildUtil",
"::",
"build",
"(",
"$",
"this",
"->",
"quickReply",
",",
"'buildQuickReply'",
")",
",",
"]",
")",
"]",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds flex message structure.
@return array | [
"Builds",
"flex",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/FlexMessageBuilder.php#L110-L126 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ComponentBuilder/ButtonComponentBuilder.php | ButtonComponentBuilder.build | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::BUTTON,
'action' => $this->actionBuilder->buildTemplateAction(),
'flex' => $this->flex,
'margin' => $this->margin,
'height' => $this->height,
'style' => $this->style,
'color' => $this->color,
'gravity' => $this->gravity,
]);
return $this->component;
} | php | public function build()
{
if (isset($this->component)) {
return $this->component;
}
$this->component = BuildUtil::removeNullElements([
'type' => ComponentType::BUTTON,
'action' => $this->actionBuilder->buildTemplateAction(),
'flex' => $this->flex,
'margin' => $this->margin,
'height' => $this->height,
'style' => $this->style,
'color' => $this->color,
'gravity' => $this->gravity,
]);
return $this->component;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"component",
")",
")",
"{",
"return",
"$",
"this",
"->",
"component",
";",
"}",
"$",
"this",
"->",
"component",
"=",
"BuildUtil",
"::",
"removeNullElements",
"(",
"[",
"'type'",
"=>",
"ComponentType",
"::",
"BUTTON",
",",
"'action'",
"=>",
"$",
"this",
"->",
"actionBuilder",
"->",
"buildTemplateAction",
"(",
")",
",",
"'flex'",
"=>",
"$",
"this",
"->",
"flex",
",",
"'margin'",
"=>",
"$",
"this",
"->",
"margin",
",",
"'height'",
"=>",
"$",
"this",
"->",
"height",
",",
"'style'",
"=>",
"$",
"this",
"->",
"style",
",",
"'color'",
"=>",
"$",
"this",
"->",
"color",
",",
"'gravity'",
"=>",
"$",
"this",
"->",
"gravity",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"component",
";",
"}"
]
| Builds button component structure.
@return array | [
"Builds",
"button",
"component",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ComponentBuilder/ButtonComponentBuilder.php#L183-L201 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/VideoMessageBuilder.php | VideoMessageBuilder.buildMessage | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$video = [
'type' => MessageType::VIDEO,
'originalContentUrl' => $this->originalContentUrl,
'previewImageUrl' => $this->previewImageUrl,
];
if ($this->quickReply) {
$video['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $video;
return $this->message;
} | php | public function buildMessage()
{
if (!empty($this->message)) {
return $this->message;
}
$video = [
'type' => MessageType::VIDEO,
'originalContentUrl' => $this->originalContentUrl,
'previewImageUrl' => $this->previewImageUrl,
];
if ($this->quickReply) {
$video['quickReply'] = $this->quickReply->buildQuickReply();
}
$this->message[] = $video;
return $this->message;
} | [
"public",
"function",
"buildMessage",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"message",
")",
")",
"{",
"return",
"$",
"this",
"->",
"message",
";",
"}",
"$",
"video",
"=",
"[",
"'type'",
"=>",
"MessageType",
"::",
"VIDEO",
",",
"'originalContentUrl'",
"=>",
"$",
"this",
"->",
"originalContentUrl",
",",
"'previewImageUrl'",
"=>",
"$",
"this",
"->",
"previewImageUrl",
",",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"quickReply",
")",
"{",
"$",
"video",
"[",
"'quickReply'",
"]",
"=",
"$",
"this",
"->",
"quickReply",
"->",
"buildQuickReply",
"(",
")",
";",
"}",
"$",
"this",
"->",
"message",
"[",
"]",
"=",
"$",
"video",
";",
"return",
"$",
"this",
"->",
"message",
";",
"}"
]
| Builds video message structure.
@return array | [
"Builds",
"video",
"message",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/VideoMessageBuilder.php#L63-L82 | train |
line/line-bot-sdk-php | src/LINEBot/TemplateActionBuilder/PostbackTemplateActionBuilder.php | PostbackTemplateActionBuilder.buildTemplateAction | public function buildTemplateAction()
{
$action = [
'type' => ActionType::POSTBACK,
'label' => $this->label,
'data' => $this->data,
];
if (isset($this->displayText)) {
// If text is set, append extend field.
$action['displayText'] = $this->displayText;
}
return $action;
} | php | public function buildTemplateAction()
{
$action = [
'type' => ActionType::POSTBACK,
'label' => $this->label,
'data' => $this->data,
];
if (isset($this->displayText)) {
// If text is set, append extend field.
$action['displayText'] = $this->displayText;
}
return $action;
} | [
"public",
"function",
"buildTemplateAction",
"(",
")",
"{",
"$",
"action",
"=",
"[",
"'type'",
"=>",
"ActionType",
"::",
"POSTBACK",
",",
"'label'",
"=>",
"$",
"this",
"->",
"label",
",",
"'data'",
"=>",
"$",
"this",
"->",
"data",
",",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"displayText",
")",
")",
"{",
"// If text is set, append extend field.",
"$",
"action",
"[",
"'displayText'",
"]",
"=",
"$",
"this",
"->",
"displayText",
";",
"}",
"return",
"$",
"action",
";",
"}"
]
| Builds postback action structure.
@return array Built postback action structure. | [
"Builds",
"postback",
"action",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/TemplateActionBuilder/PostbackTemplateActionBuilder.php#L57-L71 | train |
line/line-bot-sdk-php | src/LINEBot/MessageBuilder/Flex/ContainerBuilder/CarouselContainerBuilder.php | CarouselContainerBuilder.build | public function build()
{
if (!empty($this->container)) {
return $this->container;
}
$contents = array_map(function ($containerBuilder) {
return $containerBuilder->build();
}, $this->containerBuilders);
$this->container = [
'type' => ContainerType::CAROUSEL,
'contents' => $contents,
];
return $this->container;
} | php | public function build()
{
if (!empty($this->container)) {
return $this->container;
}
$contents = array_map(function ($containerBuilder) {
return $containerBuilder->build();
}, $this->containerBuilders);
$this->container = [
'type' => ContainerType::CAROUSEL,
'contents' => $contents,
];
return $this->container;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"container",
")",
")",
"{",
"return",
"$",
"this",
"->",
"container",
";",
"}",
"$",
"contents",
"=",
"array_map",
"(",
"function",
"(",
"$",
"containerBuilder",
")",
"{",
"return",
"$",
"containerBuilder",
"->",
"build",
"(",
")",
";",
"}",
",",
"$",
"this",
"->",
"containerBuilders",
")",
";",
"$",
"this",
"->",
"container",
"=",
"[",
"'type'",
"=>",
"ContainerType",
"::",
"CAROUSEL",
",",
"'contents'",
"=>",
"$",
"contents",
",",
"]",
";",
"return",
"$",
"this",
"->",
"container",
";",
"}"
]
| Builds carousel container structure.
@return array | [
"Builds",
"carousel",
"container",
"structure",
"."
]
| 01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e | https://github.com/line/line-bot-sdk-php/blob/01ba4d1c6c0c7ec57b5b34ed5bc6ee0d5f88928e/src/LINEBot/MessageBuilder/Flex/ContainerBuilder/CarouselContainerBuilder.php#L74-L90 | train |
web-push-libs/web-push-php | src/Subscription.php | Subscription.create | public static function create(array $associativeArray): Subscription
{
if (array_key_exists('keys', $associativeArray) && is_array($associativeArray['keys'])) {
return new self(
$associativeArray['endpoint'],
$associativeArray['keys']['p256dh'] ?? null,
$associativeArray['keys']['auth'] ?? null,
$associativeArray['contentEncoding'] ?? "aesgcm"
);
}
if (array_key_exists('publicKey', $associativeArray) || array_key_exists('authToken', $associativeArray) || array_key_exists('contentEncoding', $associativeArray)) {
return new self(
$associativeArray['endpoint'],
$associativeArray['publicKey'] ?? null,
$associativeArray['authToken'] ?? null,
$associativeArray['contentEncoding'] ?? "aesgcm"
);
}
return new self(
$associativeArray['endpoint']
);
} | php | public static function create(array $associativeArray): Subscription
{
if (array_key_exists('keys', $associativeArray) && is_array($associativeArray['keys'])) {
return new self(
$associativeArray['endpoint'],
$associativeArray['keys']['p256dh'] ?? null,
$associativeArray['keys']['auth'] ?? null,
$associativeArray['contentEncoding'] ?? "aesgcm"
);
}
if (array_key_exists('publicKey', $associativeArray) || array_key_exists('authToken', $associativeArray) || array_key_exists('contentEncoding', $associativeArray)) {
return new self(
$associativeArray['endpoint'],
$associativeArray['publicKey'] ?? null,
$associativeArray['authToken'] ?? null,
$associativeArray['contentEncoding'] ?? "aesgcm"
);
}
return new self(
$associativeArray['endpoint']
);
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"associativeArray",
")",
":",
"Subscription",
"{",
"if",
"(",
"array_key_exists",
"(",
"'keys'",
",",
"$",
"associativeArray",
")",
"&&",
"is_array",
"(",
"$",
"associativeArray",
"[",
"'keys'",
"]",
")",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"associativeArray",
"[",
"'endpoint'",
"]",
",",
"$",
"associativeArray",
"[",
"'keys'",
"]",
"[",
"'p256dh'",
"]",
"??",
"null",
",",
"$",
"associativeArray",
"[",
"'keys'",
"]",
"[",
"'auth'",
"]",
"??",
"null",
",",
"$",
"associativeArray",
"[",
"'contentEncoding'",
"]",
"??",
"\"aesgcm\"",
")",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'publicKey'",
",",
"$",
"associativeArray",
")",
"||",
"array_key_exists",
"(",
"'authToken'",
",",
"$",
"associativeArray",
")",
"||",
"array_key_exists",
"(",
"'contentEncoding'",
",",
"$",
"associativeArray",
")",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"associativeArray",
"[",
"'endpoint'",
"]",
",",
"$",
"associativeArray",
"[",
"'publicKey'",
"]",
"??",
"null",
",",
"$",
"associativeArray",
"[",
"'authToken'",
"]",
"??",
"null",
",",
"$",
"associativeArray",
"[",
"'contentEncoding'",
"]",
"??",
"\"aesgcm\"",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"associativeArray",
"[",
"'endpoint'",
"]",
")",
";",
"}"
]
| Subscription factory.
@param array $associativeArray (with keys endpoint, publicKey, authToken, contentEncoding)
@return Subscription
@throws \ErrorException | [
"Subscription",
"factory",
"."
]
| b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27 | https://github.com/web-push-libs/web-push-php/blob/b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27/src/Subscription.php#L66-L89 | train |
web-push-libs/web-push-php | src/VAPID.php | VAPID.getVapidHeaders | public static function getVapidHeaders(string $audience, string $subject, string $publicKey, string $privateKey, string $contentEncoding, ?int $expiration = null)
{
$expirationLimit = time() + 43200; // equal margin of error between 0 and 24h
if (null === $expiration || $expiration > $expirationLimit) {
$expiration = $expirationLimit;
}
$header = [
'typ' => 'JWT',
'alg' => 'ES256',
];
$jwtPayload = json_encode([
'aud' => $audience,
'exp' => $expiration,
'sub' => $subject,
], JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
if (!$jwtPayload) {
throw new \ErrorException('Failed to encode JWT payload in JSON');
}
list($x, $y) = Utils::unserializePublicKey($publicKey);
$jwk = JWK::create([
'kty' => 'EC',
'crv' => 'P-256',
'x' => Base64Url::encode($x),
'y' => Base64Url::encode($y),
'd' => Base64Url::encode($privateKey),
]);
$jsonConverter = new StandardConverter();
$jwsCompactSerializer = new CompactSerializer($jsonConverter);
$jwsBuilder = new JWSBuilder($jsonConverter, AlgorithmManager::create([new ES256()]));
$jws = $jwsBuilder
->create()
->withPayload($jwtPayload)
->addSignature($jwk, $header)
->build();
$jwt = $jwsCompactSerializer->serialize($jws, 0);
$encodedPublicKey = Base64Url::encode($publicKey);
if ($contentEncoding === "aesgcm") {
return [
'Authorization' => 'WebPush '.$jwt,
'Crypto-Key' => 'p256ecdsa='.$encodedPublicKey,
];
} elseif ($contentEncoding === 'aes128gcm') {
return [
'Authorization' => 'vapid t='.$jwt.', k='.$encodedPublicKey,
];
}
throw new \ErrorException('This content encoding is not supported');
} | php | public static function getVapidHeaders(string $audience, string $subject, string $publicKey, string $privateKey, string $contentEncoding, ?int $expiration = null)
{
$expirationLimit = time() + 43200; // equal margin of error between 0 and 24h
if (null === $expiration || $expiration > $expirationLimit) {
$expiration = $expirationLimit;
}
$header = [
'typ' => 'JWT',
'alg' => 'ES256',
];
$jwtPayload = json_encode([
'aud' => $audience,
'exp' => $expiration,
'sub' => $subject,
], JSON_UNESCAPED_SLASHES | JSON_NUMERIC_CHECK);
if (!$jwtPayload) {
throw new \ErrorException('Failed to encode JWT payload in JSON');
}
list($x, $y) = Utils::unserializePublicKey($publicKey);
$jwk = JWK::create([
'kty' => 'EC',
'crv' => 'P-256',
'x' => Base64Url::encode($x),
'y' => Base64Url::encode($y),
'd' => Base64Url::encode($privateKey),
]);
$jsonConverter = new StandardConverter();
$jwsCompactSerializer = new CompactSerializer($jsonConverter);
$jwsBuilder = new JWSBuilder($jsonConverter, AlgorithmManager::create([new ES256()]));
$jws = $jwsBuilder
->create()
->withPayload($jwtPayload)
->addSignature($jwk, $header)
->build();
$jwt = $jwsCompactSerializer->serialize($jws, 0);
$encodedPublicKey = Base64Url::encode($publicKey);
if ($contentEncoding === "aesgcm") {
return [
'Authorization' => 'WebPush '.$jwt,
'Crypto-Key' => 'p256ecdsa='.$encodedPublicKey,
];
} elseif ($contentEncoding === 'aes128gcm') {
return [
'Authorization' => 'vapid t='.$jwt.', k='.$encodedPublicKey,
];
}
throw new \ErrorException('This content encoding is not supported');
} | [
"public",
"static",
"function",
"getVapidHeaders",
"(",
"string",
"$",
"audience",
",",
"string",
"$",
"subject",
",",
"string",
"$",
"publicKey",
",",
"string",
"$",
"privateKey",
",",
"string",
"$",
"contentEncoding",
",",
"?",
"int",
"$",
"expiration",
"=",
"null",
")",
"{",
"$",
"expirationLimit",
"=",
"time",
"(",
")",
"+",
"43200",
";",
"// equal margin of error between 0 and 24h",
"if",
"(",
"null",
"===",
"$",
"expiration",
"||",
"$",
"expiration",
">",
"$",
"expirationLimit",
")",
"{",
"$",
"expiration",
"=",
"$",
"expirationLimit",
";",
"}",
"$",
"header",
"=",
"[",
"'typ'",
"=>",
"'JWT'",
",",
"'alg'",
"=>",
"'ES256'",
",",
"]",
";",
"$",
"jwtPayload",
"=",
"json_encode",
"(",
"[",
"'aud'",
"=>",
"$",
"audience",
",",
"'exp'",
"=>",
"$",
"expiration",
",",
"'sub'",
"=>",
"$",
"subject",
",",
"]",
",",
"JSON_UNESCAPED_SLASHES",
"|",
"JSON_NUMERIC_CHECK",
")",
";",
"if",
"(",
"!",
"$",
"jwtPayload",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Failed to encode JWT payload in JSON'",
")",
";",
"}",
"list",
"(",
"$",
"x",
",",
"$",
"y",
")",
"=",
"Utils",
"::",
"unserializePublicKey",
"(",
"$",
"publicKey",
")",
";",
"$",
"jwk",
"=",
"JWK",
"::",
"create",
"(",
"[",
"'kty'",
"=>",
"'EC'",
",",
"'crv'",
"=>",
"'P-256'",
",",
"'x'",
"=>",
"Base64Url",
"::",
"encode",
"(",
"$",
"x",
")",
",",
"'y'",
"=>",
"Base64Url",
"::",
"encode",
"(",
"$",
"y",
")",
",",
"'d'",
"=>",
"Base64Url",
"::",
"encode",
"(",
"$",
"privateKey",
")",
",",
"]",
")",
";",
"$",
"jsonConverter",
"=",
"new",
"StandardConverter",
"(",
")",
";",
"$",
"jwsCompactSerializer",
"=",
"new",
"CompactSerializer",
"(",
"$",
"jsonConverter",
")",
";",
"$",
"jwsBuilder",
"=",
"new",
"JWSBuilder",
"(",
"$",
"jsonConverter",
",",
"AlgorithmManager",
"::",
"create",
"(",
"[",
"new",
"ES256",
"(",
")",
"]",
")",
")",
";",
"$",
"jws",
"=",
"$",
"jwsBuilder",
"->",
"create",
"(",
")",
"->",
"withPayload",
"(",
"$",
"jwtPayload",
")",
"->",
"addSignature",
"(",
"$",
"jwk",
",",
"$",
"header",
")",
"->",
"build",
"(",
")",
";",
"$",
"jwt",
"=",
"$",
"jwsCompactSerializer",
"->",
"serialize",
"(",
"$",
"jws",
",",
"0",
")",
";",
"$",
"encodedPublicKey",
"=",
"Base64Url",
"::",
"encode",
"(",
"$",
"publicKey",
")",
";",
"if",
"(",
"$",
"contentEncoding",
"===",
"\"aesgcm\"",
")",
"{",
"return",
"[",
"'Authorization'",
"=>",
"'WebPush '",
".",
"$",
"jwt",
",",
"'Crypto-Key'",
"=>",
"'p256ecdsa='",
".",
"$",
"encodedPublicKey",
",",
"]",
";",
"}",
"elseif",
"(",
"$",
"contentEncoding",
"===",
"'aes128gcm'",
")",
"{",
"return",
"[",
"'Authorization'",
"=>",
"'vapid t='",
".",
"$",
"jwt",
".",
"', k='",
".",
"$",
"encodedPublicKey",
",",
"]",
";",
"}",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'This content encoding is not supported'",
")",
";",
"}"
]
| This method takes the required VAPID parameters and returns the required
header to be added to a Web Push Protocol Request.
@param string $audience This must be the origin of the push service
@param string $subject This should be a URL or a 'mailto:' email address
@param string $publicKey The decoded VAPID public key
@param string $privateKey The decoded VAPID private key
@param string $contentEncoding
@param null|int $expiration The expiration of the VAPID JWT. (UNIX timestamp)
@return array Returns an array with the 'Authorization' and 'Crypto-Key' values to be used as headers
@throws \ErrorException | [
"This",
"method",
"takes",
"the",
"required",
"VAPID",
"parameters",
"and",
"returns",
"the",
"required",
"header",
"to",
"be",
"added",
"to",
"a",
"Web",
"Push",
"Protocol",
"Request",
"."
]
| b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27 | https://github.com/web-push-libs/web-push-php/blob/b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27/src/VAPID.php#L113-L167 | train |
web-push-libs/web-push-php | src/VAPID.php | VAPID.createVapidKeys | public static function createVapidKeys(): array
{
$curve = NistCurve::curve256();
$privateKey = $curve->createPrivateKey();
$publicKey = $curve->createPublicKey($privateKey);
$binaryPublicKey = hex2bin(Utils::serializePublicKey($publicKey));
if (!$binaryPublicKey) {
throw new \ErrorException('Failed to convert VAPID public key from hexadecimal to binary');
}
$binaryPrivateKey = hex2bin(str_pad(gmp_strval($privateKey->getSecret(), 16), 2 * self::PRIVATE_KEY_LENGTH, '0', STR_PAD_LEFT));
if (!$binaryPrivateKey) {
throw new \ErrorException('Failed to convert VAPID private key from hexadecimal to binary');
}
return [
'publicKey' => Base64Url::encode($binaryPublicKey),
'privateKey' => Base64Url::encode($binaryPrivateKey)
];
} | php | public static function createVapidKeys(): array
{
$curve = NistCurve::curve256();
$privateKey = $curve->createPrivateKey();
$publicKey = $curve->createPublicKey($privateKey);
$binaryPublicKey = hex2bin(Utils::serializePublicKey($publicKey));
if (!$binaryPublicKey) {
throw new \ErrorException('Failed to convert VAPID public key from hexadecimal to binary');
}
$binaryPrivateKey = hex2bin(str_pad(gmp_strval($privateKey->getSecret(), 16), 2 * self::PRIVATE_KEY_LENGTH, '0', STR_PAD_LEFT));
if (!$binaryPrivateKey) {
throw new \ErrorException('Failed to convert VAPID private key from hexadecimal to binary');
}
return [
'publicKey' => Base64Url::encode($binaryPublicKey),
'privateKey' => Base64Url::encode($binaryPrivateKey)
];
} | [
"public",
"static",
"function",
"createVapidKeys",
"(",
")",
":",
"array",
"{",
"$",
"curve",
"=",
"NistCurve",
"::",
"curve256",
"(",
")",
";",
"$",
"privateKey",
"=",
"$",
"curve",
"->",
"createPrivateKey",
"(",
")",
";",
"$",
"publicKey",
"=",
"$",
"curve",
"->",
"createPublicKey",
"(",
"$",
"privateKey",
")",
";",
"$",
"binaryPublicKey",
"=",
"hex2bin",
"(",
"Utils",
"::",
"serializePublicKey",
"(",
"$",
"publicKey",
")",
")",
";",
"if",
"(",
"!",
"$",
"binaryPublicKey",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Failed to convert VAPID public key from hexadecimal to binary'",
")",
";",
"}",
"$",
"binaryPrivateKey",
"=",
"hex2bin",
"(",
"str_pad",
"(",
"gmp_strval",
"(",
"$",
"privateKey",
"->",
"getSecret",
"(",
")",
",",
"16",
")",
",",
"2",
"*",
"self",
"::",
"PRIVATE_KEY_LENGTH",
",",
"'0'",
",",
"STR_PAD_LEFT",
")",
")",
";",
"if",
"(",
"!",
"$",
"binaryPrivateKey",
")",
"{",
"throw",
"new",
"\\",
"ErrorException",
"(",
"'Failed to convert VAPID private key from hexadecimal to binary'",
")",
";",
"}",
"return",
"[",
"'publicKey'",
"=>",
"Base64Url",
"::",
"encode",
"(",
"$",
"binaryPublicKey",
")",
",",
"'privateKey'",
"=>",
"Base64Url",
"::",
"encode",
"(",
"$",
"binaryPrivateKey",
")",
"]",
";",
"}"
]
| This method creates VAPID keys in case you would not be able to have a Linux bash.
DO NOT create keys at each initialization! Save those keys and reuse them.
@return array
@throws \ErrorException | [
"This",
"method",
"creates",
"VAPID",
"keys",
"in",
"case",
"you",
"would",
"not",
"be",
"able",
"to",
"have",
"a",
"Linux",
"bash",
".",
"DO",
"NOT",
"create",
"keys",
"at",
"each",
"initialization!",
"Save",
"those",
"keys",
"and",
"reuse",
"them",
"."
]
| b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27 | https://github.com/web-push-libs/web-push-php/blob/b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27/src/VAPID.php#L176-L196 | train |
web-push-libs/web-push-php | src/WebPush.php | WebPush.flush | public function flush(?int $batchSize = null): \Generator
{
if (null === $this->notifications || empty($this->notifications)) {
yield from [];
return;
}
if (null === $batchSize) {
$batchSize = $this->defaultOptions['batchSize'];
}
$batches = array_chunk($this->notifications, $batchSize);
// reset queue
$this->notifications = [];
foreach ($batches as $batch) {
// for each endpoint server type
$requests = $this->prepare($batch);
$promises = [];
foreach ($requests as $request) {
$promises[] = $this->client->sendAsync($request)
->then(function ($response) use ($request) {
/** @var ResponseInterface $response * */
return new MessageSentReport($request, $response);
})
->otherwise(function ($reason) {
/** @var RequestException $reason **/
return new MessageSentReport($reason->getRequest(), $reason->getResponse(), false, $reason->getMessage());
});
}
foreach ($promises as $promise) {
yield $promise->wait();
}
}
if ($this->reuseVAPIDHeaders) {
$this->vapidHeaders = [];
}
} | php | public function flush(?int $batchSize = null): \Generator
{
if (null === $this->notifications || empty($this->notifications)) {
yield from [];
return;
}
if (null === $batchSize) {
$batchSize = $this->defaultOptions['batchSize'];
}
$batches = array_chunk($this->notifications, $batchSize);
// reset queue
$this->notifications = [];
foreach ($batches as $batch) {
// for each endpoint server type
$requests = $this->prepare($batch);
$promises = [];
foreach ($requests as $request) {
$promises[] = $this->client->sendAsync($request)
->then(function ($response) use ($request) {
/** @var ResponseInterface $response * */
return new MessageSentReport($request, $response);
})
->otherwise(function ($reason) {
/** @var RequestException $reason **/
return new MessageSentReport($reason->getRequest(), $reason->getResponse(), false, $reason->getMessage());
});
}
foreach ($promises as $promise) {
yield $promise->wait();
}
}
if ($this->reuseVAPIDHeaders) {
$this->vapidHeaders = [];
}
} | [
"public",
"function",
"flush",
"(",
"?",
"int",
"$",
"batchSize",
"=",
"null",
")",
":",
"\\",
"Generator",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"notifications",
"||",
"empty",
"(",
"$",
"this",
"->",
"notifications",
")",
")",
"{",
"yield",
"from",
"[",
"]",
";",
"return",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"batchSize",
")",
"{",
"$",
"batchSize",
"=",
"$",
"this",
"->",
"defaultOptions",
"[",
"'batchSize'",
"]",
";",
"}",
"$",
"batches",
"=",
"array_chunk",
"(",
"$",
"this",
"->",
"notifications",
",",
"$",
"batchSize",
")",
";",
"// reset queue",
"$",
"this",
"->",
"notifications",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"batches",
"as",
"$",
"batch",
")",
"{",
"// for each endpoint server type",
"$",
"requests",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"batch",
")",
";",
"$",
"promises",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"requests",
"as",
"$",
"request",
")",
"{",
"$",
"promises",
"[",
"]",
"=",
"$",
"this",
"->",
"client",
"->",
"sendAsync",
"(",
"$",
"request",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"response",
")",
"use",
"(",
"$",
"request",
")",
"{",
"/** @var ResponseInterface $response * */",
"return",
"new",
"MessageSentReport",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
")",
"->",
"otherwise",
"(",
"function",
"(",
"$",
"reason",
")",
"{",
"/** @var RequestException $reason **/",
"return",
"new",
"MessageSentReport",
"(",
"$",
"reason",
"->",
"getRequest",
"(",
")",
",",
"$",
"reason",
"->",
"getResponse",
"(",
")",
",",
"false",
",",
"$",
"reason",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
")",
";",
"}",
"foreach",
"(",
"$",
"promises",
"as",
"$",
"promise",
")",
"{",
"yield",
"$",
"promise",
"->",
"wait",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"reuseVAPIDHeaders",
")",
"{",
"$",
"this",
"->",
"vapidHeaders",
"=",
"[",
"]",
";",
"}",
"}"
]
| Flush notifications. Triggers the requests.
@param null|int $batchSize Defaults the value defined in defaultOptions during instantiation (which defaults to 1000).
@return \Generator|MessageSentReport[]
@throws \ErrorException | [
"Flush",
"notifications",
".",
"Triggers",
"the",
"requests",
"."
]
| b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27 | https://github.com/web-push-libs/web-push-php/blob/b1e09e93fbbf3d4f95cee79a61191bd9df9f8f27/src/WebPush.php#L150-L192 | train |
appzcoder/crud-generator | src/Commands/CrudModelCommand.php | CrudModelCommand.createRelationshipFunction | protected function createRelationshipFunction(&$stub, $relationshipName, $relationshipType, $argsString)
{
$tabIndent = ' ';
$code = "public function " . $relationshipName . "()\n" . $tabIndent . "{\n" . $tabIndent . $tabIndent
. "return \$this->" . $relationshipType . "(" . $argsString . ");"
. "\n" . $tabIndent . "}";
$str = '{{relationships}}';
$stub = str_replace($str, $code . "\n" . $tabIndent . $str, $stub);
return $this;
} | php | protected function createRelationshipFunction(&$stub, $relationshipName, $relationshipType, $argsString)
{
$tabIndent = ' ';
$code = "public function " . $relationshipName . "()\n" . $tabIndent . "{\n" . $tabIndent . $tabIndent
. "return \$this->" . $relationshipType . "(" . $argsString . ");"
. "\n" . $tabIndent . "}";
$str = '{{relationships}}';
$stub = str_replace($str, $code . "\n" . $tabIndent . $str, $stub);
return $this;
} | [
"protected",
"function",
"createRelationshipFunction",
"(",
"&",
"$",
"stub",
",",
"$",
"relationshipName",
",",
"$",
"relationshipType",
",",
"$",
"argsString",
")",
"{",
"$",
"tabIndent",
"=",
"' '",
";",
"$",
"code",
"=",
"\"public function \"",
".",
"$",
"relationshipName",
".",
"\"()\\n\"",
".",
"$",
"tabIndent",
".",
"\"{\\n\"",
".",
"$",
"tabIndent",
".",
"$",
"tabIndent",
".",
"\"return \\$this->\"",
".",
"$",
"relationshipType",
".",
"\"(\"",
".",
"$",
"argsString",
".",
"\");\"",
".",
"\"\\n\"",
".",
"$",
"tabIndent",
".",
"\"}\"",
";",
"$",
"str",
"=",
"'{{relationships}}'",
";",
"$",
"stub",
"=",
"str_replace",
"(",
"$",
"str",
",",
"$",
"code",
".",
"\"\\n\"",
".",
"$",
"tabIndent",
".",
"$",
"str",
",",
"$",
"stub",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Create the code for a model relationship
@param string $stub
@param string $relationshipName the name of the function, e.g. owners
@param string $relationshipType the type of the relationship, hasOne, hasMany, belongsTo etc
@param array $relationshipArgs args for the relationship function | [
"Create",
"the",
"code",
"for",
"a",
"model",
"relationship"
]
| e086cdb6a9497ddb80c849626aa22ab1e379b4a4 | https://github.com/appzcoder/crud-generator/blob/e086cdb6a9497ddb80c849626aa22ab1e379b4a4/src/Commands/CrudModelCommand.php#L198-L209 | train |
appzcoder/crud-generator | src/Commands/CrudApiCommand.php | CrudApiCommand.processJSONForeignKeys | protected function processJSONForeignKeys($file)
{
$json = File::get($file);
$fields = json_decode($json);
if (! property_exists($fields, 'foreign_keys')) {
return '';
}
$foreignKeysString = '';
foreach ($fields->foreign_keys as $foreign_key) {
$foreignKeysString .= $foreign_key->column . '#' . $foreign_key->references . '#' . $foreign_key->on;
if (property_exists($foreign_key, 'onDelete')) {
$foreignKeysString .= '#' . $foreign_key->onDelete;
}
if (property_exists($foreign_key, 'onUpdate')) {
$foreignKeysString .= '#' . $foreign_key->onUpdate;
}
$foreignKeysString .= ',';
}
$foreignKeysString = rtrim($foreignKeysString, ',');
return $foreignKeysString;
} | php | protected function processJSONForeignKeys($file)
{
$json = File::get($file);
$fields = json_decode($json);
if (! property_exists($fields, 'foreign_keys')) {
return '';
}
$foreignKeysString = '';
foreach ($fields->foreign_keys as $foreign_key) {
$foreignKeysString .= $foreign_key->column . '#' . $foreign_key->references . '#' . $foreign_key->on;
if (property_exists($foreign_key, 'onDelete')) {
$foreignKeysString .= '#' . $foreign_key->onDelete;
}
if (property_exists($foreign_key, 'onUpdate')) {
$foreignKeysString .= '#' . $foreign_key->onUpdate;
}
$foreignKeysString .= ',';
}
$foreignKeysString = rtrim($foreignKeysString, ',');
return $foreignKeysString;
} | [
"protected",
"function",
"processJSONForeignKeys",
"(",
"$",
"file",
")",
"{",
"$",
"json",
"=",
"File",
"::",
"get",
"(",
"$",
"file",
")",
";",
"$",
"fields",
"=",
"json_decode",
"(",
"$",
"json",
")",
";",
"if",
"(",
"!",
"property_exists",
"(",
"$",
"fields",
",",
"'foreign_keys'",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"foreignKeysString",
"=",
"''",
";",
"foreach",
"(",
"$",
"fields",
"->",
"foreign_keys",
"as",
"$",
"foreign_key",
")",
"{",
"$",
"foreignKeysString",
".=",
"$",
"foreign_key",
"->",
"column",
".",
"'#'",
".",
"$",
"foreign_key",
"->",
"references",
".",
"'#'",
".",
"$",
"foreign_key",
"->",
"on",
";",
"if",
"(",
"property_exists",
"(",
"$",
"foreign_key",
",",
"'onDelete'",
")",
")",
"{",
"$",
"foreignKeysString",
".=",
"'#'",
".",
"$",
"foreign_key",
"->",
"onDelete",
";",
"}",
"if",
"(",
"property_exists",
"(",
"$",
"foreign_key",
",",
"'onUpdate'",
")",
")",
"{",
"$",
"foreignKeysString",
".=",
"'#'",
".",
"$",
"foreign_key",
"->",
"onUpdate",
";",
"}",
"$",
"foreignKeysString",
".=",
"','",
";",
"}",
"$",
"foreignKeysString",
"=",
"rtrim",
"(",
"$",
"foreignKeysString",
",",
"','",
")",
";",
"return",
"$",
"foreignKeysString",
";",
"}"
]
| Process the JSON Foreign keys.
@param string $file
@return string | [
"Process",
"the",
"JSON",
"Foreign",
"keys",
"."
]
| e086cdb6a9497ddb80c849626aa22ab1e379b4a4 | https://github.com/appzcoder/crud-generator/blob/e086cdb6a9497ddb80c849626aa22ab1e379b4a4/src/Commands/CrudApiCommand.php#L190-L217 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.