Binds the uploaded file to its owner on creation.

@param object $object
@param array  $ids
2590
protected function handleFiles($object)
    {
        $request = $this->getRequest();

        $rc = new \ReflectionClass($object);
        $className = $rc->getShortName();

        $repo = $this->manager->getRepository('LibrinfoMediaBundle:File');

        if ($remove = $request->get('remove_files')) {
            foreach ($remove as $key => $id) {
                $file = $repo->find($id);

                if ($file) {
                    if (method_exists($object, 'removeLibrinfoFile')) {
                        $object->removeLibrinfoFile($file);
                        $this->manager->remove($file);
                    } elseif (method_exists($object, 'setLibrinfoFile')) {
                        $object->setLibrinfoFile();
                        $this->manager->remove($file);
                    } else {
                        throw new \Exception('You must define ' . $className . '::removeLibrinfoFile() method or ' . $className . '::setFile() in case of a one to one');
                    }
                }
            }
        }

        if ($ids = $request->get('add_files')) {
            foreach ($ids as $key => $id) {
                $file = $repo->find($id);

                if ($file) {
                    if (method_exists($object, 'addLibrinfoFile')) {
                        $object->addLibrinfoFile($file);
                        $file->setOwned(true);
                    } elseif (method_exists($object, 'setLibrinfoFile')) {
                        $object->setLibrinfoFile($file);
                        $file->setOwned(true);
                    } else {
                        throw new \Exception('You must define ' . $className . '::addLibrinfoFile() method or ' . $className . '::setLibrinfoFile() in case of a one to one');
                    }
                }
            }
        }
    }
485066
public function move($object, $parentObject = null) {
		$this->em->flush();
		
		if ($parentObject !== null) {
			$this->valMove($object, $parentObject);
		}
		
		$newLft = 1;
		if ($parentObject === null) {
			if (null !== ($maxRgt = $this->lookupMaxRgt($object))) {
				$newLft = $maxRgt + 1;
			}
		} else {
			$newLft = $this->lookupLftRgt($parentObject)['rgt'];
		}
		
		$this->moveToLft($object, $newLft);
	}
1091748
public static function setPropertiesValues($object, array $propertiesValues)
    {
        /*
         * No properties?
         * Nothing to do
         */
        if (empty($propertiesValues)) {
            return;
        }

        foreach ($propertiesValues as $property => $value) {
            static::setPropertyValue($object, $property, $value);
        }
    }
1351738
public function setObjects(array $objects)
    {
        foreach ($objects as $object) {
            $this->checkType(ObjectDataInterface::class, $object);
        }

        $this->objects = $objects;
    }
1086359
public function deleteRoles(array $ids): void
	{
		if ($this->isAjax()) {
			$roles = $this->orm->aclRoles->findById($ids);
			foreach ($roles as $role) {
				$this->orm->aclRoles->remove($role);
			}
			$this->orm->flush();
			$this['permissionsList']->reload();
		} else {
			$this->terminate();
		}
	}
680946
static function setProperties( ValueObjectInterface $object, array $values )
    {
        foreach ( $values as $property => $value )
        {
            $this->setProperty( $object, $property, $value );
        }
    }
733607
public function add($object, $defaults = [])
    {
        if (!is_array($defaults)) {
            $defaults = ['name' => $defaults];
        }

        $defaults['join'] = $this;

        return $this->owner->add($object, $defaults);
    }
481431
public function remove($ids)
    {
        if (!$this->isEmpty() &&
            ($remove = $this->_resolveIds($ids))) {
            $this->_ids = array_diff($this->_ids, array_unique($remove));
        }
    }
