eZPublish  4.7
eZSiteInstaller Class Reference

A set of functions to do web-site installation from command-line. More...

Public Member Functions

 addClassAttributes ($params)
 addPoliciesForRole ($params)
 addSetting ($name, $value)
 assignUserToRole ($params)
 buildFunctionParams (&$params)
 classByIdentifier ($params)
 classIDbyIdentifier ($params)
 contentObjectByName ($params)
 contentObjectByUrl ($params)
 createContentObject ($params)
 createContentSection ($params)
 createSiteAccess ($params)
 createSiteaccessUrls ($params)
 dbBegin ($params)
 dbCommit ($params)
 defaultErrorHandler ()
 execFunction ($function)
 executeSteps ($steps)
 extractHostname ($uri)
 eZSiteInstaller ($parameters=false)
 handleError ()
 hasSetting ($name)
 initSettings ($parameters)
 initSteps ()
instance ($params)
 isFunctionParam ($param)
 languageNameFromLocale ($locale)
 languageNameListFromLocaleList ($localeList)
 lastErrorCode ()
 moveTreeNode ($params)
 nodeByName ($params)
 nodeByUrl ($params)
 nodeIdByName ($params)
 nodePathStringByURL ($params)
 packageFileItemPath ($params)
 postInstall ()
 postInstallSteps ()
 removeClassAttribute ($params)
 removeContentObject ($params)
 removePoliciesForRole ($params)
 renameContentObject ($params)
 reportError ($text, $caption, $errCode=eZSiteInstaller::ERR_ABORT)
 sectionIDbyName ($params)
 setLastErrorCode ($errCode)
 setRSSExport ($params)
 setSection ($params)
 setting ($name)
 setVersion ($params=false)
 solutionName ()
 solutionVersion ()
 swapNodes ($params)
 updateClassAttributes ($params)
 updateContentObjectAttributes ($params)
 updateINIFiles ($params)
 updateObjectAttributeFromString ($params)
 updatePreferences ($params)
 updateRoles ($params)

Static Public Member Functions

 getParam ($params, $name, $defaultValue=false)

Public Attributes

const ERR_ABORT = 1
const ERR_CONTINUE = 2
const ERR_OK = 0

Detailed Description

A set of functions to do web-site installation from command-line.

Helps simplify installation process by providing a set of steps which will be executed sequentially. This class contains a common functions which can be reused in particular installations.

Member Function Documentation

eZSiteInstaller::addClassAttributes (   $params)

