I can't find anything in the documentation about this, and strangely also not here - is there a way to do this?
You can find information as to how to explicitly set a table name here.
https://typeorm.io/#/decorator-reference/entity
#Entity("users")
export class User {
Related
since Typo3 v10 you have to use Classes.php file in Configuration/extbase/Persistence Folder for configuration of persistence table mapping.
Does anyone know how to implement
config.tx_extbase.persistence.classes {
Domain\DomainUsergroupMailer\Domain\Model\FrontendUserGroups {
mapping {
tableName = fe_groups
columns {
subgroup.foreignClass = TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup
}
}
}
I can't find documentation concerning the foreignClass Parameter.
I found parameter subclasses in https://docs.typo3.org/m/typo3/book-extbasefluid/10.4/en-us/6-Persistence/5-modeling-the-class-hierarchy.html
Does anyone know if this is the right way parameter and how to use it?
Thank you
There never was such a feature in TYPO3 as confirmed by searching the TYPO3v9 source code for foreignClass. So this must be provided by a 3rd party extension.
However, from the name it sounds like you only need to use an appropriate element type for your collection relation:
/**
* #var ObjectStorage<FrontendUserGroup>
*/
private ObjectStorage $subgroup;
See Implementing the domain model for details.
How do I delete all session variables at once if they are not in Array?
PS I set them this way:
$this->getUser()->setAttribute('PayPalTransaction.hash', $request->getParameter('hash'));
Regards,
Roman
The sfUser class (which you get with $this->getUser()), keeps all it's attributes in a sfNamespacedParameterHolder. So the setAttribute() function on sfUser if merely a proxy to the sfNamespacedParameterHolder::setAttribute(). You can get the reference to this holder with sfUser::getAttributeHolder().
The sfNamespacedParameterHolder also has a function clear(), which clears all attributes.
So to clear all attributes, use:
$this->getUser()->getAttributeHolder()->clear().
(Please note that you will still be authenticated (e.g. logged in) when you clear the attribute holder).
Another way if you want to remove just one session variable not all of them is to use the following code
$this->getUser()->getAttributeHolder()->remove('att_name');
Again this will only remove one not all ... to clear all use the previous code by Grad
To remove all attributes of a namespace :
$this->getUser()->getAttributeHolder()->removeNamespace('yournamespace');
I know it's possible to read in values from the grails-app/conf/Config.groovy but i was wondering if it is possible to write values as well?
something as simple as this doesn't seem to actually change the value in the Config.
def oldValue = grailsApplication.config.my.value
assert oldValue == "oldValue"
def newValue = "newValue"
grailsApplication.config.my.value = newValue
assert newValue == grailsApplication.config.my.value
I would like to use this as a way to store some values outside of a database without having to load up another properties file.
That's probably not going to be practical if I understand you correctly. You're really dealing with the compiled Config.class at runtime. Do you really want to check out Config.groovy from your VCS, modify it, check it back in, recompile it, and mess around with the Classloader to reload it? The only way I have found to do this is by externalizing their properties a database or file and managing state at runtime to deal with updates.
I agree with proflux's comment. Config.groovy is not the right place to persist any data generated by your application, and it's a good thing that what you try doesn't work :)
I am very curious as to why you don't want to persist these values in a regular database (of whatever kind). There is, of course always the option of storing this in a file somewhere, the path of which you can configure in Config.groovy. But even that to me only seems marginally helpful.
Why not add a domain class along the lines of this:
class Setting{
String key
String value
static constraints = {
key(unique: true)
}
}
This will probably be the easiest way of achieving what you're looking for, from what I can tell from here. But again, you should elaborate on what kind of data it is that you need to persist...
I develop web part with custom editor part and faced with this question.
Is it possible in web part set Personalizable attribute to generic List?
For example I want something like this:
[WebBrowsable(false)]
[Personalizable(PersonalizationScope.Shared)]
public List<AnnouncementItem> Announcements
{
get { return _announcements; }
set { _announcements = value; }
}
Is it possible, and what kind of types at all can be used as "Personalizable"?
Thanks.
Solution:
I use a custom EditorPart to select multiple lists using AssetUrlSelector, but I need a way to personalize this collection for end user.List<of custom objects> doesn't work, but I found that List<string> (and only string) work perfectly. So, I get required lists in EditorPart and pass their to the web part using List<string>.
Try using a custom EditorPart to add/remove items from the collection. I've never built a web part that personalized a collection so I don't know if it works but I'd definitely try the collection with an EditorPart. If it doesn't work, serialize XML into a string property.
Your question does not seem to match your code. Your code shows a collection of custom objects. I doubt an end user will be able to set such a property. To have a property that points to a generic list, you would probably be better off defining the property as a string that contains the URL to a list.
Using Symfony 1.4.5 with Doctrine
I have a model which includes an uploaded image as one of the columns - creating and updating the record is fine (using the doSave() method to deal with the upload and any changes to the file).
The problem I'm having is if the record is deleted - I want it to remove the associated file as well. But I can't find anyway to do this after several hours of hunting through documentation and Google.
Is there a way to specify some kind of post-delete code?
Final solution:
in /lib/model/doctrine/Image.class.php
class Image extends BaseImage
{
public function postDelete()
{
$filename = $this->getFilename();
$filepath = sfConfig::get('sf_upload_dir') . '/' . $filename;
#unlink($filepath);
}
}
Thanks to Colonel Sponz for pointing me in the right direction
It's a while since I last used Doctrine but I seem to remember there is a post delete hook function that you can use for this kind of thing. If you look into the source for the Doctrine base class you should be able to find the exact method name and usage.
EDIT: The method is postDelete() and is found in the Doctrine_Record class
Here's the section from the Symfony documentation that covers advanced Doctrine usage.
Hijacking Colonel Sponsz's answer, the postDelete() method is definitely the way to go. +1 to him :-) But, you'll need to enable Doctrine callbacks in your config/ProjectConfiguration.class.php. Add this method:
public function configureDoctrine(Doctrine_Manager $manager)
{
$manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
}
Clear your Symfony cache, and Doctrine will fire the callback methods such as postDelete() at the appropriate times.