Documentation


SEARCH

TABLE OF CONTENT

    1. Getting started 2. Basic concepts 3. Request dispatching 4. Context container 5. Dual MVC 6. Component model: 7. Security 8. Configuration 9. Session handling 10. I18n 11. Cache 12. Logging 13. Error handling 14. Advanced Topics 15. API reference

      Tutorials: Frequently Asqued Questions

      See also:


      Class: __ResourceComponent


      Class Overview

      A resource is basically a I18n string. This component allow us to print whatever resource within a page content.


      Resources associated to a given controller are automatically set to the template used by the controller's view.

      i.e., a resource with a key "my_resource" associated to a controller will be shown in a placeholder with the same name within the correspondent view template:

      1.    Here is my resource content{$my_resource}

      Other resources, even if they are persisted during the session but not directly associated to the executed controller, are not set to the template automatically.
      To render them, we have the resource component.

      Resource tag is resource

      i.e.
      1.    Here is our session content:  <comp:resource key="my_session_resource"/>

      We just specify the key the resource has in order to render it within the template content

      Another interesting usage of this component is to render parameterized resources.
      i.e.
      1.  my_parameterized_resource "Dear {0}, this is a parameterized I18n resource"

      As we can see, the resource above has a parameter just after the "Dear" word. So we need to specify the value that will be replaced instead of the placeholder.
      To do that, the resource component has the attribute parameters, which allow us to specify a comma-separate list of values to be replaced by.
      i.e.

      1.    <comp:resource key="my_parameterized_resource" parameters="0=Antuan"/>
      Which will produce the following result:
      1.    Dear Antuanthis is a parameterized I18n resource

      Take into account that you must apply a comma-separated list of pair key,value as parameters.

      With template tags we are not able to specify parameters to resources, so this is another usage of this component even if resources belong to the current in execution controller.


      __UIComponent
         |
         --__ResourceComponent

      Methods

      [ Top ]

      Inherited Properties, Constants, and Methods

      Inherited Properties Inherited Methods Inherited Constants

      Inherited From __UIComponent

      Inherited From __UIComponent


      [ Top ]

      Method Summary

      string   getKey()   Get the key of the resource to render to
      array   getParameters()   Get the array of parameters to use with the current resource
      void   setKey()   Set the key of the resource to render to
      void   setParameters()   Set either a comma-separated list of parameters or an array of them
      string   __toString()   Magic method representing the result of rendering the current resource

      [ Top ]

      Properties

      Methods

      getKey


        string getKey( )

      Get the key of the resource to render to

      Access:  public



      getParameters


        array getParameters( )

      Get the array of parameters to use with the current resource

      Access:  public



      setKey


        void setKey( string $key  )

      Set the key of the resource to render to


      Parameters:
      TypeNameDescription
      string $key

      Access:  public



      setParameters


        void setParameters( mixed $parameters  )

      Set either a comma-separated list of parameters or an array of them


      Parameters:
      TypeNameDescription
      mixed $parameters

      Access:  public



      __toString


        string __toString( )

      Magic method representing the result of rendering the current resource

      Access:  public


      Redefinition of:
      __UIComponent::__toString()