PHP 클래스 Eccube\Service\CsvImportService

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
상속: implements Iterator, implements SeekableIterator, implements Countable
파일 보기 프로젝트 열기: ec-cube/ec-cube 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$columnHeaders array Column headers as read from the CSV file
$count integer Total number of rows in the CSV file
$duplicateHeadersFlag integer How to handle duplicate headers
$errors array Faulty CSV rows
$file SplFileObject CSV file
$headerRowNumber integer Number of the row that contains the column names
$headersCount integer In case of duplicate headers, this is always the number of unmerged headers.

공개 메소드들

메소드 설명
__construct ( SplFileObject $file, string $delimiter = ',', string $enclosure = '"', string $escape = '\' )
count ( )
current ( ) : array Return the current row as an array
getColumnHeaders ( ) : array Get column headers
getErrors ( ) : array Get rows that have an invalid number of columns
getFields ( )
getRow ( integer $number ) : array Get a row
hasErrors ( ) : boolean Does the reader contain any invalid rows?
key ( )
next ( )
rewind ( ) Rewind the file pointer
seek ( $pointer )
setColumnHeaders ( array $columnHeaders ) Set column headers
setHeaderRowNumber ( integer $rowNumber, integer $duplicates = null ) : boolean Set header row number
valid ( )

보호된 메소드들

메소드 설명
convertEncodingRows ( $row ) 行の文字エンコーディングを変換する.
incrementHeaders ( array $headers ) : array Add an increment to duplicate headers
mergeDuplicates ( array $line ) : array Merges values for duplicate headers into an array
readHeaderRow ( integer $rowNumber ) : array Read header row from CSV file

메소드 상세

__construct() 공개 메소드

public __construct ( SplFileObject $file, string $delimiter = ',', string $enclosure = '"', string $escape = '\' )
$file SplFileObject
$delimiter string
$enclosure string
$escape string

convertEncodingRows() 보호된 메소드

Windows 版 PHP7 環境では、ファイルエンコーディングが CP932 になるため UTF-8 に変換する. それ以外の環境では何もしない。
protected convertEncodingRows ( $row )

count() 공개 메소드

public count ( )

current() 공개 메소드

If a header row has been set, an associative array will be returned
public current ( ) : array
리턴 array

getColumnHeaders() 공개 메소드

Get column headers
public getColumnHeaders ( ) : array
리턴 array

getErrors() 공개 메소드

Get rows that have an invalid number of columns
public getErrors ( ) : array
리턴 array

getFields() 공개 메소드

public getFields ( )

getRow() 공개 메소드

Get a row
public getRow ( integer $number ) : array
$number integer Row number
리턴 array

hasErrors() 공개 메소드

Does the reader contain any invalid rows?
public hasErrors ( ) : boolean
리턴 boolean

incrementHeaders() 보호된 메소드

So the following line: |duplicate|duplicate|duplicate| |first |second |third | Yields value: $duplicate => 'first', $duplicate1 => 'second', $duplicate2 => 'third'
protected incrementHeaders ( array $headers ) : array
$headers array
리턴 array

key() 공개 메소드

public key ( )

mergeDuplicates() 보호된 메소드

So the following line: |duplicate|duplicate|duplicate| |first |second |third | Yields value: $duplicate => ['first', 'second', 'third']
protected mergeDuplicates ( array $line ) : array
$line array
리턴 array

next() 공개 메소드

public next ( )

readHeaderRow() 보호된 메소드

Read header row from CSV file
protected readHeaderRow ( integer $rowNumber ) : array
$rowNumber integer Row number
리턴 array

rewind() 공개 메소드

If a header row has been set, the pointer is set just below the header row. That way, when you iterate over the rows, that header row is skipped.
public rewind ( )

seek() 공개 메소드

public seek ( $pointer )

setColumnHeaders() 공개 메소드

Set column headers
public setColumnHeaders ( array $columnHeaders )
$columnHeaders array

setHeaderRowNumber() 공개 메소드

Set header row number
public setHeaderRowNumber ( integer $rowNumber, integer $duplicates = null ) : boolean
$rowNumber integer Number of the row that contains column header names
$duplicates integer How to handle duplicates (optional). One of: - CsvReader::DUPLICATE_HEADERS_INCREMENT; increments duplicates (dup, dup1, dup2 etc.) - CsvReader::DUPLICATE_HEADERS_MERGE; merges values for duplicate headers into an array (dup => [value1, value2, value3])
리턴 boolean

valid() 공개 메소드

public valid ( )

프로퍼티 상세

$columnHeaders 보호되어 있는 프로퍼티

Column headers as read from the CSV file
protected array $columnHeaders
리턴 array

$count 보호되어 있는 프로퍼티

Total number of rows in the CSV file
protected int $count
리턴 integer

$duplicateHeadersFlag 보호되어 있는 프로퍼티

How to handle duplicate headers
protected int $duplicateHeadersFlag
리턴 integer

$errors 보호되어 있는 프로퍼티

Faulty CSV rows
protected array $errors
리턴 array

$file 보호되어 있는 프로퍼티

CSV file
protected SplFileObject $file
리턴 SplFileObject

$headerRowNumber 보호되어 있는 프로퍼티

Number of the row that contains the column names
protected int $headerRowNumber
리턴 integer

$headersCount 보호되어 있는 프로퍼티

In case of duplicate headers, this is always the number of unmerged headers.
protected int $headersCount
리턴 integer