Blame view

lib/YiiConverter.php 970 Bytes
8e128526   Mihail   add xlsx parser
1
2
3
4
5
6
7
8
  <?php
  /**
   * Created by PhpStorm.
   * User: Cibermag
   * Date: 07.09.2015
   * Time: 15:56
   */
  
d0261fd1   Mihail   fixed namespace i...
9
  namespace yii\multiparser;
8e128526   Mihail   add xlsx parser
10
  
8e128526   Mihail   add xlsx parser
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
  use yii\base\Component;
  use yii\base\ErrorException;
  
  
  class YiiConverter extends Component{
  
  public $configuration;
  public $converter;
  
      public function init()
      {
          parent::init();
          $converter = \Yii::createObject( $this->configuration );
          if ( $converter instanceof ConverterInterface ) {
  
              $this->converter = $converter;
          }else{
              throw new ErrorException('Wrong type of converter');
          }
  
  
      }
  
      public function convertTo( $method, $value, $attributes = [] ){
  
          if ( $attributes ) {
              $this->converter->setAttributes($attributes);
          }
          return $this->converter->$method( $value );
  
      }
  
      public function convertByConfiguration( $value, $configuration ){
  
          return $this->converter->convertByConfiguration( $value, $configuration );
  
      }
  
  
  }