425018
protected function createAttachRecords($ids, array $attributes)
	{
		$records = array();

		$timed = ($this->hasPivotColumn($this->createdAt()) ||
			      $this->hasPivotColumn($this->updatedAt()));

		// To create the attachment records, we will simply spin through the IDs given
		// and create a new record to insert for each ID. Each ID may actually be a
		// key in the array, with extra attributes to be placed in other columns.
		foreach ($ids as $key => $value)
		{
			$records[] = $this->attacher($key, $value, $attributes, $timed);
		}

		return $records;
	}
1058659
public function delete($object, array $options = [])
    {
        $this->checkPermission('DELETE', $object, [], true);

        if ($this->dispatch('delete', 'pre', [$object, $options])) {
            if (!in_array(Options::SOFT_DELETE, $options)) {
                $this->om->remove($object);
                $this->om->flush();
            }
            $this->dispatch('delete', 'post', [$object, $options]);
        }
    }
251600
public function uploadFilesById($id, $files)
    {
        $crudeName = $this->getCalledClassName();
        $model = $this->getById($id);

        $fileAttrName = $this->getFileAttrName();

        $model = (new CrudeFiles)->upload($model, $crudeName, $files, $fileAttrName);

        return $this->updateById($id, [$fileAttrName => $model->files]);
    }
409409
private function removeByChunk(array $ids) {
    $storage = $this->entityTypeManager->getStorage('openy_pef_gxp_mapping');
    $chunks = array_chunk($ids, self::CHUNK_DELETE);

    foreach ($chunks as $chunk) {
      $entities = $storage->loadMultiple($chunk);
      $storage->delete($entities);
      $this->loggerChannel->debug(
        'Chunk of %chunk openy_pef_gxp_mapping entities has been deleted.',
        ['%chunk' => count($chunk)]
      );
    }
  }
1373084
function onPublish( $object, $nodes  )
    {
        $dataType = $this->dataType();
        if ( $dataType )
            $dataType->onPublish( $this, $object, $nodes );
    }
1251019
private function prepareUploadFileReferences(UploadObjectInterface $object)
    {
        $object->setFileUploadPath($this->fileUploadPath);

        $reflectionClass = new ReflectionClass($object);
        $objectName = $reflectionClass->getShortName();

        $fileUploads = $object->getFileUploads();
        $fileFieldConfigurations = $this->flexModel->getFieldsByDatatype($objectName, 'FILE');
        foreach ($fileFieldConfigurations as $fileFieldConfiguration) {
            $camelizedFieldName = Container::camelize($fileFieldConfiguration['name']);
            $fileFieldProperty = lcfirst($camelizedFieldName);
            if (isset($fileUploads[$fileFieldProperty])) {
                $getter = 'get'.$camelizedFieldName;
                $setter = 'set'.$camelizedFieldName;

                $previousFileReference = $object->$getter();
                if (empty($previousFileReference) === false) {
                    $this->filesScheduledForDeletion[] = sprintf('%s/%s', $this->getFilePath($objectName, $fileFieldConfiguration['name']), $previousFileReference);
                }

                $fileName = md5(uniqid()).'.'.$fileUploads[$fileFieldProperty]->guessExtension();

                $object->$setter($fileName);
            }
        }
    }
547081
public function deletePermissions(array $ids): void
	{
		if ($this->isAjax()) {
			$permissions = $this->orm->acl->findById($ids);
			foreach ($permissions as $permission) {
				$this->orm->acl->remove($permission);
			}
			$this->orm->flush();
			$this['permissionsList']->reload();
		} else {
			$this->terminate();
		}
	}
276605
public function registerObject($object, $identifier)
    {
        $this->objectMap[$object] = $identifier;
        $this->identifierMap[$identifier] = $object;
    }
817471
public function preUpdate($object): void
    {
        /** @var BlockAdmin $block */
        $block = $this->blockManager->get($object);

        $block->preUpdate($object);

        // fix weird bug with setter object not being call
        $object->setChildren($object->getChildren());

        $dashboard = $object->getDashboard();

        if ($dashboard instanceof DashboardInterface) {
            $dashboard->setEdited(true);
        }
    }