_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q25900
Builder.expr
train
public function expr() : Expr { $expr = new Expr($this->dm); $expr->setClassMetadata($this->class); return $expr; }
php
{ "resource": "" }
q25901
Builder.field
train
public function field(string $field) : self { $this->currentField = $field; $this->expr->field($field); return $this; }
php
{ "resource": "" }
q25902
Builder.find
train
public function find(?string $documentName = null) : self { $this->setDocumentName($documentName); $this->query['type'] = Query::TYPE_FIND; return $this; }
php
{ "resource": "" }
q25903
Builder.selectMeta
train
public function selectMeta(string $fieldName, string $metaDataKeyword) : self { $this->query['select'][$fieldName] = ['$meta' => $metaDataKeyword]; return $this; }
php
{ "resource": "" }
q25904
Builder.getDiscriminatorValues
train
private function getDiscriminatorValues($classNames) : array { $discriminatorValues = []; $collections = []; foreach ($classNames as $className) { $class = $this->dm->getClassMetadata($className); $discriminatorValues[] = $class->discriminatorV...
php
{ "resource": "" }
q25905
UuidGenerator.generate
train
public function generate(DocumentManager $dm, object $document) { $uuid = $this->generateV4(); return $this->generateV5($uuid, $this->salt ?: php_uname('n')); }
php
{ "resource": "" }
q25906
Builder.bucket
train
public function bucket() : Stage\Bucket { $stage = new Stage\Bucket($this, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25907
Builder.bucketAuto
train
public function bucketAuto() : Stage\BucketAuto { $stage = new Stage\BucketAuto($this, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25908
Builder.collStats
train
public function collStats() : Stage\CollStats { $stage = new Stage\CollStats($this); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25909
Builder.count
train
public function count(string $fieldName) : Stage\Count { $stage = new Stage\Count($this, $fieldName); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25910
Builder.execute
train
public function execute(array $options = []) : Iterator { // Force cursor to be used $options = array_merge($options, ['cursor' => true]); $cursor = $this->collection->aggregate($this->getPipeline(), $options); assert($cursor instanceof Cursor); return $this->prepareIterato...
php
{ "resource": "" }
q25911
Builder.facet
train
public function facet() : Stage\Facet { $stage = new Stage\Facet($this); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25912
Builder.getPipeline
train
public function getPipeline() : array { $pipeline = array_map( static function (Stage $stage) { return $stage->getExpression(); }, $this->stages ); if ($this->getStage(0) instanceof Stage\GeoNear) { $pipeline[0]['$geoNear']['qu...
php
{ "resource": "" }
q25913
Builder.graphLookup
train
public function graphLookup(string $from) : Stage\GraphLookup { $stage = new Stage\GraphLookup($this, $from, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25914
Builder.group
train
public function group() : Stage\Group { $stage = new Stage\Group($this); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25915
Builder.indexStats
train
public function indexStats() : Stage\IndexStats { $stage = new Stage\IndexStats($this); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25916
Builder.limit
train
public function limit(int $limit) : Stage\Limit { $stage = new Stage\Limit($this, $limit); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25917
Builder.matchExpr
train
public function matchExpr() : QueryExpr { $expr = new QueryExpr($this->dm); $expr->setClassMetadata($this->class); return $expr; }
php
{ "resource": "" }
q25918
Builder.out
train
public function out(string $from) : Stage\Out { $stage = new Stage\Out($this, $from, $this->dm); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25919
Builder.project
train
public function project() : Stage\Project { $stage = new Stage\Project($this); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25920
Builder.redact
train
public function redact() : Stage\Redact { $stage = new Stage\Redact($this); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25921
Builder.replaceRoot
train
public function replaceRoot($expression = null) : Stage\ReplaceRoot { $stage = new Stage\ReplaceRoot($this, $this->dm, $this->class, $expression); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25922
Builder.sample
train
public function sample(int $size) : Stage\Sample { $stage = new Stage\Sample($this, $size); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25923
Builder.skip
train
public function skip(int $skip) : Stage\Skip { $stage = new Stage\Skip($this, $skip); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25924
Builder.sortByCount
train
public function sortByCount(string $expression) : Stage\SortByCount { $stage = new Stage\SortByCount($this, $expression, $this->dm, $this->class); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25925
Builder.unwind
train
public function unwind(string $fieldName) : Stage\Unwind { // Fixme: move field name translation to stage $stage = new Stage\Unwind($this, $this->getDocumentPersister()->prepareFieldName($fieldName)); $this->addStage($stage); return $stage; }
php
{ "resource": "" }
q25926
Builder.applyFilters
train
private function applyFilters(array $query) : array { $documentPersister = $this->dm->getUnitOfWork()->getDocumentPersister($this->class->name); $query = $documentPersister->addDiscriminatorToPreparedQuery($query); $query = $documentPersister->addFilterToPreparedQuery($query); retu...
php
{ "resource": "" }
q25927
CachingIterator.storeCurrentItem
train
private function storeCurrentItem() : void { $key = $this->iterator->key(); if ($key === null) { return; } $this->items[$key] = $this->iterator->current(); }
php
{ "resource": "" }
q25928
Project.avg
train
public function avg($expression1, ...$expressions) : self { $this->expr->avg(empty($expressions) ? $expression1 : func_get_args()); return $this; }
php
{ "resource": "" }
q25929
Project.stdDevSamp
train
public function stdDevSamp($expression1, ...$expressions) : self { $this->expr->stdDevSamp(empty($expressions) ? $expression1 : func_get_args()); return $this; }
php
{ "resource": "" }
q25930
Project.sum
train
public function sum($expression1, ...$expressions) : self { $this->expr->sum(empty($expressions) ? $expression1 : func_get_args()); return $this; }
php
{ "resource": "" }
q25931
Expr.expression
train
public function expression($value) : self { $this->requiresCurrentField(__METHOD__); $this->expr[$this->currentField] = $this->ensureArray($value); return $this; }
php
{ "resource": "" }
q25932
Expr.field
train
public function field(string $fieldName) : self { $fieldName = $this->getDocumentPersister()->prepareFieldName($fieldName); $this->currentField = $fieldName; return $this; }
php
{ "resource": "" }
q25933
Expr.addToSet
train
public function addToSet($valueOrExpression) : self { if ($valueOrExpression instanceof Expr) { $valueOrExpression = $valueOrExpression->getQuery(); } $this->requiresCurrentField(); $this->newObj['$addToSet'][$this->currentField] = $valueOrExpression; return $thi...
php
{ "resource": "" }
q25934
Expr.equals
train
public function equals($value) : self { if ($this->currentField) { $this->query[$this->currentField] = $value; } else { $this->query = $value; } return $this; }
php
{ "resource": "" }
q25935
Expr.inc
train
public function inc($value) : self { $this->requiresCurrentField(); $this->newObj['$inc'][$this->currentField] = $value; return $this; }
php
{ "resource": "" }
q25936
Expr.includesReferenceTo
train
public function includesReferenceTo(object $document) : self { $this->requiresCurrentField(); $mapping = $this->getReferenceMapping(); $reference = $this->dm->createReference($document, $mapping); $storeAs = $mapping['storeAs'] ?? null; $keys = []; switch ($...
php
{ "resource": "" }
q25937
Expr.not
train
public function not($expression) : self { return $this->operator('$not', $expression instanceof Expr ? $expression->getQuery() : $expression); }
php
{ "resource": "" }
q25938
Expr.getReferenceMapping
train
private function getReferenceMapping() : array { $this->requiresCurrentField(); assert($this->currentField !== null); try { return $this->class->getFieldMapping($this->currentField); } catch (MappingException $e) { if (empty($this->class->discriminatorMap)) {...
php
{ "resource": "" }
q25939
Cache.set
train
public function set($name, Location $location) { return $this->cache->put($name, $location->toArray(), $this->expires); }
php
{ "resource": "" }
q25940
GeoIPServiceProvider.registerGeoIpService
train
public function registerGeoIpService() { $this->app->singleton('geoip', function ($app) { return new GeoIP( $app->config->get('geoip', []), $app['cache'] ); }); }
php
{ "resource": "" }
q25941
GeoIP.getService
train
public function getService() { if ($this->service === null) { // Get service configuration $config = $this->config('services.' . $this->config('service'), []); // Get service class $class = Arr::pull($config, 'class'); // Sanity check ...
php
{ "resource": "" }
q25942
GeoIP.isValid
train
private function isValid($ip) { if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) && !filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6 | FILTER_FLAG_NO_PRIV_RANGE) ) { return false; } return ...
php
{ "resource": "" }
q25943
HttpClient.get
train
public function get($url, array $query = [], array $headers = []) { return $this->execute('GET', $this->buildGetUrl($url, $query), [], $headers); }
php
{ "resource": "" }
q25944
HttpClient.parseHeaders
train
private function parseHeaders($headers) { $result = []; foreach (preg_split("/\\r\\n|\\r|\\n/", $headers) as $row) { $header = explode(':', $row, 2); if (count($header) == 2) { $result[$header[0]] = trim($header[1]); } else { ...
php
{ "resource": "" }
q25945
HttpClient.getUrl
train
private function getUrl($url) { // Check for URL scheme if (parse_url($url, PHP_URL_SCHEME) === null) { $url = Arr::get($this->config, 'base_uri') . $url; } return $url; }
php
{ "resource": "" }
q25946
HttpClient.buildGetUrl
train
private function buildGetUrl($url, array $query = []) { // Merge global and request queries $query = array_merge( Arr::get($this->config, 'query', []), $query ); // Append query if ($query = http_build_query($query)) { $url .= strpos($url,...
php
{ "resource": "" }
q25947
CustomerPaymentsEndpoint.createForId
train
public function createForId($customerId, array $options = [], array $filters = []) { $this->parentId = $customerId; return parent::rest_create($options, $filters); }
php
{ "resource": "" }
q25948
ProfileMethodEndpoint.createForId
train
public function createForId($profileId, $methodId, array $data = []) { $this->parentId = $profileId; $resource = $this->getResourcePath() . '/' . urlencode($methodId); $body = null; if (count($data) > 0) { $body = json_encode($data); } $result = $this->c...
php
{ "resource": "" }
q25949
ProfileMethodEndpoint.createFor
train
public function createFor($profile, $methodId, array $data = []) { return $this->createForId($profile->id, $methodId, $data); }
php
{ "resource": "" }
q25950
ProfileMethodEndpoint.deleteForId
train
public function deleteForId($profileId, $methodId, array $data = []) { $this->parentId = $profileId; return $this->rest_delete($methodId, $data); }
php
{ "resource": "" }
q25951
ProfileMethodEndpoint.deleteFor
train
public function deleteFor($profile, $methodId, array $data = []) { return $this->deleteForId($profile->id, $methodId, $data); }
php
{ "resource": "" }
q25952
Customer.payments
train
public function payments() { return $this->client->customerPayments->listFor($this, null, null, $this->getPresetOptions()); }
php
{ "resource": "" }
q25953
Customer.subscriptions
train
public function subscriptions() { return $this->client->subscriptions->listFor($this, null, null, $this->getPresetOptions()); }
php
{ "resource": "" }
q25954
Customer.mandates
train
public function mandates() { return $this->client->mandates->listFor($this, null, null, $this->getPresetOptions()); }
php
{ "resource": "" }
q25955
Customer.hasValidMandate
train
public function hasValidMandate() { $mandates = $this->mandates(); foreach ($mandates as $mandate) { if ($mandate->isValid()) { return true; } } return false; }
php
{ "resource": "" }
q25956
Customer.hasValidMandateForMethod
train
public function hasValidMandateForMethod($method) { $mandates = $this->mandates(); foreach ($mandates as $mandate) { if ($mandate->method === $method && $mandate->isValid()) { return true; } } return false; }
php
{ "resource": "" }
q25957
Customer.getPresetOptions
train
private function getPresetOptions() { $options = []; if($this->client->usesOAuth()) { $options["testmode"] = $this->mode === "test" ? true : false; } return $options; }
php
{ "resource": "" }
q25958
ShipmentEndpoint.listForId
train
public function listForId($orderId, array $parameters = []) { $this->parentId = $orderId; return parent::rest_list(null, null, $parameters); }
php
{ "resource": "" }
q25959
Profile.chargebacks
train
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 ResourceFact...
php
{ "resource": "" }
q25960
Profile.methods
train
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::createCursorResourceCollec...
php
{ "resource": "" }
q25961
Profile.enableMethod
train
public function enableMethod($methodId, array $data = []) { return $this->client->profileMethods->createFor($this, $methodId, $data); }
php
{ "resource": "" }
q25962
Profile.disableMethod
train
public function disableMethod($methodId, array $data = []) { return $this->client->profileMethods->deleteFor($this, $methodId, $data); }
php
{ "resource": "" }
q25963
Profile.refunds
train
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::createCurso...
php
{ "resource": "" }
q25964
Payment.getCheckoutUrl
train
public function getCheckoutUrl() { if (empty($this->_links->checkout)) { return null; } return $this->_links->checkout->href; }
php
{ "resource": "" }
q25965
Payment.captures
train
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 ); ...
php
{ "resource": "" }
q25966
Payment.getChargeback
train
public function getChargeback($chargebackId, array $parameters = []) { return $this->client->paymentChargebacks->getFor( $this, $chargebackId, $parameters ); }
php
{ "resource": "" }
q25967
Payment.refund
train
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, $r...
php
{ "resource": "" }
q25968
PaymentEndpoint.get
train
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:...
php
{ "resource": "" }
q25969
PaymentEndpoint.page
train
public function page($from = null, $limit = null, array $parameters = []) { return $this->rest_list($from, $limit, $parameters); }
php
{ "resource": "" }
q25970
PaymentEndpoint.refund
train
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_CREAT...
php
{ "resource": "" }
q25971
ResourceFactory.createFromApiResult
train
public static function createFromApiResult($apiResult, BaseResource $resource) { foreach ($apiResult as $property => $value) { $resource->{$property} = $value; } return $resource; }
php
{ "resource": "" }
q25972
Mandate.revoke
train
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 ]); } $re...
php
{ "resource": "" }
q25973
MethodEndpoint.allAvailable
train
public function allAvailable(array $parameters = []) { $url = 'methods/all' . $this->buildQueryString($parameters); $result = $this->client->performHttpCall('GET', $url); return ResourceFactory::createBaseResourceCollection( $this->client, $result->_embedded->method...
php
{ "resource": "" }
q25974
MethodEndpoint.get
train
public function get($methodId, array $parameters = []) { if (empty($methodId)) { throw new ApiException("Method ID is empty."); } return parent::rest_read($methodId, $parameters); }
php
{ "resource": "" }
q25975
OrganizationEndpoint.get
train
public function get($organizationId, array $parameters = []) { if (empty($organizationId)) { throw new ApiException("Organization ID is empty."); } return parent::rest_read($organizationId, $parameters); }
php
{ "resource": "" }
q25976
EndpointAbstract.rest_read
train
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->bu...
php
{ "resource": "" }
q25977
EndpointAbstract.rest_delete
train
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}", ...
php
{ "resource": "" }
q25978
EndpointAbstract.rest_list
train
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); ...
php
{ "resource": "" }
q25979
CursorCollection.next
train
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 ($r...
php
{ "resource": "" }
q25980
ProfileEndpoint.get
train
public function get($profileId, array $parameters = []) { if($profileId === 'me') { return $this->getCurrent($parameters); } return $this->rest_read($profileId, $parameters); }
php
{ "resource": "" }
q25981
OrderLineCollection.get
train
public function get($lineId) { foreach ($this as $line) { if ($line->id === $lineId) { return $line; } } return null; }
php
{ "resource": "" }
q25982
Subscription.cancel
train
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 ]); } $re...
php
{ "resource": "" }
q25983
Order.getShipment
train
public function getShipment($shipmentId, array $parameters = []) { return $this->client->shipments->getFor($this, $shipmentId, $parameters); }
php
{ "resource": "" }
q25984
Order.createPayment
train
public function createPayment($data, $filters = []) { return $this->client->orderPayments->createFor($this, $data, $filters); }
php
{ "resource": "" }
q25985
Order.payments
train
public function payments() { if(! isset($this->_embedded, $this->_embedded->payments) ) { return null; } return ResourceFactory::createCursorResourceCollection( $this->client, $this->_embedded->payments, Payment::class ); }
php
{ "resource": "" }
q25986
OrderLineEndpoint.cancelForId
train
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, ...
php
{ "resource": "" }
q25987
Shipment.update
train
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...
php
{ "resource": "" }
q25988
Refund.cancel
train
public function cancel() { $this->client->performHttpCallToFullUrl( MollieApiClient::HTTP_DELETE, $this->_links->self->href ); return null; }
php
{ "resource": "" }
q25989
MollieApiClient.performHttpCallToFullUrl
train
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)...
php
{ "resource": "" }
q25990
MollieApiClient.parseResponseBody
train
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....
php
{ "resource": "" }
q25991
OrderEndpoint.get
train
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(...
php
{ "resource": "" }
q25992
CalendarItemDateFormatter.viewValue
train
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, ...
php
{ "resource": "" }
q25993
BulkUploadForm.bytesToString
train
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
{ "resource": "" }
q25994
MediaHelper.getFileExtensions
train
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...
php
{ "resource": "" }
q25995
MediaHelper.getBundleFromInput
train
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') ->...
php
{ "resource": "" }
q25996
MediaHelper.createFromInput
train
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::getSourceFi...
php
{ "resource": "" }
q25997
MediaHelper.useFile
train
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) != '/') { $d...
php
{ "resource": "" }
q25998
MediaHelper.prepareFileDestination
train
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_PERMIS...
php
{ "resource": "" }
q25999
MediaHelper.getSourceField
train
public static function getSourceField(MediaInterface $entity) { $field = $entity->getSource()->getSourceFieldDefinition($entity->bundle->entity); return $field ? $entity->get($field->getName()) : NULL; }
php
{ "resource": "" }