org.codehaus.enunciate.modules.php
Class PHPDeploymentModule

java.lang.Object
  extended by org.codehaus.enunciate.modules.BasicDeploymentModule
      extended by org.codehaus.enunciate.modules.FreemarkerDeploymentModule
          extended by org.codehaus.enunciate.modules.php.PHPDeploymentModule
All Implemented Interfaces:
EnunciateClasspathListener, EnunciateModelAware, DeploymentModule

public class PHPDeploymentModule
extends FreemarkerDeploymentModule
implements EnunciateClasspathListener

PHP Module

The PHP module generates PHP data types that can be used in conjunction with the PHP JSON implementation to (de)serialize the REST resources as they are represented as JSON data.

The order of the PHP deployment module is 0, as it doesn't depend on any artifacts exported by any other module.

Configuration

The PHP module is configured with the "php" element under the "modules" element of the enunciate configuration file. It supports the following attributes:

The "package-conversions" element

The "package-conversions" subelement of the "php" element is used to map packages from the original API packages to PHP modules. This element supports an arbitrary number of "convert" child elements that are used to specify the conversions. These "convert" elements support the following attributes:

The "facets" element

The "facets" element is applicable to the Ruby module to configure which facets are to be included/excluded from the Ruby artifacts. For more information, see API Facets

Author:
Ryan Heaton

Field Summary
 
Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
enunciate
 
Constructor Summary
PHPDeploymentModule()
           
 
Method Summary
 void addClientPackageConversion(PackageModuleConversion conversion)
          Add a client package conversion.
 void addFacetExclude(String name)
          Add a facet exclude.
 void addFacetInclude(String name)
          Add a facet include.
protected  void doBuild()
           
 void doFreemarkerGenerate()
           
protected  boolean existsAnyJsonResourceMethod(List<RootResource> rootResources)
          Whether any root resources exist that produce json.
protected  String getBundleFileName()
          The name of the bundle file.
 org.apache.commons.digester.RuleSet getConfigurationRules()
           
 Set<String> getFacetExcludes()
          The set of facets to exclude.
 Set<String> getFacetIncludes()
          The set of facets to include.
 String getLabel()
          The label for the PHP API.
 String getName()
           
protected  freemarker.template.ObjectWrapper getObjectWrapper()
           
 Map<String,String> getPackageToModuleConversions()
          The package-to-module conversions.
protected  String getSourceFileName()
          The name of the generated PHP source file.
protected  URL getTemplateURL(String template)
          Get a template URL for the template of the given name.
 Validator getValidator()
           
 void initModel(EnunciateFreemarkerModel model)
           
 boolean isDisabled()
           
 boolean isForceEnable()
          Whether to force-enable the PHP module.
 boolean isSingleFilePerClass()
          Whether there should be a single file per class.
 void onClassesFound(Set<String> classes)
           
protected  String packageToModule(String pckg)
           
protected  String readResource(String resource)
          Reads a resource into string form.
 void setForceEnable(boolean forceEnable)
          Whether to force-enable the PHP module.
 void setLabel(String label)
          The label for the PHP API.
 void setSingleFilePerClass(boolean singleFilePerClass)
          Whether there should be a single file per class.
 
Methods inherited from class org.codehaus.enunciate.modules.FreemarkerDeploymentModule
close, doGenerate, getConfiguration, getModel, getModelInternal, getTemplateExceptionHandler, getTemplateLoader, processTemplate, processTemplate, processTemplate, processTemplate
 
Methods inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
debug, doCompile, doPackage, getAliases, getBuildDir, getCompileDir, getEnunciate, getGenerateDir, getOrder, getPackageDir, info, init, setBuildDir, setCompileDir, setDisabled, setGenerateDir, setPackageDir, step, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PHPDeploymentModule

public PHPDeploymentModule()
Method Detail

getName

public String getName()
Specified by:
getName in interface DeploymentModule
Overrides:
getName in class BasicDeploymentModule
Returns:
"php"

onClassesFound

public void onClassesFound(Set<String> classes)
Specified by:
onClassesFound in interface EnunciateClasspathListener

