$FP

Core framework instance for Myna FlightPath

Summary
$FPCore framework instance for Myna FlightPath
Properties
dirMynaPath to the base directory for this FLightPath app
defaultDsShortcut to $FP.config.ds[“default”], the default datsource for this FlightPath app
urlURL to the FlightPath app, minus server name
versionFlightPath version
configConfig from $application.config
Functions
c2fsee camelNameToFileName
camelNameToFileNameConverts the camelCase formatted name of a controller or action to a file name format
f2csee fileNameToCamelName
fileNameToCamelNameConverts the filename formatted name of a controller or action to a camel-cased name format
getControllerfactory function to find a a controller by name, instantiate it, initialize it, and return it.
getControllerNamesreturns an array containing all the available controller names
getModelfactory function that finds, loads, and initializes a model by name
getParamsmarshals parameters from the URL route and any url or form variables, and returns merged params
handleRequestMain entry point for requests
mergeClassesfactory function merges any number of objects, classes, or MynaPaths and returns the result
objectToUrlconverts a JS object into a URL query string.
redirectToredirects the browser to another controller/action, cancels further processing.

Properties

dir

MynaPath to the base directory for this FLightPath app

Example

file:/www/myna_dev/my_app

See: $application.directory

defaultDs

Shortcut to $FP.config.ds[“default”], the default datsource for this FlightPath app

url

URL to the FlightPath app, minus server name

Example

myna_dev/my_app/

See: $application.url

version

FlightPath version

config

Config from $application.config

Functions

c2f

camelNameToFileName

function camelNameToFileName(name)

Converts the camelCase formatted name of a controller or action to a file name format

Parameters

namename to convert

f2c

fileNameToCamelName

function fileNameToCamelName(name,
capFirst)

Converts the filename formatted name of a controller or action to a camel-cased name format

Parameters

namename to convert
capFirstOptional, default false Whether to capitalize the first letter.  Set this to true for controller names

getController

function getController(controllerName)

factory function to find a a controller by name, instantiate it, initialize it, and return it.

This is normally called by <handleAction>, but can also be used to call an action in an arbitrary controller

Parameters

controllerNameName of controller to include

getControllerNames

function getControllerNames(forceReload)

returns an array containing all the available controller names

Parameters

forceRealodDefault false Set to true to bypass caching and re-inspect the controllers on disk

getModel

function getModel(modelName)

factory function that finds, loads, and initializes a model by name

Parameters

modelNamename of model to load

getParams

function getParams()

marshals parameters from the URL route and any url or form variables, and returns merged params

handleRequest

function handleRequest()

Main entry point for requests

mergeClasses

function mergeClasses(classes)

factory function merges any number of objects, classes, or MynaPaths and returns the result

Parameters

classesArray of objects, class functions, or MynaPaths

Detail

Takes a number of “class” entries.  See Class Types below.  Any “init” functions will be chained such that they will executed in LIFO order, i.e the init function on the first argument will be executed last

Class Types

Class FunctionThis is a constructor function.  This will be called with the “new” operator before merging
MynaPath/Myna.FileThis will be included into an empty scope, which will then be merged.
ObjectObjects will merged directly

objectToUrl

function objectToUrl(object,
preserveFpParams)

converts a JS object into a URL query string.

Parameters

objectobject to convert
preserveFpParamsOptional, default false Normally,”controller”,”action” and “id” parameters are ignored.  Setting this to true allows them to be included.

Note

The resulting string will not start with a “?” or a “&”.  This function ignores any properties that start with “$”.  Unless preserveFpParams is set to true, the parameters “controller”, “action” and “id” will also be ignored.  This function is useful for converting controller params into URL params

redirectTo

function redirectTo(options)

redirects the browser to another controller/action, cancels further processing.

Parameters

optionsoptions object, see below

Options

routeOptional, default “default” Name of route to construct
controllerOptional, default null Name of controller to redirect to
actionOptional, default null Name of action to redirect to.  If controller is not also defined, then the current controller is assumed
idOptional, default null ID to redirect to.  If controller or action are not also defined, then the current controller and action is assumed
paramsOptional, default null JS object containing URL parameters to include in the redirect
anchorOptional, default null Anchor (#) string to append to redirect
<others>Any other property will be considered a $flash key.  Any property that starts with “flash” will remove “flash” and be camelCased before using as a flash key
function camelNameToFileName(name)
Converts the camelCase formatted name of a controller or action to a file name format
function fileNameToCamelName(name,
capFirst)
Converts the filename formatted name of a controller or action to a camel-cased name format
function getController(controllerName)
factory function to find a a controller by name, instantiate it, initialize it, and return it.
function getControllerNames(forceReload)
returns an array containing all the available controller names
function getModel(modelName)
factory function that finds, loads, and initializes a model by name
function getParams()
marshals parameters from the URL route and any url or form variables, and returns merged params
function handleRequest()
Main entry point for requests
function mergeClasses(classes)
factory function merges any number of objects, classes, or MynaPaths and returns the result
function objectToUrl(object,
preserveFpParams)
converts a JS object into a URL query string.
function redirectTo(options)
redirects the browser to another controller/action, cancels further processing.
MynaPath of directory of closest application.sjs CALCULATED
URL path of closest application.sjs CALCULATED