/** * Set the request options. * * @param string $entityName * @param string $lastSync * @param string $type * @return void */ public function setOptions($entityName, $lastSync = false, $type = 'receive') { $entities = $this->config->getEntities(); if (!in_array($type, array('receive', 'send'))) { throw new RequestException('Wrong request type'); } if (!isset($entities[$type][$entityName])) { throw new RequestException('Entity not found in system config file.'); } if (!$lastSync instanceof Carbon) { $lastSync = Carbon::createFromFormat($this->config->date['format'], $this->config->date['default']); } $this->options = (object) ['base_url' => array_get($this->config->config, 'base_url'), 'type' => $type, 'lastSync' => $lastSync, 'entity' => $entities[$type][$entityName]]; }
/** * Set the resource and start the builder. * * @param \Algorit\Synchronizer\Request\Contracts\ResourceInterface $resource * @param mixed $callback * @return \Algorit\Synchronizer\Loader */ public function start(ResourceInterface $resource, $callback = false) { // Set config $this->request->setConfig($this->config->setup($this->system, $resource)); // Set system resource $this->request->setResource($resource); // Set logger $this->builder->setLogger($this->logger); // Start the Builder $this->builder->start($this->request, $resource); if ($callback instanceof Closure) { return $callback($this); // return? } return $this; }