Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
eZSiteInstaller Class Reference
Utility classes

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

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

## Static Public Member Functions
| getParam ( $params, $name, $defaultValue=false)

## Public Attributes
const | ERR_OK = 0
const | ERR_ABORT = 1
const | ERR_CONTINUE = 2
| $Settings
| $Steps
| $LastErrorCode

## 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.

Definition at line 22 of file ezsiteinstaller.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZSiteInstaller::__construct | ( |  | $parameters = `false` | ) |

Definition at line 28 of file ezsiteinstaller.php.

References ERR_OK, initSettings(), and initSteps().

Referenced by eZSiteInstaller().

## Member Function Documentation

## ◆ addClassAttributes()

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 ), ... );

Definition at line 407 of file ezsiteinstaller.php.

References classByIdentifier(), eZContentClassAttribute\create(), eZContentObjectAttribute\create(), eZContentClass\fetch(), eZContentObject\fetchSameClassList(), reportError(), and eZContentClass\VERSION_STATUS_DEFINED.

## ◆ addPoliciesForRole()

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.

Definition at line 1197 of file ezsiteinstaller.php.

References eZRole\create(), eZRole\fetchByName(), and reportError().

## ◆ addSetting()

eZSiteInstaller::addSetting | ( |  | $name,
|  |  | $value
| ) |  |

Add setting with $name and $value.

Definition at line 102 of file ezsiteinstaller.php.

## ◆ assignUserToRole()

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;

Definition at line 1172 of file ezsiteinstaller.php.

References eZRole\fetchByName(), and nodeByUrl().

## ◆ buildFunctionParams()

eZSiteInstaller::buildFunctionParams | ( | & | $params | ) |

Prepare parameters for function executed in step definition.

Definition at line 198 of file ezsiteinstaller.php.

References execFunction(), and isFunctionParam().

Referenced by execFunction().

## ◆ classByIdentifier()

eZSiteInstaller::classByIdentifier | ( |  | $params | ) |

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

Definition at line 319 of file ezsiteinstaller.php.

References eZContentClass\fetchByIdentifier(), and eZDebug\writeWarning().

Referenced by addClassAttributes(), and classIDbyIdentifier().

## ◆ classIDbyIdentifier()

eZSiteInstaller::classIDbyIdentifier | ( |  | $params | ) |

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

Definition at line 300 of file ezsiteinstaller.php.

References classByIdentifier().

Referenced by updateClassAttributes().

## ◆ contentObjectByName()

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;

Definition at line 642 of file ezsiteinstaller.php.

References eZContentObject\fetchList().

Referenced by nodeByName(), and removeContentObject().

## ◆ contentObjectByUrl()

eZSiteInstaller::contentObjectByUrl | ( |  | $params | ) |

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

Definition at line 575 of file ezsiteinstaller.php.

References nodeByUrl().

Referenced by updateObjectAttributeFromString().

## ◆ createContentObject()

eZSiteInstaller::createContentObject | ( |  | $params | ) |

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

Definition at line 595 of file ezsiteinstaller.php.

References eZContentFunctions\createAndPublishObject(), and nodeByUrl().

## ◆ createContentSection()

eZSiteInstaller::createContentSection | ( |  | $params | ) |

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

Definition at line 1307 of file ezsiteinstaller.php.

## ◆ createSiteAccess()

eZSiteInstaller::createSiteAccess | ( |  | $params | ) |

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

Definition at line 1560 of file ezsiteinstaller.php.

References eZDir\copy(), eZSys\ezcrc32(), eZRole\fetchByName(), and eZDir\mkdir().

## ◆ createSiteaccessUrls()

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

Definition at line 1471 of file ezsiteinstaller.php.

References extractHostname(), eZSys\hostname(), eZSys\indexFileName(), and eZSys\wwwDir().

## ◆ dbBegin()

eZSiteInstaller::dbBegin | ( |  | $params | ) |

Start transaction. Params: no params

Definition at line 271 of file ezsiteinstaller.php.

References eZDB\instance().

## ◆ dbCommit()

eZSiteInstaller::dbCommit | ( |  | $params | ) |

Commit transaction. Params: no params

Definition at line 282 of file ezsiteinstaller.php.

References eZDB\instance().

## ◆ defaultErrorHandler()

eZSiteInstaller::defaultErrorHandler | ( |  | ) |

Default error handler

Definition at line 1728 of file ezsiteinstaller.php.

References lastErrorCode().

Referenced by executeSteps().

## ◆ execFunction()

eZSiteInstaller::execFunction | ( |  | $function | ) |

Execute $function defined in step

Definition at line 184 of file ezsiteinstaller.php.

References buildFunctionParams().

Referenced by buildFunctionParams(), and executeSteps().

## ◆ executeSteps()

eZSiteInstaller::executeSteps | ( |  | $steps | ) |

Execute $steps

Definition at line 157 of file ezsiteinstaller.php.

References defaultErrorHandler(), ERR_ABORT, ERR_OK, execFunction(), handleError(), lastErrorCode(), and reportError().

Referenced by postInstall().

## ◆ extractHostname()

eZSiteInstaller::extractHostname | ( |  | $uri | ) |

Helper function used for extracting hostname from the given

Parameters

  $uri |

Definition at line 1449 of file ezsiteinstaller.php.

Referenced by createSiteaccessUrls().

## ◆ eZSiteInstaller()

eZSiteInstaller::eZSiteInstaller | ( |  | $parameters = `false` | ) |

Deprecated:
  Use eZSiteInstaller::__construct() instead

Parameters

  bool | $parameters |

Definition at line 40 of file ezsiteinstaller.php.

References __construct().

## ◆ getParam()

eZSiteInstaller::getParam | ( |  | $params,
|  |  | $name,
|  |  | $defaultValue = `false`
| ) |  |
| static

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']

Definition at line 1703 of file ezsiteinstaller.php.

## ◆ handleError()

eZSiteInstaller::handleError | ( |  | ) |

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

Definition at line 1737 of file ezsiteinstaller.php.

Referenced by executeSteps().

## ◆ hasSetting()

eZSiteInstaller::hasSetting | ( |  | $name | ) |

Return TRUE if setting exist, otherwise FALSE.

Definition at line 128 of file ezsiteinstaller.php.

Referenced by setting().

## ◆ initSettings()

eZSiteInstaller::initSettings | ( |  | $parameters | ) |

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

Definition at line 55 of file ezsiteinstaller.php.

References eZDebug\writeWarning().

Referenced by __construct().

## ◆ initSteps()

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 ) );

Definition at line 94 of file ezsiteinstaller.php.

References eZDebug\writeWarning().

Referenced by __construct().

## ◆ instance()

& eZSiteInstaller::instance | ( |  | $params | ) |

Definition at line 45 of file ezsiteinstaller.php.

References eZDebug\writeWarning().

## ◆ isFunctionParam()

eZSiteInstaller::isFunctionParam | ( |  | $param | ) |

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

Definition at line 216 of file ezsiteinstaller.php.

Referenced by buildFunctionParams().

## ◆ languageNameFromLocale()

eZSiteInstaller::languageNameFromLocale | ( |  | $locale | ) |

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

Definition at line 1439 of file ezsiteinstaller.php.

Referenced by languageNameListFromLocaleList().

## ◆ languageNameListFromLocaleList()

eZSiteInstaller::languageNameListFromLocaleList | ( |  | $localeList | ) |

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

Definition at line 1426 of file ezsiteinstaller.php.

References languageNameFromLocale().

## ◆ lastErrorCode()

eZSiteInstaller::lastErrorCode | ( |  | ) |

Get last error code.

Definition at line 236 of file ezsiteinstaller.php.

References $LastErrorCode.

Referenced by defaultErrorHandler(), and executeSteps().

## ◆ moveTreeNode()

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 );

Definition at line 982 of file ezsiteinstaller.php.

References eZContentObjectTreeNodeOperations\move(), and nodeIdByName().

## ◆ nodeByName()

eZSiteInstaller::nodeByName | ( |  | $params | ) |

Definition at line 962 of file ezsiteinstaller.php.

References contentObjectByName().

Referenced by nodeIdByName().

## ◆ nodeByUrl()

eZSiteInstaller::nodeByUrl | ( |  | $params | ) |

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

Definition at line 927 of file ezsiteinstaller.php.

References eZContentObjectTreeNode\fetchByURLPath(), and reportError().

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

## ◆ nodeIdByName()

eZSiteInstaller::nodeIdByName | ( |  | $params | ) |

Definition at line 946 of file ezsiteinstaller.php.

References nodeByName().

Referenced by moveTreeNode(), and swapNodes().

## ◆ nodePathStringByURL()

eZSiteInstaller::nodePathStringByURL | ( |  | $params | ) |

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

Definition at line 908 of file ezsiteinstaller.php.

References nodeByUrl().

## ◆ packageFileItemPath()

eZSiteInstaller::packageFileItemPath | ( |  | $params | ) |

Return path for package item.

Definition at line 1396 of file ezsiteinstaller.php.

References setting(), and eZDebug\writeWarning().

## ◆ postInstall()

eZSiteInstaller::postInstall | ( |  | ) |

Execute 'post_install' steps

Definition at line 148 of file ezsiteinstaller.php.

References executeSteps(), and postInstallSteps().

## ◆ postInstallSteps()

eZSiteInstaller::postInstallSteps | ( |  | ) |

Return 'post_install' steps

Definition at line 140 of file ezsiteinstaller.php.

Referenced by postInstall().

## ◆ removeClassAttribute()

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;

Definition at line 346 of file ezsiteinstaller.php.

References eZContentClassAttribute\fetchFilteredList(), eZContentObjectAttribute\fetchSameClassAttributeIDList(), and reportError().

## ◆ removeContentObject()

eZSiteInstaller::removeContentObject | ( |  | $params | ) |

Remove content object. Params: see 'contentObjectByName'

Definition at line 666 of file ezsiteinstaller.php.

References contentObjectByName(), and eZDebug\writeWarning().

## ◆ removePoliciesForRole()

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.