initModel

public void initModel(EnunciateFreemarkerModel model)
Specified by:
initModel in interface EnunciateModelAware
Overrides:
initModel in class FreemarkerDeploymentModule

packageToModule

protected String packageToModule(String pckg)

doFreemarkerGenerate

public void doFreemarkerGenerate()
                          throws IOException,
                                 freemarker.template.TemplateException,
                                 EnunciateException
Specified by:
doFreemarkerGenerate in class FreemarkerDeploymentModule
Throws:
IOException
freemarker.template.TemplateException
EnunciateException

doBuild

protected void doBuild()
                throws EnunciateException,
                       IOException
Overrides:
doBuild in class BasicDeploymentModule
Throws:
EnunciateException
IOException

getBundleFileName

protected String getBundleFileName()
The name of the bundle file.

Returns:
The name of the bundle file.

readResource

protected String readResource(String resource)
                       throws IOException,
                              EnunciateException
Reads a resource into string form.

Parameters:
resource - The resource to read.
Returns:
The string form of the resource.
Throws:
IOException
EnunciateException

getSourceFileName

protected String getSourceFileName()
The name of the generated PHP source file.

Returns:
The name of the generated PHP source file.

getObjectWrapper

protected freemarker.template.ObjectWrapper getObjectWrapper()
Overrides:
getObjectWrapper in class FreemarkerDeploymentModule

getTemplateURL

protected URL getTemplateURL(String template)
Get a template URL for the template of the given name.

Parameters:
template - The specified template.
Returns:
The URL to the specified template.

isForceEnable

public boolean isForceEnable()
Whether to force-enable the PHP module.

Returns:
Whether to force-enable the PHP module.

setForceEnable

public void setForceEnable(boolean forceEnable)
Whether to force-enable the PHP module.

Parameters:
forceEnable - Whether to force-enable the PHP module.

getLabel

public String getLabel()
The label for the PHP API.

Returns:
The label for the PHP API.

setLabel

public void setLabel(String label)
The label for the PHP API.

Parameters:
label - The label for the PHP API.

getPackageToModuleConversions

public Map<String,String> getPackageToModuleConversions()
The package-to-module conversions.

Returns:
The package-to-module conversions.

addClientPackageConversion

public void addClientPackageConversion(PackageModuleConversion conversion)
Add a client package conversion.

Parameters:
conversion - The conversion to add.

getConfigurationRules

public org.apache.commons.digester.RuleSet getConfigurationRules()
Specified by:
getConfigurationRules in interface DeploymentModule
Overrides:
getConfigurationRules in class BasicDeploymentModule

getValidator

public Validator getValidator()
Specified by:
getValidator in interface DeploymentModule
Overrides:
getValidator in class BasicDeploymentModule

getFacetIncludes

public Set<String> getFacetIncludes()
The set of facets to include.

Returns:
The set of facets to include.

addFacetInclude

public void addFacetInclude(String name)
Add a facet include.

Parameters:
name - The name.

getFacetExcludes

public Set<String> getFacetExcludes()
The set of facets to exclude.

Returns:
The set of facets to exclude.

addFacetExclude

public void addFacetExclude(String name)
Add a facet exclude.

Parameters:
name - The name.

isSingleFilePerClass

public boolean isSingleFilePerClass()
Whether there should be a single file per class. Default: false (all classes are contained in a single file).

Returns:
Whether there should be a single file per class.

setSingleFilePerClass

public void setSingleFilePerClass(boolean singleFilePerClass)
Whether there should be a single file per class.

Parameters:
singleFilePerClass - Whether there should be a single file per class.

isDisabled

public boolean isDisabled()
Specified by:
isDisabled in interface DeploymentModule
Overrides:
isDisabled in class BasicDeploymentModule

existsAnyJsonResourceMethod

protected boolean existsAnyJsonResourceMethod(List<RootResource> rootResources)
Whether any root resources exist that produce json.

Parameters:
rootResources - The root resources.
Returns:
Whether any root resources exist that produce json.


Copyright © 2015. All rights reserved.