symfony create entiti from array


    public function __construct(array $data = array())
    {
        if (empty($data)) return;

        foreach ($data as $name => $value) {
            if (!(in_array($name, array_keys(get_object_vars($this))))) continue;
            if (strpos($name, '_at') != false) {
                $this->{$name} = \DateTime::createFromFormat('U', bcdiv($value, 1000));
            } else {
                $this->{$name} = $value;
            }
        }
    }

 

ловим результат

        if ($request->isMethod('post')) {
            $f = file_get_contents($_FILES['fileToUpload']['tmp_name']);
            $ar = json_decode($f, true);
            $entityManager = $this->getDoctrine()->getManager();


            foreach ($ar as $k => $v) {
                $ob = new OsinitUser($v);
                $entityManager->persist($ob);
            }
            $entityManager->flush();

        }