Validate the resource only when type is undelete.

@param ResourceInterface $resource The resource
@param int               $type     The type of persist action
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'));
            }
        }
    }
526725
protected function hasNotBeenAdded(ResourceInterface $resource): bool
    {
        return isset($this->addedResources[$resource->getId()][$resource->getType()]) === false;
    }
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');
	}
1323082
private function persistResourceType($resourceConfiguration, Plugin $plugin, PluginBundleInterface $pluginBundle)
    {
        $this->log('Adding resource type '.$resourceConfiguration['name']);
        $resourceType = new ResourceType();
        $resourceType->setName($resourceConfiguration['name']);
        $resourceType->setClass($resourceConfiguration['class']);
        $resourceType->setExportable($resourceConfiguration['exportable']);
        $resourceType->setTags($resourceConfiguration['tags']);
        $resourceType->setPlugin($plugin);
        $this->em->persist($resourceType);
        $this->mm->addDefaultPerms($resourceType);

        if (!empty($resourceConfiguration['actions'])) {
            foreach ($resourceConfiguration['actions'] as $resourceAction) {
                $this->persistResourceAction(array_merge($resourceAction, [
                    'resource_type' => $resourceType->getName(),
                ]), $plugin);
            }
        }

        $this->setResourceTypeDefaultMask($resourceConfiguration['default_rights'], $resourceType);
        $this->persistIcons($resourceConfiguration, $resourceType, $pluginBundle);

        return $resourceType;
    }
463282
public function visitResourceType(ResourceType $type)
    {
        $difference = $this->comparePrimaryType($type);

        if (0 !== $difference) {
            return $difference;
        }

        return $this->compareAttribute($this->type->ofType(), $type->ofType());
    }
107045
public function hasResource($resource) {

		if(null !== $resource && false === is_string($resource)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($resource)), E_USER_ERROR);
		}

		return true === array_key_exists($resource, $this -> resources);
	}
1298610
@SuppressWarnings("static-method")
	protected boolean isValidResource(IResource resource) {
		return resource.isAccessible() && !resource.isHidden() && !resource.isPhantom() && !resource.isDerived();
	}
502825
public function applyEntity(Resource $resource, EntityInterface $entity)
    {
        $this->validateResourceTypes($resource->getEntityType(), $entity->getType());
        $document->pushData($entity);
        return $this;
    }
828847
public function register(ResourceInterface $resource, Listener $listener)
    {
        $this->tracked[$resource->getKey()] = [$resource, $listener];
    }
71734
public function load($resource, $type = null)
    {
        if (!preg_match('/^[^\:]+(?:::?(?:[^\:]+))?$/', $resource)) {
            throw new \InvalidArgumentException(sprintf('Invalid resource "%s" passed to the "service" route loader: use the format "service::method" or "service" if your service has an "__invoke" method.', $resource));
        }

        if (1 === substr_count($resource, ':')) {
            $resource = str_replace(':', '::', $resource);
            @trigger_error(sprintf('Referencing service route loaders with a single colon is deprecated since Symfony 4.1. Use %s instead.', $resource), E_USER_DEPRECATED);
        }

        $parts = explode('::', $resource);
        $serviceString = $parts[0];
        $method = $parts[1] ?? '__invoke';

        $loaderObject = $this->getServiceObject($serviceString);

        if (!\is_object($loaderObject)) {
            throw new \LogicException(sprintf('%s:getServiceObject() must return an object: %s returned', \get_class($this), \gettype($loaderObject)));
        }

        if (!\is_callable([$loaderObject, $method])) {
            throw new \BadMethodCallException(sprintf('Method "%s" not found on "%s" when importing routing resource "%s"', $method, \get_class($loaderObject), $resource));
        }

        $routeCollection = $loaderObject->$method($this);

        if (!$routeCollection instanceof RouteCollection) {
            $type = \is_object($routeCollection) ? \get_class($routeCollection) : \gettype($routeCollection);

            throw new \LogicException(sprintf('The %s::%s method must return a RouteCollection: %s returned', \get_class($loaderObject), $method, $type));
        }

        // make the service file tracked so that if it changes, the cache rebuilds
        $this->addClassResource(new \ReflectionClass($loaderObject), $routeCollection);

        return $routeCollection;
    }
949093
public function setResourceType(ResourceType $resourceType)
    {
        $this->iteratorName = '$' . $resourceType->getName();
        $this->resourceType = $resourceType;
    }
1006543
public function checkResourcePrepared(AbstractResource $resource)
    {
        $stringErrors = '';

        //null or '' shouldn't be valid
        if ($resource->getName() == null) {
            $stringErrors .= 'The resource name is missing' . PHP_EOL;
        }

        if ($stringErrors !== '') {
            throw new MissingResourceNameException($stringErrors);
        }
    }
860772
protected function checkMissingFields(Resource $resource)
    {
        $missing = array_diff(
            $resource->model_class::getRequiredColumns(),
            array_keys($resource->data)
        );

        if (!empty($missing)) {
            $message = "Resource '$resource->name' requires the following "
                . "missing fields: '" . implode("', '", $missing) . "'";
            $this->sendError(static::ERROR_INVALID_PAYLOAD, $message);
        }
    }
817215
public function toEntityFull(ResourceInterface $resource, EntityInterface $entity)
    {
        foreach ($this->mappers as $mapper) {
            if ($mapper->supportsEntity($entity)) {
                $this->configureResourceMapper($mapper);
                $mapper->toEntityFull($resource, $entity);

                return;
            }
        }

        throw new UnsupportedTypeException($resource->type());
    }
1069672
public function unregisterCacheResource($type)
    {
        if (isset($this->smarty->registered_cache_resources[$type])) {
            unset($this->smarty->registered_cache_resources[$type]);
        }
    }
45519
public function resolve($resource, $type = null){
		$resolvingLoader = false;
		foreach($this->loaders as $loader){
			if($loader->supports($resource, $type)){
				$resolvingLoader = $loader;
			}
		}
		if(!$resolvingLoader){
			if(!$type){
				$type = (is_callable($resource))
					? 'closure'
					: pathinfo($resource, PATHINFO_EXTENSION)
				;
			}
			$resolvingLoader = $this->createLoaderForType($type);
		}

		return $resolvingLoader;
	}
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;
    }