setSize example

return $result;
    }

    private function createSearch(EntityDefinition $definition, Criteria $criteria, Context $context): Search
    {
        $search = new Search();
        $this->helper->addFilters($definition$criteria$search$context);
        $this->helper->addQueries($definition$criteria$search$context);
        $this->helper->addAggregations($definition$criteria$search$context);
        $this->helper->addTerm($criteria$search$context$definition);
        $this->helper->handleIds($definition$criteria$search$context);
        $search->setSize(0);

        return $search;
    }
}

        $search = new EsSearch();

        $this->addConditions($criteria$context$search);
        $this->addCriteriaParts($criteria$context$search$criteria->getSortings());
        $this->addCriteriaParts($criteria$context$search$criteria->getFacets());

        if ($criteria->getOffset() !== null) {
            $search->setFrom($criteria->getOffset());
        }
        if ($criteria->getLimit() !== null) {
            $search->setSize($criteria->getLimit());
        }

        $search->addSort(new FieldSort('id', 'asc'));

        return $search;
    }

    /** * @param CriteriaPartInterface[] $criteriaParts */
    private function addCriteriaParts(
        

  public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);

    // The file itself might not exist or be available right now.     $uri = $this->getFileUri();
    $size = @filesize($uri);

    // Set size unless there was an error.     if ($size !== FALSE) {
      $this->setSize($size);
    }
  }

  /** * {@inheritdoc} */
  public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage$entities);

    foreach ($entities as $entity) {
      // Delete all remaining references to this file.
// If the end of the search term is not a symbol, apply the prefix search query         if (preg_match('/^[a-zA-Z0-9]+$/', $lastPart)) {
            $term = $term . '*';
        }

        $query = new SimpleQueryStringQuery($term[
            'fields' => ['text'],
        ]);

        $search->addQuery($query, BoolQuery::SHOULD);
        $search->setSize($limit);

        return $search;
    }
}
/** * Creates a new Struct\Product\Download struct with the passed data. * * @return Download */
    public function hydrate(array $data)
    {
        $download = new Download();
        $download->setId((int) $data['__download_id']);
        $download->setDescription($data['__download_description']);
        $download->setFile($data['__download_filename']);
        $download->setSize((float) $data['__download_size']);

        if (!empty($data['__downloadAttribute_id'])) {
            $this->attributeHydrator->addAttribute($download$data, 'downloadAttribute');
        }

        return $download;
    }
}
if (!$this->lock->acquire($lock_id)) {
      throw new HttpException(503, sprintf('File "%s" is already locked for writing.', $file_uri), NULL, ['Retry-After' => 1]);
    }

    // Begin building file entity.     $file = File::create([]);
    $file->setOwnerId($this->currentUser->id());
    $file->setFilename($prepared_filename);
    $file->setMimeType($this->mimeTypeGuesser->guessMimeType($prepared_filename));

    $file->setFileUri($file_uri);
    $file->setSize(@filesize($temp_file_path));

    $violations = $this->validate($file$validators);
    if ($violations->count() > 0) {
      throw new UnprocessableEntityHttpException($violations->__toString());
    }

    try {
      $this->fileSystem->move($temp_file_path$file_uri, FileSystemInterface::EXISTS_ERROR);
    }
    catch (FileException $e) {
      throw new HttpException(500, 'Temporary file could not be moved to file location');
    }
