Create (if possible) and|or returns an icon for a resource.

@param \Claroline\CoreBundle\Entity\Resource\AbstractResource $resource

@return \Claroline\CoreBundle\Entity\Resource\ResourceIcon
347379
public function getIcon(AbstractResource $resource, Workspace $workspace = null)
    {
        $node = $resource->getResourceNode();
        $mimeElements = explode('/', $node->getMimeType());
        $ds = DIRECTORY_SEPARATOR;
        // if video or img => generate the thumbnail, otherwise find an existing one.
        if (('video' === $mimeElements[0] || 'image' === $mimeElements[0])) {
            $this->om->startFlushSuite();
            $publicFile = $this->createFromFile(
                $this->fileDir.$ds.$resource->getHashName(),
                $mimeElements[0],
                $workspace
            );

            if ($publicFile) {
                $thumbnailPath = $this->webdir.$ds.$publicFile->getUrl();
                $relativeUrl = ltrim(str_replace($this->webdir, '', $thumbnailPath), "{$ds}");
                $icon = new ResourceIcon();
                $icon->setMimeType('custom');
                $icon->setRelativeUrl($relativeUrl);
                $icon->setShortcut(false);
                $icon->setUuid(uniqid('', true));
                $this->om->persist($icon);
                $this->om->endFlushSuite();

                $this->fu->createFileUse(
                  $publicFile,
                  get_class($icon),
                  $icon->getUuid(),
                  'resource-thumbnail'
                );

                return $icon;
            }
            $this->om->endFlushSuite();
        }

        //default & fallback
        return $this->searchIcon($node->getMimeType());
    }
70085
public static function create( $resource, $params=null )
    {
        self::_validateCall('create', $params);
        $requestor = new ApiRequestor();
        $url = '/' . $resource;
        return $requestor->request( 'post', $url, $params );
    }
256603
protected function _loadResource($resource) {
        return $this->cache([__METHOD__, $resource], function() use ($resource) {
            $data = $this->getLocaleBundle()->loadResource(null, $resource);

            if ($parent = $this->getParentLocale()) {
                $data = array_merge(
                    $parent->getLocaleBundle()->loadResource(null, $resource),
                    $data
                );
            }

            return $data;
        });
    }
186854
protected function createContainer( $resource, $key )
	{
		$config = $this->getContext()->getConfig();

		$type = $config->get( $key . '/type', 'Zip' );
		$format = $config->get( $key . '/format', 'CSV' );
		$options = $config->get( $key . '/options', [] );

		return \Aimeos\MW\Container\Factory::getContainer( $resource, $type, $format, $options );
	}
235957
public static function fromResource(Resource $resource)
    {
        if (isset($resource->query['with_billets'])) {
            return static::withBillets($resource);
        }
        return parent::fromResource($resource);
    }
139110
public function createStream( $resource )
	{
		if( is_resource( $resource ) === true ) {
			return new \Slim\Http\Stream( $resource );
		}

		if( ( $fh = @fopen( $resource, 'r' ) ) !== false ) {
			return new \Slim\Http\Stream( $fh );
		}

		throw new \Aimeos\MW\Exception( sprintf( 'Unable to open file "%1$s"', $resource ) );
	}
685400
public function refresh( $resource )
    {
        $url = $url = '/' . $resource . '/' . $this->id;

        $requestor = new ApiRequestor();
        $response = $requestor->request(
            'get',
            $url,
            $this->_retrieveOptions
        );
        $this->refreshFrom($response[0]);

        return $this;
    }
545173
protected function execute(ApiResourceInterface $resource)
    {
        $client = $resource->getHttpClient();

        if (is_null($options = $this->requestOptions())) {
            return $client->request($this->requestMethod(), $this->requestUrl($resource));
        }

        return $client->request($this->requestMethod(), $this->requestUrl($resource), $options);
    }
76888
protected function authorizeResource($resource)
    {
        if ($this->isEditing($resource)) {
            return $this->user()->can($resource . '.update');
        }

        return $this->user()->can($resource . '.create');
    }
586968
protected function makeReleaseRelativePath(AbstractResourceFile $resource) {
        if (is_null($this->getReleaseDir())) {
            throw new FileWriteErrorException("The release dir configuration is missed for " . get_class($this));
        }
        $relative_path = $resource->getRelativePath($this->getSourceDir());
        if ('.less' === substr($relative_path, -5)) {
            $relative_path = substr($relative_path, 0, -5) . '.css';
        } else {
            $relative_path .= '.css';
        }
        return $relative_path;
    }
1055789
public function icon($icon = null)
    {
        if (null !== $icon) {
            $this->icon = $icon;

            return $this;
        }

        return $this->icon;
    }
15459
private function createRepositoryDefinition(ResourceInterface $resource)
    {
        $definition = new Definition($resource->getRepository(), [$resource->getModel()]);
        $definition->setFactory([new Reference('lug.manager.'.$resource->getName()), 'getRepository']);
        $definition->addTag('lug.repository', ['resource' => $resource->getName()]);

        return $definition;
    }
216413
public function setParent(FedoraResource $resource): Indexer {
        $this->parent = $resource;
        $this->fedora = $this->parent->getFedora();
        $metadata     = $this->parent->getMetadata();
        $locations    = $metadata->allLiterals(RC::locProp());
        foreach ($locations as $i) {
            $loc = preg_replace('|/$|', '', self::containerDir() . $i->getValue());
            if (is_dir($loc)) {
                $this->paths[] = $i->getValue();
            }
        }
        return $this;
    }
201411
protected function getResourceName($resource)
    {
        if ($resource instanceof ResourceInterface) {
            $resource = $resource->getName();
        }

        if (false === is_string($resource)) {
            throw new InvalidArgumentException(
                'Resource argument must be string or an object implemented "Rad\Authorization\Rbac\ResourceInterface".'
            );
        }

        return $resource;
    }
646082
private function createManagerAlias(ResourceInterface $resource)
    {
        return $resource->getDriver() === ResourceInterface::DRIVER_DOCTRINE_MONGODB
            ? 'doctrine_mongodb.odm.'.$resource->getDriverManager().'_document_manager'
            : 'doctrine.orm.'.$resource->getDriverManager().'_entity_manager';
    }
934257
public function registerResource(AbstractResourceFile $resource) {
        if (!isset($this->resources[md5($resource->getRealPath())])) {
            $this->resources[md5($resource->getRealPath())] = $resource;
        }
    }
819085
private function createDriverNode(ResourceInterface $resource)
    {
        $driverNode = $this->createNode('driver')->addDefaultsIfNotSet();
        $driverNode->children()
            ->append($this->createNode('name', 'scalar', $resource->getDriver()))
            ->append($this->createNode('manager', 'scalar', $resource->getDriverManager()))
            ->append($this->createDriverMappingNode($resource));

        return $driverNode;
    }