Ferreteria/v2/class/fcLink fromArray: Difference between revisions

From Woozle Writes Code
< Ferreteria‎ | v2‎ | class
Jump to navigation Jump to search
(Created page with "{{page/code/class}} <source lang=php> class fcLink_fromArray extends fcMenuLink { →‎---- CEMENT: protected function GetLinkURL() { $arPath = $this->GetLin...")
 
No edit summary
Line 1: Line 1:
{{page/code/class}}
{{page/code/class}}
* '''file''': {{l/ferreteria/file|menu/items.php}}
* '''extends''': {{l/version|class|fcMenuLink}}
* '''extender''': {{l/version|class|fcDynamicLink}}
<source lang=php>
<source lang=php>
class fcLink_fromArray extends fcMenuLink {
class fcLink_fromArray extends fcMenuLink {
Line 50: Line 53:
}
}
</source>
</source>
* '''file''': {{l/ferreteria/file|menu/items.php}}
* '''extends''': {{l/version|class|fcMenuLink}}
* '''extender''': {{l/version|class|fcDynamicLink}}

Revision as of 17:10, 19 January 2019

Template:Page/code/class

class fcLink_fromArray extends fcMenuLink {
    /*----
      CEMENT
    */
    protected function GetLinkURL() {
	$arPath = $this->GetLinkArray();
	$fpArgs = fcURL::FromArray($arPath);
	return $this->MakeURL_fromPath($fpArgs);
    }
    /*----
      NEW
      PURPOSE: returns the array to use for calculating link URL
    */
    protected function GetLinkArray() {
	return array_merge(
	  $this->GetLinkArray_figured(),
	  $this->GetLinkArray_added()
	  );
    }
    private $arContext;
    public function AddLinkArray(array $ar) {
	$this->arContext = array_merge($this->GetLinkArray_added(),$ar);
    }
    protected function GetLinkArray_added() {
	return isset($this->arContext) ? $this->arContext : array();
    }
    /*----
      NEW
      PURPOSE: calculates self-identifying array
    */
    // PUBLIC for testing
    public function GetLinkArray_self() {
	$sValue = $this->GetKeyValue();
	$sName = $this->GetKeyName();
	return array($sName=>$sValue);
    }
    /*----
      NEW
      PURPOSE: gets the part of the link array which might change
      NOTE: There originally was code to handle value-only paths --
	    $arPath = array($sValue=>(!$isSel));
	-- but it's not clear that this is actually necessary.
	Wait for a usage case, and then test.
    */
    protected function GetLinkArray_figured() {
	return $this->GetLinkArray_self();
    }
}