HosipLan

Untitled

Jan 21st, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.36 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4.  * @package nette-foxy-forms
  5.  *
  6.  * Generate nette form components using Doctrine entity annotations
  7.  *
  8.  * @author Jiri Dubansky <[email protected]>
  9.  */
  10.  
  11. namespace Foxy\DI;
  12.  
  13.  
  14. class Extension extends \Nette\DI\CompilerExtension
  15. {
  16.     protected
  17.         $defaults = array(
  18.             'media_dir' => 'media/upload/',
  19.             'image_pattern' => 'IMG_%04d',
  20.             'media_url' => '/media',
  21.             'storage' => 'Foxy\Nejaka\Konkretni\Storage'
  22.         );
  23.  
  24.  
  25.     /**
  26.      * Loads configuration
  27.      */
  28.     public function loadConfiguration()
  29.     {
  30.         $builder = $this->getContainerBuilder();
  31.         $config = $this->getConfig($this->defaults);
  32.  
  33.         # Foxy\Media\Storage
  34.             $builder->addDefinition('mediaStorage')
  35.                 ->setClass(
  36.                     'Foxy\Media\IStorage',
  37.                     array(
  38.                         'media_dir' => $config['media_dir'],
  39.                         'image_pattern' => $config['image_pattern'],
  40.                     )
  41.                 )
  42.                 ->setFactory($config['storage']);
  43.  
  44.         # Foxy\Media\Controler
  45.        $builder->addDefinition('mediaControler')
  46.             ->setClass(
  47.                 'Foxy\Media\Controler',
  48.                 array(
  49.                     'media_url' => $config['media_dir'],
  50.                     'media_storage' => '@mediaStorage',
  51.                 )
  52.             );
  53.     }
  54.  
  55.  
  56.     public static function register(Configurator $config)
  57.     {
  58.         $compiler->addExtension('foxy-forms', new RedisExtension());
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment