Creates a new resource object or a list of resource objects

@param string Resource location, e.g. "basket"
@param string Related resource, e.g. "product"
@return string Generated output
358202
public function postAction( $resource, $related )
	{
		$response = $this->createClient( $resource, $related )->post( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
814352
private function loadRelatedDefinition($version, $resource, $related, $type, $key = null) : string
    {
        $definition = $this->definition($resource, $version);
        $relationDefinition = $definition->relation($related);

        $classPath = $relationDefinition->$type;
        if (is_array($classPath) && array_key_exists($key, $classPath)) {
            $classPath = $classPath[$key];
        }

        if ($classPath === null) {
            throw ResourceNotDefinedException::resource($resource, $type);
        }

        return $classPath;
    }
1001015
public function describeResource($resource,$context=null)
    {
        $resource = $this->labeller->uri_to_alias($resource);
        $query = array(
            "_id" => array(
                _ID_RESOURCE=>$resource,
                _ID_CONTEXT=>$this->getContextAlias($context)));
        return $this->fetchGraph($query,MONGO_DESCRIBE);
    }
1278996
protected function collectResource($resource)
    {
        if ($resource instanceof MissingValue) {
            return $resource;
        }

        $collects = $this->collects();

        $this->collection = $collects && ! $resource->first() instanceof $collects
            ? $resource->mapInto($collects)
            : $resource->toBase();

        return $resource instanceof AbstractPaginator
                    ? $resource->setCollection($this->collection)
                    : $this->collection;
    }
764389
public function putAction( $resource )
	{
		$response = $this->createAdmin( $resource )->put( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
1015861
public function deleteAction( $resource, $related )
	{
		$response = $this->createClient( $resource, $related )->delete( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
897696
public function newInstance($uri) : ResourceObject
    {
        if (is_string($uri)) {
            $uri = new Uri($uri);
        }
        $adapter = $this->scheme->getAdapter($uri);

        return $adapter->get($uri);
    }
1323376
protected function createResourceOutput(?array $resources) : ?string
    {
        if (empty($resources)) {
            return null;
        }

        $extra = [];

        foreach ($resources as $attr => $value) {
            $extra[] = e($attr) . '="' . e($value) . '"';
        }

        return implode(' ', $extra);
    }
120559
private function fixForRelations(RelatedResourceInterface $resource): void
    {
        $relations = $resource->getRelations();

        foreach ($relations as $relation) {
            $routeHref = $relation->getHref();
            $href = $this->fixHref($routeHref);
            $relation->setHref($href);
        }
    }
646463
public function relatedItem($resourceModel, $relatedId, RelatedRepository $repository)
    {
        if ($repository instanceof JsonApiRepository) {
            $this->applyFilters($this->filters, $this->filterFactory, $repository);
        }

        return $repository->findRelated($resourceModel, $relatedId);
    }
223705
public function indexOf( common_Object $resource)
    {
        $returnValue = null;

        
        $returnValue = -1;
        foreach($this->sequence as $index => $_resource){
        	if ($_resource instanceof  core_kernel_classes_Resource){
				if($resource->equals($_resource)){
					return $index;
				}
        	}
		}
        

        return $returnValue;
    }
349790
public static function createResource($resource, $system = false)
    {
        $group        = ucfirst($resource);
        $slug         = strtolower($group);
        $permissions  = [
            [
                'slug'     => $slug . '.view',
                'resource' => $group,
                'name'     => 'View ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.create',
                'resource' => $group,
                'name'     => 'Create ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.update',
                'resource' => $group,
                'name'     => 'Update ' . $group,
                'system'   => $system,
            ],
            [
                'slug'     => $slug . '.delete',
                'resource' => $group,
                'name'     => 'Delete ' . $group,
                'system'   => $system,
            ],
        ];

        $collection = new Collection;
        foreach ($permissions as $permission) {
            try {
                $collection->push(static::create($permission));
            } catch (\Exception $e) {
                // permission already exists.
            }
        }

        return $collection;
    }
402717
protected function createModel(Resource $resource)
    {
        $model = new $resource->model_class;
        $model->fill($resource->data);

        $result = $model->save();
        if ($result === true) {
            return $model;
        }

        $code = (empty($resource->data) || $result === null)
            ? static::ERROR_INVALID_PAYLOAD
            : static::ERROR_INTERNAL_SERVER;

        $message = "Resource '$resource->name' could not be created: ";

        if (is_string($result)) {
            $message .= "Database failure ($result)";
        } elseif ($result === false) {
            $message .= 'post-save failure';
        } else {
            $message .= 'pre-save failure';
        }

        $this->sendError($code, $message);
    }
963689
protected function create_relatedObject($key, $relation_type)
    {
        $c = $this->addChild($this->working_node, 'relatedObject');
        $this->addChild($c, 'key', $key);
        $c = $this->addChild($c, 'relation');
        // Mimick ANDS with enpty value to get both tags for relation. Only for better display
        // $c = $this->addChild($c, 'relation','     ');
        $c->setAttribute('type', $relation_type);
    }
958908
public function getAction( $resource )
	{
		$response = $this->createAdmin( $resource )->get( $this->getPsrRequest(), new Response() );
		return $this->setPsrResponse( $response );
	}
122504
private function generateResourceName($resource)
    {
        if (false === $this->pluralize) {
            return $resource;
        }

        return $this->inflector->pluralize($resource);
    }
1085229
public function create($related)
	{
		if($related instanceof $this->model)
		{
			$related->{$this->getForeignKey()} = $this->parent->getPrimaryKeyValue();

			$related->save();

			return $related;
		}

		return $this->model->create([$this->getForeignKey() => $this->parent->getPrimaryKeyValue()] + $related);
	}