Filed under symfony

Symfony partial

Include partial in the same module, can skip module name. Because it can be included by other modules, partials requires all params to pass to it.

Symfony view more

Helpers. If you override a helper file make sure you override all as there is no inheritance. Symfony uses the decorator pattern to form the page. Layout.php has a sf_data to hold the template data. To include code fragments, use partial to include simple HTML, component to include some logic, and slot to replace stuff … Continue reading

Symfony helpers

Helpers uses underscore naming convention, rather than camel case, as they are functions rather than class methods. Default helpers included in every template are: URL, Helper, Tag, Asset, Partial, Cache, Form. They can configurable in the settings.yml file. To use a helper outside of the template, use sfLoader::loadHelpers(‘Text’)

Symfony links

Action names and URL can be completely different. In template we can use link_to() from the route tags. Link_to() can also have params like class, confirm, absolute. Getting request from the user, In action $this->getRequestParameter(‘name’); In template, $sf_params->get(‘name’);

Symfony template

Already has some global variables such as sf_context, sf_request (request), sf_params (request parameters), sf_user (sessions)


// JobeetJobTable.class.php function getActiveJobs() { $q = $this->createQuery(‘j’)->where(‘j.expires_at > ?’, date(‘Y-m-d H:i:s’, time())); return $q->execute(); } // still in JobeetJob_Table.class.php, this is overiding save() to set a auto expired date function save(Doctrine_Connection $conn) { if ($this->isNew() && !$this->expiredAt()) { $c = $this->getCreatedAt()? $this->getDateTimeObject(‘created_at’)->format(‘U’):time(); $this->setExpiredAt(date(‘Y-m-d H:i:s’, $c + 86400*30)); } parent::save($conn); } // JobeetJobCategoryTable.php function getWithJobs … Continue reading

Dec diary

Went to work in a good mood. Listened to sermon a lot. Sat down and already felt exhausted. Anyway continue with the ellipsify function. Found out how to use the includes from one helper to another. But how to verify its working? Looking around for pages to verify. T came in and asked how I … Continue reading

symfony starts

cathy@cathy-VirtualBox:~/sfprojects/myproject2$ mkdir -p lib/vendorcathy@cathy-VirtualBox:~/sfprojects/myproject2$ cd lib/vendor cathy@cathy-VirtualBox:~/sfprojects/myproject2/lib/vendor$ cp /home/cathy/Downloads/symfony-1.4.20.tgz . cathy@cathy-VirtualBox:~/sfprojects/myproject2/lib/vendor$ ls symfony-1.4.20.tgz cathy@cathy-VirtualBox:~/sfprojects/myproject2/lib/vendor$ tar zxpf symfony-1.4.20.tgz cathy@cathy-VirtualBox:~/sfprojects/myproject2/lib/vendor$ mv symfony-1.4.20 symfony cathy@cathy-VirtualBox:~/sfprojects/myproject2/lib/vendor$ rm symfony-1.4.20.tgz cathy@cathy-VirtualBox:~/sfprojects/myproject2/lib/vendor$ ls -al total 608 drwxrwxr-x 3 cathy cathy   4096 Mar  1 19:41 . drwxrwxr-x 3 cathy cathy   4096 Mar  1 19:39 .. -rw-r–r– 1 cathy cathy 608786 Jan  1  1970 … Continue reading

Symfony in 2 minutes

localhost/Symfony/web/app_dev.php is the website. To create new project, there are only 2 steps: 1. Create a route. 2. Create a bundle and change the controller. The route is in /app/config/routing.yml The application can have many bundles. The bundle can be created with > php app/console generate:bundle –namespace=CathySoft/CoolBundle which will create src/CathySoft/CoolBundle/ and register it with … Continue reading