Getting System Assets into System Management

Hey guys,


I've got a system asset loading into MSM without any errors but it's not appearing in the System Management folder in the asset manager.



I think I know where this might not be working for me… In the example file you sent (package_manager_yourpackage.inc) there is the following function;

      function &createYourSystemAsset()
      {
        // we get the system management folder asset that we will use as the parent for our new system asset
        $system_management_folder = &$GLOBALS['SQ_SYSTEM']->am->getAsset($GLOBALS['SQ_SYSTEM_ASSETS']['system_management_folder']);
    
        // create a new system asset
        $GLOBALS['SQ_SYSTEM']->am->includeAsset('your_system_asset');
        $your_system_asset = new Search_Manager();
        $your_system_asset_link = Array('asset' => &$system_management_folder, 'link_type' => SQ_LINK_TYPE_1, 'exclusive' => 1);
        if (!$your_system_asset->create($your_system_asset_link)) trigger_error('Your System Asset NOT CREATED', E_USER_ERROR);
        pre_echo('Your System Asset Asset Id : '.$your_system_asset->id);
    
        $GLOBALS['SQ_SYSTEM_ASSETS']['your_system_asset'] = $your_system_asset->id;
    
        return $your_system_asset;
    }


In my version of this file I've made a few changes that seemed obvious but I'm wondering if the are now. Every occurance of [i]your_system_asset[/i] has been replaced with [i]doc_importer[/i] so, for example [i]$your_system_asset_link[/i] became [i]$doc_importer_link[/i]

I don't see how this could have prevented things working and suspect it would be needed in order to get a package with several system assets to load them all in.

I've also done the same thing with the function name renaming it based on the type_code.
i.e. asset.xml has this; <type_code>doc_importer</type_code> and I've named the function createDocImporter().

I'm pretty sure I've either missed something or something was not covered in the examples that were sent. I'm thinking that createDocImporter() need to be called somewhere or something in there isn't quite right.

The following is the actual function I'm using.;
      function &createDocImporter()
      {
        // we get the system management folder asset that we will use as the parent for our new system asset
        $system_management_folder = &$GLOBALS['SQ_SYSTEM']->am->getAsset($GLOBALS['SQ_SYSTEM_ASSETS']['system_management_folder']);
 &nbsp; &nbsp;// create a new system asset
 &nbsp; &nbsp;$GLOBALS['SQ_SYSTEM']->am->includeAsset('doc_importer');
 &nbsp; &nbsp;$doc_importer = new Doc_Importer();
 &nbsp; &nbsp;$doc_importer_link = Array('asset' => &$system_management_folder, 'link_type' => SQ_LINK_TYPE_1, 'exclusive' => 1);
 &nbsp; &nbsp;if (!$doc_importer->create($doc_importer_link)) trigger_error('Document Importer Asset NOT CREATED', E_USER_ERROR);
 &nbsp; &nbsp;pre_echo('Doc Importer Asset Id : '.$doc_importer->id);

 &nbsp; &nbsp;$GLOBALS['SQ_SYSTEM_ASSETS']['doc_importer'] = $doc_importer->id;

 &nbsp; &nbsp;return $doc_importer;

 &nbsp;}</pre><br />

Any thoughts on this one?

Cheers,
Gold

What is the output from running step_03? Does it tell you the doc_importer was not installed or does it give you its assetid?


If you dont get any output, this function is porbably not getting called. Make sure you've also changed the getSystemAssetTypes() function in the file to list your doc_importer asset type.

As far as I can see it's working fine. These are the last few lines; EDIT: ok, not the last few lines

    Install Order :
    
    0 => "page",
    1 => "design_area",
    2 => "design",
    3 => "design_area_menu_type",
    4 => "design_area_menu_recursive",
    5 => "design_area_menu_normal",
    6 => "design_area_body",
    7 => "design_area_nest_content",
    8 => "design_area_declared_vars",
    9 => "design_area_metadata",
    10 => "design_area_custom_image",
    11 => "design_area_datetime",
    12 => "design_area_constant_button",
    13 => "design_area_colourise_image",
    14 => "design_area_asset_lineage",
    15 => "design_area_login_form",
    16 => "design_customisation",
    17 => "metadata_field",
    18 => "file",
    19 => "image",
    20 => "thumbnail",
    21 => "user",
    22 => "inbox",
    23 => "backend_user",
    24 => "page_standard",
    25 => "bridge",
    26 => "folder",
    27 => "workflow_schema",
    28 => "workflow_step_condition",
    29 => "workflow_step",
    30 => "cron_manager",
    31 => "cron_job",
    32 => "trash_folder",
    33 => "layout_manager",
    34 => "designs_folder",
    35 => "root_folder",
    36 => "system_management_folder",
    37 => "authentication",
    38 => "authentication_folder",
    39 => "system_user",
    40 => "remap_manager",
    41 => "login_design",
    42 => "bodycopy_container",
    43 => "bodycopy_div",
    44 => "bodycopy_table",
    45 => "bodycopy",
    46 => "content_type",
    47 => "site",
    48 => "design_area_menu_stalks",
    49 => "metadata_field_select",
    50 => "metadata_field_date",
    51 => "metadata_field_text",
    52 => "metadata_schema",
    53 => "metadata_section",
    54 => "workspace",
    55 => "user_group",
    56 => "content_type_wysiwyg",
    57 => "layout",
    58 => "cron_job_future_status",
    59 => "cron_job_future_lineage",
    60 => "system_user_group",
    61 => "root_user",
    62 => "authentication_default" 
    
    Install Order :
    
    0 => "page_redirect",
    1 => "page_asset_listing" 
    
    Install Order :
    
    0 => "redirector",
    1 => "doc_importer" 
    
    Install Order :
    
    0 => "page_redirect",
    1 => "page_asset_listing" 
    
    Install Order :
    
    0 => "redirector",
    1 => "doc_importer"