Add attribute to the content class Params: array( 'class' => array( 'identifier' => optional, string: identifire of content class; see 'id'; 'id' => optional, ID of content class. if set it's used instead of 'class_identifier' to speed up things. you must supply either 'class_identifier' or 'class_id'; ), 'attributes' => array( array( 'identifier' => attibute identifier, 'name' => attribute name, 'data_type_string' => attribute datatype, 'default_value' => optional, attribute default value, default is 'false' 'can_translate' => optional, default '1' 'is_required' => optional, default '0' 'is_searchable' => optional, default '0' 'content' => optional, attribute content ), ... );

eZSiteInstaller::addPoliciesForRole (   $params)

Add policies from role Params: role_name - name of role; policies - array of policies to remove. Each item is an array of policy definition: array( 'module' => 'function' => ['limitation'] => ); create_role - boolean, optional. If TRUE - will create new role if it doesn't exist. Default is TRUE.

eZSiteInstaller::addSetting (   $name,

Add setting with $name and $value.

eZSiteInstaller::assignUserToRole (   $params)

Assign user to role. Params: location - path to user node where user object is located; role_name - name of role to assign;

eZSiteInstaller::buildFunctionParams ( $params)

Prepare parameters for function executed in step definition.

Referenced by execFunction().

eZSiteInstaller::classByIdentifier (   $params)

Return content class. Params: 'identifier' - identifier of the class.

Referenced by addClassAttributes(), and classIDbyIdentifier().

eZSiteInstaller::classIDbyIdentifier (   $params)

Return ID of the content class. Params: 'identifier' - identifier of the class.

Referenced by updateClassAttributes().

eZSiteInstaller::contentObjectByName (   $params)

Return content object. The first object is returned in case if several objects have the same name. Params: 'name' - object's name to look up; 'class_id' - optional, ID of content class;

Referenced by nodeByName(), and removeContentObject().

eZSiteInstaller::contentObjectByUrl (   $params)

Return content object by path identification string of its node. Params: 'location' - path_identification_string of the node.

Referenced by updateObjectAttributeFromString().

eZSiteInstaller::createContentObject (   $params)

Create content object. Params: class_identifier - identifier of class; location - path identification string of parent node; attributes - array with object attributes;

eZSiteInstaller::createContentSection (   $params)

Create new content section. Params: 'name' - string: section name; 'navigation_part_identifier' - string: identifier of navigation part;

eZSiteInstaller::createSiteAccess (   $params)

Create localized siteaccess: copy general setting form 'source' siteaccess, apply new custom settings(locale, others...).

Referenced by createTranslationSiteAccesses().

eZSiteInstaller::createSiteaccessUrls (   $params)

Create siteaccess urls for additional user siteacceses using info about access type(host, post, uri) Params: 'siteaccess_list' - list of siteaccess names to build urls; 'access_type' - access type: port, hostname, url; 'access_type_value' - access type value provided by setup wizard 'exclude_port_list' - optional, ports to skip. used if 'access_type' is 'port'; 'host' - host name 'host_prepend_siteaccess' - optional, boolean which instructs to prepend the site access name or not to the value of 'host', by default true

eZSiteInstaller::dbBegin (   $params)

Start transaction. Params: no params

eZSiteInstaller::dbCommit (   $params)

Commit transaction. Params: no params

eZSiteInstaller::defaultErrorHandler ( )

Default error handler

Referenced by executeSteps().

eZSiteInstaller::execFunction (   $function)

Execute $function defined in step

Referenced by buildFunctionParams(), and executeSteps().

eZSiteInstaller::executeSteps (   $steps)

Execute $steps

Referenced by postInstall().

eZSiteInstaller::extractHostname (   $uri)

Helper function used for extracting hostname from the given


Referenced by createSiteaccessUrls().

eZSiteInstaller::eZSiteInstaller (   $parameters = false)
eZSiteInstaller::getParam (   $params,
  $defaultValue = false 

Return a value from $params hash. Return $defaultValue is value is not set. $name - a key in $params hash. $name can point to 2-dimensional array. example: $name = 'foo' will return $params['foo']; $name = 'foo/boo' will return $params['foo']['boo']

eZSiteInstaller::handleError ( )

Virtual function to re-implement in derived classes to handle error. Default error handler will be called if returns FALSE.

Referenced by executeSteps().

eZSiteInstaller::hasSetting (   $name)

Return TRUE if setting exist, otherwise FALSE.

Referenced by setting().

eZSiteInstaller::initSettings (   $parameters)

Initialize $Settings member with custom values which can be used in install steps.

Referenced by eZSiteInstaller().

eZSiteInstaller::initSteps ( )
 Define install steps
 Step definition:
     array( '_function' => <function_name>,
            '_params' => array( <param_list> ) )
     where '_function' defines function name(which should be implemented within installer class) which will be called,
           '_params' is an array of parameters which will be passed to function <function_name>. Note that items of <param_list>
           can be defined in the form as <step definition> and this rule can be applied recursively.

 Each function used in step definition should be defined as:
 function someFunction( $params )

you code goes here ...

optionally you can set $LastErrorCode to 'eZSiteInstaller::ERR_ABORT' if you want to break installation if some step is failed. $this->setLastErrorCode( eZSiteInstaller::ERR_ABORT ); }

Example: array( '_function' => 'step_1', '_params' => array( 'param_a' => 'foo', 'param_b' => array( '_function' => 'helper_function_for_b', '_params' => array( 'param_b_a' => 'goo', 'param_b_b' => array( '_function' => 'helper_functin_for_b_b', '_params' => array( 'param_b_b_a' => 'b_b_a' ) ) ) ) ) ); Execution flow:

  • $b_b = helper_function_b_b( array( 'param_b_b_a' => 'b_b_a' ) );
  • $b = helper_function_for_b( array( 'param_b_a' => 'goo', 'param_b_b' => $b_b ) );
  • $result = step_1( array( 'param_a' => 'foo', 'param_b' => $b ) );

Referenced by eZSiteInstaller().

& eZSiteInstaller::instance (   $params)
eZSiteInstaller::isFunctionParam (   $param)

Return TRUE is custom function should be called to prepare params, otherwise FALSE( $param is constant).

Referenced by buildFunctionParams().

eZSiteInstaller::languageNameFromLocale (   $locale)

Return language name from locale string. Example: 'rus' from 'rus-RU'

Referenced by createTranslationSiteAccesses(), and languageNameListFromLocaleList().

eZSiteInstaller::languageNameListFromLocaleList (   $localeList)

Build array of language names from locale list. Example: array( 'eng-GB', 'rus-RU' ) => array( 'eng', 'rus' )

eZSiteInstaller::lastErrorCode ( )

Get last error code.

Referenced by defaultErrorHandler(), and executeSteps().

eZSiteInstaller::moveTreeNode (   $params)

Move node. Params: 'node' - array( 'name' => object's name to move, 'class_id' => optional, object's content class ID );

'parent_node' - array( 'name' => parent object's name to move; 'class_id' => optional, parent object's content class ID );

eZSiteInstaller::nodeByName (   $params)

Referenced by nodeIdByName().

eZSiteInstaller::nodeByUrl (   $params)

Return node. Params: 'location' - path_identification_string of the node.

Referenced by assignUserToRole(), contentObjectByUrl(), createContentObject(), nodePathStringByURL(), and setSection().

eZSiteInstaller::nodeIdByName (   $params)

Referenced by moveTreeNode(), and swapNodes().

eZSiteInstaller::nodePathStringByURL (   $params)

Return 'path_string' attribute of the node. Params: 'location' - path_identification_string of the node.

eZSiteInstaller::packageFileItemPath (   $params)

Return path for package item.

eZSiteInstaller::postInstall ( )

Execute 'post_install' steps

eZSiteInstaller::postInstallSteps ( )

Return 'post_install' steps

Referenced by postInstall().

eZSiteInstaller::removeClassAttribute (   $params)

Remove attribute from the content class Params: 'class_id' - ID of content class to remove attribute from; 'attribute_identifier' - attibute identifier to remove;

eZSiteInstaller::removeContentObject (   $params)

Remove content object. Params: see 'contentObjectByName'

eZSiteInstaller::removePoliciesForRole (   $params)

Remove policies from role Params: role_name - name of role; policies - array of policies to remove. Each item is an array of policy definition: array( 'module' => , 'function' => ); remove_role - boolean, optional. If TRUE - empty(without policies) role will be removed. Default is TRUE.

eZSiteInstaller::renameContentObject (   $params)

Change name of content object. Params: contentobject_id - ID of object; name - new object name;

eZSiteInstaller::reportError (   $text,
  $errCode = eZSiteInstaller::ERR_ABORT 

Set last error code and write error message to debug output Params: $text - error message text; $caption - error message caption; $errCode - error code to set;

Referenced by addClassAttributes(), addPoliciesForRole(), executeSteps(), nodeByUrl(), removeClassAttribute(), removePoliciesForRole(), swapNodes(), updateContentObjectAttributes(), and updateObjectAttributeFromString().

eZSiteInstaller::sectionIDbyName (   $params)

Return ID of the section. Params: 'section_name' - name of the section

Referenced by setSection().

eZSiteInstaller::setLastErrorCode (   $errCode)

Set last error code.

Referenced by reportError().

eZSiteInstaller::setRSSExport (   $params)

Create rss export.

eZSiteInstaller::setSection (   $params)

Assign section to subtree. Params: 'section_name' - string: section name; 'location' - string: path_identification_string of the node(root node of subtree);

eZSiteInstaller::setting (   $name)

Return value for setting $name.

Referenced by packageFileItemPath().

eZSiteInstaller::setVersion (   $params = false)

Set solution name and version into db. Params: not used

eZSiteInstaller::solutionName ( )

Referenced by setVersion().

eZSiteInstaller::solutionVersion ( )

Referenced by setVersion().

eZSiteInstaller::swapNodes (   $params)

Swap two nodes. It's a copy/paste from kernel/content/action.php

eZSiteInstaller::updateClassAttributes (   $params)

Update class attribute data. Currently only attribute 'name' is supported. Params: 'class' - array( 'identifier' - identifire of content class ); 'attributes - array( array( 'identifier' - attibute identifier to update; 'new_name' - new attribute name ), ... );

eZSiteInstaller::updateContentObjectAttributes (   $params)
eZSiteInstaller::updateINIFiles (   $params)
eZSiteInstaller::updateObjectAttributeFromString (   $params)

Update contentObjectAttribute with value specified in string. The object can be specified either by ID or by path identification string of its node. Params: object_id - optional, ID of object to update; location - optional, path to node with object; class_attribute_identifier - an identifier of attribute to update; string - new attribute value;

eZSiteInstaller::updatePreferences (   $params)
eZSiteInstaller::updateRoles (   $params)

Member Data Documentation


Referenced by lastErrorCode().

const eZSiteInstaller::ERR_ABORT = 1

Referenced by executeSteps().

const eZSiteInstaller::ERR_CONTINUE = 2
const eZSiteInstaller::ERR_OK = 0

Referenced by executeSteps(), and eZSiteInstaller().

The documentation for this class was generated from the following file: