key() public method

public key ( )
Ejemplo n.º 1
0
 /**
  * タグの登録
  *
  * @param array $row
  * @param Product $Product
  * @param Application $app
  * @param CsvImportService $data
  */
 protected function createProductTag($row, Product $Product, $app, $data)
 {
     // タグの削除
     $ProductTags = $Product->getProductTag();
     foreach ($ProductTags as $ProductTags) {
         $Product->removeProductTag($ProductTags);
         $this->em->remove($ProductTags);
     }
     if ($row['タグ(ID)'] == '') {
         return;
     }
     // タグの登録
     $tags = explode(',', $row['タグ(ID)']);
     foreach ($tags as $tag_id) {
         $Tag = null;
         if (preg_match('/^\\d+$/', $tag_id)) {
             $Tag = $app['eccube.repository.master.tag']->find($tag_id);
             if ($Tag) {
                 $ProductTags = new ProductTag();
                 $ProductTags->setProduct($Product)->setTag($Tag);
                 $Product->addProductTag($ProductTags);
                 $this->em->persist($ProductTags);
             }
         }
         if (!$Tag) {
             $this->addErrors($data->key() + 1 . '行目のタグ(ID)「' . $tag_id . '」が存在しません。');
         }
     }
 }
Ejemplo n.º 2
0
 public function testCountDoesNotMoveFilePointer()
 {
     $file = new \SplFileObject(__DIR__ . '/../../../Fixtures/data_column_headers.csv');
     $CsvImportService = new CsvImportService($file);
     $CsvImportService->setHeaderRowNumber(0);
     $key_before_count = $CsvImportService->key();
     $CsvImportService->count();
     $key_after_count = $CsvImportService->key();
     $this->assertEquals($key_after_count, $key_before_count);
 }