_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q14500
MediaRepository.applyFilterToMediaCollection
train
protected function applyFilterToMediaCollection(Collection $media, $filter): Collection { if (is_array($filter)) {
php
{ "resource": "" }
q14501
MediaRepository.getDefaultFilterFunction
train
protected function getDefaultFilterFunction(array $filters): Closure { return function (Media $media) use ($filters) { foreach ($filters as $property => $value) { if (!
php
{ "resource": "" }
q14502
Conversion.setManipulations
train
public function setManipulations($manipulations) : self { if ($manipulations instanceof Manipulations) { $this->manipulations = $this->manipulations->mergeManipulations($manipulations); }
php
{ "resource": "" }
q14503
Conversion.addAsFirstManipulations
train
public function addAsFirstManipulations(Manipulations $manipulations) : self { $manipulationSequence = $manipulations->getManipulationSequence()->toArray(); $this->manipulations
php
{ "resource": "" }
q14504
FileManipulator.createDerivedFiles
train
public function createDerivedFiles(Media $media, array $only = [], $onlyIfMissing = false) { $profileCollection = ConversionCollection::createForMedia($media); if (! empty($only)) { $profileCollection = $profileCollection->filter(function ($collection) use ($only) { return in_array($collection->getName(), $only); }); } $this->performConversions( $profileCollection->getNonQueuedConversions($media->collection_name), $media, $onlyIfMissing
php
{ "resource": "" }
q14505
FileManipulator.performConversions
train
public function performConversions(ConversionCollection $conversions, Media $media, $onlyIfMissing = false) { if ($conversions->isEmpty()) { return; } $imageGenerator = $this->determineImageGenerator($media); if (! $imageGenerator) { return; } $temporaryDirectory = TemporaryDirectory::create(); $copiedOriginalFile = app(Filesystem::class)->copyFromMediaLibrary( $media, $temporaryDirectory->path(str_random(16).'.'.$media->extension) ); $conversions ->reject(function (Conversion $conversion) use ($onlyIfMissing, $media) { $relativePath = $media->getPath($conversion->getName()); $rootPath = config('filesystems.disks.'.$media->disk.'.root'); if ($rootPath) { $relativePath = str_replace($rootPath, '', $relativePath); } return $onlyIfMissing && Storage::disk($media->disk)->exists($relativePath); }) ->each(function (Conversion $conversion) use ($media, $imageGenerator, $copiedOriginalFile) { event(new ConversionWillStart($media, $conversion, $copiedOriginalFile)); $copiedOriginalFile = $imageGenerator->convert($copiedOriginalFile, $conversion); $manipulationResult = $this->performManipulations($media, $conversion, $copiedOriginalFile); $newFileName = pathinfo($media->file_name, PATHINFO_FILENAME). '-'.$conversion->getName().
php
{ "resource": "" }
q14506
LocalUrlGenerator.getResponsiveImagesDirectoryUrl
train
public function getResponsiveImagesDirectoryUrl(): string { return
php
{ "resource": "" }
q14507
ConversionCollection.getByName
train
public function getByName(string $name): Conversion { $conversion = $this->first(function (Conversion $conversion) use ($name) { return $conversion->getName() === $name; }); if
php
{ "resource": "" }
q14508
ConversionCollection.addConversionsFromRelatedModel
train
protected function addConversionsFromRelatedModel(Media $media) { $modelName = Arr::get(Relation::morphMap(), $media->model_type, $media->model_type); /** @var \Spatie\MediaLibrary\HasMedia\HasMedia $model */ $model = new $modelName(); /* * In some cases the user might want to get the actual model * instance so conversion parameters can depend on model
php
{ "resource": "" }
q14509
ConversionCollection.addManipulationsFromDb
train
protected function addManipulationsFromDb(Media $media) { collect($media->manipulations)->each(function ($manipulations,
php
{ "resource": "" }
q14510
S3UrlGenerator.getTemporaryUrl
train
public function getTemporaryUrl(DateTimeInterface $expiration, array $options = []): string { return $this ->filesystemManager
php
{ "resource": "" }
q14511
HasMediaTrait.addMediaFromUrl
train
public function addMediaFromUrl(string $url, ...$allowedMimeTypes) { if (! $stream = @fopen($url, 'r')) { throw UnreachableUrl::create($url); } $temporaryFile = tempnam(sys_get_temp_dir(), 'media-library'); file_put_contents($temporaryFile, $stream); $this->guardAgainstInvalidMimeType($temporaryFile, $allowedMimeTypes); $filename = basename(parse_url($url, PHP_URL_PATH)); $filename = str_replace('%20', ' ', $filename); if ($filename === '') { $filename = 'file'; } $mediaExtension = explode('/', mime_content_type($temporaryFile));
php
{ "resource": "" }
q14512
HasMediaTrait.addMediaFromBase64
train
public function addMediaFromBase64(string $base64data, ...$allowedMimeTypes): FileAdder { // strip out data uri scheme information (see RFC 2397) if (strpos($base64data, ';base64') !== false) { [$_, $base64data] = explode(';', $base64data); [$_, $base64data] = explode(',', $base64data); } // strict mode filters for non-base64 alphabet characters if (base64_decode($base64data, true) === false) { throw InvalidBase64Data::create(); } // decoding and then reencoding should not change the data if (base64_encode(base64_decode($base64data)) !== $base64data) { throw InvalidBase64Data::create();
php
{ "resource": "" }
q14513
HasMediaTrait.updateMedia
train
public function updateMedia(array $newMediaArray, string $collectionName = 'default'): Collection { $this->removeMediaItemsNotPresentInArray($newMediaArray, $collectionName); return collect($newMediaArray) ->map(function (array $newMediaItem) use ($collectionName) { static $orderColumn = 1; $mediaClass = config('medialibrary.media_model'); $currentMedia = $mediaClass::findOrFail($newMediaItem['id']); if ($currentMedia->collection_name !== $collectionName) { throw MediaCannotBeUpdated::doesNotBelongToCollection($collectionName, $currentMedia); }
php
{ "resource": "" }
q14514
HasMediaTrait.clearMediaCollection
train
public function clearMediaCollection(string $collectionName = 'default'): self { $this->getMedia($collectionName) ->each->delete(); event(new CollectionHasBeenCleared($this, $collectionName));
php
{ "resource": "" }
q14515
HasMediaTrait.clearMediaCollectionExcept
train
public function clearMediaCollectionExcept(string $collectionName = 'default', $excludedMedia = []) { if ($excludedMedia instanceof Media) { $excludedMedia = collect()->push($excludedMedia); } $excludedMedia = collect($excludedMedia); if ($excludedMedia->isEmpty()) {
php
{ "resource": "" }
q14516
HasMediaTrait.deleteMedia
train
public function deleteMedia($mediaId) { if ($mediaId instanceof Media) { $mediaId = $mediaId->id; } $media = $this->media->find($mediaId); if (! $media) {
php
{ "resource": "" }
q14517
HasMediaTrait.loadMedia
train
public function loadMedia(string $collectionName) { $collection = $this->exists ? $this->media : collect($this->unAttachedMediaLibraryItems)->pluck('media'); return $collection
php
{ "resource": "" }
q14518
ParamHelpers.cleanParams
train
protected function cleanParams(array $params) { $values = []; foreach ($params as $name => $details) { $this->cleanValueFrom($name,
php
{ "resource": "" }
q14519
ParamHelpers.cleanValueFrom
train
protected function cleanValueFrom($name, $value, array &$values = []) { if (str_contains($name, '[')) { $name = str_replace(['][', '[', ']', '..'],
php
{ "resource": "" }
q14520
ResponseTagStrategy.getDocBlockResponses
train
protected function getDocBlockResponses(array $tags) { $responseTags = array_values( array_filter($tags, function ($tag) { return $tag instanceof Tag && strtolower($tag->getName()) === 'response'; }) ); if (empty($responseTags)) { return; }
php
{ "resource": "" }
q14521
ResponseFileStrategy.getFileResponses
train
protected function getFileResponses(array $tags) { // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array $responseFileTags = array_values( array_filter($tags, function ($tag) { return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile'; }) ); if (empty($responseFileTags)) { return; } return array_map(function (Tag $responseFileTag) { preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result); $status = $result[1] ?: 200;
php
{ "resource": "" }
q14522
Generator.castToType
train
private function castToType(string $value, string $type) { $casts = [ 'integer' => 'intval', 'number' => 'floatval', 'float' => 'floatval', 'boolean' => 'boolval', ]; // First, we handle booleans. We can't use a regular cast, //because PHP considers
php
{ "resource": "" }
q14523
TransformerTagsStrategy.getTransformerResponse
train
protected function getTransformerResponse(array $tags) { try { if (empty($transformerTag = $this->getTransformerTag($tags))) { return; } $transformer = $this->getTransformerClass($transformerTag); $model = $this->getClassToBeTransformed($tags, (new ReflectionClass($transformer))->getMethod('transform')); $modelInstance = $this->instantiateTransformerModel($model); $fractal = new Manager(); if (! is_null(config('apidoc.fractal.serializer'))) { $fractal->setSerializer(app(config('apidoc.fractal.serializer'))); }
php
{ "resource": "" }
q14524
Lfm.currentLfmType
train
public function currentLfmType() { $lfm_type = 'file'; $request_type = lcfirst(str_singular($this->input('type') ?: ''));
php
{ "resource": "" }
q14525
Lfm.translateFromUtf8
train
public function translateFromUtf8($input) { if ($this->isRunningOnWindows()) {
php
{ "resource": "" }
q14526
Lfm.routes
train
public static function routes() { $middleware = [ CreateDefaultFolder::class, MultiUser::class ]; $as = 'unisharp.lfm.'; $namespace = '\\UniSharp\\LaravelFilemanager\\Controllers\\'; Route::group(compact('middleware', 'as', 'namespace'), function () { // display main layout Route::get('/', [ 'uses' => 'LfmController@show', 'as' => 'show', ]); // display integration error messages Route::get('/errors', [ 'uses' => 'LfmController@getErrors', 'as' => 'getErrors', ]); // upload Route::any('/upload', [ 'uses' => 'UploadController@upload', 'as' => 'upload', ]); // list images & files Route::get('/jsonitems', [ 'uses' => 'ItemsController@getItems', 'as' => 'getItems', ]); Route::get('/move', [ 'uses' => 'ItemsController@move', 'as' => 'move', ]); Route::get('/domove', [ 'uses' => 'ItemsController@domove', 'as' => 'domove' ]); // folders Route::get('/newfolder', [ 'uses' => 'FolderController@getAddfolder', 'as' => 'getAddfolder', ]); // list folders Route::get('/folders', [ 'uses' => 'FolderController@getFolders', 'as' => 'getFolders', ]); // crop Route::get('/crop', [ 'uses' => 'CropController@getCrop', 'as' => 'getCrop', ]); Route::get('/cropimage', [
php
{ "resource": "" }
q14527
ItemsController.getItems
train
public function getItems() { return [ 'items' => array_map(function ($item) { return $item->fill()->attributes; }, array_merge($this->lfm->folders(), $this->lfm->files())),
php
{ "resource": "" }
q14528
FolderController.getAddfolder
train
public function getAddfolder() { $folder_name = $this->helper->input('name'); try { if (empty($folder_name)) { return $this->helper->error('folder-name'); } elseif ($this->lfm->setName($folder_name)->exists()) { return $this->helper->error('folder-exist'); } elseif (config('lfm.alphanumeric_directory') && preg_match('/[^\w-]/i', $folder_name)) {
php
{ "resource": "" }
q14529
DeleteController.getDelete
train
public function getDelete() { $item_names = request('items'); $errors = []; foreach ($item_names as $name_to_delete) { $file_to_delete = $this->lfm->pretty($name_to_delete); $file_path = $file_to_delete->path(); event(new ImageIsDeleting($file_path)); if (is_null($name_to_delete)) { array_push($errors, parent::error('folder-name')); continue; } if (! $this->lfm->setName($name_to_delete)->exists()) { array_push($errors, parent::error('folder-not-found', ['folder' => $file_path])); continue; } if ($this->lfm->setName($name_to_delete)->isDirectory()) { if (! $this->lfm->setName($name_to_delete)->directoryIsEmpty()) { array_push($errors, parent::error('delete-folder')); continue; }
php
{ "resource": "" }
q14530
LfmPath.createFolder
train
public function createFolder() { if ($this->storage->exists($this)) {
php
{ "resource": "" }
q14531
LfmPath.sortByColumn
train
public function sortByColumn($arr_items) { $sort_by = $this->helper->input('sort_type'); if (in_array($sort_by, ['name', 'time'])) { $key_to_sort = $sort_by; } else { $key_to_sort = 'name';
php
{ "resource": "" }
q14532
LfmController.getErrors
train
public function getErrors() { $arr_errors = []; if (! extension_loaded('gd') && ! extension_loaded('imagick')) { array_push($arr_errors, trans('laravel-filemanager::lfm.message-extension_not_found')); } if (! extension_loaded('exif')) { array_push($arr_errors, 'EXIF extension not found.'); } if (! extension_loaded('fileinfo')) { array_push($arr_errors, 'Fileinfo extension not found.'); } $mine_config_key = 'lfm.folder_categories.'
php
{ "resource": "" }
q14533
LfmController.applyIniOverrides
train
public function applyIniOverrides() { $overrides = config('lfm.php_ini_overrides'); if ($overrides && is_array($overrides) && count($overrides) === 0) { return; } foreach ($overrides
php
{ "resource": "" }
q14534
ResizeController.getResize
train
public function getResize() { $ratio = 1.0; $image = request('img'); $original_image = Image::make($this->lfm->setName($image)->path('absolute')); $original_width = $original_image->width(); $original_height = $original_image->height(); $scaled = false; // FIXME size should be configurable if ($original_width > 600) { $ratio = 600 / $original_width; $width = $original_width * $ratio; $height = $original_height * $ratio; $scaled = true; } else { $width = $original_width; $height = $original_height; } if ($height > 400) { $ratio = 400 / $original_height; $width = $original_width * $ratio; $height = $original_height * $ratio; $scaled =
php
{ "resource": "" }
q14535
FlashPolicy.addAllowedAccess
train
public function addAllowedAccess($domain, $ports = '*', $secure = false) { if (!$this->validateDomain($domain)) { throw new \UnexpectedValueException('Invalid domain'); } if (!$this->validatePorts($ports)) { throw new \UnexpectedValueException('Invalid Port');
php
{ "resource": "" }
q14536
FlashPolicy.setSiteControl
train
public function setSiteControl($permittedCrossDomainPolicies = 'all') { if (!$this->validateSiteControl($permittedCrossDomainPolicies)) { throw new \UnexpectedValueException('Invalid site control set'); }
php
{ "resource": "" }
q14537
FlashPolicy.renderPolicy
train
public function renderPolicy() { $policy = new \SimpleXMLElement($this->_policy); $siteControl = $policy->addChild('site-control'); if ($this->_siteControl == '') { $this->setSiteControl(); } $siteControl->addAttribute('permitted-cross-domain-policies', $this->_siteControl);
php
{ "resource": "" }
q14538
Topic.broadcast
train
public function broadcast($msg, array $exclude = array(), array $eligible = array()) { $useEligible = (bool)count($eligible); foreach ($this->subscribers as $client) { if (in_array($client->WAMP->sessionId, $exclude)) { continue; }
php
{ "resource": "" }
q14539
IoServer.handleConnect
train
public function handleConnect($conn) { $conn->decor = new IoConnection($conn); $conn->decor->resourceId = (int)$conn->stream; $uri = $conn->getRemoteAddress(); $conn->decor->remoteAddress = trim( parse_url((strpos($uri, '://') === false ? 'tcp://' : '') . $uri, PHP_URL_HOST), '[]' ); $this->app->onOpen($conn->decor); $conn->on('data', function ($data) use ($conn) { $this->handleData($data, $conn);
php
{ "resource": "" }
q14540
IoServer.handleData
train
public function handleData($data, $conn) { try { $this->app->onMessage($conn->decor, $data);
php
{ "resource": "" }
q14541
IoServer.handleEnd
train
public function handleEnd($conn) { try { $this->app->onClose($conn->decor); } catch (\Exception $e) {
php
{ "resource": "" }
q14542
IoServer.handleError
train
public function handleError(\Exception $e, $conn) {
php
{ "resource": "" }
q14543
CloseResponseTrait.close
train
private function close(ConnectionInterface $conn, $code = 400, array $additional_headers = []) { $response = new Response($code, array_merge([ 'X-Powered-By' => \Ratchet\VERSION
php
{ "resource": "" }
q14544
SessionProvider.parseCookie
train
private function parseCookie($cookie, $host = null, $path = null, $decode = false) { // Explode the cookie string using a series of semicolons $pieces = array_filter(array_map('trim', explode(';', $cookie))); // The name of the cookie (first kvp) must include an equal sign. if (empty($pieces) || !strpos($pieces[0], '=')) { return false; } // Create the default return array $data = array_merge(array_fill_keys(array_keys(self::$cookieParts), null), array( 'cookies' => array(), 'data' => array(), 'path' => $path ?: '/', 'http_only' => false, 'discard' => false, 'domain' => $host )); $foundNonCookies = 0; // Add the cookie pieces into the parsed data array foreach ($pieces as $part) { $cookieParts = explode('=', $part, 2); $key = trim($cookieParts[0]); if (count($cookieParts) == 1) { // Can be a single value (e.g. secure, httpOnly) $value = true; } else { // Be sure to strip wrapping quotes $value = trim($cookieParts[1], " \n\r\t\0\x0B\""); if ($decode) { $value = urldecode($value); } } // Only check for non-cookies when cookies have been found if (!empty($data['cookies'])) { foreach (self::$cookieParts as $mapValue => $search) { if (!strcasecmp($search, $key)) {
php
{ "resource": "" }
q14545
IpBlackList.unblockAddress
train
public function unblockAddress($ip) { if (isset($this->_blacklist[$this->filterAddress($ip)])) {
php
{ "resource": "" }
q14546
WampConnection.callResult
train
public function callResult($id, $data = array()) { return
php
{ "resource": "" }
q14547
WampConnection.callError
train
public function callError($id, $errorUri, $desc = '', $details = null) { if ($errorUri instanceof Topic) { $errorUri = (string)$errorUri;
php
{ "resource": "" }
q14548
WampConnection.getUri
train
public function getUri($uri) { $curieSeperator = ':'; if (preg_match('/http(s*)\:\/\//', $uri) == false) { if (strpos($uri, $curieSeperator) !== false) { list($prefix, $action) = explode($curieSeperator, $uri);
php
{ "resource": "" }
q14549
Parameter.setValue
train
public function setValue($value, $type = null) { $this->value = $value;
php
{ "resource": "" }
q14550
FileDriver.getElement
train
public function getElement($className) { if ($this->classCache === null) { $this->initialize(); } if (isset($this->classCache[$className])) { return $this->classCache[$className]; } $result = $this->loadMappingFile($this->locator->findMappingFile($className)); if (! isset($result[$className])) {
php
{ "resource": "" }
q14551
FileDriver.initialize
train
protected function initialize() { $this->classCache = []; if ($this->globalBasename !== null) { foreach ($this->locator->getPaths() as $path) { $file = $path . '/' . $this->globalBasename . $this->locator->getFileExtension(); if (is_file($file)) {
php
{ "resource": "" }
q14552
QueryBuilder.findRootAlias
train
private function findRootAlias($alias, $parentAlias) { $rootAlias = null; if (in_array($parentAlias, $this->getRootAliases(), true)) { $rootAlias = $parentAlias; } elseif (isset($this->joinRootAliases[$parentAlias])) { $rootAlias = $this->joinRootAliases[$parentAlias]; } else {
php
{ "resource": "" }
q14553
QueryBuilder.getRootAliases
train
public function getRootAliases() { $aliases = []; foreach ($this->dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { $spacePos = strrpos($fromClause, ' ');
php
{ "resource": "" }
q14554
QueryBuilder.getRootEntities
train
public function getRootEntities() { $entities = []; foreach ($this->dqlParts['from'] as &$fromClause) { if (is_string($fromClause)) { $spacePos = strrpos($fromClause, ' ');
php
{ "resource": "" }
q14555
QueryBuilder.update
train
public function update($update = null, $alias = null) { $this->type = self::UPDATE; if (! $update) { return $this; }
php
{ "resource": "" }
q14556
QueryBuilder.from
train
public function from($from, $alias, $indexBy = null) { return
php
{ "resource": "" }
q14557
QueryBuilder.set
train
public function set($key, $value) { return $this->add('set', new Expr\Comparison($key,
php
{ "resource": "" }
q14558
QueryBuilder.addCriteria
train
public function addCriteria(Criteria $criteria) { $allAliases = $this->getAllAliases(); if (! isset($allAliases[0])) { throw new Query\QueryException('No aliases are set before invoking addCriteria().'); } $visitor = new QueryExpressionVisitor($this->getAllAliases()); $whereExpression = $criteria->getWhereExpression(); if ($whereExpression) { $this->andWhere($visitor->dispatch($whereExpression)); foreach ($visitor->getParameters() as $parameter) { $this->parameters->add($parameter); } } if ($criteria->getOrderings()) { foreach ($criteria->getOrderings() as $sort => $order) { $hasValidAlias = false; foreach ($allAliases as $alias) { if (strpos($sort . '.', $alias . '.') === 0) { $hasValidAlias = true; break;
php
{ "resource": "" }
q14559
SchemaTool.createSchema
train
public function createSchema(array $classes) { $createSchemaSql = $this->getCreateSchemaSql($classes); $conn = $this->em->getConnection(); foreach ($createSchemaSql as $sql) { try {
php
{ "resource": "" }
q14560
SchemaTool.getCreateSchemaSql
train
public function getCreateSchemaSql(array $classes) { $schema = $this->getSchemaFromMetadata($classes);
php
{ "resource": "" }
q14561
SchemaTool.dropSchema
train
public function dropSchema(array $classes) { $dropSchemaSql = $this->getDropSchemaSQL($classes); $conn = $this->em->getConnection(); foreach ($dropSchemaSql as $sql) { try {
php
{ "resource": "" }
q14562
SchemaTool.dropDatabase
train
public function dropDatabase() { $dropSchemaSql = $this->getDropDatabaseSQL(); $conn = $this->em->getConnection();
php
{ "resource": "" }
q14563
SchemaTool.getDropDatabaseSQL
train
public function getDropDatabaseSQL() { $sm = $this->em->getConnection()->getSchemaManager(); $schema
php
{ "resource": "" }
q14564
SchemaTool.getDropSchemaSQL
train
public function getDropSchemaSQL(array $classes) { $visitor = new DropSchemaSqlCollector($this->platform); $schema = $this->getSchemaFromMetadata($classes); $sm = $this->em->getConnection()->getSchemaManager(); $fullSchema = $sm->createSchema(); foreach ($fullSchema->getTables() as $table) { if (! $schema->hasTable($table->getName())) { foreach ($table->getForeignKeys() as $foreignKey) { /** @var $foreignKey \Doctrine\DBAL\Schema\ForeignKeyConstraint */ if ($schema->hasTable($foreignKey->getForeignTableName())) { $visitor->acceptForeignKey($table, $foreignKey); } } } else { $visitor->acceptTable($table); foreach ($table->getForeignKeys() as $foreignKey) { $visitor->acceptForeignKey($table, $foreignKey); } } } if ($this->platform->supportsSequences()) {
php
{ "resource": "" }
q14565
SchemaTool.updateSchema
train
public function updateSchema(array $classes, $saveMode = false) { $updateSchemaSql = $this->getUpdateSchemaSql($classes, $saveMode);
php
{ "resource": "" }
q14566
SchemaTool.getUpdateSchemaSql
train
public function getUpdateSchemaSql(array $classes, $saveMode = false) { $sm = $this->em->getConnection()->getSchemaManager(); $fromSchema = $sm->createSchema(); $toSchema = $this->getSchemaFromMetadata($classes); $comparator = new Comparator();
php
{ "resource": "" }
q14567
AbstractQuery.setParameters
train
public function setParameters($parameters) { // BC compatibility with 2.3- if (is_array($parameters)) { $parameterCollection = new ArrayCollection(); foreach ($parameters as $key => $value) {
php
{ "resource": "" }
q14568
DefaultRepositoryFactory.createRepository
train
private function createRepository(EntityManagerInterface $entityManager, $entityName) { /** @var ClassMetadata $metadata */ $metadata = $entityManager->getClassMetadata($entityName); $repositoryClassName = $metadata->getCustomRepositoryClassName()
php
{ "resource": "" }
q14569
CommitOrderCalculator.sort
train
public function sort() { foreach ($this->nodeList as $vertex) { if ($vertex->state !== self::NOT_VISITED) { continue; } $this->visit($vertex); }
php
{ "resource": "" }
q14570
ClassMetadata.validateLifecycleCallbacks
train
public function validateLifecycleCallbacks(ReflectionService $reflectionService) : void { foreach ($this->lifecycleCallbacks as $callbacks) { /** @var array $callbacks */ foreach ($callbacks as $callbackFuncName) { if (! $reflectionService->hasPublicMethod($this->className, $callbackFuncName)) {
php
{ "resource": "" }
q14571
ClassMetadata.validateAndCompleteToOneAssociationMetadata
train
protected function validateAndCompleteToOneAssociationMetadata(ToOneAssociationMetadata $property) { $fieldName = $property->getName(); if ($property->isOwningSide()) { if (empty($property->getJoinColumns())) { // Apply default join column $property->addJoinColumn(new JoinColumnMetadata()); } $uniqueConstraintColumns = []; foreach ($property->getJoinColumns() as $joinColumn) { /** @var JoinColumnMetadata $joinColumn */ if ($property instanceof OneToOneAssociationMetadata && $this->inheritanceType !== InheritanceType::SINGLE_TABLE) { if (count($property->getJoinColumns()) === 1) { if (! $property->isPrimaryKey()) { $joinColumn->setUnique(true); } } else { $uniqueConstraintColumns[] = $joinColumn->getColumnName(); } } $joinColumn->setTableName(! $this->isMappedSuperclass ? $this->getTableName() : null); if (! $joinColumn->getColumnName()) { $joinColumn->setColumnName($this->namingStrategy->joinColumnName($fieldName, $this->className)); } if (! $joinColumn->getReferencedColumnName()) { $joinColumn->setReferencedColumnName($this->namingStrategy->referenceColumnName()); } $this->fieldNames[$joinColumn->getColumnName()] = $fieldName; } if ($uniqueConstraintColumns) { if (! $this->table) { throw new RuntimeException( 'ClassMetadata::setTable() has to be called before defining a one to one relationship.' ); } $this->table->addUniqueConstraint(
php
{ "resource": "" }
q14572
ClassMetadata.validateAndCompleteManyToOneMapping
train
protected function validateAndCompleteManyToOneMapping(ManyToOneAssociationMetadata $property) { // A many-to-one mapping is essentially a one-one backreference if ($property->isOrphanRemoval()) {
php
{ "resource": "" }
q14573
ClassMetadata.getSingleIdentifierFieldName
train
public function getSingleIdentifierFieldName() { if ($this->isIdentifierComposite()) { throw MappingException::singleIdNotAllowedOnCompositePrimaryKey($this->className);
php
{ "resource": "" }
q14574
ClassMetadata.getIdentifierColumns
train
public function getIdentifierColumns(EntityManagerInterface $em) : array { $columns = []; foreach ($this->identifier as $idProperty) { $property = $this->getProperty($idProperty); if ($property instanceof FieldMetadata) { $columns[$property->getColumnName()] = $property; continue; } /** @var AssociationMetadata $property */ // Association defined as Id field $targetClass = $em->getClassMetadata($property->getTargetEntity()); if (! $property->isOwningSide()) { $property
php
{ "resource": "" }
q14575
ClassMetadata.getTemporaryIdTableName
train
public function getTemporaryIdTableName() : string { $schema = $this->getSchemaName() === null ? '' : $this->getSchemaName() . '_'; // replace dots with underscores
php
{ "resource": "" }
q14576
ClassMetadata.setPropertyOverride
train
public function setPropertyOverride(Property $property) : void { $fieldName = $property->getName(); if (! isset($this->declaredProperties[$fieldName])) { throw MappingException::invalidOverrideFieldName($this->className, $fieldName); } $originalProperty = $this->getProperty($fieldName); $originalPropertyClassName = get_class($originalProperty); // If moving from transient to persistent, assume it's a new property if ($originalPropertyClassName === TransientMetadata::class) { unset($this->declaredProperties[$fieldName]); $this->addProperty($property); return; } // Do not allow to change property type if ($originalPropertyClassName !== get_class($property)) { throw MappingException::invalidOverridePropertyType($this->className, $fieldName); } // Do not allow to change version property if ($originalProperty instanceof VersionFieldMetadata) { throw MappingException::invalidOverrideVersionField($this->className, $fieldName); } unset($this->declaredProperties[$fieldName]); if ($property instanceof FieldMetadata) { // Unset defined fieldName prior to override unset($this->fieldNames[$originalProperty->getColumnName()]); // Revert what should not be allowed to change $property->setDeclaringClass($originalProperty->getDeclaringClass()); $property->setPrimaryKey($originalProperty->isPrimaryKey()); } elseif ($property instanceof AssociationMetadata) { // Unset all defined fieldNames prior to override if ($originalProperty instanceof ToOneAssociationMetadata && $originalProperty->isOwningSide())
php
{ "resource": "" }
q14577
ClassMetadata.isInheritedProperty
train
public function isInheritedProperty($fieldName) { $declaringClass = $this->declaredProperties[$fieldName]->getDeclaringClass();
php
{ "resource": "" }
q14578
ClassMetadata.addProperty
train
public function addProperty(Property $property) { $fieldName = $property->getName(); // Check for empty field name if (empty($fieldName)) { throw MappingException::missingFieldName($this->className); } $property->setDeclaringClass($this); switch (true) { case $property instanceof VersionFieldMetadata: $this->validateAndCompleteFieldMapping($property); $this->validateAndCompleteVersionFieldMapping($property); break; case $property instanceof FieldMetadata: $this->validateAndCompleteFieldMapping($property); break; case $property instanceof OneToOneAssociationMetadata: $this->validateAndCompleteAssociationMapping($property); $this->validateAndCompleteToOneAssociationMetadata($property); $this->validateAndCompleteOneToOneMapping($property); break; case $property instanceof OneToManyAssociationMetadata: $this->validateAndCompleteAssociationMapping($property); $this->validateAndCompleteToManyAssociationMetadata($property); $this->validateAndCompleteOneToManyMapping($property); break; case $property instanceof ManyToOneAssociationMetadata:
php
{ "resource": "" }
q14579
ArrayHydrator.updateResultPointer
train
private function updateResultPointer(array &$coll, $index, $dqlAlias, $oneToOne) { if ($coll === null) { unset($this->resultPointers[$dqlAlias]); // Ticket #1228 return; } if ($oneToOne) {
php
{ "resource": "" }
q14580
LimitSubqueryOutputWalker.platformSupportsRowNumber
train
private function platformSupportsRowNumber() { return $this->platform instanceof PostgreSqlPlatform || $this->platform instanceof SQLServerPlatform || $this->platform instanceof OraclePlatform
php
{ "resource": "" }
q14581
LimitSubqueryOutputWalker.walkSelectStatement
train
public function walkSelectStatement(SelectStatement $AST) { if ($this->platformSupportsRowNumber()) { return $this->walkSelectStatementWithRowNumber($AST);
php
{ "resource": "" }
q14582
LimitSubqueryOutputWalker.walkSelectStatementWithoutRowNumber
train
public function walkSelectStatementWithoutRowNumber(SelectStatement $AST, $addMissingItemsFromOrderByToSelect = true) { // We don't want to call this recursively! if ($AST->orderByClause instanceof OrderByClause && $addMissingItemsFromOrderByToSelect) { // In the case of ordering a query by columns from joined tables, we // must add those columns to the select clause of the query BEFORE // the SQL is generated. $this->addMissingItemsFromOrderByToSelect($AST); } // Remove order by clause from the inner query // It will be re-appended in the outer select generated by this method $orderByClause = $AST->orderByClause; $AST->orderByClause = null; $innerSql = $this->getInnerSQL($AST); $sqlIdentifier = $this->getSQLIdentifier($AST); $sqlAliasIdentifier = array_map(static function ($info) { return $info['alias']; }, $sqlIdentifier); // Build the counter query $sql = sprintf('SELECT DISTINCT %s FROM (%s) dctrn_result', implode(', ', $sqlAliasIdentifier), $innerSql); // http://www.doctrine-project.org/jira/browse/DDC-1958 $sql = $this->preserveSqlOrdering($sqlAliasIdentifier, $innerSql, $sql, $orderByClause); // Apply the limit and offset. $sql = $this->platform->modifyLimitQuery( $sql,
php
{ "resource": "" }
q14583
LimitSubqueryOutputWalker.addMissingItemsFromOrderByToSelect
train
private function addMissingItemsFromOrderByToSelect(SelectStatement $AST) { $this->orderByPathExpressions = []; // We need to do this in another walker because otherwise we'll end up // polluting the state of this one. $walker = clone $this; // This will populate $orderByPathExpressions via // LimitSubqueryOutputWalker::walkPathExpression, which will be called // as the select statement is walked. We'll end up with an array of all // path expressions referenced in the query. $walker->walkSelectStatementWithoutRowNumber($AST, false); $orderByPathExpressions = $walker->getOrderByPathExpressions(); // Get a map of referenced identifiers to field names. $selects = []; foreach ($orderByPathExpressions as $pathExpression) { $idVar = $pathExpression->identificationVariable; $field = $pathExpression->field;
php
{ "resource": "" }
q14584
LimitSubqueryOutputWalker.recreateInnerSql
train
private function recreateInnerSql( OrderByClause $orderByClause, array $identifiers, string $innerSql ) : string { [$searchPatterns, $replacements] = $this->generateSqlAliasReplacements(); $orderByItems = []; foreach ($orderByClause->orderByItems as $orderByItem) { // Walk order by item to get string representation of it and // replace path expressions in the order by clause with their column alias
php
{ "resource": "" }
q14585
AbstractCollectionPersister.evictCollectionCache
train
protected function evictCollectionCache(PersistentCollection $collection) { $key = new CollectionCacheKey( $this->sourceEntity->getRootClassName(), $this->association->getName(),
php
{ "resource": "" }
q14586
AnnotationDriver.convertJoinTableAnnotationToJoinTableMetadata
train
private function convertJoinTableAnnotationToJoinTableMetadata( Annotation\JoinTable $joinTableAnnot ) : Mapping\JoinTableMetadata { $joinTable = new Mapping\JoinTableMetadata(); if (! empty($joinTableAnnot->name)) { $joinTable->setName($joinTableAnnot->name); } if (! empty($joinTableAnnot->schema)) { $joinTable->setSchema($joinTableAnnot->schema); } foreach ($joinTableAnnot->joinColumns as $joinColumnAnnot) { $joinColumn
php
{ "resource": "" }
q14587
AnnotationDriver.getCascade
train
private function getCascade(string $className, string $fieldName, array $originalCascades) { $cascadeTypes = ['remove', 'persist', 'refresh']; $cascades = array_map('strtolower', $originalCascades); if (in_array('all', $cascades, true)) { $cascades = $cascadeTypes; } if
php
{ "resource": "" }
q14588
EntityManager.clear
train
public function clear($entityName = null) { $this->unitOfWork->clear(); $this->unitOfWork = new UnitOfWork($this); if ($this->eventManager->hasListeners(Events::onClear)) {
php
{ "resource": "" }
q14589
EntityManager.persist
train
public function persist($entity) { if (! is_object($entity)) { throw ORMInvalidArgumentException::invalidObject('EntityManager#persist()', $entity);
php
{ "resource": "" }
q14590
EntityManager.refresh
train
public function refresh($entity) { if (! is_object($entity)) { throw ORMInvalidArgumentException::invalidObject('EntityManager#refresh()', $entity);
php
{ "resource": "" }
q14591
EntityManager.contains
train
public function contains($entity) { return $this->unitOfWork->isScheduledForInsert($entity)
php
{ "resource": "" }
q14592
EntityManager.createConnection
train
protected static function createConnection($connection, Configuration $config, ?EventManager $eventManager = null) { if (is_array($connection)) { return DriverManager::getConnection($connection, $config, $eventManager ?: new EventManager()); } if (! $connection instanceof Connection) { throw new InvalidArgumentException( sprintf( 'Invalid $connection argument of type %s given%s.', is_object($connection) ? get_class($connection) : gettype($connection),
php
{ "resource": "" }
q14593
MappingDescribeCommand.getClassMetadata
train
private function getClassMetadata($entityName, EntityManagerInterface $entityManager) { try { return $entityManager->getClassMetadata($entityName); } catch (MappingException $e) { } $matches = array_filter( $this->getMappedEntities($entityManager), static function ($mappedEntity) use ($entityName) { return preg_match('{' . preg_quote($entityName) . '}', $mappedEntity);
php
{ "resource": "" }
q14594
MappingDescribeCommand.formatValue
train
private function formatValue($value) { if ($value === '') { return ''; } if ($value === null) { return '<comment>Null</comment>'; } if (is_bool($value)) { return '<comment>' . ($value ? 'True' : 'False') . '</comment>'; } if (empty($value)) { return '<comment>Empty</comment>'; } if (is_array($value)) { return json_encode($value, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); } if (is_object($value))
php
{ "resource": "" }
q14595
MappingDescribeCommand.formatField
train
private function formatField($label, $value) { if ($value === null) { $value = '<comment>None</comment>'; }
php
{ "resource": "" }
q14596
MappingDescribeCommand.formatPropertyMappings
train
private function formatPropertyMappings(iterable $propertyMappings) { $output = []; foreach ($propertyMappings as $propertyName => $property) { $output[] = $this->formatField(sprintf(' %s', $propertyName), ''); if ($property instanceof FieldMetadata) { $output = array_merge($output, $this->formatColumn($property)); } elseif ($property instanceof AssociationMetadata) {
php
{ "resource": "" }
q14597
Autoloader.resolveFile
train
public static function resolveFile(string $metadataDir, string $metadataNamespace, string $className) : string { if (strpos($className, $metadataNamespace) !== 0) { throw new InvalidArgumentException( sprintf('The class "%s" is not part of the metadata namespace "%s"', $className, $metadataNamespace) ); } // remove
php
{ "resource": "" }
q14598
Autoloader.register
train
public static function register( string $metadataDir, string $metadataNamespace, ?callable $notFoundCallback = null ) : Closure { $metadataNamespace = ltrim($metadataNamespace, '\\'); if (! ($notFoundCallback === null || is_callable($notFoundCallback))) { $type = is_object($notFoundCallback) ? get_class($notFoundCallback) : gettype($notFoundCallback); throw new InvalidArgumentException( sprintf('Invalid \$notFoundCallback given: must be a callable, "%s" given', $type) ); } $autoloader = static function ($className) use ($metadataDir, $metadataNamespace, $notFoundCallback) { if (strpos($className, $metadataNamespace) === 0)
php
{ "resource": "" }
q14599
HydrationCompleteHandler.deferPostLoadInvoking
train
public function deferPostLoadInvoking(ClassMetadata $class, $entity) { $invoke = $this->listenersInvoker->getSubscribedSystems($class, Events::postLoad); if ($invoke === ListenersInvoker::INVOKE_NONE) {
php
{ "resource": "" }