protected function findOrCreateItem(array $item)
    {
        $entity = null;
        // If the table was not truncated to begin with, find current entity
        // first
        if (false === $this->truncate) {
            if (!empty($this->lookupFields)) {
                $lookupConditions = array();
                foreach ($this->lookupFields as $fieldName) {
                    $lookupConditions[$fieldName] = $item[$fieldName];
                }
                $entity = $this->entityRepository->findOneBy(
                    $lookupConditions
                );
            } else {
                $entity = $this->entityRepository->find(current($item));
            }
        }

        if (!$entity) {
            return $this->getNewInstance();
        }

        return $entity;
    }
protected function findOrCreateItem(array $item)
    {
        $entity = null;
        // If the table was not truncated to begin with, find current entity
        // first
        if (false === $this->truncate) {
            if (!empty($this->lookupFields)) {
                $lookupConditions = array();
                foreach ($this->lookupFields as $fieldName) {
                    $lookupConditions[$fieldName] = $item[$fieldName];
                }
                $entity = $this->entityRepository->findOneBy(
                    $lookupConditions
                );
            } else {
                $entity = $this->entityRepository->find(current($item));
            }
        }

        if (!$entity) {
            return $this->getNewInstance();
        }

        return $entity;
    }
protected function findOrCreateItem ( array $ item ) { $ entity = null ; // If the table was not truncated to begin with, find current entity // first if ( false === $ this -> truncate ) { if ( ! empty ( $ this -> lookupFields ) ) { $ lookupConditions = array ( ) ; foreach ( $ this -> lookupFields as $ fieldName ) { $ lookupConditions [ $ fieldName ] = $ item [ $ fieldName ] ; } $ entity = $ this -> entityRepository -> findOneBy ( $ lookupConditions ) ; } else { $ entity = $ this -> entityRepository -> find ( current ( $ item ) ) ; } } if ( ! $ entity ) { return $ this -> getNewInstance ( ) ; } return $ entity ; }
Finds existing entity or create a new instance

@param array $item
Finds existing entity or create a new instance