Operation create

Create New CancelOperation


@throws \\ApiException on non-2xx response
@throws \InvalidArgumentException
@return \\Resources\\CancelOperation
350552
public function create()
    {
        $instance = self::createCancelOperation($this);
        $this->setId($instance->getId());
        return $instance;
    }
3761
public function create()
    {
        $instance = self::createDiscountPromotion($this);
        $this->setId($instance->getId());
        return $instance;
    }
333805
protected function createApiInstance()
	{
		$configToken = $this->getConfig('token');

		if ($configToken === null)
		{
			throw new InvalidArgumentException('API token has not been set in the config.');
		}

		$token = new Token($configToken);
		$this->api = new Api();
		$this->api->setToken($token);
	}
646054
public function call() {
        $request = $this->createRequest();
        $response = $this->api->execute($request, $this);
        $this->response = $response;

        if ($this->shouldResponseBeProcessed($response)) {
            $instance = $this->api->instantiateResult($response, $this);

            return $instance;
        }
        return $response;
    }
1223703
public function createAction()
    {
        $console = $this->getServiceLocator()->get('console');

        if (!$console instanceof ConsoleAdapterInterface) {
            throw new \RuntimeException('Invalid controller invocation');
        }

        $io = new ConsoleIO($console);
        $skeleton = new ProjectSkeleton($io);
        $skeleton->addComponent(new DirectoryLayoutComponent())
            ->addComponent(new BootstrapGeneratorComponent());

        $console->writeLine('Application Skeleton Generator' . PHP_EOL, ColorInterface::LIGHT_CYAN);
        $console->writeLine('Creating application skeleton:' . PHP_EOL, ColorInterface::GREEN);

        $skeleton->create($this->params()->fromRoute());

        $console->writeLine(PHP_EOL . 'Done!' . PHP_EOL, ColorInterface::LIGHT_GREEN);
    }
890694
public function create()
    {
        $entry = $this->collection->newInstance()->set($this->getCriteria());

        $this->data['entry'] = $entry;

        if ($this->request->isPost()) {
            try {
                $result = $entry->set($this->request->getBody())->save();

                h('notification.info', $this->clazz.' created.');

                h('controller.create.success', array(
                    'model' => $entry
                ));
            } catch (Stop $e) {
                throw $e;
            } catch (Exception $e) {
                // no more set notification.error since notificationmiddleware will
                // write this later
                // h('notification.error', $e);

                h('controller.create.error', array(
                    'model' => $entry,
                    'error' => $e,
                ));

                // rethrow error to make sure notificationmiddleware know what todo
                throw $e;
            }
        }

    }
19550
public function create()
    {
        /**
         * @var BannerZoneInterface $bannerZone
         */
        $classNamespace = $this->getEntityNamespace();
        $bannerZone = new $classNamespace();
        $bannerZone->setBanners(new ArrayCollection());

        return $bannerZone;
    }
343672
public function create()
    {
        $instance = self::createOrder($this);
        $this->setId($instance->getId());
        return $instance;
    }
1011090
public function createDefaultHttpClient()
    {
        $stack = HandlerStack::create();

        $middleware = new Oauth1([
            'consumer_key'    => $this->consumerKey,
            'consumer_secret' => $this->consumerSecret,
            'token'           => $this->token,
            'token_secret'    => $this->tokenSecret
        ]);

        $stack->push($middleware);

        return new HttpClient([
            'handler' => $stack
        ]);
    }
343064
public function make()
    {
        $this->setDefaultHeaders();

        $startTime = microtime(true);
        $result = $this->httpClient->request($this->getMethod(), $this->getURL(), $this->getPayload());
        $endTime = microtime(true);

        $this->response = new Response();
        $this->response->setExecutionTime(round(($endTime - $startTime), 5))
            ->setStatusCode($result->getStatusCode());

        // set the request ID for remote debugging if it is present            
        if (!empty(($requestID = $result->getHeader('X-Moltin-Request-Id')))) {
            $this->response->setRequestID($requestID[0]);
        }

        $body = json_decode($result->getBody());
        $this->response->setRaw($body)->parse();

        return $this;
    }
716903
public function create()
    {
        event(new BeforeCreate($this));

        $this->beforeCreate();

        $this->doCreate();

        $this->afterCreate();

        event(new AfterCreate($this));
    }
809695
public function build(): StopObservingRequest
	{
		$instance = new StopObservingRequest();
		if ($this->service === null) {
			throw new BuilderException('Property [service] is required.');
		}
		$instance->service = $this->service;
		return $instance;
	}
