symfony API

sfContext Class

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to API menu

1.2 API OpenSearch

Packages

You are currently browsing the symfony API for the 1.2 version. Switch to:
This version of symfony is not maintained anymore.
If some of your projects still use this version, consider upgrading as soon as possible.

sfContext provides information about the current application context, such as the module and action names and the module directory. References to the main symfony instances are also provided.

Method Summary

  • createInstance($configuration, $name = null, $class = __CLASS__)
    Creates a new context instance.
  • dispatch()
    Dispatches the current request.
  • array filterTemplateParameters($event, $parameters)
    Listens to the template.filter_parameters event.
  • object The get($name)
    Gets an object from the current context.
  • string getActionName()
    Retrieve the action name for this context.
  • getActionStack()
    Retrieve the ActionStack.
  • getConfigCache()
    Returns the configuration cache.
  • getConfiguration()
    Returns the configuration instance.
  • getController()
    Retrieve the controller.
  • mixed getDatabaseConnection((name) $name = 'default')
    Retrieve a database connection from the database manager.
  • sfDatabaseManager getDatabaseManager()
    Retrieve the database manager.
  • getEventDispatcher()
    Retrieves the current event dispatcher.
  • getI18N()
    Retrieve the i18n instance
  • getInstance($name = null, $class = __CLASS__)
    Retrieves the singleton instance of this class.
  • getLogger()
    Retrieve the logger.
  • string getModuleDirectory()
    Retrieve the module directory for this context.
  • string getModuleName()
    Retrieve the module name for this context.
  • getRequest()
    Retrieve the request.
  • getResponse()
    Retrieve the response.
  • getRouting()
    Retrieve the routing instance.
  • getStorage()
    Retrieve the storage.
  • getUser()
    Retrieve the user.
  • getViewCacheManager()
    Retrieve the view cache manager
  • bool has($name)
    Returns true if an object is currently stored in the current context with the given name, false otherwise.
  • bool hasInstance($name = null)
    Checks to see if there has been a context created
  • initialize($configuration)
    Initializes the current sfContext instance.
  • loadFactories()
    Loads the symfony factories.
  • retrieveObjects($class, $peerMethod)
  • set($name, $object)
    Puts an object in the current context.
  • setResponse((sfResponse) $response)
    Set the response object.
  • shutdown()
    Execute the shutdown procedure.
  • switchTo($name)
    Sets the current context to something else

Method Details

  • createInstance ($configuration, $name = null, $class = __CLASS__) Browse code

    $configuration An sfApplicationConfiguration instance
    $name A name for this context (application name by default)
    $class The context class to use (sfContext by default)

    Creates a new context instance.

    returns An sfContext instance

  • dispatch () Browse code

    Dispatches the current request.

  • (array) filterTemplateParameters ($event, $parameters) Browse code

    $event An sfEvent instance
    $parameters An array of template parameters to filter

    Listens to the template.filter_parameters event.

    returns The filtered parameters array

  • (object The) get ($name) Browse code

    $name The name of the object to retrieve

    Gets an object from the current context.

    returns object associated with the given name

  • (string) getActionName () Browse code

    Retrieve the action name for this context.

    returns The currently executing action name, if one is set, otherwise null.

  • getActionStack () Browse code

    Retrieve the ActionStack.

    returns the sfActionStack instance

  • getConfigCache () Browse code

    Returns the configuration cache.

    returns A sfConfigCache instance

  • getConfiguration () Browse code

    Returns the configuration instance.

    returns The current application configuration instance

  • getController () Browse code

    Retrieve the controller.

    returns The current sfController implementation instance.

  • (mixed) getDatabaseConnection ((name) $name = 'default') Browse code

    $name A database name.

    Retrieve a database connection from the database manager.


    This is a shortcut to manually getting a connection from an existing database implementation instance.

    If the [sf_use_database] setting is off, this will return null.

    returns A database instance.

    throws sfDatabaseException if the requested database name does not exist.

  • (sfDatabaseManager) getDatabaseManager () Browse code

    Retrieve the database manager.

    returns The current sfDatabaseManager instance.

  • getEventDispatcher () Browse code

    Retrieves the current event dispatcher.

    returns An sfEventDispatcher instance

  • getI18N () Browse code

    Retrieve the i18n instance

    returns The current sfI18N implementation instance.

  • getInstance ($name = null, $class = __CLASS__) Browse code

    $name The name of the sfContext to retrieve.
    $class The context class to use (sfContext by default)

    Retrieves the singleton instance of this class.

    returns An sfContext implementation instance.

  • getLogger () Browse code

    Retrieve the logger.

    returns The current sfLogger implementation instance.

  • (string) getModuleDirectory () Browse code

    Retrieve the module directory for this context.

    returns An absolute filesystem path to the directory of the currently executing module, if one is set, otherwise null.

  • (string) getModuleName () Browse code

    Retrieve the module name for this context.

    returns The currently executing module name, if one is set, otherwise null.

  • getRequest () Browse code

    Retrieve the request.

    returns The current sfRequest implementation instance.

  • getResponse () Browse code

    Retrieve the response.

    returns The current sfResponse implementation instance.

  • getRouting () Browse code

    Retrieve the routing instance.

    returns The current sfRouting implementation instance.

  • getStorage () Browse code

    Retrieve the storage.

    returns The current sfStorage implementation instance.

  • getUser () Browse code

    Retrieve the user.

    returns The current sfUser implementation instance.

  • getViewCacheManager () Browse code

    Retrieve the view cache manager

    returns The current sfViewCacheManager implementation instance.

  • (bool) has ($name) Browse code

    $name The object name

    Returns true if an object is currently stored in the current context with the given name, false otherwise.

    returns true if the object is not null, false otherwise

  • (bool) hasInstance ($name = null) Browse code

    $name The name of the sfContext to check for

    Checks to see if there has been a context created

    returns true is instanced, otherwise false

  • initialize ($configuration) Browse code

    $configuration An sfApplicationConfiguration instance

    Initializes the current sfContext instance.

  • loadFactories () Browse code

    Loads the symfony factories.

  • retrieveObjects ($class, $peerMethod) Browse code

    $class
    $peerMethod

  • set ($name, $object) Browse code

    $name The name of the object to store
    $object The object to store

    Puts an object in the current context.

  • setResponse ((sfResponse) $response) Browse code

    $response An sfResponse instance.

    Set the response object.

  • shutdown () Browse code

    Execute the shutdown procedure.

  • switchTo ($name) Browse code

    $name The name of the context to switch to

    Sets the current context to something else