Symfony's autogenerated model classes' function location - symfony1

i'm working on a symfony project and i generated a set of model classes called Base<name>.php, <name>.php, <name>Peer.php and Base<name>Peer.php
I did the famous jobeet tutorial and i still have doubts about locating functions in these files of the model. So my question is:
What kind of functions i have to put in which file?
or expressed other way
How i know where to locate a function in these files?
thank you very much

You should never edit the files prefixed with Base, they can be overwritten if you change something in your schema and regenerate these files.
The custom methods you are writing yourself should be in the Peer class.
To easily locate a method, I use a good IDE like PDT that parses the files and allows searching methods.

Related

F# and FSharp.Configuration Check if there is a configuration file

I have a question, I am using FSharp.Configuration (https://fsprojects.github.io/FSharp.Configuration/YamlConfigProvider.html) library to read configuration file in my project using Yaml provider. Well it all works well and good but I started to wonder how to detect if there is no configuration file, if some no good user deleted this file.
I could replace it with some default hard coded config. But documentarian says none about it.
Anyone maybe solved this problem?
All values from the config file passed to the TP at compile time are stored as default values (right in the generated code), except lists of compound types, which will always be empty due to the TP restriction. So, when you instantiate a TP at runtime, it's "filled" with the default values already. If you need to fill it with different values, you can load a file, a string, or set individual properties in code. Maybe it would be a good idea to add an ability to load config from resources, but I'm not sure it's an idiomatic way in .NET world (in contrast with, say, Scala).

How do I tell dartdoc to document everything?

I've tried to lay out my classes in one file each, with the classes belonging to a couple different libraries.
Basically, these files have library inf.logic; at the top:
web/logic/realm.dart (imports region.dart)
web/logic/region.dart (imports ../events.dart)
web/logic/tile.dart
This has library inf.gfx;:
web/gfx/viewport.dart (imports ../logic/realm.dart)
This has just library inf;:
web/events.dart
And then I have the main entry point, which seems to end up in the inf library by default:
web/inf.dart (imports gfx/viewport.dart, logic/realm.dart, logic/region.dart, logic/tile.dart)
When I generate dartdoc, it only seems to catch some classes, seemingly randomly. Even though the main entry point uses all of the above classes explicitly, I only get docs generated for region.dart and events.dart. No other files are included, and the links in the doc that refers to the other classes result in 404's.
It feels like I'm doing something wrong. Should I resort to create a wrapper file for the libraries and use part and part of? I really dislike the idea of adding that need for maintenance between file relations, that should already be implicit from the imports.
Also, how can I get rid of relative paths? I tried package:inf/logic/realm.dart, but it doesn't work…
Andrei Mouravski answered this on the mailing list:
There are several issues here:
If Dartdoc is generating 404 links, then file a bug with all information you can possibly provide. It's very possible something broke. dartbug.com/new
You can document multiple things at the same time by passing multiple entrypoints. Note: if you have multiple entrypoints, you should use the 'pkg' command line option to specify your packages folder.
You shouldn't need a wrapper file, but dartdoc should document every library that was imported in the entrypoint, so a possibility is to just have a simple file that imports all the libraries you want documented. We're working on something better for this, and I'm sorry it's a little broken at the moment.

Using resources for localization in MVC4

I'm following this tutorial that was given as answer in this question, however I'm stuck at displaying the resource.
Just like in tutorial I've created two files
App_GlobalResources
/Global.en.resx
/Global.ru.resx
I've made data annotation class that works and adds a cookie with no errors, it means it injects the local data into current thread properly. When I try to output resource it cannot find it.
I've tried to output it like this and none of these works:
#Global.HomeHello
#Global.en.HomeHello
#Resources.Global.Homhello
// The name 'Resources/Global/etc...' does not exist in the current context
Also, in this tutorial site I see no logic that will inject the proper resource file, how it can do something like (in tutorial) #Global.HomeHello and it will know that if url is /en/ he needs to use Global.en.resx
Please help, first time using resources and implementing multiple languages, feels 100 times more harder and confusing than using *.yml files in other frameworks/languages...
You took a bad example to follow I guess. Please look into the following article:
Resource Files and ASP.NET MVC Projects
Don't forget to change Custom Tool to PublicResXFileCodeGenerator and Custom Tool Namespace to Resources.
Hope this helps & good luck.

Moving global resources to custom folder

I have an ASP.NET MVC2 application where I need to support not only multiple languages, but also potentially multiple versions of each language. I usually solve localization requirements by using resx files in the App_GlobalResources folder, and this works well as long as I do not need to support multiple resource-sets for the same language.
This is an issue because each customer shall be able to specify a set of resources, and they may use the same language.
My initial thought was to have a file structure where every customer has a separate folder located under for instance App_Data. In this customer folder I would put configuration files and resources. But then I would need a way to tell the application that it should look for resources in this particular folder instead of App_GlobalResources.
So my question is: Is this doable, and what do I have to do to make it work? Is this a bad way to solve a problem like this, and if that seems to be the case: Does anyone have suggestions for a better solution?
Will be thankful for all input.
I usually use a custom ResourceProviderFactory to store the resources in the database. Creating a custom provider to look in specific folders should not be to hard if you can distinguish the different customers by virtualpath.
But then I would need a way to tell the application that it should look for
resources in this particular folder instead of App_GlobalResources.
You might consider compiling your resources so that they are deployed as DLLs rather than compiled at runtime. To do this you have to move your resources our of the standard App_GlobalResources.
This post has a good explanation of the benefits of doing this:
http://odetocode.com/Blogs/scott/archive/2009/07/16/resource-files-and-asp-net-mvc-projects.aspx

Troubleshooting "call to undefined function" when adding Markdown to project

I'm trying to add some Markdown capabilities to my Symfony project (Symfony version 1.3.3).
To accomplish that, I had already included the Markdown library into lib/vendor directory. Also, I added the need configuration in the autoload.yml for the previous library.
However, I'm getting a fatal PHP error:
Call to undefined function Markdown()
How can I resolve this problem?
The symfony autoloader loads classes from php files named like <classname>.class.php. If you're using the markdown.php file from mitchelf.com, it does not follow the naming scheme, nor does it contain a class called Markdown, as a matter of fact: it has a function called Markdown.
Symfony isn't even trying to load it, for reasons I described above. You will have to include it manually. I suggest you have a look at http://www.symfony-project.org/plugins/sfEasyMarkdownPlugin.
I do NOT suggest installing a plugin for such a simple feature. It is not hard for you to figure it out if you have some real examples.
There is an open source project based on symfony named Bookeet. It has embedded MarkDowm feature. It uses markitup as the markdown editor. And it uses php markdown to convert markdown code to html code.
To save your time, go directly to changeset 29f0ba1807 of the Bookeet project(I am sorry that I can't post the hyperlink because SO doesn't permit new user to post more than one hyperlink). You could see clearly what should be done in order to add markdown feature to your website.

Resources