@param ResourceInterface $resource

@return Definition
765911
private function createChoiceFormDefinition(ResourceInterface $resource)
    {
        $definition = new Definition($resource->getChoiceForm(), [
            new Reference('lug.resource.'.$resource->getName()),
        ]);

        $definition->addTag('form.type');

        return $definition;
    }
1162319
public function load(string $resource, string $type = null) : RepositoryInterface
    {
        $resourceContent = $resource;

        if (empty($type)) {
            $file = $this->getLocation($resource);
            $resourceContent = $this->readFile($file);
        }

        $parsedResource = $this->parseJson($resourceContent);
        $errorMsg = $this->getLastErrorMessage(json_last_error());

        if ($errorMsg) {
            $msg = $type ? sprintf('JSON parse error: %s.', $errorMsg) : sprintf('JSON parse error: %s at %s', $errorMsg, $resource);

            throw new \RuntimeException($msg);
        }

        $repository = new Repository($parsedResource ?? []);

        return $this->parseImports($repository, $resource);
    }
248618
public function equals(ResourceInterface $resource) {
		if ($this->hasIdentification() === false || $resource->getResource()->hasIdentification() === false) {
			throw new Exception('can not compare resources if identification is missing');
		}
		
		return ($this->getIdentificationKey() === $resource->getResource()->getIdentificationKey());
	}
993260
private function createControllerDefinition(ResourceInterface $resource)
    {
        $definition = new Definition($resource->getController(), [
            new Reference('lug.resource.'.$resource->getName()),
        ]);

        $definition->addMethodCall('setContainer', [new Reference('service_container')]);
        $definition->addTag('lug.controller', ['resource' => $resource->getName()]);

        return $definition;
    }
84832
public function setResource($resource)
    {
        $res = $this->driverInstance->setResource($resource);
        if (!$this->isInstanceOf($res, YamlInterface::class)) {
            throw new YamlException('YamlInterface method setSource() must return YamlInterface object.');
        }

        return $this;
    }
76888
protected function authorizeResource($resource)
    {
        if ($this->isEditing($resource)) {
            return $this->user()->can($resource . '.update');
        }

        return $this->user()->can($resource . '.create');
    }
1280061
public function claimUsedResourceIdentifier(ResourceInterface $resource) {
		if ($resource->getResource()->hasIdentification() === false) {
			throw new InputException('can not validate resource without identifier, set type and id first');
		}
		
		$resourceKey = $resource->getResource()->getIdentificationKey();
		if (isset($this->usedResourceIdentifiers[$resourceKey]) === false) {
			$this->usedResourceIdentifiers[$resourceKey] = true;
			return;
		}
		
		throw new DuplicateException('can not have multiple resources with the same identification');
	}
517891
public function getResourcePermissions(ResourceInterface $resource) : array
    {
        $query = $this->getRepository()->createQueryBuilder('r')
            ->select('r')
            ->where('r.resource_class = :resourceClass AND r.resource_id=:resourceId')
            ->setParameter('resourceClass', $resource->getClass())
            ->setParameter('resourceId', $resource->getId())
            ->getQuery();

        return $query->getResult();
    }
1108292
private function createDomainManagerDefinition(ResourceInterface $resource)
    {
        $definition = new Definition($resource->getDomainManager(), [
            new Reference('lug.resource.'.$resource->getName()),
            new Reference('lug.resource.domain.event_dispatcher'),
            new Reference('lug.manager.'.$resource->getName()),
            new Reference('lug.repository.'.$resource->getName()),
        ]);

        $definition->addTag('lug.domain_manager', ['resource' => $resource->getName()]);

        return $definition;
    }
1281579
public function set(ResourceInterface $resource): ResourceCollectionInterface
    {
        if (!$this->isEmpty()) {
            throw new \LogicException('Tried to add a second resource to single resource collection...');
        }

        return parent::set($resource);
    }
853866
public function add(ResourceInterface $resource): void
    {
        if (!$resource instanceof $this->interface) {
            throw new UnexpectedTypeException($resource, $this->interface);
        }

        if (in_array($resource, $this->findAll())) {
            throw new ExistingResourceException();
        }

        $this->arrayObject->append($resource);
    }
250007
public function setResource($resource)
    {
        $this->resource = $resource;

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

        return $this;
    }
401860
protected function isExtractable(ResourceInterface $resource)
    {
        $guesser = MimeTypeGuesser::getInstance();

        return $guesser->guess($resource->getFile()->getPathname()) === 'application/zip';
    }
761294
protected function validateUndeleteResource(ResourceInterface $resource, $type): void
    {
        if (static::TYPE_UNDELETE === $type) {
            $object = $resource->getRealData();

            if ($object instanceof SoftDeletableInterface) {
                $object->setDeletedAt();
            } else {
                DomainUtil::addResourceError($resource, $this->translator->trans('domain.resource_type_not_undeleted', [], 'FxpResource'));
            }
        }
    }
22465
public static function create($resource)
    {
        $type = gettype($resource);

        if ($type == 'string') {
            $stream = fopen('php://temp', 'r+');

            if ($resource !== '') {
                fwrite($stream, $resource);
                fseek($stream, 0);
            }

            return new self($stream);
        }

        if ($type == 'resource') {
            return new self($resource);
        }

        if ($resource instanceof StreamableInterface) {
            return $resource;
        }

        throw new \InvalidArgumentException('Invalid resource type: ' . $type);
    }
72402
protected function doDeleteResource(ResourceInterface $resource, $soft)
    {
        $skipped = false;
        $object = $resource->getRealData();

        if ($object instanceof SoftDeletableInterface) {
            if ($soft) {
                if ($object->isDeleted()) {
                    $skipped = true;
                } else {
                    $this->doDeleteResourceAction($resource);
                }
            } else {
                if (!$object->isDeleted()) {
                    $object->setDeletedAt(new \DateTime());
                }
                $this->doDeleteResourceAction($resource);
            }
        } else {
            $this->doDeleteResourceAction($resource);
        }

        return $skipped;
    }
1138584
public function toResource(EntityInterface $entity, FetchRequestInterface $request, ResourceInterface $resource)
    {
        if ($request->requestedResourceBody()) {
            $this->mapAttributesToResource($entity, $request, $resource->attributes());
        }

        if ($request->requestedRelationships()) {
            $this->mapRelationshipsToResource($entity, $request, $resource->relationships());
        }

        $this->mapMetaInformationToResource($entity, $request, $resource->metaInformation());
    }