Newscoop\Service\Resource\ResourceId::getService PHP Method

getService() public method

The id should not be provided as a plain string it should be the actuall class name ot the service API beeing requested. As a convention this id should be obtain from the NAME contstant of a interface (ex: IThemeService::NAME), where NAME is defined in the interface as 'const NAME = __CLASS__', if apllicable.
public getService ( string $serviceName ) : mixed
$serviceName string The class name of the interface beeing requested, must not be null or empty.
return mixed The resource id obtained for this service request.
    public function getService($serviceName)
    {
        Validation::notEmpty($serviceName, "serviceName");
        $serviceId = new ResourceId($serviceName, ResourceId::TYPE_SERVICE);
        $serviceId->parent = $this;
        return ResourceRepository::getInstance()->getResourceFor($serviceId);
    }

Usage Example

Beispiel #1
0
 public function __construct($p_templateIdOrName = null, $p_themePath = null)
 {
     $this->m_properties = array();
     $this->m_customProperties['name'] = 'getValue';
     $this->m_customProperties['identifier'] = 'getId';
     $this->m_customProperties['type'] = 'getTemplateType';
     $this->m_customProperties['defined'] = 'defined';
     $this->m_customProperties['theme_dir'] = 'getThemeDir';
     $this->_map = array("frontPage" => "issue", "errorPage" => "default", "sectionPage" => "section", "issuePage" => "issue", "articlePage" => "article");
     if ((is_string($p_templateIdOrName) || is_int($p_templateIdOrName)) && !empty($p_templateIdOrName)) {
         $filePath = is_numeric($p_templateIdOrName) ? $p_templateIdOrName : $p_themePath . $p_templateIdOrName;
         $resourceId = new ResourceId('template_engine/metaclasses/MetaTemplate');
         /* @var $syncResourceService ISyncResourceService */
         $syncResourceService = $resourceId->getService(ISyncResourceService::NAME);
         $this->m_dbObject = $syncResourceService->findByPathOrId($filePath);
         if (is_null($this->m_dbObject)) {
             $pathRsc = new Resource();
             $pathRsc->setName('buildPage');
             $filePath = CS_PATH_TEMPLATES . DIR_SEP . $p_themePath . $p_templateIdOrName;
             if (!is_numeric($p_templateIdOrName) && !is_null($p_themePath) && file_exists($filePath)) {
                 $pathRsc->setPath($p_themePath . $p_templateIdOrName);
                 $this->m_dbObject = $syncResourceService->getSynchronized($pathRsc);
             } else {
                 $this->m_dbObject = $pathRsc;
             }
         }
     }
 }
All Usage Examples Of Newscoop\Service\Resource\ResourceId::getService