public function interact() { // Start count of records processed, and errors $processed = $errors = 0; // Fetch an empty entity.. $entity = $this->getEntity(); // ... verify that the entity can be created by the current user $this->verifyImportAuth($entity); $created_entities = array(); // Fetch a record foreach ($this->payload as $index => $record) { // ... transform record $entity = $this->transform($record); // Ensure that under review is correctly mapped to draft if (strcasecmp($entity->status, 'under review') == 0) { $entity->setState(['status' => 'draft']); } // ... verify that the entity can be created by the current user $this->verifyCreateAuth($entity); // ... verify that the entity is in a valid state $this->verifyValid($entity); // ... persist the new entity $id = $this->repo->create($entity); $created_entities[] = $id; $processed++; } // ... and return the formatted entity return ['created_ids' => $created_entities, 'processed' => $processed, 'errors' => $errors]; }
public function interact() { // Start count of records processed, and errors $processed = $errors = 0; // Fetch an empty entity.. $entity = $this->getEntity(); // ... verify that the entity can be created by the current user $this->verifyImportAuth($entity); // Fetch a record foreach ($this->payload as $index => $record) { // ... transform record $entity = $this->transform($record); // ... verify that the entity can be created by the current user $this->verifyCreateAuth($entity); // ... verify that the entity is in a valid state $this->verifyValid($entity); // ... persist the new entity $id = $this->repo->create($entity); $processed++; } // ... and return the formatted entity return ['processed' => $processed, 'errors' => $errors]; }