/** * Construct an asset object * * @param AssetOperationHandlerService $service The service object * @param stdClass $identifier The identifier of the asset * @throws NullServiceException if the service object is NULL * @throws NullIdentifierException if the identifier object is NULL * @throws NullAssetException if the asset cannot be retrieved */ public function __construct(aohs\AssetOperationHandlerService $service, \stdClass $identifier) { if ($service == NULL) { throw new e\NullServiceException(c\M::NULL_SERVICE); } if ($identifier == NULL) { throw new e\NullIdentifierException(c\M::NULL_IDENTIFIER); } if (self::DEBUG && self::DUMP) { u\DebugUtility::dump($identifier); } // get the property $property = $service->retrieve($identifier, c\T::$type_property_name_map[$identifier->type]); if ($property == NULL) { if (isset($identifier->id)) { $id = $identifier->id; } if (isset($identifier->path)) { $path = $identifier->path->path; if (isset($identifier->path->siteName)) { $site_name = $identifier->path->siteName; } } if (!isset($id)) { $id = $path; } throw new e\NullAssetException(S_SPAN . "The " . c\T::$type_property_name_map[$identifier->type] . " cannot be retrieved. ID/Path: " . $id . ". " . (isset($site_name) ? "Site: " . $site_name . ". " : "") . E_SPAN . BR . $service->getMessage()); } // store information $this->service = $service; $this->identifier = $identifier; //stdClass $this->type = $identifier->type; $this->property_name = c\T::$type_property_name_map[$this->type]; $this->property = $property; if (isset($property->id)) { $this->id = $property->id; } if (isset($property->name)) { $this->name = $property->name; } if (isset($property->path)) { $this->path = $property->path; } if (isset($property->siteId)) { $this->site_id = $property->siteId; } if (isset($property->siteName)) { $this->site_name = $property->siteName; } }