function assetTreeSimpleFunction(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    echo $type, BR;
    $asset = $child->getAsset($service);
    $asset->dump(true);
}
function assetTreeChangeFull(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    // skip entire folder
    if (strpos($child->getPathPath(), "_extra/") !== false) {
        return;
    }
    if (strpos($child->getPathPath(), "_cascade/") !== false) {
        return;
    }
    $type = $child->getType();
    if ($type != a\Page::TYPE) {
        return;
    }
    $page = $child->getAsset($service);
    try {
        if ($page->hasStructuredData()) {
            $node_ids = array("size", "content-group;0;content-group-size", "content-group;1;content-group-size", "content-group;2;content-group-size", "content-group;3;content-group-size");
            foreach ($node_ids as $node_id) {
                if ($page->hasNode($node_id) && ($page->getText($node_id) == "Full" || $page->getText($node_id) == "" || $page->getText($node_id) == NULL)) {
                    $page->setText($node_id, "full")->edit();
                }
            }
        }
    } catch (\Exception $e) {
        echo $page->getId(), BR;
        throw $e;
    }
}
function processPage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    // Get the next page to be processed
    $page = $child->getAsset($service);
    // name of dynamic metadata field
    $dynField = "columnLayout";
    var_dump($page->getMetadata()->getDynamicFieldValues($dynField));
}
function assetTreeSimpleFunction(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\Folder::TYPE) {
        return;
    }
    echo "Process ", $type, BR;
}
 public function retrieveAsset(p\Child $child)
 {
     $id = $child->getId();
     if (!isset($this->cache[$id])) {
         $this->cache[$id] = $child->getAsset(self::$service);
     }
     return $this->cache[$id];
 }
