repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
39
1.84M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
mollie/mollie-api-php
src/Resources/Customer.php
Customer.cancelSubscription
public function cancelSubscription($subscriptionId) { return $this->client->subscriptions->cancelFor($this, $subscriptionId, $this->getPresetOptions()); }
php
public function cancelSubscription($subscriptionId) { return $this->client->subscriptions->cancelFor($this, $subscriptionId, $this->getPresetOptions()); }
[ "public", "function", "cancelSubscription", "(", "$", "subscriptionId", ")", "{", "return", "$", "this", "->", "client", "->", "subscriptions", "->", "cancelFor", "(", "$", "this", ",", "$", "subscriptionId", ",", "$", "this", "->", "getPresetOptions", "(", ")", ")", ";", "}" ]
@param string $subscriptionId @return null
[ "@param", "string", "$subscriptionId" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L132-L135
mollie/mollie-api-php
src/Resources/Customer.php
Customer.subscriptions
public function subscriptions() { return $this->client->subscriptions->listFor($this, null, null, $this->getPresetOptions()); }
php
public function subscriptions() { return $this->client->subscriptions->listFor($this, null, null, $this->getPresetOptions()); }
[ "public", "function", "subscriptions", "(", ")", "{", "return", "$", "this", "->", "client", "->", "subscriptions", "->", "listFor", "(", "$", "this", ",", "null", ",", "null", ",", "$", "this", "->", "getPresetOptions", "(", ")", ")", ";", "}" ]
Get all subscriptions for this customer @return SubscriptionCollection
[ "Get", "all", "subscriptions", "for", "this", "customer" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L142-L145
mollie/mollie-api-php
src/Resources/Customer.php
Customer.createMandate
public function createMandate(array $options = [], array $filters = []) { return $this->client->mandates->createFor($this, $options, $filters); }
php
public function createMandate(array $options = [], array $filters = []) { return $this->client->mandates->createFor($this, $options, $filters); }
[ "public", "function", "createMandate", "(", "array", "$", "options", "=", "[", "]", ",", "array", "$", "filters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "mandates", "->", "createFor", "(", "$", "this", ",", "$", "options", ",", "$", "filters", ")", ";", "}" ]
@param array $options @param array $filters @return Mandate
[ "@param", "array", "$options", "@param", "array", "$filters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L153-L156
mollie/mollie-api-php
src/Resources/Customer.php
Customer.getMandate
public function getMandate($mandateId, array $parameters = []) { return $this->client->mandates->getFor($this, $mandateId, $parameters); }
php
public function getMandate($mandateId, array $parameters = []) { return $this->client->mandates->getFor($this, $mandateId, $parameters); }
[ "public", "function", "getMandate", "(", "$", "mandateId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "mandates", "->", "getFor", "(", "$", "this", ",", "$", "mandateId", ",", "$", "parameters", ")", ";", "}" ]
@param string $mandateId @param array $parameters @return Mandate
[ "@param", "string", "$mandateId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L164-L167
mollie/mollie-api-php
src/Resources/Customer.php
Customer.revokeMandate
public function revokeMandate($mandateId) { return $this->client->mandates->revokeFor($this, $mandateId, $this->getPresetOptions()); }
php
public function revokeMandate($mandateId) { return $this->client->mandates->revokeFor($this, $mandateId, $this->getPresetOptions()); }
[ "public", "function", "revokeMandate", "(", "$", "mandateId", ")", "{", "return", "$", "this", "->", "client", "->", "mandates", "->", "revokeFor", "(", "$", "this", ",", "$", "mandateId", ",", "$", "this", "->", "getPresetOptions", "(", ")", ")", ";", "}" ]
@param string $mandateId @return null
[ "@param", "string", "$mandateId" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L174-L177
mollie/mollie-api-php
src/Resources/Customer.php
Customer.mandates
public function mandates() { return $this->client->mandates->listFor($this, null, null, $this->getPresetOptions()); }
php
public function mandates() { return $this->client->mandates->listFor($this, null, null, $this->getPresetOptions()); }
[ "public", "function", "mandates", "(", ")", "{", "return", "$", "this", "->", "client", "->", "mandates", "->", "listFor", "(", "$", "this", ",", "null", ",", "null", ",", "$", "this", "->", "getPresetOptions", "(", ")", ")", ";", "}" ]
Get all mandates for this customer @return MandateCollection
[ "Get", "all", "mandates", "for", "this", "customer" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L184-L187
mollie/mollie-api-php
src/Resources/Customer.php
Customer.hasValidMandate
public function hasValidMandate() { $mandates = $this->mandates(); foreach ($mandates as $mandate) { if ($mandate->isValid()) { return true; } } return false; }
php
public function hasValidMandate() { $mandates = $this->mandates(); foreach ($mandates as $mandate) { if ($mandate->isValid()) { return true; } } return false; }
[ "public", "function", "hasValidMandate", "(", ")", "{", "$", "mandates", "=", "$", "this", "->", "mandates", "(", ")", ";", "foreach", "(", "$", "mandates", "as", "$", "mandate", ")", "{", "if", "(", "$", "mandate", "->", "isValid", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Helper function to check for mandate with status valid @return bool
[ "Helper", "function", "to", "check", "for", "mandate", "with", "status", "valid" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L194-L204
mollie/mollie-api-php
src/Resources/Customer.php
Customer.hasValidMandateForMethod
public function hasValidMandateForMethod($method) { $mandates = $this->mandates(); foreach ($mandates as $mandate) { if ($mandate->method === $method && $mandate->isValid()) { return true; } } return false; }
php
public function hasValidMandateForMethod($method) { $mandates = $this->mandates(); foreach ($mandates as $mandate) { if ($mandate->method === $method && $mandate->isValid()) { return true; } } return false; }
[ "public", "function", "hasValidMandateForMethod", "(", "$", "method", ")", "{", "$", "mandates", "=", "$", "this", "->", "mandates", "(", ")", ";", "foreach", "(", "$", "mandates", "as", "$", "mandate", ")", "{", "if", "(", "$", "mandate", "->", "method", "===", "$", "method", "&&", "$", "mandate", "->", "isValid", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Helper function to check for specific payment method mandate with status valid @return bool
[ "Helper", "function", "to", "check", "for", "specific", "payment", "method", "mandate", "with", "status", "valid" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L211-L221
mollie/mollie-api-php
src/Resources/Customer.php
Customer.getPresetOptions
private function getPresetOptions() { $options = []; if($this->client->usesOAuth()) { $options["testmode"] = $this->mode === "test" ? true : false; } return $options; }
php
private function getPresetOptions() { $options = []; if($this->client->usesOAuth()) { $options["testmode"] = $this->mode === "test" ? true : false; } return $options; }
[ "private", "function", "getPresetOptions", "(", ")", "{", "$", "options", "=", "[", "]", ";", "if", "(", "$", "this", "->", "client", "->", "usesOAuth", "(", ")", ")", "{", "$", "options", "[", "\"testmode\"", "]", "=", "$", "this", "->", "mode", "===", "\"test\"", "?", "true", ":", "false", ";", "}", "return", "$", "options", ";", "}" ]
When accessed by oAuth we want to pass the testmode by default @return array
[ "When", "accessed", "by", "oAuth", "we", "want", "to", "pass", "the", "testmode", "by", "default" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Customer.php#L228-L236
mollie/mollie-api-php
src/Endpoints/ShipmentEndpoint.php
ShipmentEndpoint.createFor
public function createFor(Order $order, array $options = [], array $filters = []) { return $this->createForId($order->id, $options, $filters); }
php
public function createFor(Order $order, array $options = [], array $filters = []) { return $this->createForId($order->id, $options, $filters); }
[ "public", "function", "createFor", "(", "Order", "$", "order", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "filters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "createForId", "(", "$", "order", "->", "id", ",", "$", "options", ",", "$", "filters", ")", ";", "}" ]
Create a shipment for some order lines. You can provide an empty array for the "lines" option to include all unshipped lines for this order. @param Order $order @param array $options @param array $filters @return Shipment @throws \Mollie\Api\Exceptions\ApiException
[ "Create", "a", "shipment", "for", "some", "order", "lines", ".", "You", "can", "provide", "an", "empty", "array", "for", "the", "lines", "option", "to", "include", "all", "unshipped", "lines", "for", "this", "order", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/ShipmentEndpoint.php#L53-L56
mollie/mollie-api-php
src/Endpoints/ShipmentEndpoint.php
ShipmentEndpoint.createForId
public function createForId($orderId, array $options = [], array $filters = []) { $this->parentId = $orderId; return parent::rest_create($options, $filters); }
php
public function createForId($orderId, array $options = [], array $filters = []) { $this->parentId = $orderId; return parent::rest_create($options, $filters); }
[ "public", "function", "createForId", "(", "$", "orderId", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "filters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "orderId", ";", "return", "parent", "::", "rest_create", "(", "$", "options", ",", "$", "filters", ")", ";", "}" ]
Create a shipment for some order lines. You can provide an empty array for the "lines" option to include all unshipped lines for this order. @param string $orderId @param array $options @param array $filters @return Shipment @throws \Mollie\Api\Exceptions\ApiException
[ "Create", "a", "shipment", "for", "some", "order", "lines", ".", "You", "can", "provide", "an", "empty", "array", "for", "the", "lines", "option", "to", "include", "all", "unshipped", "lines", "for", "this", "order", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/ShipmentEndpoint.php#L69-L74
mollie/mollie-api-php
src/Endpoints/ShipmentEndpoint.php
ShipmentEndpoint.getFor
public function getFor(Order $order, $shipmentId, array $parameters = []) { return $this->getForId($order->id, $shipmentId, $parameters); }
php
public function getFor(Order $order, $shipmentId, array $parameters = []) { return $this->getForId($order->id, $shipmentId, $parameters); }
[ "public", "function", "getFor", "(", "Order", "$", "order", ",", "$", "shipmentId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getForId", "(", "$", "order", "->", "id", ",", "$", "shipmentId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a single shipment and the order lines shipped by a shipment’s ID. @param Order $order @param string $shipmentId @param array $parameters @return Shipment @throws \Mollie\Api\Exceptions\ApiException
[ "Retrieve", "a", "single", "shipment", "and", "the", "order", "lines", "shipped", "by", "a", "shipment’s", "ID", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/ShipmentEndpoint.php#L86-L89
mollie/mollie-api-php
src/Endpoints/ShipmentEndpoint.php
ShipmentEndpoint.getForId
public function getForId($orderId, $shipmentId, array $parameters = []) { $this->parentId = $orderId; return parent::rest_read($shipmentId, $parameters); }
php
public function getForId($orderId, $shipmentId, array $parameters = []) { $this->parentId = $orderId; return parent::rest_read($shipmentId, $parameters); }
[ "public", "function", "getForId", "(", "$", "orderId", ",", "$", "shipmentId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "orderId", ";", "return", "parent", "::", "rest_read", "(", "$", "shipmentId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a single shipment and the order lines shipped by a shipment’s ID. @param string $orderId @param string $shipmentId @param array $parameters @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Shipment @throws \Mollie\Api\Exceptions\ApiException
[ "Retrieve", "a", "single", "shipment", "and", "the", "order", "lines", "shipped", "by", "a", "shipment’s", "ID", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/ShipmentEndpoint.php#L101-L106
mollie/mollie-api-php
src/Endpoints/ShipmentEndpoint.php
ShipmentEndpoint.listForId
public function listForId($orderId, array $parameters = []) { $this->parentId = $orderId; return parent::rest_list(null, null, $parameters); }
php
public function listForId($orderId, array $parameters = []) { $this->parentId = $orderId; return parent::rest_list(null, null, $parameters); }
[ "public", "function", "listForId", "(", "$", "orderId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "orderId", ";", "return", "parent", "::", "rest_list", "(", "null", ",", "null", ",", "$", "parameters", ")", ";", "}" ]
Return all shipments for the provided Order id. @param string $orderId @param array $parameters @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\ShipmentCollection @throws \Mollie\Api\Exceptions\ApiException
[ "Return", "all", "shipments", "for", "the", "provided", "Order", "id", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/ShipmentEndpoint.php#L131-L136
mollie/mollie-api-php
src/Endpoints/MandateEndpoint.php
MandateEndpoint.getFor
public function getFor(Customer $customer, $mandateId, array $parameters = []) { return $this->getForId($customer->id, $mandateId, $parameters); }
php
public function getFor(Customer $customer, $mandateId, array $parameters = []) { return $this->getForId($customer->id, $mandateId, $parameters); }
[ "public", "function", "getFor", "(", "Customer", "$", "customer", ",", "$", "mandateId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getForId", "(", "$", "customer", "->", "id", ",", "$", "mandateId", ",", "$", "parameters", ")", ";", "}" ]
@param Customer $customer @param string $mandateId @param array $parameters @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Mandate @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "Customer", "$customer", "@param", "string", "$mandateId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/MandateEndpoint.php#L73-L76
mollie/mollie-api-php
src/Endpoints/MandateEndpoint.php
MandateEndpoint.getForId
public function getForId($customerId, $mandateId, array $parameters = []) { $this->parentId = $customerId; return parent::rest_read($mandateId, $parameters); }
php
public function getForId($customerId, $mandateId, array $parameters = []) { $this->parentId = $customerId; return parent::rest_read($mandateId, $parameters); }
[ "public", "function", "getForId", "(", "$", "customerId", ",", "$", "mandateId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "customerId", ";", "return", "parent", "::", "rest_read", "(", "$", "mandateId", ",", "$", "parameters", ")", ";", "}" ]
@param string $customerId @param string $mandateId @param array $parameters @return \Mollie\Api\Resources\BaseResource @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "string", "$customerId", "@param", "string", "$mandateId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/MandateEndpoint.php#L86-L91
mollie/mollie-api-php
src/Endpoints/MandateEndpoint.php
MandateEndpoint.revokeFor
public function revokeFor(Customer $customer, $mandateId, $data = []) { return $this->revokeForId($customer->id, $mandateId, $data); }
php
public function revokeFor(Customer $customer, $mandateId, $data = []) { return $this->revokeForId($customer->id, $mandateId, $data); }
[ "public", "function", "revokeFor", "(", "Customer", "$", "customer", ",", "$", "mandateId", ",", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "revokeForId", "(", "$", "customer", "->", "id", ",", "$", "mandateId", ",", "$", "data", ")", ";", "}" ]
@param Customer $customer @param string $mandateId @param array $data @return null @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "Customer", "$customer", "@param", "string", "$mandateId", "@param", "array", "$data" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/MandateEndpoint.php#L131-L134
mollie/mollie-api-php
src/Endpoints/MandateEndpoint.php
MandateEndpoint.revokeForId
public function revokeForId($customerId, $mandateId, $data = []) { $this->parentId = $customerId; return parent::rest_delete($mandateId, $data); }
php
public function revokeForId($customerId, $mandateId, $data = []) { $this->parentId = $customerId; return parent::rest_delete($mandateId, $data); }
[ "public", "function", "revokeForId", "(", "$", "customerId", ",", "$", "mandateId", ",", "$", "data", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "customerId", ";", "return", "parent", "::", "rest_delete", "(", "$", "mandateId", ",", "$", "data", ")", ";", "}" ]
@param string $customerId @param string $mandateId @param array $data @return null @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "string", "$customerId", "@param", "string", "$mandateId", "@param", "array", "$data" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/MandateEndpoint.php#L144-L149
mollie/mollie-api-php
src/Resources/Profile.php
Profile.chargebacks
public function chargebacks() { if (!isset($this->_links->chargebacks->href)) { return new ChargebackCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->chargebacks->href); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->chargebacks, Chargeback::class, $result->_links ); }
php
public function chargebacks() { if (!isset($this->_links->chargebacks->href)) { return new ChargebackCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->chargebacks->href); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->chargebacks, Chargeback::class, $result->_links ); }
[ "public", "function", "chargebacks", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "chargebacks", "->", "href", ")", ")", "{", "return", "new", "ChargebackCollection", "(", "$", "this", "->", "client", ",", "0", ",", "null", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_GET", ",", "$", "this", "->", "_links", "->", "chargebacks", "->", "href", ")", ";", "return", "ResourceFactory", "::", "createCursorResourceCollection", "(", "$", "this", "->", "client", ",", "$", "result", "->", "_embedded", "->", "chargebacks", ",", "Chargeback", "::", "class", ",", "$", "result", "->", "_links", ")", ";", "}" ]
Retrieves all chargebacks associated with this profile @return ChargebackCollection @throws ApiException
[ "Retrieves", "all", "chargebacks", "associated", "with", "this", "profile" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Profile.php#L132-L146
mollie/mollie-api-php
src/Resources/Profile.php
Profile.methods
public function methods() { if (!isset($this->_links->methods->href)) { return new MethodCollection(0, null); } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->methods->href); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->methods, Method::class, $result->_links ); }
php
public function methods() { if (!isset($this->_links->methods->href)) { return new MethodCollection(0, null); } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->methods->href); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->methods, Method::class, $result->_links ); }
[ "public", "function", "methods", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "methods", "->", "href", ")", ")", "{", "return", "new", "MethodCollection", "(", "0", ",", "null", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_GET", ",", "$", "this", "->", "_links", "->", "methods", "->", "href", ")", ";", "return", "ResourceFactory", "::", "createCursorResourceCollection", "(", "$", "this", "->", "client", ",", "$", "result", "->", "_embedded", "->", "methods", ",", "Method", "::", "class", ",", "$", "result", "->", "_links", ")", ";", "}" ]
Retrieves all methods activated on this profile @return MethodCollection @throws ApiException
[ "Retrieves", "all", "methods", "activated", "on", "this", "profile" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Profile.php#L154-L168
mollie/mollie-api-php
src/Resources/Profile.php
Profile.enableMethod
public function enableMethod($methodId, array $data = []) { return $this->client->profileMethods->createFor($this, $methodId, $data); }
php
public function enableMethod($methodId, array $data = []) { return $this->client->profileMethods->createFor($this, $methodId, $data); }
[ "public", "function", "enableMethod", "(", "$", "methodId", ",", "array", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "profileMethods", "->", "createFor", "(", "$", "this", ",", "$", "methodId", ",", "$", "data", ")", ";", "}" ]
Enable a payment method for this profile. @param string $methodId @param array $data @return Method @throws ApiException
[ "Enable", "a", "payment", "method", "for", "this", "profile", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Profile.php#L178-L181
mollie/mollie-api-php
src/Resources/Profile.php
Profile.disableMethod
public function disableMethod($methodId, array $data = []) { return $this->client->profileMethods->deleteFor($this, $methodId, $data); }
php
public function disableMethod($methodId, array $data = []) { return $this->client->profileMethods->deleteFor($this, $methodId, $data); }
[ "public", "function", "disableMethod", "(", "$", "methodId", ",", "array", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "profileMethods", "->", "deleteFor", "(", "$", "this", ",", "$", "methodId", ",", "$", "data", ")", ";", "}" ]
Disable a payment method for this profile. @param string $methodId @param array $data @return Method @throws ApiException
[ "Disable", "a", "payment", "method", "for", "this", "profile", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Profile.php#L191-L194
mollie/mollie-api-php
src/Resources/Profile.php
Profile.refunds
public function refunds() { if (!isset($this->_links->refunds->href)) { return new RefundCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->refunds->href); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->refunds, Refund::class, $result->_links ); }
php
public function refunds() { if (!isset($this->_links->refunds->href)) { return new RefundCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->refunds->href); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->refunds, Refund::class, $result->_links ); }
[ "public", "function", "refunds", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "refunds", "->", "href", ")", ")", "{", "return", "new", "RefundCollection", "(", "$", "this", "->", "client", ",", "0", ",", "null", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_GET", ",", "$", "this", "->", "_links", "->", "refunds", "->", "href", ")", ";", "return", "ResourceFactory", "::", "createCursorResourceCollection", "(", "$", "this", "->", "client", ",", "$", "result", "->", "_embedded", "->", "refunds", ",", "Refund", "::", "class", ",", "$", "result", "->", "_links", ")", ";", "}" ]
Retrieves all refunds associated with this profile @return RefundCollection @throws ApiException
[ "Retrieves", "all", "refunds", "associated", "with", "this", "profile" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Profile.php#L224-L238
mollie/mollie-api-php
src/Resources/Payment.php
Payment.getCheckoutUrl
public function getCheckoutUrl() { if (empty($this->_links->checkout)) { return null; } return $this->_links->checkout->href; }
php
public function getCheckoutUrl() { if (empty($this->_links->checkout)) { return null; } return $this->_links->checkout->href; }
[ "public", "function", "getCheckoutUrl", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_links", "->", "checkout", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "_links", "->", "checkout", "->", "href", ";", "}" ]
Get the checkout URL where the customer can complete the payment. @return string|null
[ "Get", "the", "checkout", "URL", "where", "the", "customer", "can", "complete", "the", "payment", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Payment.php#L348-L355
mollie/mollie-api-php
src/Resources/Payment.php
Payment.getRefund
public function getRefund($refundId, array $parameters = []) { return $this->client->paymentRefunds->getFor($this, $refundId, $parameters); }
php
public function getRefund($refundId, array $parameters = []) { return $this->client->paymentRefunds->getFor($this, $refundId, $parameters); }
[ "public", "function", "getRefund", "(", "$", "refundId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "paymentRefunds", "->", "getFor", "(", "$", "this", ",", "$", "refundId", ",", "$", "parameters", ")", ";", "}" ]
@param string $refundId @param array $parameters @return Refund
[ "@param", "string", "$refundId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Payment.php#L434-L437
mollie/mollie-api-php
src/Resources/Payment.php
Payment.captures
public function captures() { if (!isset($this->_links->captures->href)) { return new CaptureCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_GET, $this->_links->captures->href ); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->captures, Capture::class, $result->_links ); }
php
public function captures() { if (!isset($this->_links->captures->href)) { return new CaptureCollection($this->client, 0, null); } $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_GET, $this->_links->captures->href ); return ResourceFactory::createCursorResourceCollection( $this->client, $result->_embedded->captures, Capture::class, $result->_links ); }
[ "public", "function", "captures", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "captures", "->", "href", ")", ")", "{", "return", "new", "CaptureCollection", "(", "$", "this", "->", "client", ",", "0", ",", "null", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_GET", ",", "$", "this", "->", "_links", "->", "captures", "->", "href", ")", ";", "return", "ResourceFactory", "::", "createCursorResourceCollection", "(", "$", "this", "->", "client", ",", "$", "result", "->", "_embedded", "->", "captures", ",", "Capture", "::", "class", ",", "$", "result", "->", "_links", ")", ";", "}" ]
Retrieves all captures associated with this payment @return CaptureCollection @throws ApiException
[ "Retrieves", "all", "captures", "associated", "with", "this", "payment" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Payment.php#L445-L462
mollie/mollie-api-php
src/Resources/Payment.php
Payment.getCapture
public function getCapture($captureId, array $parameters = []) { return $this->client->paymentCaptures->getFor( $this, $captureId, $parameters ); }
php
public function getCapture($captureId, array $parameters = []) { return $this->client->paymentCaptures->getFor( $this, $captureId, $parameters ); }
[ "public", "function", "getCapture", "(", "$", "captureId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "paymentCaptures", "->", "getFor", "(", "$", "this", ",", "$", "captureId", ",", "$", "parameters", ")", ";", "}" ]
@param string $captureId @param array $parameters @return Capture
[ "@param", "string", "$captureId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Payment.php#L470-L477
mollie/mollie-api-php
src/Resources/Payment.php
Payment.getChargeback
public function getChargeback($chargebackId, array $parameters = []) { return $this->client->paymentChargebacks->getFor( $this, $chargebackId, $parameters ); }
php
public function getChargeback($chargebackId, array $parameters = []) { return $this->client->paymentChargebacks->getFor( $this, $chargebackId, $parameters ); }
[ "public", "function", "getChargeback", "(", "$", "chargebackId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "paymentChargebacks", "->", "getFor", "(", "$", "this", ",", "$", "chargebackId", ",", "$", "parameters", ")", ";", "}" ]
Retrieves a specific chargeback for this payment. @param string $chargebackId @param array $parameters @return Chargeback
[ "Retrieves", "a", "specific", "chargeback", "for", "this", "payment", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Payment.php#L512-L519
mollie/mollie-api-php
src/Resources/Payment.php
Payment.refund
public function refund($data = []) { $resource = "payments/" . urlencode($this->id) . "/refunds"; $body = null; if (count($data) > 0) { $body = json_encode($data); } $result = $this->client->performHttpCall( MollieApiClient::HTTP_POST, $resource, $body ); return ResourceFactory::createFromApiResult( $result, new Refund($this->client) ); }
php
public function refund($data = []) { $resource = "payments/" . urlencode($this->id) . "/refunds"; $body = null; if (count($data) > 0) { $body = json_encode($data); } $result = $this->client->performHttpCall( MollieApiClient::HTTP_POST, $resource, $body ); return ResourceFactory::createFromApiResult( $result, new Refund($this->client) ); }
[ "public", "function", "refund", "(", "$", "data", "=", "[", "]", ")", "{", "$", "resource", "=", "\"payments/\"", ".", "urlencode", "(", "$", "this", "->", "id", ")", ".", "\"/refunds\"", ";", "$", "body", "=", "null", ";", "if", "(", "count", "(", "$", "data", ")", ">", "0", ")", "{", "$", "body", "=", "json_encode", "(", "$", "data", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCall", "(", "MollieApiClient", "::", "HTTP_POST", ",", "$", "resource", ",", "$", "body", ")", ";", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "new", "Refund", "(", "$", "this", "->", "client", ")", ")", ";", "}" ]
Issue a refund for this payment. The $data parameter may either be an array of endpoint parameters or empty to do a full refund. @param array|null $data @return BaseResource @throws ApiException
[ "Issue", "a", "refund", "for", "this", "payment", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Payment.php#L532-L551
mollie/mollie-api-php
src/Endpoints/PaymentEndpoint.php
PaymentEndpoint.get
public function get($paymentId, array $parameters = []) { if (empty($paymentId) || strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) { throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '".self::RESOURCE_ID_PREFIX."'."); } return parent::rest_read($paymentId, $parameters); }
php
public function get($paymentId, array $parameters = []) { if (empty($paymentId) || strpos($paymentId, self::RESOURCE_ID_PREFIX) !== 0) { throw new ApiException("Invalid payment ID: '{$paymentId}'. A payment ID should start with '".self::RESOURCE_ID_PREFIX."'."); } return parent::rest_read($paymentId, $parameters); }
[ "public", "function", "get", "(", "$", "paymentId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "paymentId", ")", "||", "strpos", "(", "$", "paymentId", ",", "self", "::", "RESOURCE_ID_PREFIX", ")", "!==", "0", ")", "{", "throw", "new", "ApiException", "(", "\"Invalid payment ID: '{$paymentId}'. A payment ID should start with '\"", ".", "self", "::", "RESOURCE_ID_PREFIX", ".", "\"'.\"", ")", ";", "}", "return", "parent", "::", "rest_read", "(", "$", "paymentId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a single payment from Mollie. Will throw a ApiException if the payment id is invalid or the resource cannot be found. @param string $paymentId @param array $parameters @return Payment @throws ApiException
[ "Retrieve", "a", "single", "payment", "from", "Mollie", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentEndpoint.php#L65-L72
mollie/mollie-api-php
src/Endpoints/PaymentEndpoint.php
PaymentEndpoint.page
public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); }
php
public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); }
[ "public", "function", "page", "(", "$", "from", "=", "null", ",", "$", "limit", "=", "null", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "rest_list", "(", "$", "from", ",", "$", "limit", ",", "$", "parameters", ")", ";", "}" ]
Retrieves a collection of Payments from Mollie. @param string $from The first payment ID you want to include in your list. @param int $limit @param array $parameters @return PaymentCollection @throws ApiException
[ "Retrieves", "a", "collection", "of", "Payments", "from", "Mollie", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentEndpoint.php#L118-L121
mollie/mollie-api-php
src/Endpoints/PaymentEndpoint.php
PaymentEndpoint.refund
public function refund(Payment $payment, $data = []) { $resource = "{$this->getResourcePath()}/" . urlencode($payment->id) . "/refunds"; $body = null; if (count($data) > 0) { $body = json_encode($data); } $result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body); return ResourceFactory::createFromApiResult($result, new Refund($this->client)); }
php
public function refund(Payment $payment, $data = []) { $resource = "{$this->getResourcePath()}/" . urlencode($payment->id) . "/refunds"; $body = null; if (count($data) > 0) { $body = json_encode($data); } $result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body); return ResourceFactory::createFromApiResult($result, new Refund($this->client)); }
[ "public", "function", "refund", "(", "Payment", "$", "payment", ",", "$", "data", "=", "[", "]", ")", "{", "$", "resource", "=", "\"{$this->getResourcePath()}/\"", ".", "urlencode", "(", "$", "payment", "->", "id", ")", ".", "\"/refunds\"", ";", "$", "body", "=", "null", ";", "if", "(", "count", "(", "$", "data", ")", ">", "0", ")", "{", "$", "body", "=", "json_encode", "(", "$", "data", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCall", "(", "self", "::", "REST_CREATE", ",", "$", "resource", ",", "$", "body", ")", ";", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "new", "Refund", "(", "$", "this", "->", "client", ")", ")", ";", "}" ]
Issue a refund for the given payment. The $data parameter may either be an array of endpoint parameters, a float value to initiate a partial refund, or empty to do a full refund. @param Payment $payment @param array|float|null $data @return Refund @throws ApiException
[ "Issue", "a", "refund", "for", "the", "given", "payment", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentEndpoint.php#L135-L147
mollie/mollie-api-php
src/Resources/ResourceFactory.php
ResourceFactory.createFromApiResult
public static function createFromApiResult($apiResult, BaseResource $resource) { foreach ($apiResult as $property => $value) { $resource->{$property} = $value; } return $resource; }
php
public static function createFromApiResult($apiResult, BaseResource $resource) { foreach ($apiResult as $property => $value) { $resource->{$property} = $value; } return $resource; }
[ "public", "static", "function", "createFromApiResult", "(", "$", "apiResult", ",", "BaseResource", "$", "resource", ")", "{", "foreach", "(", "$", "apiResult", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "resource", "->", "{", "$", "property", "}", "=", "$", "value", ";", "}", "return", "$", "resource", ";", "}" ]
Create resource object from Api result @param object $apiResult @param BaseResource $resource @return BaseResource
[ "Create", "resource", "object", "from", "Api", "result" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/ResourceFactory.php#L17-L24
mollie/mollie-api-php
src/Endpoints/SubscriptionEndpoint.php
SubscriptionEndpoint.createFor
public function createFor(Customer $customer, array $options = [], array $filters = []) { $this->parentId = $customer->id; return parent::rest_create($options, $filters); }
php
public function createFor(Customer $customer, array $options = [], array $filters = []) { $this->parentId = $customer->id; return parent::rest_create($options, $filters); }
[ "public", "function", "createFor", "(", "Customer", "$", "customer", ",", "array", "$", "options", "=", "[", "]", ",", "array", "$", "filters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "customer", "->", "id", ";", "return", "parent", "::", "rest_create", "(", "$", "options", ",", "$", "filters", ")", ";", "}" ]
Create a subscription for a Customer @param Customer $customer @param array $options @param array $filters @return Subscription
[ "Create", "a", "subscription", "for", "a", "Customer" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/SubscriptionEndpoint.php#L47-L52
mollie/mollie-api-php
src/Endpoints/SubscriptionEndpoint.php
SubscriptionEndpoint.getFor
public function getFor(Customer $customer, $subscriptionId, array $parameters = []) { $this->parentId = $customer->id; return parent::rest_read($subscriptionId, $parameters); }
php
public function getFor(Customer $customer, $subscriptionId, array $parameters = []) { $this->parentId = $customer->id; return parent::rest_read($subscriptionId, $parameters); }
[ "public", "function", "getFor", "(", "Customer", "$", "customer", ",", "$", "subscriptionId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "customer", "->", "id", ";", "return", "parent", "::", "rest_read", "(", "$", "subscriptionId", ",", "$", "parameters", ")", ";", "}" ]
@param Customer $customer @param string $subscriptionId @param array $parameters @return Subscription
[ "@param", "Customer", "$customer", "@param", "string", "$subscriptionId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/SubscriptionEndpoint.php#L61-L66
mollie/mollie-api-php
src/Endpoints/SubscriptionEndpoint.php
SubscriptionEndpoint.listFor
public function listFor(Customer $customer, $from = null, $limit = null, array $parameters = []) { $this->parentId = $customer->id; return parent::rest_list($from, $limit, $parameters); }
php
public function listFor(Customer $customer, $from = null, $limit = null, array $parameters = []) { $this->parentId = $customer->id; return parent::rest_list($from, $limit, $parameters); }
[ "public", "function", "listFor", "(", "Customer", "$", "customer", ",", "$", "from", "=", "null", ",", "$", "limit", "=", "null", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "customer", "->", "id", ";", "return", "parent", "::", "rest_list", "(", "$", "from", ",", "$", "limit", ",", "$", "parameters", ")", ";", "}" ]
@param Customer $customer @param string $from The first resource ID you want to include in your list. @param int $limit @param array $parameters @return SubscriptionCollection
[ "@param", "Customer", "$customer", "@param", "string", "$from", "The", "first", "resource", "ID", "you", "want", "to", "include", "in", "your", "list", ".", "@param", "int", "$limit", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/SubscriptionEndpoint.php#L76-L81
mollie/mollie-api-php
src/Endpoints/SubscriptionEndpoint.php
SubscriptionEndpoint.cancelFor
public function cancelFor(Customer $customer, $subscriptionId, array $data = []) { $this->parentId = $customer->id; return parent::rest_delete($subscriptionId, $data); }
php
public function cancelFor(Customer $customer, $subscriptionId, array $data = []) { $this->parentId = $customer->id; return parent::rest_delete($subscriptionId, $data); }
[ "public", "function", "cancelFor", "(", "Customer", "$", "customer", ",", "$", "subscriptionId", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "customer", "->", "id", ";", "return", "parent", "::", "rest_delete", "(", "$", "subscriptionId", ",", "$", "data", ")", ";", "}" ]
@param Customer $customer @param string $subscriptionId @param array $data @return null @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "Customer", "$customer", "@param", "string", "$subscriptionId" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/SubscriptionEndpoint.php#L91-L96
mollie/mollie-api-php
src/Resources/Mandate.php
Mandate.revoke
public function revoke() { if (!isset($this->_links->self->href)) { return $this; } $body = null; if($this->client->usesOAuth()) { $body = json_encode([ "testmode" => $this->mode === "test" ? true : false ]); } $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href, $body ); return $result; }
php
public function revoke() { if (!isset($this->_links->self->href)) { return $this; } $body = null; if($this->client->usesOAuth()) { $body = json_encode([ "testmode" => $this->mode === "test" ? true : false ]); } $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href, $body ); return $result; }
[ "public", "function", "revoke", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "self", "->", "href", ")", ")", "{", "return", "$", "this", ";", "}", "$", "body", "=", "null", ";", "if", "(", "$", "this", "->", "client", "->", "usesOAuth", "(", ")", ")", "{", "$", "body", "=", "json_encode", "(", "[", "\"testmode\"", "=>", "$", "this", "->", "mode", "===", "\"test\"", "?", "true", ":", "false", "]", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_DELETE", ",", "$", "this", "->", "_links", "->", "self", "->", "href", ",", "$", "body", ")", ";", "return", "$", "result", ";", "}" ]
Revoke the mandate @return null
[ "Revoke", "the", "mandate" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Mandate.php#L96-L116
mollie/mollie-api-php
src/Endpoints/MethodEndpoint.php
MethodEndpoint.allAvailable
public function allAvailable(array $parameters = []) { $url = 'methods/all' . $this->buildQueryString($parameters); $result = $this->client->performHttpCall('GET', $url); return ResourceFactory::createBaseResourceCollection( $this->client, $result->_embedded->methods, Method::class, $result->_links ); }
php
public function allAvailable(array $parameters = []) { $url = 'methods/all' . $this->buildQueryString($parameters); $result = $this->client->performHttpCall('GET', $url); return ResourceFactory::createBaseResourceCollection( $this->client, $result->_embedded->methods, Method::class, $result->_links ); }
[ "public", "function", "allAvailable", "(", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "url", "=", "'methods/all'", ".", "$", "this", "->", "buildQueryString", "(", "$", "parameters", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCall", "(", "'GET'", ",", "$", "url", ")", ";", "return", "ResourceFactory", "::", "createBaseResourceCollection", "(", "$", "this", "->", "client", ",", "$", "result", "->", "_embedded", "->", "methods", ",", "Method", "::", "class", ",", "$", "result", "->", "_links", ")", ";", "}" ]
Retrieve all available methods for the organization, including activated and not yet activated methods. The results are not paginated. Make sure to include the profileId parameter if using an OAuth Access Token. @param array $parameters Query string parameters. @return \Mollie\Api\Resources\BaseCollection|\Mollie\Api\Resources\MethodCollection @throws \Mollie\Api\Exceptions\ApiException
[ "Retrieve", "all", "available", "methods", "for", "the", "organization", "including", "activated", "and", "not", "yet", "activated", "methods", ".", "The", "results", "are", "not", "paginated", ".", "Make", "sure", "to", "include", "the", "profileId", "parameter", "if", "using", "an", "OAuth", "Access", "Token", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/MethodEndpoint.php#L58-L70
mollie/mollie-api-php
src/Endpoints/MethodEndpoint.php
MethodEndpoint.get
public function get($methodId, array $parameters = []) { if (empty($methodId)) { throw new ApiException("Method ID is empty."); } return parent::rest_read($methodId, $parameters); }
php
public function get($methodId, array $parameters = []) { if (empty($methodId)) { throw new ApiException("Method ID is empty."); } return parent::rest_read($methodId, $parameters); }
[ "public", "function", "get", "(", "$", "methodId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "methodId", ")", ")", "{", "throw", "new", "ApiException", "(", "\"Method ID is empty.\"", ")", ";", "}", "return", "parent", "::", "rest_read", "(", "$", "methodId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a payment method from Mollie. Will throw a ApiException if the method id is invalid or the resource cannot be found. @param string $methodId @param array $parameters @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Method @throws ApiException
[ "Retrieve", "a", "payment", "method", "from", "Mollie", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/MethodEndpoint.php#L95-L102
mollie/mollie-api-php
src/Endpoints/OrganizationEndpoint.php
OrganizationEndpoint.get
public function get($organizationId, array $parameters = []) { if (empty($organizationId)) { throw new ApiException("Organization ID is empty."); } return parent::rest_read($organizationId, $parameters); }
php
public function get($organizationId, array $parameters = []) { if (empty($organizationId)) { throw new ApiException("Organization ID is empty."); } return parent::rest_read($organizationId, $parameters); }
[ "public", "function", "get", "(", "$", "organizationId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "organizationId", ")", ")", "{", "throw", "new", "ApiException", "(", "\"Organization ID is empty.\"", ")", ";", "}", "return", "parent", "::", "rest_read", "(", "$", "organizationId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve an organization from Mollie. Will throw a ApiException if the organization id is invalid or the resource cannot be found. @param string $organizationId @param array $parameters @return Method @throws ApiException
[ "Retrieve", "an", "organization", "from", "Mollie", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/OrganizationEndpoint.php#L45-L52
mollie/mollie-api-php
src/Endpoints/PaymentRefundEndpoint.php
PaymentRefundEndpoint.getFor
public function getFor(Payment $payment, $refundId, array $parameters = []) { return $this->getForId($payment->id, $refundId, $parameters); }
php
public function getFor(Payment $payment, $refundId, array $parameters = []) { return $this->getForId($payment->id, $refundId, $parameters); }
[ "public", "function", "getFor", "(", "Payment", "$", "payment", ",", "$", "refundId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getForId", "(", "$", "payment", "->", "id", ",", "$", "refundId", ",", "$", "parameters", ")", ";", "}" ]
@param Payment $payment @param string $refundId @param array $parameters @return Refund @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "Payment", "$payment", "@param", "string", "$refundId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentRefundEndpoint.php#L44-L47
mollie/mollie-api-php
src/Endpoints/PaymentRefundEndpoint.php
PaymentRefundEndpoint.getForId
public function getForId($paymentId, $refundId, array $parameters = []) { $this->parentId = $paymentId; return parent::rest_read($refundId, $parameters); }
php
public function getForId($paymentId, $refundId, array $parameters = []) { $this->parentId = $paymentId; return parent::rest_read($refundId, $parameters); }
[ "public", "function", "getForId", "(", "$", "paymentId", ",", "$", "refundId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "paymentId", ";", "return", "parent", "::", "rest_read", "(", "$", "refundId", ",", "$", "parameters", ")", ";", "}" ]
@param string $paymentId @param string $refundId @param array $parameters @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Refund @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "string", "$paymentId", "@param", "string", "$refundId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentRefundEndpoint.php#L57-L62
mollie/mollie-api-php
src/Endpoints/EndpointAbstract.php
EndpointAbstract.rest_read
protected function rest_read($id, array $filters) { if (empty($id)) { throw new ApiException("Invalid resource id."); } $id = urlencode($id); $result = $this->client->performHttpCall( self::REST_READ, "{$this->getResourcePath()}/{$id}" . $this->buildQueryString($filters) ); return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); }
php
protected function rest_read($id, array $filters) { if (empty($id)) { throw new ApiException("Invalid resource id."); } $id = urlencode($id); $result = $this->client->performHttpCall( self::REST_READ, "{$this->getResourcePath()}/{$id}" . $this->buildQueryString($filters) ); return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); }
[ "protected", "function", "rest_read", "(", "$", "id", ",", "array", "$", "filters", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "throw", "new", "ApiException", "(", "\"Invalid resource id.\"", ")", ";", "}", "$", "id", "=", "urlencode", "(", "$", "id", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCall", "(", "self", "::", "REST_READ", ",", "\"{$this->getResourcePath()}/{$id}\"", ".", "$", "this", "->", "buildQueryString", "(", "$", "filters", ")", ")", ";", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "$", "this", "->", "getResourceObject", "(", ")", ")", ";", "}" ]
Retrieves a single object from the REST API. @param string $id Id of the object to retrieve. @param array $filters @return BaseResource @throws ApiException
[ "Retrieves", "a", "single", "object", "from", "the", "REST", "API", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/EndpointAbstract.php#L90-L103
mollie/mollie-api-php
src/Endpoints/EndpointAbstract.php
EndpointAbstract.rest_delete
protected function rest_delete($id, array $body = []) { if (empty($id)) { throw new ApiException("Invalid resource id."); } $id = urlencode($id); $result = $this->client->performHttpCall( self::REST_DELETE, "{$this->getResourcePath()}/{$id}", $this->parseRequestBody($body) ); if ($result === null) { return null; } return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); }
php
protected function rest_delete($id, array $body = []) { if (empty($id)) { throw new ApiException("Invalid resource id."); } $id = urlencode($id); $result = $this->client->performHttpCall( self::REST_DELETE, "{$this->getResourcePath()}/{$id}", $this->parseRequestBody($body) ); if ($result === null) { return null; } return ResourceFactory::createFromApiResult($result, $this->getResourceObject()); }
[ "protected", "function", "rest_delete", "(", "$", "id", ",", "array", "$", "body", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "throw", "new", "ApiException", "(", "\"Invalid resource id.\"", ")", ";", "}", "$", "id", "=", "urlencode", "(", "$", "id", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCall", "(", "self", "::", "REST_DELETE", ",", "\"{$this->getResourcePath()}/{$id}\"", ",", "$", "this", "->", "parseRequestBody", "(", "$", "body", ")", ")", ";", "if", "(", "$", "result", "===", "null", ")", "{", "return", "null", ";", "}", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "$", "this", "->", "getResourceObject", "(", ")", ")", ";", "}" ]
Sends a DELETE request to a single Molle API object. @param string $id @param array $body @return BaseResource @throws ApiException
[ "Sends", "a", "DELETE", "request", "to", "a", "single", "Molle", "API", "object", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/EndpointAbstract.php#L114-L132
mollie/mollie-api-php
src/Endpoints/EndpointAbstract.php
EndpointAbstract.rest_list
protected function rest_list($from = null, $limit = null, array $filters) { $filters = array_merge(["from" => $from, "limit" => $limit], $filters); $apiPath = $this->getResourcePath() . $this->buildQueryString($filters); $result = $this->client->performHttpCall(self::REST_LIST, $apiPath); /** @var BaseCollection $collection */ $collection = $this->getResourceCollectionObject($result->count, $result->_links); foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->getResourceObject()); } return $collection; }
php
protected function rest_list($from = null, $limit = null, array $filters) { $filters = array_merge(["from" => $from, "limit" => $limit], $filters); $apiPath = $this->getResourcePath() . $this->buildQueryString($filters); $result = $this->client->performHttpCall(self::REST_LIST, $apiPath); $collection = $this->getResourceCollectionObject($result->count, $result->_links); foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->getResourceObject()); } return $collection; }
[ "protected", "function", "rest_list", "(", "$", "from", "=", "null", ",", "$", "limit", "=", "null", ",", "array", "$", "filters", ")", "{", "$", "filters", "=", "array_merge", "(", "[", "\"from\"", "=>", "$", "from", ",", "\"limit\"", "=>", "$", "limit", "]", ",", "$", "filters", ")", ";", "$", "apiPath", "=", "$", "this", "->", "getResourcePath", "(", ")", ".", "$", "this", "->", "buildQueryString", "(", "$", "filters", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCall", "(", "self", "::", "REST_LIST", ",", "$", "apiPath", ")", ";", "/** @var BaseCollection $collection */", "$", "collection", "=", "$", "this", "->", "getResourceCollectionObject", "(", "$", "result", "->", "count", ",", "$", "result", "->", "_links", ")", ";", "foreach", "(", "$", "result", "->", "_embedded", "->", "{", "$", "collection", "->", "getCollectionResourceName", "(", ")", "}", "as", "$", "dataResult", ")", "{", "$", "collection", "[", "]", "=", "ResourceFactory", "::", "createFromApiResult", "(", "$", "dataResult", ",", "$", "this", "->", "getResourceObject", "(", ")", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Get a collection of objects from the REST API. @param string $from The first resource ID you want to include in your list. @param int $limit @param array $filters @return BaseCollection @throws ApiException
[ "Get", "a", "collection", "of", "objects", "from", "the", "REST", "API", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/EndpointAbstract.php#L144-L160
mollie/mollie-api-php
src/Resources/CursorCollection.php
CursorCollection.next
final public function next() { if (!$this->hasNext()) { return null; } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->next->href); $collection = new static($this->client, $result->count, $result->_links); foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->createResourceObject()); } return $collection; }
php
final public function next() { if (!$this->hasNext()) { return null; } $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_GET, $this->_links->next->href); $collection = new static($this->client, $result->count, $result->_links); foreach ($result->_embedded->{$collection->getCollectionResourceName()} as $dataResult) { $collection[] = ResourceFactory::createFromApiResult($dataResult, $this->createResourceObject()); } return $collection; }
[ "final", "public", "function", "next", "(", ")", "{", "if", "(", "!", "$", "this", "->", "hasNext", "(", ")", ")", "{", "return", "null", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_GET", ",", "$", "this", "->", "_links", "->", "next", "->", "href", ")", ";", "$", "collection", "=", "new", "static", "(", "$", "this", "->", "client", ",", "$", "result", "->", "count", ",", "$", "result", "->", "_links", ")", ";", "foreach", "(", "$", "result", "->", "_embedded", "->", "{", "$", "collection", "->", "getCollectionResourceName", "(", ")", "}", "as", "$", "dataResult", ")", "{", "$", "collection", "[", "]", "=", "ResourceFactory", "::", "createFromApiResult", "(", "$", "dataResult", ",", "$", "this", "->", "createResourceObject", "(", ")", ")", ";", "}", "return", "$", "collection", ";", "}" ]
Return the next set of resources when available @return CursorCollection|null @throws \Mollie\Api\Exceptions\ApiException
[ "Return", "the", "next", "set", "of", "resources", "when", "available" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/CursorCollection.php#L37-L52
mollie/mollie-api-php
src/Endpoints/ProfileEndpoint.php
ProfileEndpoint.get
public function get($profileId, array $parameters = []) { if($profileId === 'me') { return $this->getCurrent($parameters); } return $this->rest_read($profileId, $parameters); }
php
public function get($profileId, array $parameters = []) { if($profileId === 'me') { return $this->getCurrent($parameters); } return $this->rest_read($profileId, $parameters); }
[ "public", "function", "get", "(", "$", "profileId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "$", "profileId", "===", "'me'", ")", "{", "return", "$", "this", "->", "getCurrent", "(", "$", "parameters", ")", ";", "}", "return", "$", "this", "->", "rest_read", "(", "$", "profileId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a Profile from Mollie. Will throw an ApiException if the profile id is invalid or the resource cannot be found. @param string $profileId @param array $parameters @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Profile @throws ApiException
[ "Retrieve", "a", "Profile", "from", "Mollie", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/ProfileEndpoint.php#L63-L70
mollie/mollie-api-php
src/Resources/OrderLineCollection.php
OrderLineCollection.get
public function get($lineId) { foreach ($this as $line) { if ($line->id === $lineId) { return $line; } } return null; }
php
public function get($lineId) { foreach ($this as $line) { if ($line->id === $lineId) { return $line; } } return null; }
[ "public", "function", "get", "(", "$", "lineId", ")", "{", "foreach", "(", "$", "this", "as", "$", "line", ")", "{", "if", "(", "$", "line", "->", "id", "===", "$", "lineId", ")", "{", "return", "$", "line", ";", "}", "}", "return", "null", ";", "}" ]
Get a specific order line. Returns null if the order line cannot be found. @param string $lineId @return OrderLine|null
[ "Get", "a", "specific", "order", "line", ".", "Returns", "null", "if", "the", "order", "line", "cannot", "be", "found", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/OrderLineCollection.php#L22-L30
mollie/mollie-api-php
src/Endpoints/PaymentChargebackEndpoint.php
PaymentChargebackEndpoint.getFor
public function getFor(Payment $payment, $chargebackId, array $parameters = []) { return $this->getForId($payment->id, $chargebackId, $parameters); }
php
public function getFor(Payment $payment, $chargebackId, array $parameters = []) { return $this->getForId($payment->id, $chargebackId, $parameters); }
[ "public", "function", "getFor", "(", "Payment", "$", "payment", ",", "$", "chargebackId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "getForId", "(", "$", "payment", "->", "id", ",", "$", "chargebackId", ",", "$", "parameters", ")", ";", "}" ]
@param Payment $payment @param string $chargebackId @param array $parameters @return Chargeback @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "Payment", "$payment", "@param", "string", "$chargebackId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentChargebackEndpoint.php#L44-L47
mollie/mollie-api-php
src/Endpoints/PaymentChargebackEndpoint.php
PaymentChargebackEndpoint.getForId
public function getForId($paymentId, $chargebackId, array $parameters = []) { $this->parentId = $paymentId; return parent::rest_read($chargebackId, $parameters); }
php
public function getForId($paymentId, $chargebackId, array $parameters = []) { $this->parentId = $paymentId; return parent::rest_read($chargebackId, $parameters); }
[ "public", "function", "getForId", "(", "$", "paymentId", ",", "$", "chargebackId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "this", "->", "parentId", "=", "$", "paymentId", ";", "return", "parent", "::", "rest_read", "(", "$", "chargebackId", ",", "$", "parameters", ")", ";", "}" ]
@param string $paymentId @param string $chargebackId @param array $parameters @return Chargeback @throws \Mollie\Api\Exceptions\ApiException
[ "@param", "string", "$paymentId", "@param", "string", "$chargebackId", "@param", "array", "$parameters" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/PaymentChargebackEndpoint.php#L57-L62
mollie/mollie-api-php
src/Resources/Subscription.php
Subscription.cancel
public function cancel() { if (!isset($this->_links->self->href)) { return $this; } $body = null; if($this->client->usesOAuth()) { $body = json_encode([ "testmode" => $this->mode === "test" ? true : false ]); } $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href, $body ); return ResourceFactory::createFromApiResult($result, new Subscription($this->client)); }
php
public function cancel() { if (!isset($this->_links->self->href)) { return $this; } $body = null; if($this->client->usesOAuth()) { $body = json_encode([ "testmode" => $this->mode === "test" ? true : false ]); } $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href, $body ); return ResourceFactory::createFromApiResult($result, new Subscription($this->client)); }
[ "public", "function", "cancel", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "self", "->", "href", ")", ")", "{", "return", "$", "this", ";", "}", "$", "body", "=", "null", ";", "if", "(", "$", "this", "->", "client", "->", "usesOAuth", "(", ")", ")", "{", "$", "body", "=", "json_encode", "(", "[", "\"testmode\"", "=>", "$", "this", "->", "mode", "===", "\"test\"", "?", "true", ":", "false", "]", ")", ";", "}", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_DELETE", ",", "$", "this", "->", "_links", "->", "self", "->", "href", ",", "$", "body", ")", ";", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "new", "Subscription", "(", "$", "this", "->", "client", ")", ")", ";", "}" ]
Cancels this subscription @return Subscription
[ "Cancels", "this", "subscription" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Subscription.php#L184-L204
mollie/mollie-api-php
src/Resources/Order.php
Order.getShipment
public function getShipment($shipmentId, array $parameters = []) { return $this->client->shipments->getFor($this, $shipmentId, $parameters); }
php
public function getShipment($shipmentId, array $parameters = []) { return $this->client->shipments->getFor($this, $shipmentId, $parameters); }
[ "public", "function", "getShipment", "(", "$", "shipmentId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "shipments", "->", "getFor", "(", "$", "this", ",", "$", "shipmentId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a specific shipment for this order. @param string $shipmentId @param array $parameters @return Shipment
[ "Retrieve", "a", "specific", "shipment", "for", "this", "order", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Order.php#L340-L343
mollie/mollie-api-php
src/Resources/Order.php
Order.update
public function update() { if (!isset($this->_links->self->href)) { return $this; } $body = json_encode(array( "billingAddress" => $this->billingAddress, "shippingAddress" => $this->shippingAddress, )); $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_PATCH, $this->_links->self->href, $body); return ResourceFactory::createFromApiResult($result, new Order($this->client)); }
php
public function update() { if (!isset($this->_links->self->href)) { return $this; } $body = json_encode(array( "billingAddress" => $this->billingAddress, "shippingAddress" => $this->shippingAddress, )); $result = $this->client->performHttpCallToFullUrl(MollieApiClient::HTTP_PATCH, $this->_links->self->href, $body); return ResourceFactory::createFromApiResult($result, new Order($this->client)); }
[ "public", "function", "update", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "self", "->", "href", ")", ")", "{", "return", "$", "this", ";", "}", "$", "body", "=", "json_encode", "(", "array", "(", "\"billingAddress\"", "=>", "$", "this", "->", "billingAddress", ",", "\"shippingAddress\"", "=>", "$", "this", "->", "shippingAddress", ",", ")", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_PATCH", ",", "$", "this", "->", "_links", "->", "self", "->", "href", ",", "$", "body", ")", ";", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "new", "Order", "(", "$", "this", "->", "client", ")", ")", ";", "}" ]
Saves the order's updated billingAddress and/or shippingAddress. @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Order @throws \Mollie\Api\Exceptions\ApiException
[ "Saves", "the", "order", "s", "updated", "billingAddress", "and", "/", "or", "shippingAddress", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Order.php#L422-L436
mollie/mollie-api-php
src/Resources/Order.php
Order.createPayment
public function createPayment($data, $filters = []) { return $this->client->orderPayments->createFor($this, $data, $filters); }
php
public function createPayment($data, $filters = []) { return $this->client->orderPayments->createFor($this, $data, $filters); }
[ "public", "function", "createPayment", "(", "$", "data", ",", "$", "filters", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "->", "orderPayments", "->", "createFor", "(", "$", "this", ",", "$", "data", ",", "$", "filters", ")", ";", "}" ]
Create a new payment for this Order. @param $data @param array $filters @return \Mollie\Api\Resources\BaseResource|\Mollie\Api\Resources\Payment @throws \Mollie\Api\Exceptions\ApiException
[ "Create", "a", "new", "payment", "for", "this", "Order", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Order.php#L446-L449
mollie/mollie-api-php
src/Resources/Order.php
Order.payments
public function payments() { if(! isset($this->_embedded, $this->_embedded->payments) ) { return null; } return ResourceFactory::createCursorResourceCollection( $this->client, $this->_embedded->payments, Payment::class ); }
php
public function payments() { if(! isset($this->_embedded, $this->_embedded->payments) ) { return null; } return ResourceFactory::createCursorResourceCollection( $this->client, $this->_embedded->payments, Payment::class ); }
[ "public", "function", "payments", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_embedded", ",", "$", "this", "->", "_embedded", "->", "payments", ")", ")", "{", "return", "null", ";", "}", "return", "ResourceFactory", "::", "createCursorResourceCollection", "(", "$", "this", "->", "client", ",", "$", "this", "->", "_embedded", "->", "payments", ",", "Payment", "::", "class", ")", ";", "}" ]
Retrieve the payments for this order. Requires the order to be retrieved using the embed payments parameter. @return null|\Mollie\Api\Resources\PaymentCollection
[ "Retrieve", "the", "payments", "for", "this", "order", ".", "Requires", "the", "order", "to", "be", "retrieved", "using", "the", "embed", "payments", "parameter", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Order.php#L457-L468
mollie/mollie-api-php
src/Endpoints/OrderLineEndpoint.php
OrderLineEndpoint.cancelForId
public function cancelForId($orderId, array $data) { if(! isset($data, $data['lines']) || ! is_array($data['lines'])) { throw new ApiException("A lines array is required."); } $this->parentId = $orderId; $this->client->performHttpCall( self::REST_DELETE, "{$this->getResourcePath()}", $this->parseRequestBody($data) ); return null; }
php
public function cancelForId($orderId, array $data) { if(! isset($data, $data['lines']) || ! is_array($data['lines'])) { throw new ApiException("A lines array is required."); } $this->parentId = $orderId; $this->client->performHttpCall( self::REST_DELETE, "{$this->getResourcePath()}", $this->parseRequestBody($data) ); return null; }
[ "public", "function", "cancelForId", "(", "$", "orderId", ",", "array", "$", "data", ")", "{", "if", "(", "!", "isset", "(", "$", "data", ",", "$", "data", "[", "'lines'", "]", ")", "||", "!", "is_array", "(", "$", "data", "[", "'lines'", "]", ")", ")", "{", "throw", "new", "ApiException", "(", "\"A lines array is required.\"", ")", ";", "}", "$", "this", "->", "parentId", "=", "$", "orderId", ";", "$", "this", "->", "client", "->", "performHttpCall", "(", "self", "::", "REST_DELETE", ",", "\"{$this->getResourcePath()}\"", ",", "$", "this", "->", "parseRequestBody", "(", "$", "data", ")", ")", ";", "return", "null", ";", "}" ]
Cancel lines for the provided order id. The data array must contain a lines array. You can pass an empty lines array if you want to cancel all eligible lines. Returns null if successful. @param string $orderId @param array $data @return null @throws ApiException
[ "Cancel", "lines", "for", "the", "provided", "order", "id", ".", "The", "data", "array", "must", "contain", "a", "lines", "array", ".", "You", "can", "pass", "an", "empty", "lines", "array", "if", "you", "want", "to", "cancel", "all", "eligible", "lines", ".", "Returns", "null", "if", "successful", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/OrderLineEndpoint.php#L74-L88
mollie/mollie-api-php
src/Resources/Shipment.php
Shipment.update
public function update() { if (!isset($this->_links->self->href)) { return $this; } $body = json_encode([ "tracking" => $this->tracking, ]); $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_PATCH, $this->_links->self->href, $body ); return ResourceFactory::createFromApiResult($result, new Shipment($this->client)); }
php
public function update() { if (!isset($this->_links->self->href)) { return $this; } $body = json_encode([ "tracking" => $this->tracking, ]); $result = $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_PATCH, $this->_links->self->href, $body ); return ResourceFactory::createFromApiResult($result, new Shipment($this->client)); }
[ "public", "function", "update", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_links", "->", "self", "->", "href", ")", ")", "{", "return", "$", "this", ";", "}", "$", "body", "=", "json_encode", "(", "[", "\"tracking\"", "=>", "$", "this", "->", "tracking", ",", "]", ")", ";", "$", "result", "=", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_PATCH", ",", "$", "this", "->", "_links", "->", "self", "->", "href", ",", "$", "body", ")", ";", "return", "ResourceFactory", "::", "createFromApiResult", "(", "$", "result", ",", "new", "Shipment", "(", "$", "this", "->", "client", ")", ")", ";", "}" ]
Save changes made to this shipment. @return BaseResource|Shipment @throws \Mollie\Api\Exceptions\ApiException
[ "Save", "changes", "made", "to", "this", "shipment", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Shipment.php#L117-L134
mollie/mollie-api-php
src/Resources/Refund.php
Refund.cancel
public function cancel() { $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href ); return null; }
php
public function cancel() { $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href ); return null; }
[ "public", "function", "cancel", "(", ")", "{", "$", "this", "->", "client", "->", "performHttpCallToFullUrl", "(", "MollieApiClient", "::", "HTTP_DELETE", ",", "$", "this", "->", "_links", "->", "self", "->", "href", ")", ";", "return", "null", ";", "}" ]
Cancel the refund. Returns null if successful. @return null @throws \Mollie\Api\Exceptions\ApiException
[ "Cancel", "the", "refund", ".", "Returns", "null", "if", "successful", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Resources/Refund.php#L133-L141
mollie/mollie-api-php
src/MollieApiClient.php
MollieApiClient.setApiKey
public function setApiKey($apiKey) { $apiKey = trim($apiKey); if (!preg_match('/^(live|test)_\w{30,}$/', $apiKey)) { throw new ApiException("Invalid API key: '{$apiKey}'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long."); } $this->apiKey = $apiKey; $this->oauthAccess = false; return $this; }
php
public function setApiKey($apiKey) { $apiKey = trim($apiKey); if (!preg_match('/^(live|test)_\w{30,}$/', $apiKey)) { throw new ApiException("Invalid API key: '{$apiKey}'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long."); } $this->apiKey = $apiKey; $this->oauthAccess = false; return $this; }
[ "public", "function", "setApiKey", "(", "$", "apiKey", ")", "{", "$", "apiKey", "=", "trim", "(", "$", "apiKey", ")", ";", "if", "(", "!", "preg_match", "(", "'/^(live|test)_\\w{30,}$/'", ",", "$", "apiKey", ")", ")", "{", "throw", "new", "ApiException", "(", "\"Invalid API key: '{$apiKey}'. An API key must start with 'test_' or 'live_' and must be at least 30 characters long.\"", ")", ";", "}", "$", "this", "->", "apiKey", "=", "$", "apiKey", ";", "$", "this", "->", "oauthAccess", "=", "false", ";", "return", "$", "this", ";", "}" ]
@param string $apiKey The Mollie API key, starting with 'test_' or 'live_' @return MollieApiClient @throws ApiException
[ "@param", "string", "$apiKey", "The", "Mollie", "API", "key", "starting", "with", "test_", "or", "live_" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/MollieApiClient.php#L334-L345
mollie/mollie-api-php
src/MollieApiClient.php
MollieApiClient.setAccessToken
public function setAccessToken($accessToken) { $accessToken = trim($accessToken); if (!preg_match('/^access_\w+$/', $accessToken)) { throw new ApiException("Invalid OAuth access token: '{$accessToken}'. An access token must start with 'access_'."); } $this->apiKey = $accessToken; $this->oauthAccess = true; return $this; }
php
public function setAccessToken($accessToken) { $accessToken = trim($accessToken); if (!preg_match('/^access_\w+$/', $accessToken)) { throw new ApiException("Invalid OAuth access token: '{$accessToken}'. An access token must start with 'access_'."); } $this->apiKey = $accessToken; $this->oauthAccess = true; return $this; }
[ "public", "function", "setAccessToken", "(", "$", "accessToken", ")", "{", "$", "accessToken", "=", "trim", "(", "$", "accessToken", ")", ";", "if", "(", "!", "preg_match", "(", "'/^access_\\w+$/'", ",", "$", "accessToken", ")", ")", "{", "throw", "new", "ApiException", "(", "\"Invalid OAuth access token: '{$accessToken}'. An access token must start with 'access_'.\"", ")", ";", "}", "$", "this", "->", "apiKey", "=", "$", "accessToken", ";", "$", "this", "->", "oauthAccess", "=", "true", ";", "return", "$", "this", ";", "}" ]
@param string $accessToken OAuth access token, starting with 'access_' @return MollieApiClient @throws ApiException
[ "@param", "string", "$accessToken", "OAuth", "access", "token", "starting", "with", "access_" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/MollieApiClient.php#L353-L364
mollie/mollie-api-php
src/MollieApiClient.php
MollieApiClient.performHttpCall
public function performHttpCall($httpMethod, $apiMethod, $httpBody = null) { $url = $this->apiEndpoint . "/" . self::API_VERSION . "/" . $apiMethod; return $this->performHttpCallToFullUrl($httpMethod, $url, $httpBody); }
php
public function performHttpCall($httpMethod, $apiMethod, $httpBody = null) { $url = $this->apiEndpoint . "/" . self::API_VERSION . "/" . $apiMethod; return $this->performHttpCallToFullUrl($httpMethod, $url, $httpBody); }
[ "public", "function", "performHttpCall", "(", "$", "httpMethod", ",", "$", "apiMethod", ",", "$", "httpBody", "=", "null", ")", "{", "$", "url", "=", "$", "this", "->", "apiEndpoint", ".", "\"/\"", ".", "self", "::", "API_VERSION", ".", "\"/\"", ".", "$", "apiMethod", ";", "return", "$", "this", "->", "performHttpCallToFullUrl", "(", "$", "httpMethod", ",", "$", "url", ",", "$", "httpBody", ")", ";", "}" ]
Perform an http call. This method is used by the resource specific classes. Please use the $payments property to perform operations on payments. @param string $httpMethod @param string $apiMethod @param string|null|resource|StreamInterface $httpBody @return object @throws ApiException @codeCoverageIgnore
[ "Perform", "an", "http", "call", ".", "This", "method", "is", "used", "by", "the", "resource", "specific", "classes", ".", "Please", "use", "the", "$payments", "property", "to", "perform", "operations", "on", "payments", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/MollieApiClient.php#L400-L405
mollie/mollie-api-php
src/MollieApiClient.php
MollieApiClient.performHttpCallToFullUrl
public function performHttpCallToFullUrl($httpMethod, $url, $httpBody = null) { if (empty($this->apiKey)) { throw new ApiException("You have not set an API key or OAuth access token. Please use setApiKey() to set the API key."); } $userAgent = implode(' ', $this->versionStrings); if ($this->usesOAuth()) { $userAgent .= " OAuth/2.0"; } $headers = [ 'Accept' => "application/json", 'Authorization' => "Bearer {$this->apiKey}", 'User-Agent' => $userAgent, ]; if (function_exists("php_uname")) { $headers['X-Mollie-Client-Info'] = php_uname(); } $request = new Request($httpMethod, $url, $headers, $httpBody); try { $response = $this->httpClient->send($request, ['http_errors' => false]); } catch (GuzzleException $e) { throw ApiException::createFromGuzzleException($e); } if (!$response) { throw new ApiException("Did not receive API response."); } return $this->parseResponseBody($response); }
php
public function performHttpCallToFullUrl($httpMethod, $url, $httpBody = null) { if (empty($this->apiKey)) { throw new ApiException("You have not set an API key or OAuth access token. Please use setApiKey() to set the API key."); } $userAgent = implode(' ', $this->versionStrings); if ($this->usesOAuth()) { $userAgent .= " OAuth/2.0"; } $headers = [ 'Accept' => "application/json", 'Authorization' => "Bearer {$this->apiKey}", 'User-Agent' => $userAgent, ]; if (function_exists("php_uname")) { $headers['X-Mollie-Client-Info'] = php_uname(); } $request = new Request($httpMethod, $url, $headers, $httpBody); try { $response = $this->httpClient->send($request, ['http_errors' => false]); } catch (GuzzleException $e) { throw ApiException::createFromGuzzleException($e); } if (!$response) { throw new ApiException("Did not receive API response."); } return $this->parseResponseBody($response); }
[ "public", "function", "performHttpCallToFullUrl", "(", "$", "httpMethod", ",", "$", "url", ",", "$", "httpBody", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "apiKey", ")", ")", "{", "throw", "new", "ApiException", "(", "\"You have not set an API key or OAuth access token. Please use setApiKey() to set the API key.\"", ")", ";", "}", "$", "userAgent", "=", "implode", "(", "' '", ",", "$", "this", "->", "versionStrings", ")", ";", "if", "(", "$", "this", "->", "usesOAuth", "(", ")", ")", "{", "$", "userAgent", ".=", "\" OAuth/2.0\"", ";", "}", "$", "headers", "=", "[", "'Accept'", "=>", "\"application/json\"", ",", "'Authorization'", "=>", "\"Bearer {$this->apiKey}\"", ",", "'User-Agent'", "=>", "$", "userAgent", ",", "]", ";", "if", "(", "function_exists", "(", "\"php_uname\"", ")", ")", "{", "$", "headers", "[", "'X-Mollie-Client-Info'", "]", "=", "php_uname", "(", ")", ";", "}", "$", "request", "=", "new", "Request", "(", "$", "httpMethod", ",", "$", "url", ",", "$", "headers", ",", "$", "httpBody", ")", ";", "try", "{", "$", "response", "=", "$", "this", "->", "httpClient", "->", "send", "(", "$", "request", ",", "[", "'http_errors'", "=>", "false", "]", ")", ";", "}", "catch", "(", "GuzzleException", "$", "e", ")", "{", "throw", "ApiException", "::", "createFromGuzzleException", "(", "$", "e", ")", ";", "}", "if", "(", "!", "$", "response", ")", "{", "throw", "new", "ApiException", "(", "\"Did not receive API response.\"", ")", ";", "}", "return", "$", "this", "->", "parseResponseBody", "(", "$", "response", ")", ";", "}" ]
Perform an http call to a full url. This method is used by the resource specific classes. @see $payments @see $isuers @param string $httpMethod @param string $url @param string|null|resource|StreamInterface $httpBody @return object|null @throws ApiException @codeCoverageIgnore
[ "Perform", "an", "http", "call", "to", "a", "full", "url", ".", "This", "method", "is", "used", "by", "the", "resource", "specific", "classes", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/MollieApiClient.php#L422-L457
mollie/mollie-api-php
src/MollieApiClient.php
MollieApiClient.parseResponseBody
private function parseResponseBody(ResponseInterface $response) { $body = (string) $response->getBody(); if (empty($body)) { if ($response->getStatusCode() === self::HTTP_NO_CONTENT) { return null; } throw new ApiException("No response body found."); } $object = @json_decode($body); if (json_last_error() !== JSON_ERROR_NONE) { throw new ApiException("Unable to decode Mollie response: '{$body}'."); } if ($response->getStatusCode() >= 400) { throw ApiException::createFromResponse($response); } return $object; }
php
private function parseResponseBody(ResponseInterface $response) { $body = (string) $response->getBody(); if (empty($body)) { if ($response->getStatusCode() === self::HTTP_NO_CONTENT) { return null; } throw new ApiException("No response body found."); } $object = @json_decode($body); if (json_last_error() !== JSON_ERROR_NONE) { throw new ApiException("Unable to decode Mollie response: '{$body}'."); } if ($response->getStatusCode() >= 400) { throw ApiException::createFromResponse($response); } return $object; }
[ "private", "function", "parseResponseBody", "(", "ResponseInterface", "$", "response", ")", "{", "$", "body", "=", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ";", "if", "(", "empty", "(", "$", "body", ")", ")", "{", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", "===", "self", "::", "HTTP_NO_CONTENT", ")", "{", "return", "null", ";", "}", "throw", "new", "ApiException", "(", "\"No response body found.\"", ")", ";", "}", "$", "object", "=", "@", "json_decode", "(", "$", "body", ")", ";", "if", "(", "json_last_error", "(", ")", "!==", "JSON_ERROR_NONE", ")", "{", "throw", "new", "ApiException", "(", "\"Unable to decode Mollie response: '{$body}'.\"", ")", ";", "}", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", ">=", "400", ")", "{", "throw", "ApiException", "::", "createFromResponse", "(", "$", "response", ")", ";", "}", "return", "$", "object", ";", "}" ]
Parse the PSR-7 Response body @param ResponseInterface $response @return object|null @throws ApiException
[ "Parse", "the", "PSR", "-", "7", "Response", "body" ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/MollieApiClient.php#L466-L488
mollie/mollie-api-php
src/Endpoints/OrderEndpoint.php
OrderEndpoint.get
public function get($orderId, array $parameters = []) { if (empty($orderId) || strpos($orderId, self::RESOURCE_ID_PREFIX) !== 0) { throw new ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '".self::RESOURCE_ID_PREFIX."'."); } return parent::rest_read($orderId, $parameters); }
php
public function get($orderId, array $parameters = []) { if (empty($orderId) || strpos($orderId, self::RESOURCE_ID_PREFIX) !== 0) { throw new ApiException("Invalid order ID: '{$orderId}'. An order ID should start with '".self::RESOURCE_ID_PREFIX."'."); } return parent::rest_read($orderId, $parameters); }
[ "public", "function", "get", "(", "$", "orderId", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "orderId", ")", "||", "strpos", "(", "$", "orderId", ",", "self", "::", "RESOURCE_ID_PREFIX", ")", "!==", "0", ")", "{", "throw", "new", "ApiException", "(", "\"Invalid order ID: '{$orderId}'. An order ID should start with '\"", ".", "self", "::", "RESOURCE_ID_PREFIX", ".", "\"'.\"", ")", ";", "}", "return", "parent", "::", "rest_read", "(", "$", "orderId", ",", "$", "parameters", ")", ";", "}" ]
Retrieve a single order from Mollie. Will throw a ApiException if the order id is invalid or the resource cannot be found. @param string $paymentId @param array $parameters @return Order @throws ApiException
[ "Retrieve", "a", "single", "order", "from", "Mollie", "." ]
train
https://github.com/mollie/mollie-api-php/blob/370b61d22334657a4644bb9c74f5095f38df189b/src/Endpoints/OrderEndpoint.php#L68-L75
govCMS/govCMS8
modules/custom/core/govcms_media/src/FileInputExtensionMatchTrait.php
FileInputExtensionMatchTrait.appliesTo
public function appliesTo($value, MediaTypeInterface $media_type) { if (is_numeric($value)) { $value = $this->entityTypeManager()->getStorage('file')->load($value); } if ($value instanceof FileInterface && ($field = $this->getSourceFieldDefinition($media_type))) { $extension = pathinfo($value->getFilename(), PATHINFO_EXTENSION); $extension = strtolower($extension); return in_array( $extension, preg_split('/,?\s+/', $field->getSetting('file_extensions')) ); } return FALSE; }
php
public function appliesTo($value, MediaTypeInterface $media_type) { if (is_numeric($value)) { $value = $this->entityTypeManager()->getStorage('file')->load($value); } if ($value instanceof FileInterface && ($field = $this->getSourceFieldDefinition($media_type))) { $extension = pathinfo($value->getFilename(), PATHINFO_EXTENSION); $extension = strtolower($extension); return in_array( $extension, preg_split('/,?\s+/', $field->getSetting('file_extensions')) ); } return FALSE; }
[ "public", "function", "appliesTo", "(", "$", "value", ",", "MediaTypeInterface", "$", "media_type", ")", "{", "if", "(", "is_numeric", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "entityTypeManager", "(", ")", "->", "getStorage", "(", "'file'", ")", "->", "load", "(", "$", "value", ")", ";", "}", "if", "(", "$", "value", "instanceof", "FileInterface", "&&", "(", "$", "field", "=", "$", "this", "->", "getSourceFieldDefinition", "(", "$", "media_type", ")", ")", ")", "{", "$", "extension", "=", "pathinfo", "(", "$", "value", "->", "getFilename", "(", ")", ",", "PATHINFO_EXTENSION", ")", ";", "$", "extension", "=", "strtolower", "(", "$", "extension", ")", ";", "return", "in_array", "(", "$", "extension", ",", "preg_split", "(", "'/,?\\s+/'", ",", "$", "field", "->", "getSetting", "(", "'file_extensions'", ")", ")", ")", ";", "}", "return", "FALSE", ";", "}" ]
Implements InputMatchInterface::appliesTo().
[ "Implements", "InputMatchInterface", "::", "appliesTo", "()", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/FileInputExtensionMatchTrait.php#L29-L44
govCMS/govCMS8
modules/custom/core/govcms_media/src/Element/AjaxUpload.php
AjaxUpload.process
public static function process(array $element, FormStateInterface $form_state) { $element = parent::process($element, $form_state); // Generate a CSS ID for the wrapping DIV. $wrapper_id = implode('-', $element['#parents']); $wrapper_id = Html::cleanCssIdentifier($wrapper_id); // The element being processed is just a wrapper, and does not accept input // or support AJAX directly. Still, store the wrapping DIV ID in a spot // where other elements can access it if they need to refer to it. $element['#ajax']['wrapper'] = $wrapper_id; // Bring in the File module's slick auto-uploading stuff. $element['#attached']['library'][] = 'file/drupal.file'; // The js-form-managed-file class is needed for the File module's // auto-upload JavaScript to target this element. $element['#prefix'] = '<div class="js-form-managed-file" id="' . $wrapper_id . '">'; $element['#suffix'] = '</div>'; // Hide the upload button. It will be triggered by the auto-upload JS. $element['upload']['#attributes']['class'][] = 'js-hide'; // As far as AJAX is concerned, the Upload and Remove buttons do the same // thing (return their parent element). The differences lie in their // respective submit functions. $element['upload']['#ajax'] = $element['remove']['#ajax'] = [ 'callback' => [static::class, 'el'], 'wrapper' => $wrapper_id, ]; return $element; }
php
public static function process(array $element, FormStateInterface $form_state) { $element = parent::process($element, $form_state); $wrapper_id = implode('-', $element[' $wrapper_id = Html::cleanCssIdentifier($wrapper_id); $element[' $element[' $element[' $element[' $element['upload'][' $element['upload'][' 'callback' => [static::class, 'el'], 'wrapper' => $wrapper_id, ]; return $element; }
[ "public", "static", "function", "process", "(", "array", "$", "element", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "element", "=", "parent", "::", "process", "(", "$", "element", ",", "$", "form_state", ")", ";", "// Generate a CSS ID for the wrapping DIV.", "$", "wrapper_id", "=", "implode", "(", "'-'", ",", "$", "element", "[", "'#parents'", "]", ")", ";", "$", "wrapper_id", "=", "Html", "::", "cleanCssIdentifier", "(", "$", "wrapper_id", ")", ";", "// The element being processed is just a wrapper, and does not accept input", "// or support AJAX directly. Still, store the wrapping DIV ID in a spot", "// where other elements can access it if they need to refer to it.", "$", "element", "[", "'#ajax'", "]", "[", "'wrapper'", "]", "=", "$", "wrapper_id", ";", "// Bring in the File module's slick auto-uploading stuff.", "$", "element", "[", "'#attached'", "]", "[", "'library'", "]", "[", "]", "=", "'file/drupal.file'", ";", "// The js-form-managed-file class is needed for the File module's", "// auto-upload JavaScript to target this element.", "$", "element", "[", "'#prefix'", "]", "=", "'<div class=\"js-form-managed-file\" id=\"'", ".", "$", "wrapper_id", ".", "'\">'", ";", "$", "element", "[", "'#suffix'", "]", "=", "'</div>'", ";", "// Hide the upload button. It will be triggered by the auto-upload JS.", "$", "element", "[", "'upload'", "]", "[", "'#attributes'", "]", "[", "'class'", "]", "[", "]", "=", "'js-hide'", ";", "// As far as AJAX is concerned, the Upload and Remove buttons do the same", "// thing (return their parent element). The differences lie in their", "// respective submit functions.", "$", "element", "[", "'upload'", "]", "[", "'#ajax'", "]", "=", "$", "element", "[", "'remove'", "]", "[", "'#ajax'", "]", "=", "[", "'callback'", "=>", "[", "static", "::", "class", ",", "'el'", "]", ",", "'wrapper'", "=>", "$", "wrapper_id", ",", "]", ";", "return", "$", "element", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element/AjaxUpload.php#L21-L53
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/CustomLinearGradientModifier.php
CustomLinearGradientModifier.modification
public static function modification($selector, array $config) { if (!empty($config['cl_gradient_colors'])) { $media = parent::getMediaQuery($config); $direction = ''; if (!empty($config['cl_gradient_direction'])) { $direction = $config['cl_gradient_direction'] . 'deg,'; } // If there is only one color specified we use single color fill. if (count($config['cl_gradient_colors']) === 1) { $css[$media][$selector][] = 'background:' . $config['cl_gradient_colors'][0]; } else { $css[$media][$selector][] = 'background:linear-gradient(' . $direction . implode(',', $config['cl_gradient_colors']) . ')'; } $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; return new Modification($css, [], [], $attributes); } return NULL; }
php
public static function modification($selector, array $config) { if (!empty($config['cl_gradient_colors'])) { $media = parent::getMediaQuery($config); $direction = ''; if (!empty($config['cl_gradient_direction'])) { $direction = $config['cl_gradient_direction'] . 'deg,'; } if (count($config['cl_gradient_colors']) === 1) { $css[$media][$selector][] = 'background:' . $config['cl_gradient_colors'][0]; } else { $css[$media][$selector][] = 'background:linear-gradient(' . $direction . implode(',', $config['cl_gradient_colors']) . ')'; } $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; return new Modification($css, [], [], $attributes); } return NULL; }
[ "public", "static", "function", "modification", "(", "$", "selector", ",", "array", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'cl_gradient_colors'", "]", ")", ")", "{", "$", "media", "=", "parent", "::", "getMediaQuery", "(", "$", "config", ")", ";", "$", "direction", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'cl_gradient_direction'", "]", ")", ")", "{", "$", "direction", "=", "$", "config", "[", "'cl_gradient_direction'", "]", ".", "'deg,'", ";", "}", "// If there is only one color specified we use single color fill.", "if", "(", "count", "(", "$", "config", "[", "'cl_gradient_colors'", "]", ")", "===", "1", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background:'", ".", "$", "config", "[", "'cl_gradient_colors'", "]", "[", "0", "]", ";", "}", "else", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background:linear-gradient('", ".", "$", "direction", ".", "implode", "(", "','", ",", "$", "config", "[", "'cl_gradient_colors'", "]", ")", ".", "')'", ";", "}", "$", "attributes", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "'class'", "]", "[", "]", "=", "'modifiers-has-background'", ";", "return", "new", "Modification", "(", "$", "css", ",", "[", "]", ",", "[", "]", ",", "$", "attributes", ")", ";", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/CustomLinearGradientModifier.php#L22-L44
govCMS/govCMS8
modules/custom/optional/govcms8_default_content/src/Plugin/ImportProcessor/FoiProcessor.php
FoiProcessor.process
public function process(&$values) { $item = $this->item; if (!empty($item['field_thumbnail'])) { $values['field_thumbnail'] = $this->populateMediaField('field_thumbnail'); } if (!empty($item['field_foi_date_listed'])) { $values['field_foi_date_listed'] = $item['field_foi_date_listed']; } if (!empty($item['field_foi_location'])) { $values['field_foi_proposed_deletion_date'] = $item['field_foi_proposed_deletion_date']; } }
php
public function process(&$values) { $item = $this->item; if (!empty($item['field_thumbnail'])) { $values['field_thumbnail'] = $this->populateMediaField('field_thumbnail'); } if (!empty($item['field_foi_date_listed'])) { $values['field_foi_date_listed'] = $item['field_foi_date_listed']; } if (!empty($item['field_foi_location'])) { $values['field_foi_proposed_deletion_date'] = $item['field_foi_proposed_deletion_date']; } }
[ "public", "function", "process", "(", "&", "$", "values", ")", "{", "$", "item", "=", "$", "this", "->", "item", ";", "if", "(", "!", "empty", "(", "$", "item", "[", "'field_thumbnail'", "]", ")", ")", "{", "$", "values", "[", "'field_thumbnail'", "]", "=", "$", "this", "->", "populateMediaField", "(", "'field_thumbnail'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "item", "[", "'field_foi_date_listed'", "]", ")", ")", "{", "$", "values", "[", "'field_foi_date_listed'", "]", "=", "$", "item", "[", "'field_foi_date_listed'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "item", "[", "'field_foi_location'", "]", ")", ")", "{", "$", "values", "[", "'field_foi_proposed_deletion_date'", "]", "=", "$", "item", "[", "'field_foi_proposed_deletion_date'", "]", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/Plugin/ImportProcessor/FoiProcessor.php#L22-L36
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_calendar_item/src/Plugin/Field/FieldFormatter/CalendarItemDateFormatter.php
CalendarItemDateFormatter.viewElements
public function viewElements(FieldItemListInterface $items, $langcode) { $elements = []; foreach ($items as $delta => $item) { $elements[$delta] = $this->viewValue($item); } return $elements; }
php
public function viewElements(FieldItemListInterface $items, $langcode) { $elements = []; foreach ($items as $delta => $item) { $elements[$delta] = $this->viewValue($item); } return $elements; }
[ "public", "function", "viewElements", "(", "FieldItemListInterface", "$", "items", ",", "$", "langcode", ")", "{", "$", "elements", "=", "[", "]", ";", "foreach", "(", "$", "items", "as", "$", "delta", "=>", "$", "item", ")", "{", "$", "elements", "[", "$", "delta", "]", "=", "$", "this", "->", "viewValue", "(", "$", "item", ")", ";", "}", "return", "$", "elements", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_calendar_item/src/Plugin/Field/FieldFormatter/CalendarItemDateFormatter.php#L26-L34
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_calendar_item/src/Plugin/Field/FieldFormatter/CalendarItemDateFormatter.php
CalendarItemDateFormatter.viewValue
protected function viewValue(FieldItemInterface $item) { $field = $item->getFieldDefinition(); if ($field->get('field_type') == 'daterange') { $value = $item->start_date; } else { $value = $item->date; } $build = [ '#theme' => 'calendar_item_date', '#datetime' => $value, '#attached' => [ 'library' => [ 'govcms8_calendar_item/calendar_item', ], ], ]; return $build; }
php
protected function viewValue(FieldItemInterface $item) { $field = $item->getFieldDefinition(); if ($field->get('field_type') == 'daterange') { $value = $item->start_date; } else { $value = $item->date; } $build = [ ' ' ' 'library' => [ 'govcms8_calendar_item/calendar_item', ], ], ]; return $build; }
[ "protected", "function", "viewValue", "(", "FieldItemInterface", "$", "item", ")", "{", "$", "field", "=", "$", "item", "->", "getFieldDefinition", "(", ")", ";", "if", "(", "$", "field", "->", "get", "(", "'field_type'", ")", "==", "'daterange'", ")", "{", "$", "value", "=", "$", "item", "->", "start_date", ";", "}", "else", "{", "$", "value", "=", "$", "item", "->", "date", ";", "}", "$", "build", "=", "[", "'#theme'", "=>", "'calendar_item_date'", ",", "'#datetime'", "=>", "$", "value", ",", "'#attached'", "=>", "[", "'library'", "=>", "[", "'govcms8_calendar_item/calendar_item'", ",", "]", ",", "]", ",", "]", ";", "return", "$", "build", ";", "}" ]
Generate the output appropriate for one field item. @param \Drupal\Core\Field\FieldItemInterface $item One field item. @return array The textual output generated.
[ "Generate", "the", "output", "appropriate", "for", "one", "field", "item", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_calendar_item/src/Plugin/Field/FieldFormatter/CalendarItemDateFormatter.php#L45-L63
govCMS/govCMS8
modules/custom/core/govcms_media/src/Form/BulkUploadForm.php
BulkUploadForm.buildForm
public function buildForm(array $form, FormStateInterface $form_state) { $extensions = $this->helper->getFileExtensions(TRUE); $form['dropzone'] = [ '#type' => 'dropzonejs', '#dropzone_description' => $this->t('Drag files here to upload them'), '#extensions' => implode(' ', $extensions), ]; $form['continue'] = [ '#type' => 'submit', '#value' => $this->t('Continue'), ]; $variables = [ '@max_size' => static::bytesToString(file_upload_max_size()), '@extensions' => Element::oxford($extensions), ]; $form['dropzone']['#description'] = $this->t('You can upload as many files as you like. Each file can be up to @max_size in size. The following file extensions are accepted: @extensions', $variables); return $form; }
php
public function buildForm(array $form, FormStateInterface $form_state) { $extensions = $this->helper->getFileExtensions(TRUE); $form['dropzone'] = [ ' ' ' ]; $form['continue'] = [ ' ' ]; $variables = [ '@max_size' => static::bytesToString(file_upload_max_size()), '@extensions' => Element::oxford($extensions), ]; $form['dropzone'][' return $form; }
[ "public", "function", "buildForm", "(", "array", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "extensions", "=", "$", "this", "->", "helper", "->", "getFileExtensions", "(", "TRUE", ")", ";", "$", "form", "[", "'dropzone'", "]", "=", "[", "'#type'", "=>", "'dropzonejs'", ",", "'#dropzone_description'", "=>", "$", "this", "->", "t", "(", "'Drag files here to upload them'", ")", ",", "'#extensions'", "=>", "implode", "(", "' '", ",", "$", "extensions", ")", ",", "]", ";", "$", "form", "[", "'continue'", "]", "=", "[", "'#type'", "=>", "'submit'", ",", "'#value'", "=>", "$", "this", "->", "t", "(", "'Continue'", ")", ",", "]", ";", "$", "variables", "=", "[", "'@max_size'", "=>", "static", "::", "bytesToString", "(", "file_upload_max_size", "(", ")", ")", ",", "'@extensions'", "=>", "Element", "::", "oxford", "(", "$", "extensions", ")", ",", "]", ";", "$", "form", "[", "'dropzone'", "]", "[", "'#description'", "]", "=", "$", "this", "->", "t", "(", "'You can upload as many files as you like. Each file can be up to @max_size in size. The following file extensions are accepted: @extensions'", ",", "$", "variables", ")", ";", "return", "$", "form", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Form/BulkUploadForm.php#L73-L93
govCMS/govCMS8
modules/custom/core/govcms_media/src/Form/BulkUploadForm.php
BulkUploadForm.bytesToString
public static function bytesToString($bytes) { $units = array_map('t', ['bytes', 'KB', 'MB', 'GB', 'TB']); while ($bytes > 1024) { $bytes /= 1024; array_shift($units); } return $bytes . ' ' . reset($units); }
php
public static function bytesToString($bytes) { $units = array_map('t', ['bytes', 'KB', 'MB', 'GB', 'TB']); while ($bytes > 1024) { $bytes /= 1024; array_shift($units); } return $bytes . ' ' . reset($units); }
[ "public", "static", "function", "bytesToString", "(", "$", "bytes", ")", "{", "$", "units", "=", "array_map", "(", "'t'", ",", "[", "'bytes'", ",", "'KB'", ",", "'MB'", ",", "'GB'", ",", "'TB'", "]", ")", ";", "while", "(", "$", "bytes", ">", "1024", ")", "{", "$", "bytes", "/=", "1024", ";", "array_shift", "(", "$", "units", ")", ";", "}", "return", "$", "bytes", ".", "' '", ".", "reset", "(", "$", "units", ")", ";", "}" ]
Converts a number of bytes into a human-readable string. @param int $bytes A number of bytes. @return string The human-readable measurement, like '2 MB' or '10 GB'.
[ "Converts", "a", "number", "of", "bytes", "into", "a", "human", "-", "readable", "string", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Form/BulkUploadForm.php#L104-L112
govCMS/govCMS8
modules/custom/core/govcms_media/src/Form/BulkUploadForm.php
BulkUploadForm.submitForm
public function submitForm(array &$form, FormStateInterface $form_state) { $bulk_create = []; $uploads = $form_state->getValue(['dropzone', 'uploaded_files']); foreach ($uploads as $upload) { // Create a file entity for the temporary file. /** @var \Drupal\file\FileInterface $file */ $file = $this->entityTypeManager->getStorage('file')->create([ 'uri' => $upload['path'], ]); $file->setTemporary(); $file->save(); try { $entity = $this->helper->createFromInput($file); } catch (IndeterminateBundleException $e) { drupal_set_message('error', (string) $e); continue; } $file = MediaHelper::useFile($entity, $file); $file->setPermanent(); $file->save(); $entity->save(); array_push($bulk_create, $bulk_create ? $entity->id() : $entity); } if ($bulk_create) { /** @var \Drupal\media\MediaInterface $entity */ $redirect = array_shift($bulk_create)->toUrl('edit-form', [ 'query' => [ 'bulk_create' => $bulk_create, ], ]); $form_state->setRedirectUrl($redirect); } }
php
public function submitForm(array &$form, FormStateInterface $form_state) { $bulk_create = []; $uploads = $form_state->getValue(['dropzone', 'uploaded_files']); foreach ($uploads as $upload) { $file = $this->entityTypeManager->getStorage('file')->create([ 'uri' => $upload['path'], ]); $file->setTemporary(); $file->save(); try { $entity = $this->helper->createFromInput($file); } catch (IndeterminateBundleException $e) { drupal_set_message('error', (string) $e); continue; } $file = MediaHelper::useFile($entity, $file); $file->setPermanent(); $file->save(); $entity->save(); array_push($bulk_create, $bulk_create ? $entity->id() : $entity); } if ($bulk_create) { $redirect = array_shift($bulk_create)->toUrl('edit-form', [ 'query' => [ 'bulk_create' => $bulk_create, ], ]); $form_state->setRedirectUrl($redirect); } }
[ "public", "function", "submitForm", "(", "array", "&", "$", "form", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "bulk_create", "=", "[", "]", ";", "$", "uploads", "=", "$", "form_state", "->", "getValue", "(", "[", "'dropzone'", ",", "'uploaded_files'", "]", ")", ";", "foreach", "(", "$", "uploads", "as", "$", "upload", ")", "{", "// Create a file entity for the temporary file.", "/** @var \\Drupal\\file\\FileInterface $file */", "$", "file", "=", "$", "this", "->", "entityTypeManager", "->", "getStorage", "(", "'file'", ")", "->", "create", "(", "[", "'uri'", "=>", "$", "upload", "[", "'path'", "]", ",", "]", ")", ";", "$", "file", "->", "setTemporary", "(", ")", ";", "$", "file", "->", "save", "(", ")", ";", "try", "{", "$", "entity", "=", "$", "this", "->", "helper", "->", "createFromInput", "(", "$", "file", ")", ";", "}", "catch", "(", "IndeterminateBundleException", "$", "e", ")", "{", "drupal_set_message", "(", "'error'", ",", "(", "string", ")", "$", "e", ")", ";", "continue", ";", "}", "$", "file", "=", "MediaHelper", "::", "useFile", "(", "$", "entity", ",", "$", "file", ")", ";", "$", "file", "->", "setPermanent", "(", ")", ";", "$", "file", "->", "save", "(", ")", ";", "$", "entity", "->", "save", "(", ")", ";", "array_push", "(", "$", "bulk_create", ",", "$", "bulk_create", "?", "$", "entity", "->", "id", "(", ")", ":", "$", "entity", ")", ";", "}", "if", "(", "$", "bulk_create", ")", "{", "/** @var \\Drupal\\media\\MediaInterface $entity */", "$", "redirect", "=", "array_shift", "(", "$", "bulk_create", ")", "->", "toUrl", "(", "'edit-form'", ",", "[", "'query'", "=>", "[", "'bulk_create'", "=>", "$", "bulk_create", ",", "]", ",", "]", ")", ";", "$", "form_state", "->", "setRedirectUrl", "(", "$", "redirect", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Form/BulkUploadForm.php#L117-L155
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/RelativeHeightModifier.php
RelativeHeightModifier.modification
public static function modification($selector, array $config) { if (!empty($config['relative_height'])) { $media = parent::getMediaQuery($config); if (!empty($config['vertical_align'])) { $css[$media][$selector][] = 'display:flex'; switch ($config['vertical_align']) { case 'top': $css[$media][$selector][] = 'align-items:flex-start'; break; case 'middle': $css[$media][$selector][] = 'align-items:center'; break; case 'bottom': $css[$media][$selector][] = 'align-items:flex-end'; break; } } $libraries = [ 'govcms8_modifiers/modifiers_relative_height_apply', ]; $settings = [ 'namespace' => 'RelativeHeightModifier', 'callback' => 'apply', 'selector' => $selector, 'media' => $media, 'args' => [ 'ratio' => $config['relative_height'], ], ]; $css[$media][$selector][] = 'overflow:hidden'; return new Modification($css, $libraries, $settings); } return NULL; }
php
public static function modification($selector, array $config) { if (!empty($config['relative_height'])) { $media = parent::getMediaQuery($config); if (!empty($config['vertical_align'])) { $css[$media][$selector][] = 'display:flex'; switch ($config['vertical_align']) { case 'top': $css[$media][$selector][] = 'align-items:flex-start'; break; case 'middle': $css[$media][$selector][] = 'align-items:center'; break; case 'bottom': $css[$media][$selector][] = 'align-items:flex-end'; break; } } $libraries = [ 'govcms8_modifiers/modifiers_relative_height_apply', ]; $settings = [ 'namespace' => 'RelativeHeightModifier', 'callback' => 'apply', 'selector' => $selector, 'media' => $media, 'args' => [ 'ratio' => $config['relative_height'], ], ]; $css[$media][$selector][] = 'overflow:hidden'; return new Modification($css, $libraries, $settings); } return NULL; }
[ "public", "static", "function", "modification", "(", "$", "selector", ",", "array", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'relative_height'", "]", ")", ")", "{", "$", "media", "=", "parent", "::", "getMediaQuery", "(", "$", "config", ")", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'vertical_align'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'display:flex'", ";", "switch", "(", "$", "config", "[", "'vertical_align'", "]", ")", "{", "case", "'top'", ":", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'align-items:flex-start'", ";", "break", ";", "case", "'middle'", ":", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'align-items:center'", ";", "break", ";", "case", "'bottom'", ":", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'align-items:flex-end'", ";", "break", ";", "}", "}", "$", "libraries", "=", "[", "'govcms8_modifiers/modifiers_relative_height_apply'", ",", "]", ";", "$", "settings", "=", "[", "'namespace'", "=>", "'RelativeHeightModifier'", ",", "'callback'", "=>", "'apply'", ",", "'selector'", "=>", "$", "selector", ",", "'media'", "=>", "$", "media", ",", "'args'", "=>", "[", "'ratio'", "=>", "$", "config", "[", "'relative_height'", "]", ",", "]", ",", "]", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'overflow:hidden'", ";", "return", "new", "Modification", "(", "$", "css", ",", "$", "libraries", ",", "$", "settings", ")", ";", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/RelativeHeightModifier.php#L16-L56
govCMS/govCMS8
modules/custom/core/govcms_media/src/MediaHelper.php
MediaHelper.getFileExtensions
public function getFileExtensions($check_access = FALSE, array $bundles = []) { $extensions = ''; // GovCMS Media overrides the media_bundle storage handler with a special // one that adds an optional second parameter to loadMultiple(). $storage = $this->entityTypeManager ->getStorage('media_type'); $media_types = $storage->loadMultiple($bundles ?: NULL, $check_access); /** @var \Drupal\media\MediaTypeInterface $media_type */ foreach ($media_types as $media_type) { $field = $media_type->getSource()->getSourceFieldDefinition($media_type); // If the field is a FileItem or any of its descendants, we can consider // it a file field. This will automatically include things like image // fields, which extend file fields. if (is_a($field->getItemDefinition()->getClass(), FileItem::class, TRUE)) { $extensions .= $field->getSetting('file_extensions') . ' '; } } $extensions = preg_split('/,?\s+/', rtrim($extensions)); return array_unique($extensions); }
php
public function getFileExtensions($check_access = FALSE, array $bundles = []) { $extensions = ''; $storage = $this->entityTypeManager ->getStorage('media_type'); $media_types = $storage->loadMultiple($bundles ?: NULL, $check_access); foreach ($media_types as $media_type) { $field = $media_type->getSource()->getSourceFieldDefinition($media_type); if (is_a($field->getItemDefinition()->getClass(), FileItem::class, TRUE)) { $extensions .= $field->getSetting('file_extensions') . ' '; } } $extensions = preg_split('/,?\s+/', rtrim($extensions)); return array_unique($extensions); }
[ "public", "function", "getFileExtensions", "(", "$", "check_access", "=", "FALSE", ",", "array", "$", "bundles", "=", "[", "]", ")", "{", "$", "extensions", "=", "''", ";", "// GovCMS Media overrides the media_bundle storage handler with a special", "// one that adds an optional second parameter to loadMultiple().", "$", "storage", "=", "$", "this", "->", "entityTypeManager", "->", "getStorage", "(", "'media_type'", ")", ";", "$", "media_types", "=", "$", "storage", "->", "loadMultiple", "(", "$", "bundles", "?", ":", "NULL", ",", "$", "check_access", ")", ";", "/** @var \\Drupal\\media\\MediaTypeInterface $media_type */", "foreach", "(", "$", "media_types", "as", "$", "media_type", ")", "{", "$", "field", "=", "$", "media_type", "->", "getSource", "(", ")", "->", "getSourceFieldDefinition", "(", "$", "media_type", ")", ";", "// If the field is a FileItem or any of its descendants, we can consider", "// it a file field. This will automatically include things like image", "// fields, which extend file fields.", "if", "(", "is_a", "(", "$", "field", "->", "getItemDefinition", "(", ")", "->", "getClass", "(", ")", ",", "FileItem", "::", "class", ",", "TRUE", ")", ")", "{", "$", "extensions", ".=", "$", "field", "->", "getSetting", "(", "'file_extensions'", ")", ".", "' '", ";", "}", "}", "$", "extensions", "=", "preg_split", "(", "'/,?\\s+/'", ",", "rtrim", "(", "$", "extensions", ")", ")", ";", "return", "array_unique", "(", "$", "extensions", ")", ";", "}" ]
Returns all file extensions accepted by bundles that use file fields. @param bool $check_access (optional) Whether to filter the bundles by create access for the current user. Defaults to FALSE. @param string[] $bundles (optional) An array of bundle IDs from which to retrieve source field extensions. If omitted, all available bundles are allowed. @return string[] The file extensions accepted by all available bundles.
[ "Returns", "all", "file", "extensions", "accepted", "by", "bundles", "that", "use", "file", "fields", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/MediaHelper.php#L49-L71
govCMS/govCMS8
modules/custom/core/govcms_media/src/MediaHelper.php
MediaHelper.getBundleFromInput
public function getBundleFromInput($value, $check_access = TRUE, array $bundles = []) { // GovCMS Media overrides the media_bundle storage handler with a special // one that adds an optional second parameter to loadMultiple(). $media_types = $this->entityTypeManager ->getStorage('media_type') ->loadMultiple($bundles ?: NULL, $check_access); ksort($media_types); /** @var \Drupal\media\MediaTypeInterface $media_type */ foreach ($media_types as $media_type) { $source = $media_type->getSource(); if ($source instanceof InputMatchInterface && $source->appliesTo($value, $media_type)) { return $media_type; } } throw new IndeterminateBundleException($value); }
php
public function getBundleFromInput($value, $check_access = TRUE, array $bundles = []) { $media_types = $this->entityTypeManager ->getStorage('media_type') ->loadMultiple($bundles ?: NULL, $check_access); ksort($media_types); foreach ($media_types as $media_type) { $source = $media_type->getSource(); if ($source instanceof InputMatchInterface && $source->appliesTo($value, $media_type)) { return $media_type; } } throw new IndeterminateBundleException($value); }
[ "public", "function", "getBundleFromInput", "(", "$", "value", ",", "$", "check_access", "=", "TRUE", ",", "array", "$", "bundles", "=", "[", "]", ")", "{", "// GovCMS Media overrides the media_bundle storage handler with a special", "// one that adds an optional second parameter to loadMultiple().", "$", "media_types", "=", "$", "this", "->", "entityTypeManager", "->", "getStorage", "(", "'media_type'", ")", "->", "loadMultiple", "(", "$", "bundles", "?", ":", "NULL", ",", "$", "check_access", ")", ";", "ksort", "(", "$", "media_types", ")", ";", "/** @var \\Drupal\\media\\MediaTypeInterface $media_type */", "foreach", "(", "$", "media_types", "as", "$", "media_type", ")", "{", "$", "source", "=", "$", "media_type", "->", "getSource", "(", ")", ";", "if", "(", "$", "source", "instanceof", "InputMatchInterface", "&&", "$", "source", "->", "appliesTo", "(", "$", "value", ",", "$", "media_type", ")", ")", "{", "return", "$", "media_type", ";", "}", "}", "throw", "new", "IndeterminateBundleException", "(", "$", "value", ")", ";", "}" ]
Returns the first media bundle that can accept an input value. @param mixed $value The input value. @param bool $check_access (optional) Whether to filter the bundles by create access for the current user. Defaults to TRUE. @param string[] $bundles (optional) A set of media bundle IDs which might match the input. If omitted, all available bundles are checked. @return \Drupal\media\MediaTypeInterface A media bundle that can accept the input value. @throws \Drupal\govcms_media\Exception\IndeterminateBundleException If no bundle can be matched to the input value.
[ "Returns", "the", "first", "media", "bundle", "that", "can", "accept", "an", "input", "value", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/MediaHelper.php#L91-L108
govCMS/govCMS8
modules/custom/core/govcms_media/src/MediaHelper.php
MediaHelper.createFromInput
public function createFromInput($value, array $bundles = []) { /** @var \Drupal\media\MediaInterface $entity */ $entity = $this->entityTypeManager ->getStorage('media') ->create([ 'bundle' => $this->getBundleFromInput($value, TRUE, $bundles)->id(), ]); $field = static::getSourceField($entity); if ($field) { $field->setValue($value); } return $entity; }
php
public function createFromInput($value, array $bundles = []) { $entity = $this->entityTypeManager ->getStorage('media') ->create([ 'bundle' => $this->getBundleFromInput($value, TRUE, $bundles)->id(), ]); $field = static::getSourceField($entity); if ($field) { $field->setValue($value); } return $entity; }
[ "public", "function", "createFromInput", "(", "$", "value", ",", "array", "$", "bundles", "=", "[", "]", ")", "{", "/** @var \\Drupal\\media\\MediaInterface $entity */", "$", "entity", "=", "$", "this", "->", "entityTypeManager", "->", "getStorage", "(", "'media'", ")", "->", "create", "(", "[", "'bundle'", "=>", "$", "this", "->", "getBundleFromInput", "(", "$", "value", ",", "TRUE", ",", "$", "bundles", ")", "->", "id", "(", ")", ",", "]", ")", ";", "$", "field", "=", "static", "::", "getSourceField", "(", "$", "entity", ")", ";", "if", "(", "$", "field", ")", "{", "$", "field", "->", "setValue", "(", "$", "value", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Creates a media entity from an input value. @param mixed $value The input value. @param string[] $bundles (optional) A set of media bundle IDs which might match the input value. If omitted, all bundles to which the user has create access are checked. @return \Drupal\media\MediaInterface The unsaved media entity.
[ "Creates", "a", "media", "entity", "from", "an", "input", "value", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/MediaHelper.php#L122-L135
govCMS/govCMS8
modules/custom/core/govcms_media/src/MediaHelper.php
MediaHelper.useFile
public static function useFile(MediaInterface $entity, FileInterface $file, $replace = FILE_EXISTS_RENAME) { $field = static::getSourceField($entity); $field->setValue($file); $destination = ''; $destination .= static::prepareFileDestination($entity); if (substr($destination, -1) != '/') { $destination .= '/'; } $destination .= $file->getFilename(); if ($destination == $file->getFileUri()) { return $file; } else { $file = file_move($file, $destination, $replace); if ($file) { $field->setValue($file); return $file; } else { return FALSE; } } }
php
public static function useFile(MediaInterface $entity, FileInterface $file, $replace = FILE_EXISTS_RENAME) { $field = static::getSourceField($entity); $field->setValue($file); $destination = ''; $destination .= static::prepareFileDestination($entity); if (substr($destination, -1) != '/') { $destination .= '/'; } $destination .= $file->getFilename(); if ($destination == $file->getFileUri()) { return $file; } else { $file = file_move($file, $destination, $replace); if ($file) { $field->setValue($file); return $file; } else { return FALSE; } } }
[ "public", "static", "function", "useFile", "(", "MediaInterface", "$", "entity", ",", "FileInterface", "$", "file", ",", "$", "replace", "=", "FILE_EXISTS_RENAME", ")", "{", "$", "field", "=", "static", "::", "getSourceField", "(", "$", "entity", ")", ";", "$", "field", "->", "setValue", "(", "$", "file", ")", ";", "$", "destination", "=", "''", ";", "$", "destination", ".=", "static", "::", "prepareFileDestination", "(", "$", "entity", ")", ";", "if", "(", "substr", "(", "$", "destination", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "destination", ".=", "'/'", ";", "}", "$", "destination", ".=", "$", "file", "->", "getFilename", "(", ")", ";", "if", "(", "$", "destination", "==", "$", "file", "->", "getFileUri", "(", ")", ")", "{", "return", "$", "file", ";", "}", "else", "{", "$", "file", "=", "file_move", "(", "$", "file", ",", "$", "destination", ",", "$", "replace", ")", ";", "if", "(", "$", "file", ")", "{", "$", "field", "->", "setValue", "(", "$", "file", ")", ";", "return", "$", "file", ";", "}", "else", "{", "return", "FALSE", ";", "}", "}", "}" ]
Attaches a file entity to a media entity. @param \Drupal\media\MediaInterface $entity The media entity. @param \Drupal\file\FileInterface $file The file entity. @param int $replace (optional) What to do if the file already exists. Can be any of the constants accepted by file_move(). @return \Drupal\file\FileInterface|false The final file entity (unsaved), or FALSE if an error occurred.
[ "Attaches", "a", "file", "entity", "to", "a", "media", "entity", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/MediaHelper.php#L151-L176
govCMS/govCMS8
modules/custom/core/govcms_media/src/MediaHelper.php
MediaHelper.prepareFileDestination
public static function prepareFileDestination(MediaInterface $entity) { /** @var \Drupal\file\Plugin\Field\FieldType\FileItem $item */ $item = static::getSourceField($entity)->first(); $dir = $item->getUploadLocation(); $is_ready = file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); if ($is_ready) { return $dir; } else { throw new \RuntimeException('Could not prepare ' . $dir . ' for writing'); } }
php
public static function prepareFileDestination(MediaInterface $entity) { $item = static::getSourceField($entity)->first(); $dir = $item->getUploadLocation(); $is_ready = file_prepare_directory($dir, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS); if ($is_ready) { return $dir; } else { throw new \RuntimeException('Could not prepare ' . $dir . ' for writing'); } }
[ "public", "static", "function", "prepareFileDestination", "(", "MediaInterface", "$", "entity", ")", "{", "/** @var \\Drupal\\file\\Plugin\\Field\\FieldType\\FileItem $item */", "$", "item", "=", "static", "::", "getSourceField", "(", "$", "entity", ")", "->", "first", "(", ")", ";", "$", "dir", "=", "$", "item", "->", "getUploadLocation", "(", ")", ";", "$", "is_ready", "=", "file_prepare_directory", "(", "$", "dir", ",", "FILE_CREATE_DIRECTORY", "|", "FILE_MODIFY_PERMISSIONS", ")", ";", "if", "(", "$", "is_ready", ")", "{", "return", "$", "dir", ";", "}", "else", "{", "throw", "new", "\\", "RuntimeException", "(", "'Could not prepare '", ".", "$", "dir", ".", "' for writing'", ")", ";", "}", "}" ]
Prepares the destination directory for a file attached to a media entity. @param \Drupal\media\MediaInterface $entity The media entity. @return string The destination directory URI. @throws \RuntimeException If the destination directory is not writable.
[ "Prepares", "the", "destination", "directory", "for", "a", "file", "attached", "to", "a", "media", "entity", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/MediaHelper.php#L190-L203
govCMS/govCMS8
modules/custom/core/govcms_media/src/MediaHelper.php
MediaHelper.getSourceField
public static function getSourceField(MediaInterface $entity) { $field = $entity->getSource()->getSourceFieldDefinition($entity->bundle->entity); return $field ? $entity->get($field->getName()) : NULL; }
php
public static function getSourceField(MediaInterface $entity) { $field = $entity->getSource()->getSourceFieldDefinition($entity->bundle->entity); return $field ? $entity->get($field->getName()) : NULL; }
[ "public", "static", "function", "getSourceField", "(", "MediaInterface", "$", "entity", ")", "{", "$", "field", "=", "$", "entity", "->", "getSource", "(", ")", "->", "getSourceFieldDefinition", "(", "$", "entity", "->", "bundle", "->", "entity", ")", ";", "return", "$", "field", "?", "$", "entity", "->", "get", "(", "$", "field", "->", "getName", "(", ")", ")", ":", "NULL", ";", "}" ]
Returns the media entity's source field item list. @param \Drupal\media\MediaInterface $entity The media entity. @return \Drupal\Core\Field\FieldItemListInterface|null The media entity's source field item list, or NULL if the media type plugin does not define a source field.
[ "Returns", "the", "media", "entity", "s", "source", "field", "item", "list", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/MediaHelper.php#L230-L236
govCMS/govCMS8
modules/custom/core/govcms_media/src/Plugin/media/Source/RemoteVideo.php
RemoteVideo.appliesTo
public function appliesTo($value, MediaTypeInterface $media_type) { if (is_string($value)) { try { return (bool) $this->urlResolver->getProviderByUrl($value); } catch (\Exception $e) { } } return FALSE; }
php
public function appliesTo($value, MediaTypeInterface $media_type) { if (is_string($value)) { try { return (bool) $this->urlResolver->getProviderByUrl($value); } catch (\Exception $e) { } } return FALSE; }
[ "public", "function", "appliesTo", "(", "$", "value", ",", "MediaTypeInterface", "$", "media_type", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "try", "{", "return", "(", "bool", ")", "$", "this", "->", "urlResolver", "->", "getProviderByUrl", "(", "$", "value", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "}", "return", "FALSE", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Plugin/media/Source/RemoteVideo.php#L17-L26
govCMS/govCMS8
modules/custom/optional/govcms8_default_content/src/Plugin/ImportProcessor/ImageBgModifierParagraphProcessor.php
ImageBgModifierParagraphProcessor.process
public function process(&$values) { $item = $this->item; $this->mapBasicField($values, 'field_mod_bgi_color_val'); $this->mapBasicField($values, 'field_mod_image_position'); $this->mapBasicField($values, 'field_mod_image_style'); $this->mapBasicField($values, 'field_mod_media_query'); if (!empty($item['field_mod_image'])) { $values['field_mod_image'] = $this->populateMediaField('field_mod_image'); } }
php
public function process(&$values) { $item = $this->item; $this->mapBasicField($values, 'field_mod_bgi_color_val'); $this->mapBasicField($values, 'field_mod_image_position'); $this->mapBasicField($values, 'field_mod_image_style'); $this->mapBasicField($values, 'field_mod_media_query'); if (!empty($item['field_mod_image'])) { $values['field_mod_image'] = $this->populateMediaField('field_mod_image'); } }
[ "public", "function", "process", "(", "&", "$", "values", ")", "{", "$", "item", "=", "$", "this", "->", "item", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_bgi_color_val'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_image_position'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_image_style'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_media_query'", ")", ";", "if", "(", "!", "empty", "(", "$", "item", "[", "'field_mod_image'", "]", ")", ")", "{", "$", "values", "[", "'field_mod_image'", "]", "=", "$", "this", "->", "populateMediaField", "(", "'field_mod_image'", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/Plugin/ImportProcessor/ImageBgModifierParagraphProcessor.php#L22-L34
govCMS/govCMS8
modules/custom/core/govcms_media/src/Element/Upload.php
Upload.validate
public static function validate(array &$element, FormStateInterface $form_state) { if ($element['#value']) { $file = File::load($element['#value']); $errors = file_validate($file, $element['#upload_validators']); if ($errors) { foreach ($errors as $error) { $form_state->setError($element, (string) $error); } static::delete($element); } } }
php
public static function validate(array &$element, FormStateInterface $form_state) { if ($element[' $file = File::load($element[' $errors = file_validate($file, $element[' if ($errors) { foreach ($errors as $error) { $form_state->setError($element, (string) $error); } static::delete($element); } } }
[ "public", "static", "function", "validate", "(", "array", "&", "$", "element", ",", "FormStateInterface", "$", "form_state", ")", "{", "if", "(", "$", "element", "[", "'#value'", "]", ")", "{", "$", "file", "=", "File", "::", "load", "(", "$", "element", "[", "'#value'", "]", ")", ";", "$", "errors", "=", "file_validate", "(", "$", "file", ",", "$", "element", "[", "'#upload_validators'", "]", ")", ";", "if", "(", "$", "errors", ")", "{", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "$", "form_state", "->", "setError", "(", "$", "element", ",", "(", "string", ")", "$", "error", ")", ";", "}", "static", "::", "delete", "(", "$", "element", ")", ";", "}", "}", "}" ]
Validates the uploaded file. @param array $element The element. @param \Drupal\Core\Form\FormStateInterface $form_state The current form state.
[ "Validates", "the", "uploaded", "file", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element/Upload.php#L43-L55
govCMS/govCMS8
modules/custom/core/govcms_media/src/Element/Upload.php
Upload.delete
public static function delete(array $element) { if ($element['#value']) { $file = File::load($element['#value']); $file->delete(); // Clean up the file system if needed. $uri = $file->getFileUri(); if (file_exists($uri)) { \Drupal::service('file_system')->unlink($uri); } } }
php
public static function delete(array $element) { if ($element[' $file = File::load($element[' $file->delete(); $uri = $file->getFileUri(); if (file_exists($uri)) { \Drupal::service('file_system')->unlink($uri); } } }
[ "public", "static", "function", "delete", "(", "array", "$", "element", ")", "{", "if", "(", "$", "element", "[", "'#value'", "]", ")", "{", "$", "file", "=", "File", "::", "load", "(", "$", "element", "[", "'#value'", "]", ")", ";", "$", "file", "->", "delete", "(", ")", ";", "// Clean up the file system if needed.", "$", "uri", "=", "$", "file", "->", "getFileUri", "(", ")", ";", "if", "(", "file_exists", "(", "$", "uri", ")", ")", "{", "\\", "Drupal", "::", "service", "(", "'file_system'", ")", "->", "unlink", "(", "$", "uri", ")", ";", "}", "}", "}" ]
Deletes the file referenced by the element. @param array $element The element. If set, its value should be a file entity ID.
[ "Deletes", "the", "file", "referenced", "by", "the", "element", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element/Upload.php#L63-L74
govCMS/govCMS8
modules/custom/core/govcms_media/src/Element/Upload.php
Upload.processFile
public static function processFile(&$element, FormStateInterface $form_state, &$complete_form) { $element['#name'] = implode('_', $element['#parents']); $form_state->setHasFileElement(); return parent::processFile($element, $form_state, $complete_form); }
php
public static function processFile(&$element, FormStateInterface $form_state, &$complete_form) { $element[' $form_state->setHasFileElement(); return parent::processFile($element, $form_state, $complete_form); }
[ "public", "static", "function", "processFile", "(", "&", "$", "element", ",", "FormStateInterface", "$", "form_state", ",", "&", "$", "complete_form", ")", "{", "$", "element", "[", "'#name'", "]", "=", "implode", "(", "'_'", ",", "$", "element", "[", "'#parents'", "]", ")", ";", "$", "form_state", "->", "setHasFileElement", "(", ")", ";", "return", "parent", "::", "processFile", "(", "$", "element", ",", "$", "form_state", ",", "$", "complete_form", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element/Upload.php#L79-L83
govCMS/govCMS8
modules/custom/core/govcms_media/src/Element/Upload.php
Upload.valueCallback
public static function valueCallback(&$element, $input, FormStateInterface $form_state) { $id = implode('_', $element['#parents']); $upload = \Drupal::request()->files->get($id); if ($upload instanceof UploadedFile) { $destination = \Drupal::service('file_system') ->realPath($element['#upload_location']); $name = file_munge_filename($upload->getClientOriginalName(), NULL); $name = file_create_filename($name, $destination); $name = $upload->move($destination, $name)->getFilename(); $uri = $element['#upload_location']; if (substr($uri, -1) != '/') { $uri .= '/'; } $uri .= $name; $file = File::create([ 'uri' => $uri, 'uid' => \Drupal::currentUser()->id(), ]); $file->setTemporary(); $file->save(); \Drupal::request()->files->remove($id); return $file->id(); } else { return NULL; } }
php
public static function valueCallback(&$element, $input, FormStateInterface $form_state) { $id = implode('_', $element[' $upload = \Drupal::request()->files->get($id); if ($upload instanceof UploadedFile) { $destination = \Drupal::service('file_system') ->realPath($element[' $name = file_munge_filename($upload->getClientOriginalName(), NULL); $name = file_create_filename($name, $destination); $name = $upload->move($destination, $name)->getFilename(); $uri = $element[' if (substr($uri, -1) != '/') { $uri .= '/'; } $uri .= $name; $file = File::create([ 'uri' => $uri, 'uid' => \Drupal::currentUser()->id(), ]); $file->setTemporary(); $file->save(); \Drupal::request()->files->remove($id); return $file->id(); } else { return NULL; } }
[ "public", "static", "function", "valueCallback", "(", "&", "$", "element", ",", "$", "input", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "id", "=", "implode", "(", "'_'", ",", "$", "element", "[", "'#parents'", "]", ")", ";", "$", "upload", "=", "\\", "Drupal", "::", "request", "(", ")", "->", "files", "->", "get", "(", "$", "id", ")", ";", "if", "(", "$", "upload", "instanceof", "UploadedFile", ")", "{", "$", "destination", "=", "\\", "Drupal", "::", "service", "(", "'file_system'", ")", "->", "realPath", "(", "$", "element", "[", "'#upload_location'", "]", ")", ";", "$", "name", "=", "file_munge_filename", "(", "$", "upload", "->", "getClientOriginalName", "(", ")", ",", "NULL", ")", ";", "$", "name", "=", "file_create_filename", "(", "$", "name", ",", "$", "destination", ")", ";", "$", "name", "=", "$", "upload", "->", "move", "(", "$", "destination", ",", "$", "name", ")", "->", "getFilename", "(", ")", ";", "$", "uri", "=", "$", "element", "[", "'#upload_location'", "]", ";", "if", "(", "substr", "(", "$", "uri", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "uri", ".=", "'/'", ";", "}", "$", "uri", ".=", "$", "name", ";", "$", "file", "=", "File", "::", "create", "(", "[", "'uri'", "=>", "$", "uri", ",", "'uid'", "=>", "\\", "Drupal", "::", "currentUser", "(", ")", "->", "id", "(", ")", ",", "]", ")", ";", "$", "file", "->", "setTemporary", "(", ")", ";", "$", "file", "->", "save", "(", ")", ";", "\\", "Drupal", "::", "request", "(", ")", "->", "files", "->", "remove", "(", "$", "id", ")", ";", "return", "$", "file", "->", "id", "(", ")", ";", "}", "else", "{", "return", "NULL", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element/Upload.php#L88-L120
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/CustomColorsModifier.php
CustomColorsModifier.modification
public static function modification($selector, array $config) { $css = []; $attributes = []; $media = parent::getMediaQuery($config); if (!empty($config['background_color_val'])) { $css[$media][$selector][] = 'background-color:' . $config['background_color_val']; $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; } if (!empty($config['text_color_val'])) { $css[$media][$selector][] = 'color:' . $config['text_color_val']; } if (!empty($config['link_color_val'])) { $css[$media][$selector . ' a'][] = 'color:' . $config['link_color_val']; } if (!empty($config['h_background_color_val'])) { $css[$media][$selector . ':hover'][] = 'background-color:' . $config['h_background_color_val']; if (empty($config['background_color_val'])) { $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; } } if (!empty($config['h_link_color_val'])) { $css[$media][$selector . ' a:hover'][] = 'color:' . $config['h_link_color_val']; } if (!empty($config['h_text_color_val'])) { $css[$media][$selector . ':hover'][] = 'color:' . $config['h_text_color_val']; } if (!empty($config['transition_duration'])) { $css[$media][$selector][] = 'transition-duration:' . $config['transition_duration'] . 's'; $css[$media][$selector . ':hover'][] = 'transition-duration:' . $config['transition_duration'] . 's'; $css[$media][$selector . ' a'][] = 'transition-duration:' . $config['transition_duration'] . 's'; $css[$media][$selector . ' a:hover'][] = 'transition-duration:' . $config['transition_duration'] . 's'; } if (!empty($css) || !empty($attributes)) { return new Modification($css, [], [], $attributes); } return NULL; }
php
public static function modification($selector, array $config) { $css = []; $attributes = []; $media = parent::getMediaQuery($config); if (!empty($config['background_color_val'])) { $css[$media][$selector][] = 'background-color:' . $config['background_color_val']; $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; } if (!empty($config['text_color_val'])) { $css[$media][$selector][] = 'color:' . $config['text_color_val']; } if (!empty($config['link_color_val'])) { $css[$media][$selector . ' a'][] = 'color:' . $config['link_color_val']; } if (!empty($config['h_background_color_val'])) { $css[$media][$selector . ':hover'][] = 'background-color:' . $config['h_background_color_val']; if (empty($config['background_color_val'])) { $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; } } if (!empty($config['h_link_color_val'])) { $css[$media][$selector . ' a:hover'][] = 'color:' . $config['h_link_color_val']; } if (!empty($config['h_text_color_val'])) { $css[$media][$selector . ':hover'][] = 'color:' . $config['h_text_color_val']; } if (!empty($config['transition_duration'])) { $css[$media][$selector][] = 'transition-duration:' . $config['transition_duration'] . 's'; $css[$media][$selector . ':hover'][] = 'transition-duration:' . $config['transition_duration'] . 's'; $css[$media][$selector . ' a'][] = 'transition-duration:' . $config['transition_duration'] . 's'; $css[$media][$selector . ' a:hover'][] = 'transition-duration:' . $config['transition_duration'] . 's'; } if (!empty($css) || !empty($attributes)) { return new Modification($css, [], [], $attributes); } return NULL; }
[ "public", "static", "function", "modification", "(", "$", "selector", ",", "array", "$", "config", ")", "{", "$", "css", "=", "[", "]", ";", "$", "attributes", "=", "[", "]", ";", "$", "media", "=", "parent", "::", "getMediaQuery", "(", "$", "config", ")", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'background_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-color:'", ".", "$", "config", "[", "'background_color_val'", "]", ";", "$", "attributes", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "'class'", "]", "[", "]", "=", "'modifiers-has-background'", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'text_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'color:'", ".", "$", "config", "[", "'text_color_val'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'link_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "' a'", "]", "[", "]", "=", "'color:'", ".", "$", "config", "[", "'link_color_val'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'h_background_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "':hover'", "]", "[", "]", "=", "'background-color:'", ".", "$", "config", "[", "'h_background_color_val'", "]", ";", "if", "(", "empty", "(", "$", "config", "[", "'background_color_val'", "]", ")", ")", "{", "$", "attributes", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "'class'", "]", "[", "]", "=", "'modifiers-has-background'", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'h_link_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "' a:hover'", "]", "[", "]", "=", "'color:'", ".", "$", "config", "[", "'h_link_color_val'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'h_text_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "':hover'", "]", "[", "]", "=", "'color:'", ".", "$", "config", "[", "'h_text_color_val'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'transition_duration'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'transition-duration:'", ".", "$", "config", "[", "'transition_duration'", "]", ".", "'s'", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "':hover'", "]", "[", "]", "=", "'transition-duration:'", ".", "$", "config", "[", "'transition_duration'", "]", ".", "'s'", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "' a'", "]", "[", "]", "=", "'transition-duration:'", ".", "$", "config", "[", "'transition_duration'", "]", ".", "'s'", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", ".", "' a:hover'", "]", "[", "]", "=", "'transition-duration:'", ".", "$", "config", "[", "'transition_duration'", "]", ".", "'s'", ";", "}", "if", "(", "!", "empty", "(", "$", "css", ")", "||", "!", "empty", "(", "$", "attributes", ")", ")", "{", "return", "new", "Modification", "(", "$", "css", ",", "[", "]", ",", "[", "]", ",", "$", "attributes", ")", ";", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/CustomColorsModifier.php#L22-L62
govCMS/govCMS8
src/IniEncoder.php
IniEncoder.doEncode
protected function doEncode(array $input, array $keys = []) { $output = []; foreach ($input as $key => $value) { $keys[] = $key; if (is_array($value)) { if ($this->isAssociative($value)) { $output = array_merge($output, $this->doEncode($value, $keys)); } else { foreach ($value as $j) { $output[] = $this->keysToString($keys) . '[] = ' . $j; } } } else { $output[] = $this->keysToString($keys) . ' = ' . $value; } array_pop($keys); } return $output; }
php
protected function doEncode(array $input, array $keys = []) { $output = []; foreach ($input as $key => $value) { $keys[] = $key; if (is_array($value)) { if ($this->isAssociative($value)) { $output = array_merge($output, $this->doEncode($value, $keys)); } else { foreach ($value as $j) { $output[] = $this->keysToString($keys) . '[] = ' . $j; } } } else { $output[] = $this->keysToString($keys) . ' = ' . $value; } array_pop($keys); } return $output; }
[ "protected", "function", "doEncode", "(", "array", "$", "input", ",", "array", "$", "keys", "=", "[", "]", ")", "{", "$", "output", "=", "[", "]", ";", "foreach", "(", "$", "input", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "keys", "[", "]", "=", "$", "key", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "$", "this", "->", "isAssociative", "(", "$", "value", ")", ")", "{", "$", "output", "=", "array_merge", "(", "$", "output", ",", "$", "this", "->", "doEncode", "(", "$", "value", ",", "$", "keys", ")", ")", ";", "}", "else", "{", "foreach", "(", "$", "value", "as", "$", "j", ")", "{", "$", "output", "[", "]", "=", "$", "this", "->", "keysToString", "(", "$", "keys", ")", ".", "'[] = '", ".", "$", "j", ";", "}", "}", "}", "else", "{", "$", "output", "[", "]", "=", "$", "this", "->", "keysToString", "(", "$", "keys", ")", ".", "' = '", ".", "$", "value", ";", "}", "array_pop", "(", "$", "keys", ")", ";", "}", "return", "$", "output", ";", "}" ]
Recursively serializes data to legacy make format. @param array $input The data to serialize. @param array $keys The current key path. @return string[] The serialized data as a flat array of lines.
[ "Recursively", "serializes", "data", "to", "legacy", "make", "format", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/IniEncoder.php#L36-L60
govCMS/govCMS8
src/IniEncoder.php
IniEncoder.keysToString
protected function keysToString(array $keys) { $head = array_shift($keys); if ($keys) { return $head . '[' . implode('][', $keys) . ']'; } else { return $head; } }
php
protected function keysToString(array $keys) { $head = array_shift($keys); if ($keys) { return $head . '[' . implode('][', $keys) . ']'; } else { return $head; } }
[ "protected", "function", "keysToString", "(", "array", "$", "keys", ")", "{", "$", "head", "=", "array_shift", "(", "$", "keys", ")", ";", "if", "(", "$", "keys", ")", "{", "return", "$", "head", ".", "'['", ".", "implode", "(", "']['", ",", "$", "keys", ")", ".", "']'", ";", "}", "else", "{", "return", "$", "head", ";", "}", "}" ]
Transforms an key path to a string. @param string[] $keys The key path. @return string The flattened key path.
[ "Transforms", "an", "key", "path", "to", "a", "string", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/IniEncoder.php#L71-L79
govCMS/govCMS8
src/IniEncoder.php
IniEncoder.parse
public function parse($data) { $info = []; if (preg_match_all(' @^\s* # Start at the beginning of a line, ignoring leading whitespace ((?: [^=;\[\]]| # Key names cannot contain equal signs, semi-colons or square brackets, \[[^\[\]]*\] # unless they are balanced and not nested )+?) \s*=\s* # Key/value pairs are separated by equal signs (ignoring white-space) (?: ("(?:[^"]|(?<=\\\\)")*")| # Double-quoted string, which may contain slash-escaped quotes/slashes (\'(?:[^\']|(?<=\\\\)\')*\')| # Single-quoted string, which may contain slash-escaped quotes/slashes ([^\r\n]*?) # Non-quoted string )\s*$ # Stop at the next end of a line, ignoring trailing whitespace @msx', $data, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { // Fetch the key and value string. $i = 0; foreach (['key', 'value1', 'value2', 'value3'] as $var) { $$var = isset($match[++$i]) ? $match[$i] : ''; } if (isset($key) && isset($value1) && isset($value2) && isset($value3)) { $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; // Parse array syntax. $keys = preg_split('/\]?\[/', rtrim($key, ']')); $last = array_pop($keys); $parent = &$info; // Create nested arrays. foreach ($keys as $key) { if ($key == '') { $key = count($parent); } if (!isset($parent[$key]) || !is_array($parent[$key])) { $parent[$key] = []; } $parent = &$parent[$key]; } // Handle PHP constants. if (preg_match('/^\w+$/i', $value) && defined($value)) { $value = constant($value); } // Insert actual value. if ($last == '') { $last = count($parent); } $parent[$last] = $value; } } } return $info; }
php
public function parse($data) { $info = []; if (preg_match_all(' @^\s* ((?: [^=;\[\]]| \[[^\[\]]*\] )+?) \s*=\s* (?: ("(?:[^"]|(?<=\\\\)")*")| (\'(?:[^\']|(?<=\\\\)\')*\')| ([^\r\n]*?) )\s*$ @msx', $data, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $i = 0; foreach (['key', 'value1', 'value2', 'value3'] as $var) { $$var = isset($match[++$i]) ? $match[$i] : ''; } if (isset($key) && isset($value1) && isset($value2) && isset($value3)) { $value = stripslashes(substr($value1, 1, -1)) . stripslashes(substr($value2, 1, -1)) . $value3; $keys = preg_split('/\]?\[/', rtrim($key, ']')); $last = array_pop($keys); $parent = &$info; foreach ($keys as $key) { if ($key == '') { $key = count($parent); } if (!isset($parent[$key]) || !is_array($parent[$key])) { $parent[$key] = []; } $parent = &$parent[$key]; } if (preg_match('/^\w+$/i', $value) && defined($value)) { $value = constant($value); } if ($last == '') { $last = count($parent); } $parent[$last] = $value; } } } return $info; }
[ "public", "function", "parse", "(", "$", "data", ")", "{", "$", "info", "=", "[", "]", ";", "if", "(", "preg_match_all", "(", "'\n @^\\s* # Start at the beginning of a line, ignoring leading whitespace\n ((?:\n [^=;\\[\\]]| # Key names cannot contain equal signs, semi-colons or square brackets,\n \\[[^\\[\\]]*\\] # unless they are balanced and not nested\n )+?)\n \\s*=\\s* # Key/value pairs are separated by equal signs (ignoring white-space)\n (?:\n (\"(?:[^\"]|(?<=\\\\\\\\)\")*\")| # Double-quoted string, which may contain slash-escaped quotes/slashes\n (\\'(?:[^\\']|(?<=\\\\\\\\)\\')*\\')| # Single-quoted string, which may contain slash-escaped quotes/slashes\n ([^\\r\\n]*?) # Non-quoted string\n )\\s*$ # Stop at the next end of a line, ignoring trailing whitespace\n @msx'", ",", "$", "data", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ")", "{", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "// Fetch the key and value string.", "$", "i", "=", "0", ";", "foreach", "(", "[", "'key'", ",", "'value1'", ",", "'value2'", ",", "'value3'", "]", "as", "$", "var", ")", "{", "$", "$", "var", "=", "isset", "(", "$", "match", "[", "++", "$", "i", "]", ")", "?", "$", "match", "[", "$", "i", "]", ":", "''", ";", "}", "if", "(", "isset", "(", "$", "key", ")", "&&", "isset", "(", "$", "value1", ")", "&&", "isset", "(", "$", "value2", ")", "&&", "isset", "(", "$", "value3", ")", ")", "{", "$", "value", "=", "stripslashes", "(", "substr", "(", "$", "value1", ",", "1", ",", "-", "1", ")", ")", ".", "stripslashes", "(", "substr", "(", "$", "value2", ",", "1", ",", "-", "1", ")", ")", ".", "$", "value3", ";", "// Parse array syntax.", "$", "keys", "=", "preg_split", "(", "'/\\]?\\[/'", ",", "rtrim", "(", "$", "key", ",", "']'", ")", ")", ";", "$", "last", "=", "array_pop", "(", "$", "keys", ")", ";", "$", "parent", "=", "&", "$", "info", ";", "// Create nested arrays.", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "$", "key", "==", "''", ")", "{", "$", "key", "=", "count", "(", "$", "parent", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "parent", "[", "$", "key", "]", ")", "||", "!", "is_array", "(", "$", "parent", "[", "$", "key", "]", ")", ")", "{", "$", "parent", "[", "$", "key", "]", "=", "[", "]", ";", "}", "$", "parent", "=", "&", "$", "parent", "[", "$", "key", "]", ";", "}", "// Handle PHP constants.", "if", "(", "preg_match", "(", "'/^\\w+$/i'", ",", "$", "value", ")", "&&", "defined", "(", "$", "value", ")", ")", "{", "$", "value", "=", "constant", "(", "$", "value", ")", ";", "}", "// Insert actual value.", "if", "(", "$", "last", "==", "''", ")", "{", "$", "last", "=", "count", "(", "$", "parent", ")", ";", "}", "$", "parent", "[", "$", "last", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "info", ";", "}" ]
Parses data in Drupal's .info format. @see https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_parse_info_format/7.x @param string $data A string to parse. @return array The parsed data.
[ "Parses", "data", "in", "Drupal", "s", ".", "info", "format", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/IniEncoder.php#L107-L164
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/ParallaxBgModifier.php
ParallaxBgModifier.modification
public static function modification($selector, array $config) { if (!empty($config['parallax'])) { $media = parent::getMediaQuery($config); $css[$media][$selector][] = 'background-image:url("' . $config['parallax'] . '")'; $libraries = [ 'govcms8_modifiers/jarallax', 'govcms8_modifiers/modifiers_bg_parallax_apply', ]; $settings = [ 'namespace' => 'ParallaxBgModifier', 'callback' => 'apply', 'selector' => $selector, 'media' => $media, 'args' => [], ]; if (!empty($config['parallax_speed'])) { $settings['args']['speed'] = floatval($config['parallax_speed']); } if (!empty($config['bgp_color_val'])) { $css[$media][$selector][] = 'background-color:' . $config['bgp_color_val']; } $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; return new Modification($css, $libraries, $settings, $attributes); } return NULL; }
php
public static function modification($selector, array $config) { if (!empty($config['parallax'])) { $media = parent::getMediaQuery($config); $css[$media][$selector][] = 'background-image:url("' . $config['parallax'] . '")'; $libraries = [ 'govcms8_modifiers/jarallax', 'govcms8_modifiers/modifiers_bg_parallax_apply', ]; $settings = [ 'namespace' => 'ParallaxBgModifier', 'callback' => 'apply', 'selector' => $selector, 'media' => $media, 'args' => [], ]; if (!empty($config['parallax_speed'])) { $settings['args']['speed'] = floatval($config['parallax_speed']); } if (!empty($config['bgp_color_val'])) { $css[$media][$selector][] = 'background-color:' . $config['bgp_color_val']; } $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; return new Modification($css, $libraries, $settings, $attributes); } return NULL; }
[ "public", "static", "function", "modification", "(", "$", "selector", ",", "array", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'parallax'", "]", ")", ")", "{", "$", "media", "=", "parent", "::", "getMediaQuery", "(", "$", "config", ")", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-image:url(\"'", ".", "$", "config", "[", "'parallax'", "]", ".", "'\")'", ";", "$", "libraries", "=", "[", "'govcms8_modifiers/jarallax'", ",", "'govcms8_modifiers/modifiers_bg_parallax_apply'", ",", "]", ";", "$", "settings", "=", "[", "'namespace'", "=>", "'ParallaxBgModifier'", ",", "'callback'", "=>", "'apply'", ",", "'selector'", "=>", "$", "selector", ",", "'media'", "=>", "$", "media", ",", "'args'", "=>", "[", "]", ",", "]", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'parallax_speed'", "]", ")", ")", "{", "$", "settings", "[", "'args'", "]", "[", "'speed'", "]", "=", "floatval", "(", "$", "config", "[", "'parallax_speed'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'bgp_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-color:'", ".", "$", "config", "[", "'bgp_color_val'", "]", ";", "}", "$", "attributes", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "'class'", "]", "[", "]", "=", "'modifiers-has-background'", ";", "return", "new", "Modification", "(", "$", "css", ",", "$", "libraries", ",", "$", "settings", ",", "$", "attributes", ")", ";", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/ParallaxBgModifier.php#L22-L51
govCMS/govCMS8
modules/custom/optional/govcms8_default_content/src/Plugin/ImportProcessor/PaddingModifierParagraphProcessor.php
PaddingModifierParagraphProcessor.process
public function process(&$values) { $this->mapBasicField($values, 'field_mod_padding_b_size'); $this->mapBasicField($values, 'field_mod_padding_b_units'); $this->mapBasicField($values, 'field_mod_padding_l_size'); $this->mapBasicField($values, 'field_mod_padding_l_units'); $this->mapBasicField($values, 'field_mod_padding_r_size'); $this->mapBasicField($values, 'field_mod_padding_r_units'); $this->mapBasicField($values, 'field_mod_padding_t_size'); $this->mapBasicField($values, 'field_mod_padding_t_units'); $this->mapBasicField($values, 'field_mod_media_query'); }
php
public function process(&$values) { $this->mapBasicField($values, 'field_mod_padding_b_size'); $this->mapBasicField($values, 'field_mod_padding_b_units'); $this->mapBasicField($values, 'field_mod_padding_l_size'); $this->mapBasicField($values, 'field_mod_padding_l_units'); $this->mapBasicField($values, 'field_mod_padding_r_size'); $this->mapBasicField($values, 'field_mod_padding_r_units'); $this->mapBasicField($values, 'field_mod_padding_t_size'); $this->mapBasicField($values, 'field_mod_padding_t_units'); $this->mapBasicField($values, 'field_mod_media_query'); }
[ "public", "function", "process", "(", "&", "$", "values", ")", "{", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_b_size'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_b_units'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_l_size'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_l_units'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_r_size'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_r_units'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_t_size'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_padding_t_units'", ")", ";", "$", "this", "->", "mapBasicField", "(", "$", "values", ",", "'field_mod_media_query'", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/Plugin/ImportProcessor/PaddingModifierParagraphProcessor.php#L22-L37
govCMS/govCMS8
src/Task/SetXMLPropertyTask.php
SetXMLPropertyTask.main
public function main() { $doc = new DOMDocument(); $doc->load($this->file); (new DOMXPath($doc)) ->query($this->element) ->item(0) ->setAttribute($this->attribute, $this->value); $doc->save($this->file); }
php
public function main() { $doc = new DOMDocument(); $doc->load($this->file); (new DOMXPath($doc)) ->query($this->element) ->item(0) ->setAttribute($this->attribute, $this->value); $doc->save($this->file); }
[ "public", "function", "main", "(", ")", "{", "$", "doc", "=", "new", "DOMDocument", "(", ")", ";", "$", "doc", "->", "load", "(", "$", "this", "->", "file", ")", ";", "(", "new", "DOMXPath", "(", "$", "doc", ")", ")", "->", "query", "(", "$", "this", "->", "element", ")", "->", "item", "(", "0", ")", "->", "setAttribute", "(", "$", "this", "->", "attribute", ",", "$", "this", "->", "value", ")", ";", "$", "doc", "->", "save", "(", "$", "this", "->", "file", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/Task/SetXMLPropertyTask.php#L86-L96
govCMS/govCMS8
modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/ImageBgModifier.php
ImageBgModifier.modification
public static function modification($selector, array $config) { if (!empty($config['image'])) { $media = parent::getMediaQuery($config); $css[$media][$selector][] = 'background-image:url("' . $config['image'] . '")'; $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; if (!empty($config['image_style'])) { switch ($config['image_style']) { case 'stretch': $css[$media][$selector][] = 'background-size:cover'; break; case 'no-repeat': case 'repeat': case 'repeat-x': case 'repeat-y': $css[$media][$selector][] = 'background-repeat:' . $config['image_style']; break; } } if (!empty($config['image_position'])) { $position = str_replace('-', ' ', $config['image_position']); $css[$media][$selector][] = 'background-position:' . $position; } if (!empty($config['bgi_color_val'])) { $css[$media][$selector][] = 'background-color:' . $config['bgi_color_val']; } return new Modification($css, [], [], $attributes); } return NULL; }
php
public static function modification($selector, array $config) { if (!empty($config['image'])) { $media = parent::getMediaQuery($config); $css[$media][$selector][] = 'background-image:url("' . $config['image'] . '")'; $attributes[$media][$selector]['class'][] = 'modifiers-has-background'; if (!empty($config['image_style'])) { switch ($config['image_style']) { case 'stretch': $css[$media][$selector][] = 'background-size:cover'; break; case 'no-repeat': case 'repeat': case 'repeat-x': case 'repeat-y': $css[$media][$selector][] = 'background-repeat:' . $config['image_style']; break; } } if (!empty($config['image_position'])) { $position = str_replace('-', ' ', $config['image_position']); $css[$media][$selector][] = 'background-position:' . $position; } if (!empty($config['bgi_color_val'])) { $css[$media][$selector][] = 'background-color:' . $config['bgi_color_val']; } return new Modification($css, [], [], $attributes); } return NULL; }
[ "public", "static", "function", "modification", "(", "$", "selector", ",", "array", "$", "config", ")", "{", "if", "(", "!", "empty", "(", "$", "config", "[", "'image'", "]", ")", ")", "{", "$", "media", "=", "parent", "::", "getMediaQuery", "(", "$", "config", ")", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-image:url(\"'", ".", "$", "config", "[", "'image'", "]", ".", "'\")'", ";", "$", "attributes", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "'class'", "]", "[", "]", "=", "'modifiers-has-background'", ";", "if", "(", "!", "empty", "(", "$", "config", "[", "'image_style'", "]", ")", ")", "{", "switch", "(", "$", "config", "[", "'image_style'", "]", ")", "{", "case", "'stretch'", ":", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-size:cover'", ";", "break", ";", "case", "'no-repeat'", ":", "case", "'repeat'", ":", "case", "'repeat-x'", ":", "case", "'repeat-y'", ":", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-repeat:'", ".", "$", "config", "[", "'image_style'", "]", ";", "break", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'image_position'", "]", ")", ")", "{", "$", "position", "=", "str_replace", "(", "'-'", ",", "' '", ",", "$", "config", "[", "'image_position'", "]", ")", ";", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-position:'", ".", "$", "position", ";", "}", "if", "(", "!", "empty", "(", "$", "config", "[", "'bgi_color_val'", "]", ")", ")", "{", "$", "css", "[", "$", "media", "]", "[", "$", "selector", "]", "[", "]", "=", "'background-color:'", ".", "$", "config", "[", "'bgi_color_val'", "]", ";", "}", "return", "new", "Modification", "(", "$", "css", ",", "[", "]", ",", "[", "]", ",", "$", "attributes", ")", ";", "}", "return", "NULL", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms8_foundations/modules/govcms8_modifiers/src/Plugin/modifiers/ImageBgModifier.php#L16-L51
govCMS/govCMS8
src/Composer/Package.php
Package.execute
public static function execute(Event $event) { $composer = $event->getComposer(); $handler = new static( $composer->getPackage(), $composer->getLocker() ); $encoder = new IniEncoder(); $make = $handler->make(); $core = $handler->makeCore($make); file_put_contents('drupal-org-core.make', $encoder->encode($core)); file_put_contents('drupal-org.make', $encoder->encode($make)); }
php
public static function execute(Event $event) { $composer = $event->getComposer(); $handler = new static( $composer->getPackage(), $composer->getLocker() ); $encoder = new IniEncoder(); $make = $handler->make(); $core = $handler->makeCore($make); file_put_contents('drupal-org-core.make', $encoder->encode($core)); file_put_contents('drupal-org.make', $encoder->encode($make)); }
[ "public", "static", "function", "execute", "(", "Event", "$", "event", ")", "{", "$", "composer", "=", "$", "event", "->", "getComposer", "(", ")", ";", "$", "handler", "=", "new", "static", "(", "$", "composer", "->", "getPackage", "(", ")", ",", "$", "composer", "->", "getLocker", "(", ")", ")", ";", "$", "encoder", "=", "new", "IniEncoder", "(", ")", ";", "$", "make", "=", "$", "handler", "->", "make", "(", ")", ";", "$", "core", "=", "$", "handler", "->", "makeCore", "(", "$", "make", ")", ";", "file_put_contents", "(", "'drupal-org-core.make'", ",", "$", "encoder", "->", "encode", "(", "$", "core", ")", ")", ";", "file_put_contents", "(", "'drupal-org.make'", ",", "$", "encoder", "->", "encode", "(", "$", "make", ")", ")", ";", "}" ]
Script entry point. @param \Composer\Script\Event $event The script event.
[ "Script", "entry", "point", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/Composer/Package.php#L48-L59
govCMS/govCMS8
src/Composer/Package.php
Package.buildPackage
protected function buildPackage(array $package) { if (isset($package['source'])) { $info = [ 'download' => [ 'type' => 'git', 'url' => $package['source']['url'], 'branch' => $package['version'], 'revision' => $package['source']['reference'], ], ]; } elseif (isset($package['dist'])) { $info = [ 'download' => [ 'type' => 'get', 'url' => $package['dist']['url'], ], ]; } if (isset($package['extra']['patches_applied'])) { $info['patch'] = array_values($package['extra']['patches_applied']); } return $info; }
php
protected function buildPackage(array $package) { if (isset($package['source'])) { $info = [ 'download' => [ 'type' => 'git', 'url' => $package['source']['url'], 'branch' => $package['version'], 'revision' => $package['source']['reference'], ], ]; } elseif (isset($package['dist'])) { $info = [ 'download' => [ 'type' => 'get', 'url' => $package['dist']['url'], ], ]; } if (isset($package['extra']['patches_applied'])) { $info['patch'] = array_values($package['extra']['patches_applied']); } return $info; }
[ "protected", "function", "buildPackage", "(", "array", "$", "package", ")", "{", "if", "(", "isset", "(", "$", "package", "[", "'source'", "]", ")", ")", "{", "$", "info", "=", "[", "'download'", "=>", "[", "'type'", "=>", "'git'", ",", "'url'", "=>", "$", "package", "[", "'source'", "]", "[", "'url'", "]", ",", "'branch'", "=>", "$", "package", "[", "'version'", "]", ",", "'revision'", "=>", "$", "package", "[", "'source'", "]", "[", "'reference'", "]", ",", "]", ",", "]", ";", "}", "elseif", "(", "isset", "(", "$", "package", "[", "'dist'", "]", ")", ")", "{", "$", "info", "=", "[", "'download'", "=>", "[", "'type'", "=>", "'get'", ",", "'url'", "=>", "$", "package", "[", "'dist'", "]", "[", "'url'", "]", ",", "]", ",", "]", ";", "}", "if", "(", "isset", "(", "$", "package", "[", "'extra'", "]", "[", "'patches_applied'", "]", ")", ")", "{", "$", "info", "[", "'patch'", "]", "=", "array_values", "(", "$", "package", "[", "'extra'", "]", "[", "'patches_applied'", "]", ")", ";", "}", "return", "$", "info", ";", "}" ]
Builds a make structure for any kind of package. @param array $package The Composer package definition. @return array The generated make structure.
[ "Builds", "a", "make", "structure", "for", "any", "kind", "of", "package", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/Composer/Package.php#L201-L225
govCMS/govCMS8
src/Composer/Package.php
Package.isLibrary
protected function isLibrary(array $package) { // Add Swiftmailer support. if ($package['name'] == 'swiftmailer/swiftmailer') { $package['type'] = 'drupal-library'; } $package_types = [ 'drupal-library', 'bower-asset', 'npm-asset', ]; return ( in_array($package['type'], $package_types) && array_key_exists($package['name'], $this->rootPackage->getRequires()) ); }
php
protected function isLibrary(array $package) { if ($package['name'] == 'swiftmailer/swiftmailer') { $package['type'] = 'drupal-library'; } $package_types = [ 'drupal-library', 'bower-asset', 'npm-asset', ]; return ( in_array($package['type'], $package_types) && array_key_exists($package['name'], $this->rootPackage->getRequires()) ); }
[ "protected", "function", "isLibrary", "(", "array", "$", "package", ")", "{", "// Add Swiftmailer support.", "if", "(", "$", "package", "[", "'name'", "]", "==", "'swiftmailer/swiftmailer'", ")", "{", "$", "package", "[", "'type'", "]", "=", "'drupal-library'", ";", "}", "$", "package_types", "=", "[", "'drupal-library'", ",", "'bower-asset'", ",", "'npm-asset'", ",", "]", ";", "return", "(", "in_array", "(", "$", "package", "[", "'type'", "]", ",", "$", "package_types", ")", "&&", "array_key_exists", "(", "$", "package", "[", "'name'", "]", ",", "$", "this", "->", "rootPackage", "->", "getRequires", "(", ")", ")", ")", ";", "}" ]
Determines if a package is an asset library. @param array $package The package info. @return bool TRUE if the package is an asset library, otherwise FALSE.
[ "Determines", "if", "a", "package", "is", "an", "asset", "library", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/Composer/Package.php#L259-L274
govCMS/govCMS8
src/Composer/Package.php
Package.isGovCMSTheme
protected function isGovCMSTheme(array $package) { // Exlucde package theme from custom repos. if ($package['name'] == 'govcms-custom/govcms8_uikit' || $package['name'] == 'govcms-custom/govcms8_uikit_starter') { return FALSE; } $package_types = [ 'drupal-theme', ]; return ( in_array($package['type'], $package_types) && array_key_exists($package['name'], $this->rootPackage->getRequires()) ); }
php
protected function isGovCMSTheme(array $package) { if ($package['name'] == 'govcms-custom/govcms8_uikit' || $package['name'] == 'govcms-custom/govcms8_uikit_starter') { return FALSE; } $package_types = [ 'drupal-theme', ]; return ( in_array($package['type'], $package_types) && array_key_exists($package['name'], $this->rootPackage->getRequires()) ); }
[ "protected", "function", "isGovCMSTheme", "(", "array", "$", "package", ")", "{", "// Exlucde package theme from custom repos.", "if", "(", "$", "package", "[", "'name'", "]", "==", "'govcms-custom/govcms8_uikit'", "||", "$", "package", "[", "'name'", "]", "==", "'govcms-custom/govcms8_uikit_starter'", ")", "{", "return", "FALSE", ";", "}", "$", "package_types", "=", "[", "'drupal-theme'", ",", "]", ";", "return", "(", "in_array", "(", "$", "package", "[", "'type'", "]", ",", "$", "package_types", ")", "&&", "array_key_exists", "(", "$", "package", "[", "'name'", "]", ",", "$", "this", "->", "rootPackage", "->", "getRequires", "(", ")", ")", ")", ";", "}" ]
Determines if a package is a GovCMS theme. @param array $package The package info. @return bool True if the package is a GovCMS theme, otherwise FALSE.
[ "Determines", "if", "a", "package", "is", "a", "GovCMS", "theme", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/src/Composer/Package.php#L285-L298
govCMS/govCMS8
modules/custom/core/govcms_media/src/Element/InteractiveUpload.php
InteractiveUpload.process
public static function process(array $element, FormStateInterface $form_state) { $element['fid'] = [ '#type' => 'hidden', ]; $element['upload'] = $element['remove'] = [ '#type' => 'submit', '#is_button' => TRUE, '#limit_validation_errors' => [ $element['#parents'], ], '#weight' => 100, ]; $element['upload']['#value'] = t('Upload'); $element['upload']['#submit'][] = [static::class, 'upload']; $element['remove']['#value'] = t('Remove'); $element['remove']['#submit'][] = [static::class, 'remove']; $key = array_merge($element['#parents'], ['fid']); // Don't use $form_state->hasValue(), because it will return TRUE if the // value exists and is falsy. Valid file IDs will always be truthy. $fid = $form_state->getValue($key); if ($fid) { $element['fid']['#value'] = $fid; $element['file'] = [ '#theme' => 'file_link', '#file' => File::load($fid), ]; $element['upload']['#access'] = FALSE; } else { $element['file'] = [ '#type' => 'upload', '#title' => $element['#title'], '#upload_location' => $element['#upload_location'], '#upload_validators' => $element['#upload_validators'], ]; $element['remove']['#access'] = FALSE; } return $element; }
php
public static function process(array $element, FormStateInterface $form_state) { $element['fid'] = [ ' ]; $element['upload'] = $element['remove'] = [ ' ' ' $element[' ], ' ]; $element['upload'][' $element['upload'][' $element['remove'][' $element['remove'][' $key = array_merge($element[' $fid = $form_state->getValue($key); if ($fid) { $element['fid'][' $element['file'] = [ ' ' ]; $element['upload'][' } else { $element['file'] = [ ' ' ' ' ]; $element['remove'][' } return $element; }
[ "public", "static", "function", "process", "(", "array", "$", "element", ",", "FormStateInterface", "$", "form_state", ")", "{", "$", "element", "[", "'fid'", "]", "=", "[", "'#type'", "=>", "'hidden'", ",", "]", ";", "$", "element", "[", "'upload'", "]", "=", "$", "element", "[", "'remove'", "]", "=", "[", "'#type'", "=>", "'submit'", ",", "'#is_button'", "=>", "TRUE", ",", "'#limit_validation_errors'", "=>", "[", "$", "element", "[", "'#parents'", "]", ",", "]", ",", "'#weight'", "=>", "100", ",", "]", ";", "$", "element", "[", "'upload'", "]", "[", "'#value'", "]", "=", "t", "(", "'Upload'", ")", ";", "$", "element", "[", "'upload'", "]", "[", "'#submit'", "]", "[", "]", "=", "[", "static", "::", "class", ",", "'upload'", "]", ";", "$", "element", "[", "'remove'", "]", "[", "'#value'", "]", "=", "t", "(", "'Remove'", ")", ";", "$", "element", "[", "'remove'", "]", "[", "'#submit'", "]", "[", "]", "=", "[", "static", "::", "class", ",", "'remove'", "]", ";", "$", "key", "=", "array_merge", "(", "$", "element", "[", "'#parents'", "]", ",", "[", "'fid'", "]", ")", ";", "// Don't use $form_state->hasValue(), because it will return TRUE if the", "// value exists and is falsy. Valid file IDs will always be truthy.", "$", "fid", "=", "$", "form_state", "->", "getValue", "(", "$", "key", ")", ";", "if", "(", "$", "fid", ")", "{", "$", "element", "[", "'fid'", "]", "[", "'#value'", "]", "=", "$", "fid", ";", "$", "element", "[", "'file'", "]", "=", "[", "'#theme'", "=>", "'file_link'", ",", "'#file'", "=>", "File", "::", "load", "(", "$", "fid", ")", ",", "]", ";", "$", "element", "[", "'upload'", "]", "[", "'#access'", "]", "=", "FALSE", ";", "}", "else", "{", "$", "element", "[", "'file'", "]", "=", "[", "'#type'", "=>", "'upload'", ",", "'#title'", "=>", "$", "element", "[", "'#title'", "]", ",", "'#upload_location'", "=>", "$", "element", "[", "'#upload_location'", "]", ",", "'#upload_validators'", "=>", "$", "element", "[", "'#upload_validators'", "]", ",", "]", ";", "$", "element", "[", "'remove'", "]", "[", "'#access'", "]", "=", "FALSE", ";", "}", "return", "$", "element", ";", "}" ]
Processes the element. @param array $element The unprocessed element. @param \Drupal\Core\Form\FormStateInterface $form_state The current form state. @return array The processed element.
[ "Processes", "the", "element", "." ]
train
https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element/InteractiveUpload.php#L48-L91