347264
public function create()
    {
        $instance = self::createAddress($this);
        $this->setId($instance->getId());
        return $instance;
    }
1074741
public function createAction() {
        $this->setStatusCode(201);
        $createObjects = $this->createActionProcess();

        if(sizeOf($createObjects) == 1) { //Default handling of passing in one
            $createObject = $createObjects[0];
            $this->setErrors($createObject->getErrors());
            $this->setStatusCode($createObject->getStatusCode());
            if(!is_null($createObject->getEntity())) {
                try {
                    $this->showActionInternal($createObject->getEntity());
                } catch(Exception $e) {
                    $this->handleError($e);
                } catch(ValidationException $e) {
                    $this->handleValidationError($e);
                } catch(AclException $e) {
                    $this->handleAclError($e);
                } catch(CatchableException $e) {
                    $this->handleCatchableError($e);
                }
            }
        } else {
            $this->setStatusCode(400);
            $hasOneSuccessful = false;
            $objects = [];
            foreach($createObjects as $createObject) {
                $object = new \stdClass();
                try {
                    if(!is_null($createObject->getEntity())) {
                        $hasOneSuccessful = true;
                        $object->{$createObject->getEntity()->getEntityName()} = $this->generateEntityAction($createObject->getEntity());
                    }
                    $object = $this->addErrorsAndStatus($createObject->getErrors(), $createObject->getStatusCode(), $object);
                } catch(Exception $e) {
                    $this->handleError($e);
                } catch(ValidationException $e) {
                    $this->handleValidationError($e);
                } catch(AclException $e) {
                    $this->handleAclError($e);
                } catch(CatchableException $e) {
                    $this->handleCatchableError($e);
                }
                $objects[] = $object;
            }
            $blankEntity = $this->generateEntity();
            $outputObject = $this->getOutputObject();
            $outputObject->{$blankEntity->getEntityName() . 's'} = $objects;
            $this->setOutputObject($outputObject);
            if($hasOneSuccessful) {
                $this->setStatusCode(201);
            }
        }


    }
1006616
protected function create()
    {
        $this->user = app(\SuperV\Platform\Domains\Auth\Contracts\User::class)->create([
            'name'    => $this->request['name'],
            'email'    => $this->request['email'],
            'password' => bcrypt($this->request['password']),
        ]);

        return $this;
    }
1230454
protected function create()
	{
		// Only allow creation with new object, otherwise: clone first, create later
		if ( ! $this->is_new())
		{
			return false;
		}

		$this->observe('before_insert');

		// Set all current values
		$query = Query::forge(get_called_class(), static::connection(true));
		$primary_key = static::primary_key();
		$properties  = array_keys(static::properties());
		foreach ($properties as $p)
		{
			if ( ! (in_array($p, $primary_key) and is_null($this->{$p})))
			{
				$query->set($p, $this->{$p});
			}
		}

		// Insert!
		$id = $query->insert();

		// when there's one PK it might be auto-incremented, get it and set it
		if (count($primary_key) == 1 and $id !== false)
		{
			$pk = reset($primary_key);
			// only set it if it hasn't been set manually
			is_null($this->{$pk}) and $this->{$pk} = $id;
		}

		// update the original properties on creation and cache object for future retrieval in this request
		$this->_is_new = false;
		$this->_original = $this->_data;
		static::$_cached_objects[get_class($this)][static::implode_pk($this)] = $this;

		$this->observe('after_insert');

		return $id !== false;
	}
226076
public function createAction()
    {
        $this->checkAuth($this->resources, $this->modules, AccessManager::CREATE);

        $baseForm = $this->getCreationForm();

        $con = Propel::getConnection();
        $con->beginTransaction();

        try {
            $form = $this->validateForm($baseForm);
            $data = $form->getData();

            $event = $this->getCreationEvent($data);

            $dispatcher = $this->getDispatcher();
            foreach ($this->createEvents as $eventName) {
                $dispatcher->dispatch($eventName, $event);
            }

            $this->afterCreateEvents($event, $data);

            $con->commit();
        } catch (HttpException $e) {
            $con->rollBack();

            return new JsonResponse(["error" => $e->getMessage()], $e->getStatusCode());
        } catch (\Exception $e) {
            $con->rollBack();

            return new JsonResponse(["error" => $e->getMessage()], 500);
        }

        $obj = $this->extractObjectFromEvent($event);
        $id = $this->extractIdFromObject($obj);

        return new JsonResponse(
            $this->getLoopResults(
                array_merge(
                    $this->getRequest()->query->all(),
                    [$this->idParameterName => $id]
                )
            ),
            201
        );
    }