function assetTreeReportPagePath(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE) {
        return;
    }
    echo $child->getPathPath(), BR;
}
function processPage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    // Get the next page to be processed
    $page = $child->getAsset($service);
    echo "<tr>\n";
    // get the full Page asset
    echo "<td><a href='" . $GLOBALS['url'] . $child->getId() . "'>" . $child->getPathPath() . "</a></td>\n<td>" . $page->getContentTypePath() . "</td>\n";
    echo "</tr>\n";
}
function assetTreeTouchAsset(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\File::TYPE) {
        return;
    }
    $asset = $child->getAsset($service);
    $asset->edit();
}
function submitPage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    // submit page (and remove phantom nodes)
    $page = $child->getAsset($service);
    $page->edit();
    // Recheck the page's current content type
    echo "<td>" . $page->getContentTypeId() . "</td>\n";
    echo "</tr>\n";
}
function assetTreeRemoveUnwantedPage(aohs\AssetOperationHandlerService $service, p\Child $child, array $params = NULL, array &$results = NULL)
{
    if ($child->getType() != a\Page::TYPE) {
        return;
    }
    $page_path = $child->getPathPath();
    // junk page names
    if (u\StringUtility::endsWith($page_path, "/pdf") || u\StringUtility::endsWith($page_path, "/word") || u\StringUtility::endsWith($page_path, "/externallink") || u\StringUtility::endsWith($page_path, "/keytiny") || u\StringUtility::endsWith($page_path, "/index-2")) {
        $service->delete($child->toStdClass());
    }
}
function assetTreeSearchForNeedleInHaystack(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    $needle = $params[$type]['needle'];
    // the method name should be defined for the asset
    // and returns a string
    $method = $params[$type]['method'];
    $haystack = $child->getAsset($service)->{$method}();
    if (strpos($haystack, $needle) !== false) {
        $results[$type][] = $child->getPathPath();
    }
}
function assetTreeCountAsset(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    $site_name = $params[0];
    if ($type != a\Page::TYPE) {
        return;
    }
    if (!isset($results[$site_name])) {
        $results[$site_name] = 0;
    }
    if (!isset($results["total"])) {
        $results["total"] = 0;
    }
    $results["total"] = $results["total"] + 1;
    $results[$site_name] = $results[$site_name] + 1;
}
function assetTreeFindDDBlockPageWithIntialId(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    if (!isset($params['partial-id'])) {
        throw new \Exception("The id is not included");
    }
    $partial_id = $params['partial-id'];
    $type = $child->getType();
    if ($type != a\DataBlock::TYPE && $type != a\Page::TYPE) {
        return;
    }
    $id = $child->getId();
    if (!u\StringUtility::startsWith($id, $partial_id)) {
        return;
    } else {
        echo $id;
    }
}
function assetTreeReportUnpublishableAsset(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Folder::TYPE && $type != a\Page::TYPE && $type != a\File::TYPE) {
        return;
    }
    if (!isset($results)) {
        throw new \Exception("No result array is passed in");
    }
    if (!isset($results[$type])) {
        $results[$type] = array();
    }
    $asset = $child->getAsset($service);
    if (!$asset->isPublishable()) {
        $results[$type][] = $asset->getPath();
    }
}
function assetTreeReportPhantomNodes(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    if (!isset($results) || !is_array($results)) {
        throw new \Exception("The results array is required");
    }
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) {
        return;
    }
    if (!isset($results[$type])) {
        $results[$type] = array();
    }
    $asset = $child->getAsset($service);
    if ($asset->hasPhantomNodes()) {
        $results[$type][] = $child->getPathPath();
    }
}
function assetTreeAssociateFoldersBlocksWithMetadataSets(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Folder::TYPE && $type != a\IndexBlock::TYPE && $type != a\TextBlock::TYPE && $type != a\DataBlock::TYPE && $type != a\FeedBlock::TYPE && $type != a\XmlBlock::TYPE) {
        return;
    }
    if (!is_array($params) || !isset($params["folder-ms"]) || !isset($params["block-ms"])) {
        throw new \Exception("The metadata sets are not supplied");
    }
    $folder_ms = $params["folder-ms"];
    $block_ms = $params["block-ms"];
    if ($type == a\Folder::TYPE) {
        $child->getAsset($service)->setMetadataSet($folder_ms);
    } else {
        $child->getAsset($service)->setMetadataSet($block_ms);
    }
}
function assetTreeFixPhantomNodes(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    // skip entire folder
    if (strpos($child->getPathPath(), "_extra/") !== false) {
        return;
    }
    if (strpos($child->getPathPath(), "_cascade/") !== false) {
        return;
    }
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) {
        return;
    }
    try {
        $asset = $child->getAsset($service);
        if ($asset->hasPhantomNodes()) {
            $asset->mapData();
        }
    } catch (e\NoSuchFieldException $e) {
        if ($type == a\Page::TYPE) {
            $asset = new a\PagePhantom($service, $child->toStdClass());
        } else {
            $asset = new a\DataDefinitionBlockPhantom($service, $child->toStdClass());
        }
        $dd = $asset->getDataDefinition();
        $healthy_sd = new p\StructuredData($dd->getStructuredData(), $service, $dd->getId());
        $phantom_sd = $asset->getStructuredDataPhantom();
        $healthy_sd = $healthy_sd->removePhantomNodes($phantom_sd);
        $asset->setStructuredData($healthy_sd);
    }
}
function assetTreeSimpleFunction(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    switch ($type) {
        case a\Page::TYPE:
            echo "Process page", BR;
            break;
        case a\Folder::TYPE:
            echo "Process folder", BR;
            break;
        case a\File::TYPE:
            echo "Process file", BR;
            break;
        default:
            echo "Do Nothing", BR;
            break;
    }
}
function processPage(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $contentType = "9fb82b39956aa0783236eb66c57479a3";
    // Content Types/Bootstrap/Standard Bootstrap
    $newContentType = $cascade->getAsset(a\ContentType::TYPE, $contentType);
    // Get the next page to be processed
    $page = $child->getAsset($service);
    echo "<tr>\n";
    // get the full Page asset
    echo "<td>" . $child->getPathPath() . "</td>\n<td>" . $page->getContentTypePath() . "</td>\n";
    /*
        Assumes old and new content types are associated with the same data definition.
        http://www.upstate.edu/cascade-admin/projects/web-services/oop/classes/asset-classes/page.php
    */
    $page->setContentType($newContentType, true)->edit();
    // Recheck the page's current content type
    echo "<td>" . $page->getContentTypeId() . "</td>\n";
    echo "</tr>\n";
}
function assetTreeSearchTextByPattern(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) {
        return;
    }
    $pattern = $params["pattern"];
    if (!isset($pattern) || trim($pattern) == "") {
        throw new \Exception("No pattern is supplied");
    }
    if (!isset($results) || !is_array($results)) {
        throw new \Exception("No results array is supplied");
    }
    $asset = $child->getAsset($service);
    $identifiers = $asset->searchTextByPattern($pattern);
    if (count($identifiers) > 0) {
        $results[$child->getPathPath()] = $identifiers;
    }
}
function assetTreeReplaceTextByPattern(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE && $type != a\DataBlock::TYPE) {
        return;
    }
    $pattern = $params["pattern"];
    $replacement = $params["replacement"];
    if (!isset($pattern) || trim($pattern) == "") {
        throw new \Exception("No pattern is supplied");
    }
    if (!isset($replacement) || trim($replacement) == "") {
        throw new \Exception("No replacement is supplied");
    }
    $asset = $child->getAsset($service);
    if (count($asset->searchTextByPattern($pattern)) > 0) {
        echo $child->getPathPath(), BR;
        $asset->replaceByPattern($pattern, $replacement)->edit();
    }
}
function assetTreeSetPageDisplayName(aohs\AssetOperationHandlerService $service, p\Child $child, array $params = NULL, array &$results = NULL)
{
    $type = $child->getType();
    if ($type != a\Page::TYPE) {
        return;
    }
    $default_title = "THIS PAGE NEEDS A TITLE";
    $page = $child->getAsset($service);
    $page_md = $page->getMetadata();
    $page_title = $page_md->getTitle();
    $page_h1 = $page->getText("main-content-title");
    if ($page_title == "" || $page_h1 == "") {
        if ($page_title == "") {
            $page_md->setTitle($default_title);
        }
        if ($page_h1 == "") {
            $page->setText("main-content-title", $default_title);
        }
        $page->edit();
    }
}
function assetTreeAssignGroupToAssetFactory(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    // get the child type
    $type = $child->getType();
    // get out if not asset factory
    if ($type != a\AssetFactory::TYPE) {
        return;
    }
    // the group must be supplied
    if (!is_array($params) || !isset($params['group'])) {
        throw new e\NullAssetException(S_SPAN . "The group must be supplied" . E_SPAN);
    }
    // retrieve the group; this can in fact be an array
    // if so, loop through each group
    $group = $params['group'];
    // associate group with asset factory
    //$child->getAsset( $service )->addGroup( $group )->edit();
    // for the moment, just output some info
    echo $child->getAsset($service)->getName(), BR;
    echo $group->getName(), BR;
}
function assetTreeConvertToOneRegionTemplate(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    if (!isset($params['site-storage']) || !isset($params['global-link-script']) || !isset($params['page-title']) || !isset($params['search-form']) || !isset($params['content-type'])) {
        throw new \Exception("Some of the parameters are missing.");
    }
    $type = $child->getType();
    if ($type != a\Page::TYPE) {
        return;
    }
    // skip entire folder
    if (strpos($child->getPathPath(), "_extra/") !== false) {
        return;
    }
    if (strpos($child->getPathPath(), "_cascade/") !== false) {
        return;
    }
    $site_storage_block = $params['site-storage'];
    $global_link_script_block = $params['global-link-script'];
    $page_title_block = $params['page-title'];
    $search_form_block = $params['search-form'];
    $one_region_ct = $params['content-type'];
    $page = $service->getAsset($child->getType(), $child->getId());
    try {
        $page->setContentType($one_region_ct);
        $cur_sd = $page->getStructuredData();
        $new_sd = $cur_sd->mapData();
        $page->setStructuredData($new_sd);
        $page->setBlock("site-config-group;site-storage", $site_storage_block)->setBlock("site-config-group;global-link-script", $global_link_script_block)->setBlock("site-config-group;page-title", $page_title_block)->setBlock("site-config-group;search-form", $search_form_block)->edit();
    } catch (\Exception $e) {
        echo $page->getId(), BR;
        throw $e;
    }
}
function assetTreeSetLinkURLForSymlink(aohs\AssetOperationHandlerService $service, p\Child $child, array $params = NULL, array &$results = NULL)
{
    /*
    // if a map is not supplied, quit
    if( !isset( $param[ 'symlink_map' ] ) )
        throw new \Exception( "A symlink map is required" );
        
    // get the map
    $symlink_map = $param[ 'symlink_map' ];
    */
    // get the child type
    $type = $child->getType();
    // get out if not symlink
    if ($type != a\Symlink::TYPE) {
        return;
    }
    // get the symlink asset
    $symlink = $child->getAsset($service);
    // get the url
    // $url = $symlink_map[ $symlink->getName() ];
    // do whatever you need to do with symlink
    $symlink->setLinkURL("http://www.google.com/")->edit();
    // $symlink->setLinkURL( $url )->edit();
}
function assetTreeSwitchPageContentType(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    if ($child->getType() != a\Page::TYPE) {
        return;
    }
    // make sure that there is a content type passed in
    if (!isset($params['ct'])) {
        throw new \Exception("No content type is supplied");
    }
    // make sure that there is a base page passed in
    if (!isset($params['bp'])) {
        throw new \Exception("No base page is supplied");
    }
    // pages to skip
    if (isset($params['skip'])) {
        $skip = $params['skip'];
    }
    if (in_array($child->getPathPath(), $skip)) {
        return;
    }
    $ct = $params['ct'];
    $bp = $params['bp'];
    // retrieve page to be processed
    $p = $child->getAsset($service);
    // get number of content-group
    $identifier = "content-group;0";
    $num_of_groups = 1;
    // get the number of instances of the multiple node
    if ($p->hasIdentifier($identifier)) {
        $num_of_groups = $p->getNumberOfSiblings($identifier);
    }
    // get the current structured data with data
    $sd_old = $p->getStructuredData();
    if (!isset($sd_old)) {
        return;
    }
    // create enough instances of the multiple field
    if ($num_of_groups > 1) {
        $bp->createNInstancesForMultipleField($num_of_groups, $identifier);
    }
    // get the blank structured data with needed nodes
    $sd_new = clone $bp->getStructuredData();
    // roll back the base page
    if ($num_of_groups > 1) {
        $bp->createNInstancesForMultipleField(1, $identifier);
    }
    // switch the content type
    $p->setContentType($ct, false);
    // fix the data
    if (u\StringUtility::endsWith($child->getPathPath(), 'index')) {
        $sd_new->setText("right-column", "yes");
    } else {
        $sd_new->setText("right-column", "no");
    }
    $sd_new->setText("left-column", "yes");
    $sd_new->setText("left-column-group;left-setup", "default");
    // the H1
    $sd_new->setText("main-content-title", $sd_old->getText("main-content-title"));
    // main WYSIWYG
    $sd_new->setText("main-content-content", $sd_old->getText("main-content-content"));
    // multiple groups with choosers
    for ($i = 0; $i < $num_of_groups; $i++) {
        $identifier = "content-group;" . $i . ";content-group-chooser";
        // null the id for the upcoming round
        $block_id = NULL;
        // read the block
        if ($sd_old->hasIdentifier($identifier)) {
            $block_id = $sd_old->getBlockId($identifier);
        }
        // if there is a block attached
        if (isset($block_id) && $block_id != "") {
            $b = a\Block::getBlock($service, $block_id);
            $sd_new->setBlock($identifier, $b);
            $identifier = "content-group;" . $i . ";content-group-size";
            $size_str = strtolower($sd_old->getText($identifier));
            // fix the possible value for the new data definition
            if ($size_str != 'full') {
                $size_str = 'half';
            }
            $sd_new->setText($identifier, $size_str);
            $identifier = "content-group;" . $i . ";content-group-block-floating";
            $sd_new->setText($identifier, strtolower($sd_old->getText($identifier)));
        }
        // WYSIWYGs in group
        $identifier = "content-group;" . $i . ";content-group-content";
        $sd_new->setText($identifier, $sd_old->getText($identifier));
    }
    // set the data
    $p->setStructuredData($sd_new);
}
 private function applyFunctionsToChild(aohs\AssetOperationHandlerService $service, p\Child $child, $function_array, $params = NULL, &$results = NULL)
 {
     $type = $child->getType();
     // match the type first
     if (isset($function_array[$type])) {
         $functions = $function_array[$type];
         $func_count = count($functions);
         for ($i = 0; $i < $func_count; $i++) {
             if ($functions[$i] == NULL) {
                 continue;
             }
             // class static method
             if (strpos($functions[$i], "::") !== false) {
                 $method_array = u\StringUtility::getExplodedStringArray(":", $functions[$i]);
                 $class_name = $method_array[0];
                 $class_name = Asset::NAME_SPACE . "\\" . $class_name;
                 $method_name = $method_array[1];
                 if (!method_exists($class_name, $method_name)) {
                     throw new e\NoSuchFunctionException("The function " . $functions[$i] . " does not exist.");
                 }
             } else {
                 if (!function_exists($functions[$i])) {
                     throw new e\NoSuchFunctionException("The function " . $functions[$i] . " does not exist.");
                 }
             }
         }
         // apply function with parameters and results array
         for ($i = 0; $i < $func_count; $i++) {
             if ($functions[$i] == NULL) {
                 continue;
             }
             if (strpos($functions[$i], "::") !== false) {
                 $method_array = u\StringUtility::getExplodedStringArray(":", $functions[$i]);
                 $class_name = $method_array[0];
                 $class_name = Asset::NAME_SPACE . "\\" . $class_name;
                 $method_name = $method_array[1];
                 $class_name::$method_name($service, $child, $params, $results);
             } else {
                 $func_name = $functions[$i];
                 $func_name($service, $child, $params, $results);
             }
         }
     }
 }
 public static function assetTreeReportScheduledPublishPublishSet(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
 {
     if (!isset($params['cache'])) {
         throw new e\ReportException(S_SPAN . c\M::NULL_CACHE . E_SPAN);
     }
     $cache = $params['cache'];
     $path = $child->getPathPath();
     $type = $child->getType();
     if ($type != PublishSet::TYPE) {
         return;
     }
     $ps = $cache->retrieveAsset($child);
     if ($ps->getUsesScheduledPublishing()) {
         $time_expression = self::getTimeInfo($ps);
         $site = $ps->getSiteName();
         $results[$type][] = $site . ":" . $path . ", " . $time_expression;
     }
 }
 public static function assetTreeUpdateXmlBlock(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
 {
     if (isset($params['target-cascade'])) {
         $target_cascade = $params['target-cascade'];
     } else {
         echo c\M::TARGET_CASCADE_NOT_SET . BR;
         return;
     }
     if (isset($params['source-site'])) {
         $source_site = $params['source-site'];
     } else {
         echo c\M::SOURCE_SITE_NOT_SET . BR;
         return;
     }
     if (isset($params['target-site'])) {
         $target_site = $params['target-site'];
     } else {
         echo c\M::TARGET_SITE_NOT_SET . BR;
         return;
     }
     if (isset($params['exception-thrown'])) {
         $exception_thrown = $params['exception-thrown'];
     } else {
         echo c\M::EXCEPTION_THROWN_NOT_SET . BR;
         return;
     }
     $source_block = $child->getAsset($service);
     $source_content = $source_block->getXml();
     $source_block_path = u\StringUtility::removeSiteNameFromPath($source_block->getPath());
     $source_block_path_array = u\StringUtility::getExplodedStringArray("/", $source_block_path);
     $source_block_path = $source_block_path_array[count($source_block_path_array) - 1];
     $source_block_parent_path = $source_block->getParentContainerPath();
     // create block
     $target_site_name = $target_site->getName();
     // parent must be there
     $target_parent = $target_cascade->getAsset(Folder::TYPE, $source_block_parent_path, $target_site_name);
     $target_block = $target_cascade->createXmlBlock($target_parent, $source_block_path, $source_content);
     // if asset already exists containing different xml, update xml
     $target_content = $target_block->getXml();
     try {
         if ($source_content != $target_content) {
             $target_block->setXml($source_content, $exception_thrown)->edit();
         }
     } catch (\Exception $e) {
         throw new e\CascadeInstancesErrorException($e . BR . S_SPAN . "Path: " . $target_block->getPath() . E_SPAN);
     }
     // metadata
     self::setMetadataSet($target_cascade, $source_site, $target_site, $source_block, $target_block, $exception_thrown);
 }
function assetTreeSwitchDataDefinitionForBlock(aohs\AssetOperationHandlerService $service, p\Child $child, $params = NULL, &$results = NULL)
{
    global $common_assets_site_name;
    $type = $child->getType();
    if ($type != a\DataBlock::TYPE) {
        return;
    }
    if (!isset($params["cascade"])) {
        throw new \Exception("The Cascade object is not supplied");
    } else {
        $cascade = $params["cascade"];
    }
    $block = $child->getAsset($service);
    $b_name = $block->getName();
    if ($b_name == "_footer-contact") {
        $dd_name = "Footer Contact";
    } elseif ($b_name == "_left-column") {
        $dd_name = "Left Column";
    } elseif ($b_name == "_right-column") {
        $dd_name = "Right Column";
    } elseif ($b_name == "_site-info") {
        $dd_name = "Site Info";
    } else {
        return;
    }
    $dd = $cascade->getAsset(a\DataDefinition::TYPE, $dd_name, $common_assets_site_name);
    $st = new p\StructuredData($dd->getStructuredData(), $service, $dd->getId());
    $identifiers = $block->getIdentifiers();
    foreach ($identifiers as $identifier) {
        // create the correct number of instances for multiple field
        if (u\StringUtility::endsWith($identifier, ";0") && $st->hasIdentifier($identifier)) {
            $st->createNInstancesForMultipleField($block->getNumberOfSiblings($identifier), $identifier);
        }
        // map the data
        if ($st->hasNode($identifier) && $block->isTextNode($identifier)) {
            $st->setText($identifier, $block->getText($identifier));
        } elseif ($st->hasNode($identifier) && $block->isAssetNode($identifier)) {
            $asset_node_type = $block->getAssetNodeType($identifier);
            if ($asset_node_type == "page" && $block->getPageId($identifier) != null) {
                $st->setPage($identifier, $cascade->getPage($block->getPageId($identifier)));
            } elseif ($asset_node_type == "file" && $block->getFileId($identifier) != null) {
                $st->setFile($identifier, $cascade->getFile($block->getFileId($identifier)));
            } elseif ($asset_node_type == "block" && $block->getBlockId($identifier) != null) {
                $st->setBlock($identifier, a\Block::getBlock($service, $block->getBlockId($identifier)));
            } elseif ($asset_node_type == "page,file,symlink" && $block->getLinkableId($identifier) != null) {
                $st->setLinkable($identifier, a\Linkable::getLinkable($service, $block->getLinkableId($identifier)));
            }
        }
    }
    $block->setStructuredData($st);
}