custom-type

Symfony2 Custom form type using entity trying to test it

爱⌒轻易说出口 提交于 2019-12-01 05:43:50
I am trying to test a form type I have creating that uses a field with class entity here is the creation of the form $builder ->add('name', 'text') ->add('description', 'textarea') ->add('services', 'entity', array('class' => 'MyBundle:Service', 'group_by' => 'category.name', 'property' => 'name', 'multiple' => true, 'required' => false)); This works very nice when I build the form, but then I am trying to unit test this type Following this example on how to test my custom form types I am getting this error Symfony\Component\Form\Exception\Exception: Could not load type "entity" The error is

Symfony2 Custom form type using entity trying to test it

半城伤御伤魂 提交于 2019-12-01 03:20:41
问题 I am trying to test a form type I have creating that uses a field with class entity here is the creation of the form $builder ->add('name', 'text') ->add('description', 'textarea') ->add('services', 'entity', array('class' => 'MyBundle:Service', 'group_by' => 'category.name', 'property' => 'name', 'multiple' => true, 'required' => false)); This works very nice when I build the form, but then I am trying to unit test this type Following this example on how to test my custom form types I am

Custom UnmarshalYAML, how to implement Unmarshaler interface on custom type

有些话、适合烂在心里 提交于 2019-12-01 01:58:52
问题 I parse a .yaml file and need to unmarshal one of its properties in a custom manner. I am using the "gopkg.in/yaml.v2" package. The property in question is stored like this in my .yaml file: endPointNumberSequences: AD1: [ 0, 10, 14, 1, 11, 2, 100, 101, 12 ] So it is basically a map[string][]uint16 kind of type. But I need map[string]EpnSeq where EpnSeq is defined as: type EpnSeq map[uint16]uint16 My struct: type CitConfig struct { // lots of other properties // ... EndPointNumberSequences

How can I create an enum using numbers?

余生长醉 提交于 2019-11-30 23:20:53
问题 Is it possible to make an enum using just numbers in C#? In my program I have a variable, Gain, that can only be set to 1, 2, 4, and 8. I am using a propertygrid control to display and set this value. If I were to create an enum like this... private enum GainValues {One, Two, Four, Eight} and I made my gain variable of type GainValues then the drop-down list in the propertygrid would only show the available values for the gain variable. The problem is I want the gain values to read

Is there a way for phpDoc to document an array of objects as a parameter?

烂漫一生 提交于 2019-11-29 05:32:12
In phpDoc-generated documentation I can cause phpDoc to generate a link to a custom type definition for a given param using @param CustomType $variablename and that works great. However, the code I'm currently documenting requires CustomType[] parameters, i.e. an array of said CustomType. I want the documentation to be clear that an array is required, but when I use @param CustomType[] $variablename phpDoc no longer recognizes the type, and thus can't link to it's definition. This is pretty important in this case - I'm documenting an API that has some fairly complex types that need to be

Custom content type - is registering with IANA mandatory?

独自空忆成欢 提交于 2019-11-29 01:30:37
问题 I'm developing an API as RESTful as possible (though the HATEOAS constraint is not met thus it is not a REST API per se ) I'm versioning the API, and since there are several ways to do this, I think I'm going to use the Accept header. I do know the alternatives, but the purpose of this question is not to find a suitable way to version the API. As far as I know, there are two ways to version API using the Accept header, as seen here, here and here: application/vnd.company.myapp-v1+json or

How to map the PostgreSQL Interval column type in Hibernate?

时光毁灭记忆、已成空白 提交于 2019-11-26 21:16:02
问题 Under PostgreSQL, I'm using PersistentDuration for the mapping between the sql type interval & duration but it doesn't work. Another user found the same issue & come with his own class: public void nullSafeSet(PreparedStatement statement, Object value, int index) throws HibernateException, SQLException { if (value == null) { statement.setNull(index, Types.OTHER); } else { Long interval = ((Long) value).longValue(); Long hours = interval / 3600; Long minutes = (interval - (hours * 3600)) / 60;