I'd like to create an upload form for documents.
It's possible to select several so called 'agencies' and each of these agencies belongs to one specific market.
What I want to do is, set the markets automatically.
So in my controller I had something like this:
$document->setMarket($document->getAgencies()->getMarket());
But since the agencies are an ArrayCollection, I can't call a getter on them. So I was thinking about a for each loop in order to get the markets for every single agency. Would that work and if yes how would I do it best and most efficiently?
Would be happy about tips and tricks :D
Related
I have an app that can have one or more streams
Example:
Book of author A
Book of author B
Book of author C
So my queries can have one or more relationship filters.
Assuming that I would like to use only one template for more views, and a view can have more streams so I can't have the names of each one in my template, how can i do that?
Basically in my template I would like to have a unique list even if I got more streams
AsDynamic(Data["Default"]) //This should get all the streams in my data
Is that possible? Maybe aggregating them in Visual query?
I'm trying to have an out stream coming from many but giving the same name I got and error.
At the moment this is not possible (2sxc 8.5.6). There are a few problems related to this idea
the same item could occur multiple times, this is not supposed to happen in a stream
you will probably loose the "which author was this for" information
As of now, I recommend to either just merge them in js or server-side code if this is what you need.
We have a document base that needs the metadata to be structured in order to facilitate search, but due to the nature of the information, it will be impossible to use constraints. Tagging seems like an interesting option: it keeps the metadata structured, but allows users to create new values on the fly.
The problem with this solution is that each property needs to have a specific pool of tags. Imagine a document with two properties:
Entity
Process
In theory, we could put this information into metadata fields with constraints (database backed even), but the users want to be able to create values on the fly. Tags seem interesting, but we don't want to mix tags from the Entity list with tags from the Process list. Each tag should have its own "pool".
Has anyone done something like this in Alfresco? It seems like we'd have to tear apart the tagging system and basically rewrite it, but maybe it's easier than that.
If your only issue with tag is related to on the fly creation then you should look into "Categories". In Categories only admin user can create required Category structure.Then normal user will be able to use them to categories docs.
I your case I guess you require something like this
Entity
Entity1
Entity2
Entity3
....
Process
Process1
Process2
Process3
.....
If yes, you should b able to use categories.
I feel pretty lost on collections, and entities as it stands.
My purpose:
A user will have one or more abilities. There are a set number of abilities, and numerous users. (A user entity, usertoabilities, abilities)
I want to display a form of the set abilities (lets say running, swimming, climbing), with properties such as (skill level, length of time).
The user would check each ability they have, and select their skill level and time.
My current understanding, is that my form will contain:
a collection of abilities (collection of entities), a collection of skill levels, and a collection times.
The form will print out each row of abilities with the corresponding properties. Where the user selects these abilities and saves them.
Is my understanding correct?
My current approach seems to have me going in circles.
you can create only two Entities (User and ability) and you need to create a ManyToMany Relation where you need to set a field (property) that is the relations field with some annotations where you wil set the "JoinTable" that in this case is "usertoabilities" for the two entities and more fields that will be the "abilities" you can find more information in http://doctrine-orm.readthedocs.org/en/latest/reference/association-mapping.html
I'm working on a studio project to try to learn different approaches using Symfony2, Doctrine 2.4.7 as ORM and MySql 5.5 as DB. I've deliberately minimized my question for a better understandability and readability, if you need more details you only have to ask and apologize me if my english is not so good.
To avoid a large discussion due to the title of my question let me synthesize the problem showing a simple and common case (but complex for me because I'm new with doctrine).
The Model:
The User entity (mapped) that stores the user's data
The Category entity (mapped) that stores some categories associated to the User with a ManyToMany BD.
Each User can select one or more Categories.
The Problem:
User categories are near 100.
Many Categories could have a specific associated form.
Each form is composed by common and/or only specific fields (from 1 to 10 fields per category).
The Goal:
Understand what's the most balanced approach for this use case (in terms of flexibility and performances), for create the entities and associations needed to store the data filled by the user (some of these data I wish they were to be searchable).
Some Related References:
Doctrine2 docs
Serialized LOB
Extensible Data Modelling
and many other threads not much relevant...
A Possible Solution:
Create manually a form type for each category with inside the block of related fields (I use this forms as services in DIC and use blocks for the fields I need to reuse on more then one category).
Create a CategoryForm entity with the properties needed to retrieve the name of the form related to the category (useful to the form factory when I build the form) with an association ManyToMany UD with Category and to store the serialized LOB (the data coming from the form and related to the User).
There is a better approach to avoid the serialization of the object in a LOB? (maybe I'm wrong but serialized data are not searchable/indexable in mysql)
Any other solution or reference to a readable resource is welcome!
Well, I will try to answer the question with a simple guess: the category is something shared beetween several users (since you got the many to many).
So, if you want the User's form to be able to set (add/delete or update) Categories assiated to the user, then you should just have acollection of entity widgets related to the Category.
Why do I say that ?
Since your categories are linked to several users, the way you want to treat the relation beetween Categories and Users will cause any update on existing Category from a User's form to be propagated to other Users.
This means that Categories should be created/updated by a single form (modulo your needs). You can then link the Category to the User from User's form.
As far as the number of form of Categories is concerned, there are several parameters to handle:
Are all the Categories validated the same way (to know if you simply need to hide widgets to make the validation work) ?
Do you have a large amount of different types of Categories ?
If yes, are always composed the same way for a given type ?
Give further details if I'm wrong in my initial guess ;)
I'd like to have your opinion about code organization. I have two entities: City and Country. I have an unidirectional ManyToOne between them, Many side is of course City.
Now, I need to get all the cities corresponding to a country. I have two choices:
Changing the relation to a bidirectionnal ManyToOne
Creating custom method in City repository
What is the best way to do so ?
Depends. If the two entities are in the same Bundle (or in Bundles that require each other's presence), then make it bi-directional, especially if you think this'll be a common thing to search for.
On the other hand, if this is a special case, the entities are in different Bundles, and you don't want to couple them further, then it's better to make a custom method for it.
It depends on what kind of data and how oftend you need it:
if you have the Country object and you need City objects, make it a 2-way ManyToOne
if you have the Country id and you need City objects, add a query to repository
if you have the Country id and you need City ids, add a query to repository
#Erik's response is also a good view on the subject