Namespaces

  • Latte
    • Loaders
    • Macros
    • Runtime
  • Nette
    • Application
      • Responses
      • Routers
      • UI
    • Bridges
      • ApplicationDI
      • ApplicationLatte
      • ApplicationTracy
      • CacheDI
      • CacheLatte
      • DatabaseDI
      • DatabaseTracy
      • DITracy
      • FormsDI
      • FormsLatte
      • Framework
      • HttpDI
      • HttpTracy
      • MailDI
      • ReflectionDI
      • SecurityDI
      • SecurityTracy
    • Caching
      • Storages
    • ComponentModel
    • Database
      • Conventions
      • Drivers
      • Reflection
      • Table
    • DI
      • Config
        • Adapters
      • Extensions
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
    • Loaders
    • Localization
    • Mail
    • Neon
    • PhpGenerator
    • Reflection
    • Security
    • Templating
    • Utils
  • NetteModule
  • none
  • Tracy
    • Bridges
      • Nette

Classes

  • FormsExtension
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (http://nette.org)
 5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Bridges\FormsDI;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Forms extension for Nette DI.
15:  *
16:  * @author David Grudl
17:  * @author Miroslav PaulĂ­k
18:  */
19: class FormsExtension extends Nette\DI\CompilerExtension
20: {
21:     public $defaults = array(
22:         'messages' => array()
23:     );
24: 
25: 
26:     public function afterCompile(Nette\PhpGenerator\ClassType $class)
27:     {
28:         $initialize = $class->getMethod('initialize');
29:         $config = $this->validateConfig($this->defaults);
30: 
31:         foreach ((array) $config['messages'] as $name => $text) {
32:             if (defined('Nette\Forms\Form::' . $name)) {
33:                 $initialize->addBody('Nette\Forms\Validator::$messages[Nette\Forms\Form::?] = ?;', array($name, $text));
34:             } elseif (defined($name)) {
35:                 $initialize->addBody('Nette\Forms\Validator::$messages[' . $name . '] = ?;', array($text));
36:             } else {
37:                 throw new Nette\InvalidArgumentException('Constant Nette\Forms\Form::' . $name . ' or constant ' . $name . ' does not exist.');
38:             }
39:         }
40:     }
41: 
42: }
43: 
Nette 2.3.1 API API documentation generated by ApiGen 2.8.0