SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Boston
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Phrame: MappingMgr Question

    I've dug through the innards of Phrame and have figured out how each of the attributes set in the MappingManager get processed by the ActionController -- except for one: psInput.

    The third variable passed into the _AddMapping() method, called $psInput, is said to the "the default location where the action is called." I see that it get called in the MappingManager::_AddForward() method as the default forward path. But what exactly is the role of this variable?

    Here's an example: Take the HelloWorld example from the php|a article last May. The MappingMgr was less mature, but the concept still applies.

    PHP Code:
    function HelloMap()
        {
            
    //set options
            
    $this->_SetOptions('handle_error');
            
            
    //add application forms
            
    $this->_AddForm('helloForm''ActionForm');
            
            
    //add application actions and forwards
            
    $this->_AddMapping('sayHello''HelloAction'APPL_VIEW.'index',  'helloForm');
            
    $this->_AddForward('sayHello''index');
            
    $this->_AddForward('sayHello''hello'APPL_VIEW.'hello');
        } 
    The psInput variable is set either to APPL_VIEW.'index', or (as the Path variable in the ActionForward) to APPL_VIEW.'hello'. Yet I see no change in the URL when executing the code in the browser, nor do I get the concept of "the default location where the action is called" from the example. Can anyone clarify this for me?

    Thanks!

  2. #2
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi bostoncello,

    The purpose of this class was to facilitate constructing an array that was in the proper form for Phrame to consume Here is an example from the Phrame 2.0 release examples:
    PHP Code:
    <?php
    //build mapping information to pass into controller
    $mappings = array(
        
    _ACTION_FORMS => array(
            
    'form' => array(
                
    _TYPE => 'HelloForm'
            
    )
        ),
        
    _ACTION_MAPPINGS => array(
            
    'sayHello' => array(
                
    _TYPE => 'HelloAction',
                
    _NAME => 'form',
                
    _INPUT => 'index.php?view=views/index.xsl',
                
    _VALIDATE => 1,
                
    _ACTION_FORWARDS => array(
                    
    'hello' => array(
                        
    _PATH => 'index.php?view=views/hello.xsl',
                        
    _REDIRECT => 0
                    
    ),
                    
    'index' => array(
                        
    _PATH => 'index.php?view=views/index.xsl',
                        
    _REDIRECT => 0
                    
    )
                )
            )
        )
    );
    ?>
    So $psInput corresponds to the _INPUT key of the mappings array.

    Checking throught the source, I find that:
    Code:
    > find . -name "*" -exec grep _INPUT {} /dev/null \;
    ./ActionMapping.php:            $this->setInput($mapping[_INPUT]);
    ./Constants.php:define('_INPUT', '_input');
    ./MappingManager.php:                   ,_INPUT                         => $psInput
    ./MappingManager.php:    *      @param  string  $psPath optional - the path to use, will default to the mapping _INPUT
    ./MappingManager.php:                   $psPath = $this->_aaMap[_ACTION_MAPPINGS][$psMapIdent][_INPUT];
    so it looks like the constant is defined, and I use it in the mapping class, so the only potential place for it to do any work is as $this->setInput in the ActionMapping class, however:
    Code:
    > grep setInput ActionMapping.php
                    $this->setInput($mapping[_INPUT]);
            function setInput($input)
    so at first blush, it looks like that input is vestigal.

    HTH
    Jason Sweat ZCE - jsweat_php@yahoo.com
    Book: PHP Patterns
    Good Stuff: SimpleTest PHPUnit FireFox ADOdb YUI
    Detestable (adjective): software that isn't testable.

  3. #3
    SitePoint Member
    Join Date
    Sep 2003
    Location
    Boston
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Jason. I'm building a how-to on the MappingManager and will integrate the "vestigial-ness" of psInput into the doc (primarily for the web-person at my client's shop). I'll pm you with the doc before I post it here.

    Will you be modifying the MappingManager?

  4. #4
    eschew sesquipedalians silver trophy sweatje's Avatar
    Join Date
    Jun 2003
    Location
    Iowa, USA
    Posts
    3,749
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is already an optional parameter so hopefully it does not get in the way too much . Phrame is getting ready to release a phrame-2.1RC1 so I will try to look into it more then.

    Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •