コード例 #1
0
 /**
  * ArrayAdapter constructor.
  * @param array $data
  */
 public function __construct($data)
 {
     $this->_array = $data;
     $this->_position = 0;
     $colnames = array_keys($this->current());
     parent::__construct($colnames);
 }
コード例 #2
0
ファイル: Generator.php プロジェクト: andrewhowdencom/m2onk8s
 /**
  * Read the row pattern to determine which columns are dynamic, set the collection size
  *
  * @param Pattern $rowPattern
  * @param int $count how many records to generate
  */
 public function __construct(Pattern $rowPattern, $count)
 {
     $this->_pattern = $rowPattern;
     $this->_count = $count;
     $this->_patternRowsCount = $this->_pattern->getRowsCount();
     $this->_limit = (int) $count * $this->_patternRowsCount;
     parent::__construct($this->_pattern->getHeaders());
 }
コード例 #3
0
 /**
  * Read the row pattern to determine which columns are dynamic, set the collection size
  *
  * @param array $rowPattern
  * @param int $limit how many records to generate
  */
 public function __construct(array $rowPattern, $limit)
 {
     foreach ($rowPattern as $key => $value) {
         if (is_callable($value) || is_string($value) && false !== strpos($value, '%s')) {
             $this->_dynamicColumns[$key] = $value;
         }
     }
     $this->_pattern = $rowPattern;
     $this->_limit = (int) $limit;
     parent::__construct(array_keys($rowPattern));
 }
コード例 #4
0
ファイル: Csv.php プロジェクト: shabbirvividads/magento2
 /**
  * Open file and detect column names
  *
  * There must be column names in the first line
  *
  * @param string $file
  * @param \Magento\Framework\Filesystem\Directory\Write $directory
  * @param string $delimiter
  * @param string $enclosure
  * @throws \LogicException
  */
 public function __construct($file, \Magento\Framework\Filesystem\Directory\Write $directory, $delimiter = ',', $enclosure = '"')
 {
     try {
         $this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
     } catch (\Magento\Framework\Filesystem\FilesystemException $e) {
         throw new \LogicException("Unable to open file: '{$file}'");
     }
     $this->_delimiter = $delimiter;
     $this->_enclosure = $enclosure;
     parent::__construct($this->_getNextRow());
 }
コード例 #5
0
ファイル: Csv.php プロジェクト: Doability/magento2dev
 /**
  * Open file and detect column names
  *
  * There must be column names in the first line
  *
  * @param string $file
  * @param \Magento\Framework\Filesystem\Directory\Read $directory
  * @param string $delimiter
  * @param string $enclosure
  * @throws \LogicException
  */
 public function __construct($file, \Magento\Framework\Filesystem\Directory\Read $directory, $delimiter = ',', $enclosure = '"')
 {
     register_shutdown_function([$this, 'destruct']);
     try {
         $this->_file = $directory->openFile($directory->getRelativePath($file), 'r');
     } catch (\Magento\Framework\Exception\FileSystemException $e) {
         throw new \LogicException("Unable to open file: '{$file}'");
     }
     if ($delimiter) {
         $this->_delimiter = $delimiter;
     }
     $this->_enclosure = $enclosure;
     parent::__construct($this->_getNextRow());
 }