Filereference extbase versus Core - typo3

I am confused because I figured out, that there are 2 different FileReference classes inside TYPO3. One of them is from the Core and the other one is from Extbase.
The one from the core has function like delete(), but this delete is not implemented yet. I cannot find any function for deleting the FileReference.
If I use update in my extension from the repository, the image will be added not replaced by the new one.
I would like to understand how I can add, delete and fetch files to/from ext_file_reference in a simple way.
Does anybody have a solution or a hint?

It's unclear from your question what you are trying to do.
If you want to replaces files, you do that on the File Object itself, not the references. But note, that this replaces the file for all references. There is a replaceFile() function on the ResourceStorage object of the file.
If you want to replace a file in a Property, you have to detach one file and attach the other. Every Property that holds FileReferences is an ObjectStorage, and as such comes with attach() and detach() methods to do that.

let me try to explain it in more details. I try to replace an image on a page with another one, but without modifying the image at all. Also the new image is already stored under fileadmin. I would need a new filereference and to replace the old one in the sys_file_reference.
So attach and detach would be the goodsolutions, but are not working with extbase filereference. For that I need a \TYPO3\CMS\Extbase\Persistence\ObjectStorage object. I tried "\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\HGA\Hgarecipes\Domain\Model\FileReference>" but it creates an error "Cannot cast object of type "TYPO3\CMS\Extbase\Persistence\ObjectStorage" to string". So finally I am looking for a sulution to add and delete images from sys_file_reference under extbase. I found many pleople which are looking for something, but no solution. Alo if I use the objectstorage I have not longer access to the originalResource of the filereference.
With other words, to create a entry in the sys_file_reference with a given filepath and delete this entry if not longer needed.
On the other hand I want to understand why extbase needs a own filereference.

Related

TYPO3 object storage table does not exist - (tx_extbase_persistence_objectstorage)

I recently upgraded a relatively old System TYPO3 4.7 => 6.2.
I changed alot of namespaces/imports etc. and fixed stuff here and there. After the system was stable I made some changes in the extension builder and added some new fields.
I had to change some code in some files that threw errors but after that I was able to successfully save in the extension builder.
It added the correct classes,attributes and actions but now the system shows me this error:
1247602160: Table 'keepins_upgrade.tx_extbase_persistence_objectstorage' doesn't exist
Usually this error is related to models that are mapped incorrectly in the typoscript file but this seems different.. any suggestions?
Shot from the hip: you have one or more properties in your domain model which is annotated incorrectly - so it is read as a 1:1 relation to ObjectStorage, not a 1:n to a collection of another object. Or, less likely given your previous version, you've annotated a setter method or controller action so it requires an instance of ObjectStorage, but neglected to add PHPDOC that defines the true expected child type or is somehow else invalid or not connected to the right property.

Is it possible to save a GameObject with its components in Unity?

I'm trying to Save/Serialize a GameObject and its components (with their current values), but I don't think it's possible, any ideas ???
Keep in mind that I don't wanna use an asset from the assets store, I wanna code it myself.
Thanks in advance :)
Sorry I dont have the rep to make a comment. I use two methods to acheive this save state.
First is what programmer seems to suggest, make a class that hosts the property's needed to recreate the object. Component names can be saved as strings, then fetched using
gameObject.AddComponent(Type.GetType(componentName));
If you are doing this alot it may be worth checking out this forum first.Here
You can serialize these classes using the unity serializer(the string names of types will serialise. You may have to make a sub class to handle the values in each object of different type.
This can be a fairly complicated approach so I prefer a file path serialized for a prefab in the resources folder. Any values that need saving can be saved in a serializable class like first approach which is referenced in a script on the saved prefab. This script has a method to apply all details saved in the deserialized class to the prefab when it is created. The details are captured by the script,added to the class and serialized whenever the object state should be recorded.
The exact way this is managed may vary but I have done this myself with he ability to store any values I could need. Even if you use a third party serializer from the asset store you will still have trouble saving entire objects, but you will be able to get enough info to recreate.
I've managed to save the components I want (custom scripts) by saving them in a json file, then serializing them with binary so they can be more secure.
Thanks to everyone who tried to help tho...

Access to an object's fields is only permitted within its methods in matlab

I need to modify the cluster methods of the phytree object in matlab. After modifying it, I change the name to cluster_second. Then, when I run the function, I got the error saying that
Access to an object's fields is only permitted within its methods.
I understand what is going on here. Because I need to use tr.tree, and it is a field of the phytree object which can only be accessed within that phytree object's method. Obviously, cluster_second does not satisfy that condition. Can anyone help me out with this? Many thanks.
If you want your cluster_second method to be a method of phytree, put the file cluster_second.m into the directory \toolbox\bioinfo\bioinfo\#phytree. All phytree objects will then have an additional method cluster_second (as well as the original cluster method).
It's possible that you may also be able to put it into a different folder named #phytree, as long this #phytree folder is on your path. I'm afraid I don't have Bioinformatics Toolbox on my current machine to test that, though.

Completely remove RLMObject in Realm.io

I see there are ways to empty an RLMObject, but I want to completely remove it from the RLMRealm storage. And I don't want to do a migration either, I want it removed. Is that possible?
A better way is to do realm.deleteAllObjects on your instance of the realm. More about that here http://realm.io/docs/cocoa/0.90.6/#deleting-objects. This removes all of your objects.
If you want to remove one object, you can do realm.deleteObject(object here). There is more on that in the link above as well.
Removing the file like you are doing does prevent the need for migrations, just don't forget to remove that line if you do go that route!
Did it the hard way. Used RLMRealm.defaultRealmPath() to give me the default path. You can use NSFileManager to remove that, and other Realm related files in that directory, or you can do it manually. This will clear ALL the objects.

How to build assetBundle without using Selection

I want to write my own editor that would allow me to search the whole Assets folder for object type of X and make an AssetBundle from them.
I went through all the manuals and docs and it seems that they all use the Selection class to build the Assets Bundle.
But what if there are 10 000+ objects scattered in different folders and I don't want to select each manually, yet I still want to track their dependencies. Is there a way to do so?
I have already tried editing Selection.objects, but as much as I understand it's limited to one concrete scene.
Is it possible to skip the whole Selection class and just use BuildPipeline.BuildAssetBundle() method? If yes, how to get the correct list of objects that can be used? Do I need to write my own deep threading loop to get the dependencies?
All you need is a list of objects. That's it. How you get them is irrelevant. You can do that with the Selection class, but if you have other means of finding the assets, that's no problem either.
As for dependencies, keep in mind that your final call will be something like:
BuildPipeline.BuildAssetBundle(main_asset, objects_array, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets);
See that BuildAssetBundleOptions.CollectDependencies? It will make sure that all the necessary dependencies for the objects you've specified get included as well.