Set entity images
@param array $data
@param \gplcart\core\models\File $file_model
@param string $entity
@return bool
778639
public function setImages(array &$data, $file_model, $entity)
    {
        if (empty($data['images']) || empty($data[$entity . '_id'])) {
            return false;
        }

        foreach ($data['images'] as &$image) {
            if (empty($image['file_id'])) {
                $image['entity'] = $entity;
                $image['entity_id'] = $data[$entity . '_id'];
                $image['file_id'] = (int) $file_model->add($image);
            } else {
                $file_model->update($image['file_id'], $image);
            }
        }

        return true;
    }
755170
public final function setEntityClass($str_class)
    {
        if(class_exists($str_class)) {
            if(is_a($str_class, '\\GDS\\Entity', TRUE)) {
                $this->str_entity_class = $str_class;
            } else {
                throw new \InvalidArgumentException('Cannot set an Entity class that does not extend "GDS\Entity": ' . $str_class);
            }
        } else {
            throw new \InvalidArgumentException('Cannot set missing Entity class: ' . $str_class);
        }
        return $this;
    }
1243006
protected function hydrateProperties($entity, $data)
    {
        if (isset($data['attributes']) && is_array($data['attributes'])) {
            $entity = parent::hydrateProperties($entity, $data['attributes']);
        }

        return $entity;
    }
636418
public function setFile(\Sulu\Bundle\MediaBundle\Entity\File $file = null)
    {
        $this->file = $file;

        return $this;
    }
1327768
protected function applyCrops(array $item, FileInterface $entity) {
    // Add coordinates for cropping images.
    foreach ($item['crops'] as $crop_name => $data) {
      $crop_type = $this->entityTypeManager
        ->getStorage('crop_type')
        ->load($crop_name);

      if (!empty($crop_type) && $crop_type instanceof CropType) {
        $this->imageWidgetCropManager->applyCrop($data, [
          'file-uri' => $item['uri'],
          'file-id' => $entity->id(),
        ], $crop_type);
      }
    }
  }
1214979
public function add(ActiveRecord $activeRecord, array $data = []): void
    {
        $this->collection[] = new Entity($activeRecord, $data);
    }
971737
public static function create($data = [], Entity $entity = null)
    {
        $record = new static($data, $entity);

        $record->save();

        return $record;
    }
577837
public function setImageData($image_data)
    {

        if (!is_null($image_data) && (!preg_match("/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/", $image_data))) {
            throw new \InvalidArgumentException("invalid value for $image_data when calling ConditionalFormattingIcon., must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.");
        }

        $this->container['image_data'] = $image_data;

        return $this;
    }
36629
public function setEntitiesAttribute($entities)
    {
        static::saved(function ($model) use ($entities) {
            $values = [];
            foreach ($entities as $entity) {
                $values[] = ['attribute_id' => $model->id, 'entity_type' => $entity];
            }

            DB::table(config('rinvex.attributable.tables.attribute_entity'))->where('attribute_id', $model->id)->delete();
            DB::table(config('rinvex.attributable.tables.attribute_entity'))->insert($values);
        });
    }
481724
public function loadEntity($entity, $entity_id)
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $entity, 'data', array($entity_id));
        } catch (Exception $ex) {
            return array();
        }
    }
721320
protected function updateByEntity($data, $entity)
	{
		return $this->aggregate[$entity->getType(true)]->update($data, $entity);
	}
678867
protected function getEntityType(FileAbstraction $entity)
	{
		$type = null;

		if ($entity instanceof Folder) {
			$type = self::TYPE_FOLDER;
		} elseif ($entity instanceof Image) {
			$type = self::TYPE_IMAGE;
		} elseif ($entity instanceof File) {
			$type = self::TYPE_FILE;
		}

		return $type;
	}
205104
protected function modifyRecord(Content $entity, array $fieldData)
    {
        foreach ($fieldData as $field => $value) {
            if (strtolower($field) === 'status') {
                $this->transistionRecordStatus($entity, $value);
            } elseif (strtolower($field) === 'ownerid') {
                $this->transistionRecordOwner($entity, $value);
            } else {
                $this->modifyRecordValue($entity, $field, $value);
            }
        }
    }
1075048
protected function persistEntity(EntityInterface $entity, array $data, array $options = []) : ?Response
    {
        $table = $this->loadModel();
        Assert::isInstanceOf($table, Table::class);

        $options = array_merge($options, ['lookup' => true]);
        $entity = $table->patchEntity($entity, $data, $options);

        $saved = false;
        try {
            $saved = $table->save($entity);
        } catch (PDOException $e) {
            Log::error($e->getMessage());
        }

        if ($entity->getErrors()) {
            Log::warning((string)json_encode($entity->getErrors()));
        }

        if (! $saved) {
            $this->Flash->error((string)__('The record could not be saved, please try again.'));
        }

        if ($saved) {
            $this->Flash->success((string)__('The record has been saved.'));

            $primaryKey = $table->getPrimaryKey();
            if (! is_string($primaryKey)) {
                throw new UnsupportedPrimaryKeyException();
            }

            // handle file uploads if found in the request data
            $fileUpload = new FileUpload($table);
            $fileUpload->link(
                $entity->get($primaryKey),
                (array)$this->request->getData()
            );

            $url = [];
            if ($table instanceof Table) {
                $url = $table->getParentRedirectUrl($table, $entity);
            }
            $url = ! empty($url) ? $url : ['action' => 'view', $entity->get($primaryKey)];

            return $this->redirect($url);
        }

        return null;
    }
1319267
public function setPropertyValue(&$entity, $field, $value)
    {
        $this->assertEntity($entity);

        if (is_array($entity) || $entity instanceof \ArrayAccess) {
            $entity[$field] = $value;

            return;
        }

        $ref = $this->getReflection($entity);
        if (!$ref->hasProperty($field)) {
            $entity->{$field} = $value;

            return;
        }

        $this->getProperty($ref, $field)->setValue($entity, $value);
    }
568720
public function setEntity(Entity $entity)
    {
        /** @var SharedEventManager $events */
        $events = $this->getContainer()->get('sharedEventManager');
        $events->attach(
            get_class($entity),
            Save::BEFORE_SAVE,
            [$this, 'beforeSave']
        );
        $events->attach(
            get_class($entity),
            Select::BEFORE_SELECT,
            [$this, 'beforeSelect']
        );
        $events->attach(
            get_class($entity),
            Select::AFTER_SELECT,
            [$this, 'afterSelect']
        );
        $this->getContainer()->set('sharedEventManager', $events);
        return parent::setEntity($entity);
    }
1022574
public static function gets($data = [], Entity $entity = null)
    {
        if (!$entity) {
            $entity = (new static)->getEntity();
        }

        if (is_scalar($data)) {
            return $entity->where('id', $data)->one();
        } else {
            return $entity->whereArr($data)->one();
        }
    }