public function __construct(\stdClass $sd = NULL, aohs\AssetOperationHandlerService $service = NULL, $data_definition_id = NULL, $data2 = NULL, $data3 = NULL) { // a data definition block will have a data definition id in the sd object // a page will need to pass into the data definition id if (isset($sd)) { // store the data if (isset($sd->definitionId)) { $this->definition_id = $sd->definitionId; $this->type = a\DataDefinitionBlock::TYPE; } else { if (isset($data_definition_id)) { $this->definition_id = $data_definition_id; $this->type = a\Page::TYPE; } } if (isset($sd->definitionPath)) { $this->definition_path = $sd->definitionPath; } // initialize the arrays $this->children = array(); $this->node_map = array(); // store the data definition $this->data_definition = new a\DataDefinition($service, $service->createId(a\DataDefinition::TYPE, $this->definition_id)); // turn structuredDataNode into an array if (isset($sd->structuredDataNodes->structuredDataNode) && !is_array($sd->structuredDataNodes->structuredDataNode)) { $child_nodes = array($sd->structuredDataNodes->structuredDataNode); } elseif (isset($sd->structuredDataNodes->structuredDataNode)) { $child_nodes = $sd->structuredDataNodes->structuredDataNode; if (self::DEBUG) { u\DebugUtility::out("Number of nodes in std: " . count($child_nodes)); } } // convert stdClass to objects StructuredDataNodePhantom::processStructuredDataNodePhantom('', $this->children, $child_nodes, $this->data_definition); } $this->node_map = $this->getIdentifierNodeMap(); $this->identifiers = array_keys($this->node_map); $this->host_asset = $data2; $this->service = $service; if (self::DEBUG) { u\DebugUtility::out("First node ID: " . $first_node_id); } }
public static function getLinkableType(aohs\AssetOperationHandlerService $service, $id_string) { $types = array(Page::TYPE, File::TYPE, Symlink::TYPE); $type_count = count($types); for ($i = 0; $i < $type_count; $i++) { $id = $service->createId($types[$i], $id_string); $operation = new \stdClass(); $read_op = new \stdClass(); $read_op->identifier = $id; $operation->read = $read_op; $operations[] = $operation; } $service->batch($operations); $reply_array = $service->getReply()->batchReturn; for ($j = 0; $j < $type_count; $j++) { if ($reply_array[$j]->readResult->success == 'true') { foreach (c\T::$type_property_name_map as $type => $property) { if (isset($reply_array[$j]->readResult->asset->{$property})) { return $type; } } } } return "The id does not match any asset type."; }