12.07.2015 Views

My first symfony project - Mesurex

My first symfony project - Mesurex

My first symfony project - Mesurex

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>My</strong> <strong>first</strong> <strong>symfony</strong> <strong>project</strong> 18Listing1-45_delete: ~max_per_page: 5filters: [title, created_at]edit:title:Post detailfields:title: { type: input_tag, params: size=53 }excerpt: { type: textarea_tag, params: size=50x2 }body: { type: textarea_tag, params: size=50x10 }created_at: { type: input_date_tag, params: rich=on }Note that among the existing columns of the blog_post table, the admin will look for acolumn (or getter method) for nb_comments. Since this is a generated value and not acolumn, we can add a getter to our model (sf_sandbox/lib/model/BlogPost.php):public function getNbComments(){return count($this->getBlogComments());}Now refresh the Post administration screen to see the changes:Restrict access to the backendCurrently the backend application can be accessed by everybody. We therefore need to addsome access restrictions. In apps/backend/config/, edit the file called security.ymland reset the content to:Listing1-46all:is_secure: onNow you can no longer access these modules, unless you are logged in. However, currentlythe login action doesn’t exist! Of course, we can easily add it. To do so, let’s install a suitableplugin from the <strong>symfony</strong> website - sfGuardPlugin. Type the following at the command line:Listing1-47$ php <strong>symfony</strong> plugin:install sfGuardPluginThis will download the plugin from the <strong>symfony</strong> plugin repository. At this point the commandline should give you an indication that the installation was successful:Listing1-48$ php <strong>symfony</strong> plugin:install sfGuardPlugin>> plugin installing plugin "sfGuardPlugin"----------------- Brought to you by

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!