@deprecated since version 7.10.0, to be removed in 8.0.

@param \core_kernel_classes_Resource $resource
@return \common_report_Report
501637
public function getReportByLinkedResource(\core_kernel_classes_Resource $resource)
    {
        $taskResource = $this->getTaskResource($resource);
        if ($taskResource !== null) {
            $report = $taskResource->getOnePropertyValue($this->getProperty(Task::PROPERTY_REPORT));
            if ($report) {
                $report = \common_report_Report::jsonUnserialize($report->literal);
            } else {
                $task = $this->getTask($taskResource->getUri());
                if ($task) {
                    $report = \common_report_Report::createInfo(__('Task is in \'%s\' state', $task->getStatus()));
                } else {
                    //this is an assumption.
                    //in case if sync implementation is used task may not be found.
                    $report = \common_report_Report::createInfo(__('Task is in progress'));
                }
            }
        } else {
            $report = \common_report_Report::createFailure(__('Resource is not the task placeholder'));
        }
        return $report;
    }
1272026
public function getDataByItem(\core_kernel_classes_Resource $item)
    {
        foreach ($this->columns as $column => $config) {
            /** @var Extractor $extractor */
            $extractor = $this->extractors[$config['extractor']];
            if (isset($config['parameters'])) {
                $parameters = $config['parameters'];
            } else {
                $parameters = [];
            }
            $extractor->addColumn($column, $parameters);
        }

        $data = ['0' => []];
        foreach ($this->extractors as $extractor) {

            $extractor->setItem($item);
            $extractor->run();
            $values = $extractor->getData();

            foreach ($values as $key => $value) {

                $interactionData = is_array($value) && count($value) > 1 ? $value : $values;

                if (array_values(array_intersect(array_keys($data[0]), array_keys($interactionData))) == array_keys($interactionData)) {
                    $line = array_intersect_key($data[0], array_flip($this->headers));
                    $data[] = array_merge($line, $interactionData);
                } else {
                    $data[0] = array_merge($data[0], $interactionData);
                }

                $this->headers = array_unique(array_merge($this->headers, array_keys($interactionData)));
            }
        }

        return $data;
    }
1171868
public function getUsers( core_kernel_classes_Resource $role)
    {
        $returnValue = array();

        $filters = array(GenerisRdf::PROPERTY_USER_ROLES => $role->getUri());
        $options = array('like' => false, 'recursive' => true);

        $userClass = new core_kernel_classes_Class(GenerisRdf::CLASS_GENERIS_USER);
        $results = $userClass->searchInstances($filters, $options);

        $returnValue = array_keys($results);

        return (array) $returnValue;
    }
573509
public function getPolicy($resource)
    {
        if (!is_object($resource)) {
            $message = sprintf('Resource must be an object, `%s` given.', gettype($resource));
            throw new InvalidArgumentException($message);
        }

        $class = get_class($resource);

        if (!isset($this->map[$class])) {
            throw new MissingPolicyException($resource);
        }

        $policy = $this->map[$class];

        if (is_callable($policy)) {
            return $policy($resource, $this);
        }

        if (is_object($policy)) {
            return $policy;
        }

        return new $policy();
    }
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;
        });
    }
526488
public function checkResource($resource)
    {
        $resource =
            $resource instanceof Resource
                ? $resource
                : $this->getResourceBySlug($resource);

        $checked = $this->cache->remember($resource->slug, function () use (
            $resource
        ) {
            return $resource->check($this->getCurrentAction());
        });

        $resource->targets = $checked->targets;

        return $resource;
    }
93822
public function podeAcessar($resource)
    {
        if (! ($this->acesso instanceof Acesso)) {
            throw new MalUsoException('Acesso\AcessoViewModel->acesso deve ser um instância de Acesso\Acesso');
        }
        return $this->acesso->isRoleAtualAllowed($resource);
    }
649841
public function getStrings(\core_kernel_classes_Resource $resource)
    {
        $tokenizer = $this->getItemContentTokenizer($resource);
        if (is_null($tokenizer)) {
            return [];
        }
        return $tokenizer->getStrings($resource);
    }
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;
    }
1284932
public function prependResource($resource) {
		$resource = $this->handleResource($resource);
		
		$this->resources->unshift($resource);
		return $resource;
	}
370250
protected function deleteDeliveryRuntime(core_kernel_classes_Resource $assembly)
    {
        /** @var GroupAssignment $deliveryAssignement */
        $deliveryAssignement = $this->getServiceManager()->get(GroupAssignment::SERVICE_ID);
        $deliveryAssignement->onDelete($assembly);
        /** @var core_kernel_classes_Resource $runtimeResource */
        $runtimeResource = $assembly->getUniquePropertyValue(new core_kernel_classes_Property(self::PROPERTY_DELIVERY_RUNTIME));
        return $runtimeResource->delete();
    }
678881
public function getAuthType(\core_kernel_classes_Resource $resource = null)
    {
        if ($resource) {
            $authTypeUri = $resource->getUri();
            foreach ($this->getOption(self::OPTION_TYPES) as $type) {
                if ($type instanceof AbstractAuthType && $type->getAuthClass()->getUri() == $authTypeUri) {
                    $authType = $type;
                }
            }
        } else {
            $authType = $this->getOption(self::OPTION_DEFAULT_TYPE);
        }

        if (!isset($authType) || !is_a($authType, AbstractAuthType::class)) {
            throw new \common_Exception('Auth type not defined');
        }

        return $authType;
    }
235957
public static function fromResource(Resource $resource)
    {
        if (isset($resource->query['with_billets'])) {
            return static::withBillets($resource);
        }
        return parent::fromResource($resource);
    }
603144
public static function removeIncludedRoles( core_kernel_classes_Resource $role)
    {
        $serial = self::buildIncludedRolesSerial($role);
        ServiceManager::getServiceManager()->get('generis/cache')->remove($serial);;

        // -- note: the cache might exist even if it was successfully
        // removed due to race conditions.
        // $returnValue = (file_exists(GENERIS_CACHE_PATH . $serial)) ? false : true;
        return true;
    }
739585
public function deleteInstances( core_kernel_classes_Class $resource, $resources, $deleteReference = false)
    {
        $returnValue = false;

        $class = new core_kernel_classes_Class($resource->getUri());
        $uris = array();
        
        foreach ($resources as $r) {
            $uri = (($r instanceof core_kernel_classes_Resource) ? $r->getUri() : $r);
            $uris[] = $this->getPersistence()->quote($uri);
        }
        
        if ($class->exists()) {
            $inValues = implode(',', $uris);
            $query = 'DELETE FROM statements WHERE subject IN (' . $inValues . ')';
        	
            if (true === $deleteReference) {
                $params[] = $resource->getUri();
                $query .= ' OR object IN (' . $inValues . ')';
            }
        	
            try {
        		// Even if now rows are affected, we consider the resources
        		// as deleted.
        		$this->getPersistence()->exec($query);	
        		$returnValue = true;
            } catch (PDOException $e) {
        	    throw new core_kernel_persistence_smoothsql_Exception("An error occured while deleting resources: " . $e->getMessage());
            }
        }

        return $returnValue;
    }
865098
public function getRuntime( core_kernel_classes_Resource $assembly) {
        return $this->getServiceLocator()->get(RuntimeService::SERVICE_ID)->getRuntime($assembly->getUri());
    }
46540
public function remove( Resource $resource )
    {
        $cnt = 0;
        if( false !== $key = array_search( $resource, $this->instances, true ) ) {
            unset( $this->instances[$key] );
            $cnt++;
        }
        return $cnt;
    }