Gdn::factory PHP Method

factory() public static method

Get an object from the factory.
See also: Gdn_Factory::Factory()
public static factory ( string $Alias = false )
$Alias string The alias of the class.
    public static function factory($Alias = false)
    {
        if (is_null(self::$_Factory)) {
            self::setFactory(new Gdn_Factory());
            self::factoryOverwrite(false);
        }
        if ($Alias === false) {
            return self::$_Factory;
        }
        // Get the arguments to pass to the factory.
        //$Args = array($Arg1, $Arg2, $Arg3, $Arg4, $Arg5);
        $Args = func_get_args();
        array_shift($Args);
        return self::$_Factory->factory($Alias, $Args);
    }

Usage Example

Example #1
0
/**
 * Writes the search box to the page.
 *
 * @param array The parameters passed into the function. This currently takes no parameters.
 * @param $smarty The smarty object rendering the template.
 * @return The url.
 */
function smarty_function_searchbox($params, &$smarty)
{
    $placeholder = array_key_exists('placeholder', $params) ? val('placeholder', $params, '', true) : t('SearchBoxPlaceHolder', 'Search');
    $form = Gdn::factory('Form');
    $result = $form->open(array('action' => url('/search'), 'method' => 'get')) . $form->textBox('Search', array('placeholder' => $placeholder, 'accesskey' => '/')) . $form->button('Go', array('Name' => '')) . $form->close();
    return $result;
}
All Usage Examples Of Gdn::factory