throw new HttpException(503, sprintf('File "%s" is already locked for writing.', $file_uri), NULL, ['Retry-After' => 1]);
    }

    // Begin building file entity.     $file = File::create([]);
    $file->setOwnerId($owner->id());
    $file->setFilename($prepared_filename);
    $file->setMimeType($this->mimeTypeGuesser->guessMimeType($prepared_filename));
    $file->setFileUri($temp_file_path);
    // Set the size. This is done in File::preSave() but we validate the file     // before it is saved.     $file->setSize(@filesize($temp_file_path));

    // Validate the file against field-level validators first while the file is     // still a temporary file. Validation is split up in 2 steps to be the same     // as in \Drupal\file\Upload\FileUploadHandler::handleFileUpload().     // For backwards compatibility this part is copied from ::validate() to     // leave that method behavior unchanged.     // @todo Improve this with a file uploader service in     // https://www.drupal.org/project/drupal/issues/2940383     $errors = file_validate($file$validators);
    if (!empty($errors)) {
      $violations = new EntityConstraintViolationList($file);
      
if (empty($ids)) {
            return;
        }

        $groupIds = $this->getGroupIds($ids);

        $search = new EsSearch();
        $search->addQuery(new IdsQuery($groupIds), BoolQuery::FILTER);
        $search->addQuery(new TermQuery('filterable', true), BoolQuery::FILTER);
        $search->addSort(new FieldSort('name', 'asc'));
        $search->setFrom(0);
        $search->setSize(self::AGGREGATION_SIZE);

        $index = $this->indexFactory->createShopIndex($context->getShop(), PropertyMapping::TYPE);

        $arguments = [
            'index' => $index->getName(),
            'body' => $search->toArray(),
            'rest_total_hits_as_int' => true,
            'track_total_hits' => true,
        ];

        $data = $this->client->search(
            
/** * @return EsSearch */
    protected function buildSearchObject(SearchCriteria $criteria)
    {
        $search = new EsSearch();

        if ($criteria->offset) {
            $search->setFrom($criteria->offset);
        }
        if ($criteria->limit) {
            $search->setSize($criteria->limit);
        }

        if ($criteria->term) {
            $search->addQuery($this->buildSearchQuery($criteria));
        }

        if (!empty($criteria->conditions)) {
            $this->addFilters($search$criteria);
        }
        if (!empty($criteria->sortings)) {
            $this->addSortings($criteria$search);
        }
throw new HttpException(503, sprintf('File "%s" is already locked for writing', $file_uri), NULL, ['Retry-After' => 1]);
    }

    // Begin building file entity.     $file = File::create([]);
    $file->setOwnerId($this->currentUser->id());
    $file->setFilename($prepared_filename);
    $file->setMimeType($this->mimeTypeGuesser->guessMimeType($prepared_filename));
    $file->setFileUri($temp_file_path);
    // Set the size. This is done in File::preSave() but we validate the file     // before it is saved.     $file->setSize(@filesize($temp_file_path));

    // Validate the file against field-level validators first while the file is     // still a temporary file. Validation is split up in 2 steps to be the same     // as in \Drupal\file\Upload\FileUploadHandler::handleFileUpload().     // For backwards compatibility this part is copied from ::validate() to     // leave that method behavior unchanged.     // @todo Improve this with a file uploader service in     // https://www.drupal.org/project/drupal/issues/2940383     $errors = file_validate($file$validators);

    if (!empty($errors)) {
      

    protected function saveBackup($path$filterString$operations$items)
    {
        $backup = new BackupModel();

        $backup->setFilterString($filterString);
        $backup->setOperationString($this->operationsToString($operations));
        $backup->setItems($items);
        $backup->setPath($path);
        $backup->setHash(sha1_file($path));
        $backup->setSize((int) filesize($path));

        $backup->setDate(new DateTime());

        $this->getDqlHelper()->getEntityManager()->persist($backup);
        $this->getDqlHelper()->getEntityManager()->flush($backup);
    }

    /** * Dumps a given table to disc - as only needed columns are exported, this is quite fast * * @param string $table * @param string $name * @param int[] $ids * @param bool $newBackup * * @throws RuntimeException */
private function createSearch(Criteria $criteria, EntityDefinition $definition, Context $context): Search
    {
        $search = new Search();

        $this->helper->handleIds($definition$criteria$search$context);
        $this->helper->addFilters($definition$criteria$search$context);
        $this->helper->addPostFilters($definition$criteria$search$context);
        $this->helper->addQueries($definition$criteria$search$context);
        $this->helper->addSortings($definition$criteria$search$context);
        $this->helper->addTerm($criteria$search$context$definition);

        $search->setSize(self::MAX_LIMIT);
        $limit = $criteria->getLimit();
        if ($limit !== null) {
            $search->setSize($limit);
        }
        $search->setFrom((int) $criteria->getOffset());

        return $search;
    }

    /** * @return array<string, mixed> */


    $file = File::create([
      'uid' => $this->currentUser->id(),
      'status' => 0,
      'uri' => $uploadedFile->getRealPath(),
    ]);

    // This will be replaced later with a filename based on the destination.     $file->setFilename($filename);
    $file->setMimeType($mimeType);
    $file->setSize($uploadedFile->getSize());

    // Add in our check of the file name length.     $validators['file_validate_name_length'] = [];

    // Call the validation functions specified by this function's caller.     $errors = file_validate($file$validators);
    if (!empty($errors)) {
      throw new FileValidationException('File validation failed', $filename$errors);
    }

    $file->setFileUri($destinationFilename);

    
Home | Imprint | This part of the site doesn't use cookies.