Target factory.

@param $resource
@param $data
@return Target
516123
public static function factory($resource, $data, $name = null)
    {
        $instance = new static();

        $instance->id = (string) Uuid::uuid4();

        $instance->name = self::makeName($data, $name);

        $instance->display = $instance->name;

        $instance->resource = $resource;

        $instance->importProperties($data);

        return $instance;
    }
61460
public function resolve($resource): Stream
    {
        // detect best way to load and process configuration content
        if (is_array($resource)) {
            return new DataStream($resource, new ArrayProcessor());
        } elseif (is_callable($resource)) {
            return new DataStream($resource, new CallableProcessor());
        } elseif ($resource instanceof Config) {
            return new DataStream($resource, new ConfigProcessor());
        } elseif ($resource instanceof Collection) {
            return new DataStream($resource, new CollectionProcessor());
        } elseif ($resource instanceof Stream) {
            return $resource;
        } elseif ($resource instanceof stdClass) {
            return new DataStream($resource, new StdClassProcessor());
        } elseif (is_string($resource)) {
            $filesHandlers = $this->filesHandlers;
            if (null === $filesHandlers) {
                $filesHandlers = new FilesHandlers(null);
            }
            return new FileStream($resource, $filesHandlers);
        }

        throw new UnknownResourceException($resource);
    }
250007
public function setResource($resource)
    {
        $this->resource = $resource;

        if (null !== $resource) {
            $this->stopPropagation();
        }

        return $this;
    }
1030537
public static function fromResource($resource) {
        $newImage = new self();
        try {
            $newImage->setResource($resource);
        } catch(\Exception $e) {
            throw new ImageException($e->getMessage(), ImageException::UnsupportedFormatException, $e);
        }
        return $newImage;
    }
663280
public function getResource($resource)
    {
        if (array_key_exists($resource, $this->cache)) {
            return $this->cache[$resource];
        }

        if (!array_key_exists($resource, $this->resources)) {
            throw new ResourceNotImplemented($resource);
        }

        $params = $this->resources[$resource];
        $instance = $params['instance'];

        if (is_null($instance)) {
            $class = $params['class'];

            $instance = new $class($this);
        }

        return $this->cache[$resource] = $instance;
    }
662212
public function normalize($data, Resource $resource)
    {
        if (isset($data['value']['map'])) {
            $options = isset($data['value']['map']['options']) ? $data['value']['map']['options'] : [];
            $data['value']['map'] = $this->normalizer->normalize(
                [
                    'key'   => $data['value']['map']['validator'],
                    'value' => $options,
                ],
                $resource
            );
        }

        return $this->createDefinition($data['value']);
    }
1119712
public function delete($resource)
    {
        $event = $this->createResourceEvent($resource);
        $this->dispatcher->dispatch($this->config->getEventName('pre_delete'), $event);

        if (!$event->isPropagationStopped()) {
            $this->removeResource($event);

            $this->dispatcher->dispatch($this->config->getEventName('post_delete'), $event);
        }

        return $event;
    }
659617
private function createRequest($method, $resource, array $data = [])
    {
        if (!empty($data)) {
            $data['signature'] = $this->apiSignature;
        }

        return $this->requestFactory->createRequest($method, $resource, [], $this->encode($data));
    }
1009587
protected function setupCreateReference($resource)
    {
        foreach ($resource->settings['actions']['CreateReference']['uris'] as $property => $uri) {
            $this->setupCreate($resource, $uri, $property);
        }
    }
631959
protected function createAdmin( $resource )
	{
		$context = $this->getContextBackend( 'admin/jsonadm/templates' );
		return \Aimeos\Admin\JsonAdm::create( $context, Base::getAimeos(), $resource );
	}
1370986
public static function createAdapterFromResource($resource)
    {
        if (is_scalar($resource) || is_array($resource)) {
            throw new Exception\InvalidArgumentException("Resource param must be a valid 'resource' link (mysqli, pdo)");
        }
        if ($resource instanceof \PDO) {
            $adapter = self::getAdapterFromPdo($resource);
        } elseif (extension_loaded('mysqli') && $resource instanceof \mysqli) {
            $adapter = new Adapter\MysqliAdapter($resource);
        } else {
            throw new Exception\InvalidArgumentException('Resource must be a valid connection link, like PDO or mysqli');
        }

        return $adapter;
    }
1249909
public function writeProcessingInstruction(string $target, string $data = ''): XmlStreamWriter
    {
        $this->writer->writePi($target, $data);
        return $this;
    }
572139
protected function create(array $data)
    {
        if (null === $this->resultFactory) {
            $this->resultFactory = new Factory();
        }

        return $this->resultFactory->create($data);
    }
244144
public final function makeReleaseFile(AbstractResourceFile $resource) {
        if (!isset($this->__release__file__map[$resource->getMemberId()])) {
            $this->__release__file__map[$resource->getMemberId()] = new File($this->makeReleaseRelativePath($resource), $this->getReleaseDir()->getAbsolutePath());
        }
        return $this->__release__file__map[$resource->getMemberId()];
    }
1094535
public function create($data)
    {
        $descriptor = new ThrowsDescriptor($data->getName());
        $descriptor->setDescription($data->getDescription());
        $descriptor->setTypes(
            $this->builder->buildDescriptor(new Collection($data->getTypes()))
        );

        return $descriptor;
    }
70085
public static function create( $resource, $params=null )
    {
        self::_validateCall('create', $params);
        $requestor = new ApiRequestor();
        $url = '/' . $resource;
        return $requestor->request( 'post', $url, $params );
    }
297355
public static function toObject($resource) {
		if (self::isObject($resource)) {
			return $resource;

		} else if (self::isArray($resource)) {
			return self::buildObject($resource);

		} else if (self::isJson($resource)) {
			return json_decode($resource);

		} else if ($ser = self::isSerialized($resource)) {
			return self::toObject($ser);

		} else if ($xml = self::isXml($resource)) {
			return $xml;
		}

		return $resource;
	}