Definition at line 1244 of file ezsiteinstaller.php.

References eZRole\fetchByName(), and reportError().

## ◆ renameContentObject()

eZSiteInstaller::renameContentObject | ( |  | $params | ) |

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

Definition at line 626 of file ezsiteinstaller.php.

References eZContentObject\fetch().

## ◆ reportError()

eZSiteInstaller::reportError | ( |  | $text,
|  |  | $caption,
|  |  | $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;

Definition at line 248 of file ezsiteinstaller.php.

References setLastErrorCode(), and eZDebug\writeError().

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

## ◆ sectionIDbyName()

eZSiteInstaller::sectionIDbyName | ( |  | $params | ) |

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

Definition at line 1282 of file ezsiteinstaller.php.

References eZSection\fetchFilteredList().

Referenced by setSection().

## ◆ setLastErrorCode()

eZSiteInstaller::setLastErrorCode | ( |  | $errCode | ) |

Set last error code.

Definition at line 228 of file ezsiteinstaller.php.

Referenced by reportError().

## ◆ setRSSExport()

eZSiteInstaller::setRSSExport | ( |  | $params | ) |

Create rss export.

Definition at line 1354 of file ezsiteinstaller.php.

References eZRSSExportItem\create(), and eZRSSExport\create().

## ◆ setSection()

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);

Definition at line 1328 of file ezsiteinstaller.php.

References eZContentObjectTreeNode\assignSectionToSubTree(), nodeByUrl(), and sectionIDbyName().

## ◆ setting()

eZSiteInstaller::setting | ( |  | $name | ) |

Return value for setting $name.

Definition at line 110 of file ezsiteinstaller.php.

References hasSetting(), and eZDebug\writeWarning().

Referenced by packageFileItemPath().

## ◆ setVersion()

eZSiteInstaller::setVersion | ( |  | $params = `false` | ) |

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

Definition at line 1612 of file ezsiteinstaller.php.

References eZDB\instance(), solutionName(), and solutionVersion().

## ◆ solutionName()

eZSiteInstaller::solutionName | ( |  | ) |

Definition at line 1601 of file ezsiteinstaller.php.

References eZDebug\writeWarning().

Referenced by setVersion().

## ◆ solutionVersion()

eZSiteInstaller::solutionVersion | ( |  | ) |

Definition at line 1595 of file ezsiteinstaller.php.

References eZDebug\writeWarning().

Referenced by setVersion().

## ◆ swapNodes()

eZSiteInstaller::swapNodes | ( |  | $params | ) |

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

Definition at line 996 of file ezsiteinstaller.php.

References eZContentObjectTreeNode\assignSectionToSubTree(), eZContentCacheManager\clearContentCacheIfNeeded(), eZContentObjectTreeNode\fetch(), eZDB\instance(), nodeIdByName(), and reportError().

## ◆ updateClassAttributes()

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 ), ... );

Definition at line 531 of file ezsiteinstaller.php.

References classIDbyIdentifier(), and eZContentClassAttribute\fetchFilteredList().

## ◆ updateContentObjectAttributes()

eZSiteInstaller::updateContentObjectAttributes | ( |  | $params | ) |

Definition at line 751 of file ezsiteinstaller.php.

References eZUser\create(), ERR_CONTINUE, eZContentObject\fetch(), and reportError().

## ◆ updateINIFiles()

eZSiteInstaller::updateINIFiles | ( |  | $params | ) |

Definition at line 1624 of file ezsiteinstaller.php.

## ◆ updateObjectAttributeFromString()

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;

Definition at line 697 of file ezsiteinstaller.php.

References contentObjectByUrl(), eZContentObject\fetch(), and reportError().

## ◆ updatePreferences()

eZSiteInstaller::updatePreferences | ( |  | $params | ) |

Definition at line 1680 of file ezsiteinstaller.php.

References eZPreferences\setValue().

## ◆ updateRoles()

eZSiteInstaller::updateRoles | ( |  | $params | ) |

Definition at line 1640 of file ezsiteinstaller.php.

References eZRole\create(), and eZRole\fetchByName().

## Member Data Documentation

## ◆ $LastErrorCode

eZSiteInstaller::$LastErrorCode

Definition at line 1748 of file ezsiteinstaller.php.

Referenced by lastErrorCode().

## ◆ $Settings

eZSiteInstaller::$Settings

Definition at line 1744 of file ezsiteinstaller.php.

## ◆ $Steps

eZSiteInstaller::$Steps

Definition at line 1746 of file ezsiteinstaller.php.

## ◆ ERR_ABORT

const eZSiteInstaller::ERR_ABORT = 1

Definition at line 25 of file ezsiteinstaller.php.

Referenced by executeSteps().

## ◆ ERR_CONTINUE

const eZSiteInstaller::ERR_CONTINUE = 2

Definition at line 26 of file ezsiteinstaller.php.

Referenced by updateContentObjectAttributes().

## ◆ ERR_OK

const eZSiteInstaller::ERR_OK = 0

Definition at line 24 of file ezsiteinstaller.php.

Referenced by __construct(), and executeSteps().

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

- ezsiteinstaller.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.