Tuesday, April 17, 2012

Add Group to User Automatically when Creating a New User with Form

Add this to the form...
public function save($con = null)
  {
    //Do the main save to get an ID
    $user = parent::save($con);
  
    //Add the user to the relevant group, for permissions and authentication
    if (!$user->hasGroup('Dispatchers'))
    {
      $user->addGroupByName('Dispatchers');
      $user->save();
    }
  
    return $user;
  }

Friday, April 13, 2012

Format Datetime in Symfony

$user->getDateTimeObject('created_at')->format('Y-m-d H:i');

Tuesday, April 10, 2012

Customize Zend Studio

Disable AltGr + N to create a New Document
Windows / Customize Perspective -> Command Groups Availability -> uncheck New PHP Document.

To open a file by double-clicking in Zend Studio, not in external editor
 Add the file type to the list of file types which will automatically be opened in Zend Studio by doing the following:
  1. From Zend Studio 's Menu Bar, go to Window | Preferences | General | Content Types.
  2. The Content Types dialog will be displayed.
  3. Select Text | PHP Content Type from the list.
  4. A list of file types associated with Zend Studio will be displayed.
  5. Click Add to add your file's type to the list, Enter the file type (e.g. .php) and click OK.
  6. The file type will be added to the list.
Encoding / character set + Line delimiter:
Window / Preferences -> General -> Workspace -> Text file encoding -> UTF-8
+
New text file line delimiter

Remove trailing whitespace:
Window / Preferences -> PHP -> Editor -> Save Actions -> Remove trailing whitespace

Ctrl + TAB to the next file
Windows / Preferences -> General -> Keys
Search for: Previous Editor, Next Editor...

Default indentation for array initializers

Window > Preferences > PHP > Code Style > Formatter > Edit... > Line Wrapping
Set Default indentation for array initializers to 0.

Mark Occurrences
Windows / Preferences -> PHP -> Editor -> Mark Occurrences