Set an internal resource from a framework resource
@param string $name Resource name
@param string|array $resource Framework resource referece
@return boolean
485595
public function setResource ($name, $resource)
	{
		
		// Get the resource
		
		$obj	=& Sonic::getResource ($resource);
		
		if (!$obj)
		{
			return FALSE;
		}
		
		// Set resource object
		
		$this->setResourceObj ($name, $obj);
		
		// Return
		
		return TRUE;
		
	}
977730
protected function _setResourceName( $name )
	{
		$config = $this->_context->getConfig();

		if( $config->get( 'resource/' . $name ) === null ) {
			$this->_resourceName = $config->get( 'resource/default', 'db' );
		} else {
			$this->_resourceName = $name;
		}
	}
443660
public function addResource(string $name, $resource): self
    {
        if ($resource instanceof StreamInterface) {
            $in = $resource;
        } elseif (\is_resource($resource)) {
            $in = new ResourceInputStream($resource);
        } else {
            $resource = (string) $resource;
            
            if (\preg_match("'^/|(?:[^:\\\\/]+://)|(?:[a-z]:[\\\\/])'i", $resource)) {
                $in = ResourceInputStream::fromUrl($resource);
            } else {
                $in = new StringStream($resource);
            }
        }
        
        $this->resources[\trim(\str_replace('\\', '/', $name), '/')] = $in;
        
        return $this;
    }
1125192
protected function createResourceClient(string $name, array $options = []): ResourceInterface
    {
        $entry = $this->manifest->getResource($name);
        # we check for the manifest entry
        
        if (empty($entry)) {
            throw new ResourceNotFoundException('Could not find the client for the requested resource '.$name);
        }
        $resource = $entry['namespace'] . '\\' . $entry['client'];
        return new $resource($this, ...$options);
    }
1208562
public function setResources($resources)
    {
        foreach ($resources as $resource) {
            $resource->setWidget($this);
        }

        $this->resources = $resources;

        return $this;
    }
879887
public function setName($name)
    {
        if (strpos(self::PATH_SEPARATOR, $name) !== false) {
            throw new \InvalidArgumentException(
                'Invalid character "' . self::PATH_SEPARATOR . '" in resource name.'
            );
        }

        $this->name = $name;
    }
766816
public function setConnectionResource($resource): void
    {
        foreach ($this->items as $converter) {
            if ($converter instanceof ConnectionAware) {
                $converter->setConnectionResource($resource);
            }
        }
    }
236432
public static function &_getResource ($name)
	{
		
		if (is_array ($name))
		{
			return Sonic::getResource ($name);
		}
		else if (isset (static::$defaultResources[$name]))
		{
			return Sonic::getResource (static::$defaultResources[$name]);
		}
		else
		{
			return Sonic::getSelectedResource ($name);
		}
		
	}
558692
public static function use(string $name, callable $callback)
    {
        $resource = static::getResource($name);
        $result = null;
        try{
            $result = call_user_func($callback, $resource, $resource->getInstance());
        }
        finally{
            static::releaseResource($resource);
        }
        return $result;
    }
851153
public function resource($name, $controller, array $options = array())
	{
		// If the resource name contains a slash, we will assume the developer wishes to
		// register these resource routes with a prefix so we will set that up out of
		// the box so they don't have to mess with it. Otherwise, we will continue.
		if (str_contains($name, '/'))
		{
			$this->prefixedResource($name, $controller, $options);

			return;
		}

		// We need to extract the base resource from the resource name. Nested resources
		// are supported in the framework, but we need to know what name to use for a
		// place-holder on the route wildcards, which should be the base resources.
		$base = $this->getResourceWildcard(last(explode('.', $name)));

		$defaults = $this->resourceDefaults;

		foreach ($this->getResourceMethods($defaults, $options) as $m)
		{
			$this->{'addResource'.ucfirst($m)}($name, $base, $controller, $options);
		}
	}
744832
protected function createFileResource($name)
    {
        if ($this->getResource()->getPattern() && !preg_match($this->getResource()->getPattern(), $name)) {
            $this->files[$name] = 'skip';
        } else {
            $this->files[$name] = new FileResource($this->getResource()->getResource().'/'.$name);
        }
    }
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);
    }
807193
public function get_resource_content($name)
    {
        if (!strpos($name, '/')) {
            $name = "program/resources/$name";
        }

        $assets_dir = $this->config->get('assets_dir');

        if ($assets_dir) {
            $path = slashify($assets_dir) . $name;
            if (@file_exists($path)) {
                $name = $path;
            }
        }

        return file_get_contents($name, false);
    }
858575
public static function fromResource(Resource $resource)
    {
        if (!is_subclass_of($resource->model_class, Medools\Model::class)) {
            $message = 'Invalid Resource model_class in ' . static::class . ': '
                . $resource->model_class;
            throw new \LogicException($message);
        }

        $controller = new static;

        $list = $resource->getList();
        if (empty($list)) {
            return false;
        }

        foreach ($list as $id) {
            if (!$controller->generate($id)) {
                return false;
            }
        }

        if ($resource->content_type === 'application/zip') {
            $controller->zip();
        } else {
            $controller->output();
        }

        return true;
    }
182152
protected function setResource( string $resource, string $endpoint ): self
	{
		$this->resource = $resource;
		$this->resource_endpoint = $endpoint;
		return $this;
	}
410795
public function setResource(ResourceInterface $resource = null)
    {
        $this->resource = $resource;

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

        return $this;
    }
867990
public function set($name)
    {
        $exec = $this->getExecutor();
        $exec->setCommand('hostname ' . $name);
        $exec->run();

        return $exec->hasErrors();
    }