Skip to content

yagmort/JagmortTimezone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JagmortTimezonePlugin

With this module the user can set the timezone.

Requirements

  • PHP 5 >= 5.2.0
  • Symfony 1.4
  • Doctrine
  • sfGuardDoctrinePlugin

Model and view timezones

Model time is a unified time (by default your server's system time), view is a user time, may specific for any user.

Installation

Activate the plugin in the config/ProjectConfiguration.class.php

    class ProjectConfiguration extends sfProjectConfiguration
    {
      public function setup()
      {
        $this->enablePlugins(array(
          'sfDoctrinePlugin', 
          'sfDoctrineGuardPlugin',

          'JagmortTimezonePlugin'
        ));
      }
    }

Setup timezone in config/app.yml:

    default_timezone: UTC

Setup timezone in config/ProjectConfiguration.class.php:

    class ProjectConfiguration extends sfProjectConfiguration
    {
      //...

      public function setup()
      {
        //...

        $this->dispatcher->connect(
          'doctrine.filter_model_builder_options',
          array($this, 'configureDoctrineBuilderOptions')
        );

        //...
      }

      //...

      public function configureDoctrineBuilderOptions(sfEvent $event, $options)
      {
        $options['baseClassName'] = 'JagmortTzDoctrineRecord';

        return $options;
      }

      //...
    }

Rebuild your models:

    ./symfony doctrine:build-model
    ./symfony doctrine:build-forms

Testing

To run tests you need SQLite extension installed:

    apt-get install php5-sqlite

Then run:

    cd /path/to/your/project/plugins/JagmortTimezonePlugin
    touch symfony
    /path/to/symfony/data/bin/symfony test:unit -t JagmortTimezonePlugin

or add to your config/ProjectConfiguration.class.php:

  public function setupPlugins()
  {
    $this->pluginConfigurations['JagmortTimezonePlugin']->connectTests();
  }

and then run:

    cd /path/to/your/project
    ./symfony test:unit -t JagmortTimezonePlugin

Links

About

Provide timezonable Doctrine records for Symfony 1.4

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages