{@inheritdoc}

@throws ResourceNotFoundException
@throws \Ray\Di\Exception\Unbound
558153
public function get(AbstractUri $uri) : ResourceObject
    {
        if (substr($uri->path, -1) === '/') {
            $uri->path .= 'index';
        }
        $path = str_replace('-', '', ucwords($uri->path, '/-'));
        $class = sprintf('%s%s\Resource\%s', $this->namespace, $this->path, str_replace('/', '\\', ucwords($uri->scheme) . $path));
        try {
            $instance = $this->injector->getInstance($class);
        } catch (Unbound $e) {
            throw $this->getNotFound($uri, $e, $class);
        }

        return $instance;
    }
365516
public function findResources ($resourceName) {
        $request = get_request();
        $resource = Resources::get($resourceName);
        if ($request->has("rawQuery")) {
            $query = unserialize($request->get("rawQuery"));
            $resource->limit($query->getLimit());
            $resource->offset($query->getOffset());
            $resource->distinct($query->getDistinct());
            $resource->selectFields($query->getSelectFields());
            $resource->orderByFields($query->getOrderByFields());
            $resource->groupByFields($query->getGroupByFields());
            $resource->whereConditionGroup($query->getwhereConditionGroup());
            $resource->havingConditionGroup($query->getHavingConditionGroup());
            $resource->joins($query->getJoins());
        }
        else {
            $resource->limit(100);
            $parameters = $request->params();
            foreach ($parameters as $key=>$value) {
                switch ($key) {
                    case "limit":
                        $resource->limit($value);
                        break;
                    case "offset":
                        $resource->offset($value);
                        break;
                    case "distinct":
                        $resource->distinct($value);
                        break;
                    case "select":
                        $resource->selectFields(explode(",", $value));
                        break;
                    case "orderBy":
                        $resource->orderByFields(explode(",", $value));
                        break;
                    case "groupBy":
                        $resource->groupByFields(explode(",", $value));
                        break;
                    case "where":
                        $resource->whereConditionGroup($this->createConditionGroup($value));
                        break;
                    case "having":
                        $resource->havingConditionGroup($this->createConditionGroup($value));
                        break;
                    case "filters":
                        $filters = $value;
                        foreach ($filters as $filter) {
                            if (!empty($filter["operator"])) {
                                $resource->where($filter["property"], $filter["operator"], $filter["property"]);
                            } else {
                                $resource->where($filter["property"], $filter["value"]);
                            }
                        }
                        break;
                    default:
                        $resource->where($key, $value);
                        break;
                }
            }
        }
        return $resource->find();
    }
1083407
public function insertResource ($resourceName) {
        $request = get_request();
        $resource = Resources::get($resourceName);
        if ($request->has("rawQuery")) {
            $query = unserialize($request->get("rawQuery"));
            $resource->fields($query->getFields());
        }
        return $resource->insert();
    }
1014225
public function checkResourceTypes(array $resourceTypes)
    {
        $validTypes = [];
        $unknownTypes = [];

        foreach ($resourceTypes as $type) {
            //@todo write findByNames method.
            $rt = $this->resourceTypeRepo->findOneBy(['name' => $type['name']]);
            if (null === $rt) {
                $unknownTypes[] = $type['name'];
            } else {
                $validTypes[] = $rt;
            }
        }

        if (count($unknownTypes) > 0) {
            $content = 'The resource type(s) ';
            foreach ($unknownTypes as $unknown) {
                $content .= "{$unknown}, ";
            }
            $content .= 'were not found';

            throw new ResourceTypeNotFoundException($content);
        }

        return $validTypes;
    }
1520
public function load($resource, $locale, $domain = 'messages') {
		$repo = $this->service->getResourceRepository();
		if (!$repo->contains($resource)) {
			throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource));
		}

		// find file in puli repo
		$file = $repo->get($resource);
		$json = $file->getBody();
		$data = Json::decode($json);
		$messages = [];

		// flatten plural strings
		foreach ($data as $key => $value) {
			if (is_array($value)) {
				$vals = [];
				foreach ($value as $k => $v) {
					$vals[] = sprintf('%s: %s', $k, $v);
				}
				$val = implode('|', $vals);
			} else {
				$val = $value;
			}

			$messages[$key] = str_replace(['{{', '}}'], '%', $val);
		}

		// put them into message catalog
		$catalogue = new MessageCatalogue($locale);
		$catalogue->add($messages, $domain);

		return $catalogue;
	}
410736
public function unsetForResource($resource)
    {
        $resourceName = $this->resourceName($resource);

        if (!isset($this->resourceFactories[$resourceName])) {
            throw new HandlerNotFoundException("No handler found for resource '$resourceName'");
        }

        unset($this->resourceFactories[$resourceName]);

        return $this;

    }