This is interspersed with a [i]lot[/i] of the Undefined property: parser type errors but it's been established that this isn't actually a problem. I notice that the last 2 Install Orders get repeated. This has always happened and the other asset (Redirector) works fine.

Is this what you were after?

Firstly is the your system asset installed ?


In your DB check :



SELECT * FROM sq_asset WHERE type_code = 'doc_importer';



Secondly that list of things under the "Install Order :" headings are only showing you what asset types are being installed/updated. It has nothing to do with installing system assets.



If the system asset was installed you should have got something like this :


    Doc Importer Asset Id : 1234



As Greg mentioned do you have getSystemAssetTypes() function in your package class ?

Check core/assets/package_manager_core.inc for an example of what it is.

The repeat is normal - you can ignore it.


AS for the output, what I'm after is evidence that the function is being called. It doesnt look like it is. The function will print one of the following message:

Document Importer Asset NOT CREATED (and then die) OR

Doc Importer Asset Id : <ASSETID>



Doesn't look like its getting there. Can you send me the files so I can do a test run from here.

[quote]Firstly is the your system asset installed ?


In your DB check :



    SELECT * FROM sq_asset WHERE type_code = 'doc_importer';[/quote]



Hmm… Doesn't appear to be installing after all.


[quote]Secondly that list of things under the "Install Order :" headings are only showing you what asset types are being installed/updated. It has nothing to do with installing system assets.[/quote]

I was wondering about that. Apart from the Undefined property: parser errors though there's not other output. Is this something new in RC2? I've not yet had time to do the upgrade.


[quote]If the system asset was installed you should have got something like this :


    Doc Importer Asset Id : 1234



As Greg mentioned do you have getSystemAssetTypes() function in your package class ?

Check core/assets/package_manager_core.inc for an example of what it is.[/quote]

Hmm... this function isn't in this file on my local install. Another RC1 vs. RC2 thing maybe?

Yep. Got that. Just out of interest though, why does it repeat the extra packages like that?

[quote]AS for the output, what I'm after is evidence that the function is being called. It doesnt look like it is. The function will print one of the following message:
Document Importer Asset NOT CREATED (and then die) OR
Doc Importer Asset Id : <ASSETID>

Doesn't look like its getting there. Can you send me the files so I can do a test run from here.[/quote]

Agreed.

I've not seen these Asset ID lines for anything else though. Another difference between RC1 and RC2?

I've PM'd you a link so you can grab the archive.

The packages repeat because some assets (like search_manager) require a list of all asset types that are installed when they are installed. Because the install order can only be set per package, the search manager could be installed before a bunch of new asset types - so the search manager didnt know about them. Hence the running of that part of the install twice.


This will be changed to use the event management system eventually so the search_manager will catch events fired when new asset types are installed.

These lines are only displayed when the install script first installs a system asset (the next time the install script runs that asset is already installed).

Hmm… The upgrade to RC2 seems to have gone smoothly. I also re-ran the web installer and now the Document Importer appears in the System Management folder.


It is appearing as "Document Importer #653" though. Anyone know what the deal with the number is?

653 is its asset id :slight_smile:

I was wondering if that was the case. None of the others have it though. I take it this is because my asset is the only one from packages directory?

Ohh, wait, you mean that's the name of the asset as it appears in the listing? I thought you meant when you hover over it… hmm, are you sure the name isn't having anything appended to it?

If you dont set a name in the create function, the asset will get a default name. I forgot to mention this.


Add a function to the doc_importer.inc file to return a better name:

    /**
    * Returns name of the asset
    *
    * @param bool   $short_name     whether or not we are after the shortname or the full name
    *
    * @see Asset::_getName()
    * @access private
    */
    function _getName($short_name=false)
    {
        return $GLOBALS['SQ_SYSTEM']->am->getTypeInfo($this->type(), 'name');
    
    }//end _getName();

Doesn't seem to be being called.


I've tried echoing the value, echoing "here" and exiting, returning a string literal… during Step 16 (web installer) _getname doesn't appear to be being called. Is there any way to force this to be called? Do I have to start at an earlier step or change a version number somewhere maybe?

_getName() get's called mainly when _updated() get's called and it's results are placed in the sq_asset table in the "name" and "short_name" fields.


In other words to force it to change, make a change to the asset somehow.