675224
protected function readAll()
    {
        try {
            return $this->flysystem->read((string)$this->url);
        } catch (FileNotFoundException $e) {
            throw new ResourceNotFoundException($e->getMessage(), 0, $e);
        }
    }
410795
public function setResource(ResourceInterface $resource = null)
    {
        $this->resource = $resource;

        // Clear urls
        $this->urls = null;

        return $this;
    }
35292
public function oneByOrFail(string $field, $value): Model
    {
        $model = $this->oneBy($field, $value);
        if (empty($model)) {
            throw new ResourceNotFoundException();
        }

        return $model;
    }
1125128
public function toResource(EntityInterface $entity, FetchRequestInterface $request, ResourceInterface $resource)
    {
        foreach ($this->mappers as $mapper) {
            if ($mapper->supportsEntity($entity)) {
                $this->configureResourceMapper($mapper);
                $mapper->toResource($entity, $request, $resource);

                return;
            }
        }

        throw new UnsupportedTypeException($resource->type());
    }
1370588
public function resolve($name)
        {
            if (!isset(self::$resources[$name])) {
                throw new Exception("[$name] is not a known resource.");
            }

            return isAke(self::$resources, $name);
        }
908613
public function loadConfiguration(): void
	{
		$builder = $this->getContainerBuilder();

		// Expand config (cause %appDir% etc..)
		$config = $this->validateConfig($this->defaults);
		$config = $this->config = Helpers::expand($config, $builder->parameters);

		foreach ($config['resources'] as $namespace => $resource) {
			if (substr($namespace, -1) !== '\\') {
				throw new RuntimeException(sprintf('Resource "%s" must end with /', $namespace));
			}

			// Merge and validace resource config
			$resource = $this->validateConfig($this->resource, $resource, $namespace);

			// Normalize resource config
			if (is_scalar($resource['paths'])) $resource['paths'] = [$resource['paths']];
			if (is_scalar($resource['excludes'])) $resource['excludes'] = [$resource['excludes']];

			// Find classes of given resource
			$classes = $this->findClasses($namespace, $resource['paths'], $resource['excludes']);

			//  of given resource
			$counter = 1;
			$name = preg_replace('#\W+#', '_', '.' . $namespace);
			foreach ($classes as $class) {
				// Check already registered classes
				if ($builder->getByType($class) !== null) return;

				$def = $builder->addDefinition($this->prefix($name . '.' . ($counter++)))
					->setFactory($class);

				// Merge and validace decorator config
				$decorator = $this->validateConfig($this->decorator, $resource['decorator'], $namespace);

				if ($decorator['tags'] !== []) {
					$def->setTags(Arrays::normalize($decorator['tags'], true));
				}

				if ($decorator['setup'] !== []) {
					foreach ($decorator['setup'] as $setup) {
						if (is_array($setup)) {
							$setup = new Statement(key($setup), array_values($setup));
						}
						$def->addSetup($setup);
					}
				}

				if ($decorator['autowired'] !== null) {
					$def->setAutowired($decorator['autowired']);
				}

				if ($decorator['inject'] !== null) {
					$def->setInject($decorator['inject']);
				}
			}
		}
	}
936280
protected function findResourceOrThrowException(array $criteria)
    {
        if (null === $resource = $this->getRepository()->findOneBy($criteria)) {
            throw new NotFoundHttpException('Resource not found.');
        }
        return $resource;
    }
863771
public function delete(Resource $resource)
    {
        $data = $resource->toArray();

        $client = $this->getRepository()->findOneBy(array('id' => $data['id']));
        if (!$client) {
            $errorMessage = $this->translator->trans('error.client_not_found', array('%id%' => $data['id']));
            throw new NotFoundHttpException($errorMessage);
        }

        $this->entityManager->remove($client);
    }
30524
public function seek($offset, $whence = \SEEK_SET) : void
	{
		if (! \is_resource($this->resource))
		{
			throw new Exception\UnseekableStreamException('Stream is not resourceable');
		}

		if (! $this->isSeekable())
		{
			throw new Exception\UnseekableStreamException('Stream is not seekable');
		}

		$result = \fseek($this->resource, $offset, $whence);

		if (! (0 === $result))
		{
			throw new Exception\UnseekableStreamException('Unable to move the stream pointer to the given position');
		}
	}
1195216
public function setResource(ImageResourceInterface $resource)
    {
        $this->resource = $resource;

        if ($this->resource instanceof ImageFilterableInterface) {
            $this->filterResolver = new FilterResolver($this->resource->loadFilters());
        }
    }
957675
private function _checkResourceNameProperty()
    {
        if (!$this->resourceName) {
            if (Lang::has('resource-controller.propertynotset')) {
                $message = trans('resource-controller.propertynotset', ['property' => '$resourceName']);
            } else {
                $message = '$resourceName property must be set.';
            }

            throw new ResourceControllerException($message);
        }
    }