+{% endblock %}
diff --git a/.doc/phpdoc-templates/combodo-wiki/htaccess.dist b/.doc/phpdoc-templates/combodo-wiki/htaccess.dist
new file mode 100644
index 000000000..7b01f9bfd
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/htaccess.dist
@@ -0,0 +1,5 @@
+# Fixes a vulnerability in CentOS: http://stackoverflow.com/questions/20533279/prevent-php-from-parsing-non-php-files-such-as-somefile-php-txt
+
+ RemoveHandler .php
+ ForceType text/plain
+
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/code-examples.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/code-examples.txt.twig
new file mode 100644
index 000000000..314840aa9
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/code-examples.txt.twig
@@ -0,0 +1,34 @@
+{% if title_level is not defined %}
+ {%- set title_level = '==' -%}
+{% endif %}
+
+{% if sub_title_level is not defined %}
+ {%- set sub_title_level = title_level|slice(1) -%}
+{% endif %}
+{% if sub_title_level == '=' %}
+ {%- set sub_title_level = '' -%}
+{% endif %}
+
+{#{% for tagName,tags in structure.tags if tagName in ['code-example'] %}#}
+{#{% if loop.first %}#}
+{#{{title_level}} Examples {{title_level}}#}
+{#{% endif %}#}
+{#{% for tag in tags %}#}
+{#{%- set descToken = tag.description|split("\n", 2) -%}#}
+{#{%- set title = descToken[0] -%}#}
+{#{%- set code = descToken[1] -%}#}
+{#{{sub_title_level}} {{ title }} {{sub_title_level}}#}
+{#{{ code|raw }}#}
+{#{% endfor %}#}
+{#{% endfor %}#}
+
+
+{% for tagName,tags in structure.tags if tagName in ['example'] %}
+{% if loop.first %}
+{{title_level}} Examples {{title_level}}
+{% endif %}
+{% for tag in tags %}
+{{ sub_title_level }} {{ tag.filePath|escape }}{{ sub_title_level }}
+{{ tag.description|raw }}
+{% endfor %}
+{% endfor %}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/inherited-from.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/inherited-from.txt.twig
new file mode 100644
index 000000000..e56611be8
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/inherited-from.txt.twig
@@ -0,0 +1,12 @@
+{% if title_level is not defined %}
+ {% set title_level='' %}
+{% endif %}
+
+{% if (node.parent is null) %}
+{{title_level}} File {{ structure.path }} {{title_level}}
+{% endif %}
+
+{% if (node.parent is not null and structure.parent.fullyQualifiedStructuralElementName != node.fullyQualifiedStructuralElementName) %}
+{{title_level}} Inherited from {{title_level}}
+[[{{structure.parent}}|{{structure.parent}}]]
+{% endif %}
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/namespace-structure-toc.html.twig b/.doc/phpdoc-templates/combodo-wiki/includes/namespace-structure-toc.html.twig
new file mode 100644
index 000000000..0d79ae9d5
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/namespace-structure-toc.html.twig
@@ -0,0 +1,26 @@
+{% for structure in structures|sort_asc if structure.tags['internal'] is not defined and (structure.tags['api'] is defined or structure.tags['api-advanced'] is defined or structure.tags['overwritable-hook'] is defined or structure.tags['extension-hook'] is defined ) %}
+{#{{ structure|raw }}#}
+
+{% set structureName = structure|trim('\\', 'left') %}
+
+
+
+==== {{ structureName }} ====
+{# twothirds column#}
+
+
+{% if structure.deprecated %}deprecated{% endif %}
+{% if structure.abstract %}abstract{% endif %}
+{% if structure.final %}final{% endif %}
+{% if (node.parent is not null and structure.parent.fullyQualifiedStructuralElementName != node.fullyQualifiedStructuralElementName) %}inherited {% endif %}
+{% include 'includes/wrap-tags.txt.twig' with {structure:structure, wrap: 'safety', wrapTags: ['api', 'api-advanced', 'overwritable-hook', 'extension-hook']} %}
+{# third column#}
+
+
+{{ structure.summary|raw }}
+[[{{structureName}}|More informations]]
+
+{# group #}
+
+{% endfor %}
+
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/see-also.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/see-also.txt.twig
new file mode 100644
index 000000000..2d41c0d3b
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/see-also.txt.twig
@@ -0,0 +1,26 @@
+{% if title_level is not defined %}
+ {%- set title_level='==' -%}
+{% endif %}
+{% for tagName,tags in structure.tags if tagName in ['link', 'see'] %}
+{% if loop.first %}
+{{title_level}} See also {{title_level}}
+{% endif %}
+{% for tag in tags %}
+{%- set linkTag = tag.reference|trim('\\', 'left') -%}
+{% if not('()' in linkTag or '$' in linkTag or node.name in linkTag or '::' in linkTag ) %}
+ {%- set linkTag = linkTag|lower -%}
+{% elseif node.name~'::' in linkTag %}
+ {%- set linkTag = linkTag|replace({(node.name~'::'): '#'})|lower -%}
+{% elseif '::' in linkTag -%}
+ {%- set linkTag = linkTag|replace({'::': '#'})|lower -%}
+{% else %}
+ {%- set linkTag = '#' ~ linkTag|lower -%}
+{%- endif %}
+
+{% if loop.length > 1 %} * {% endif %}{% if tag.reference is not empty -%}
+ [[{{linkTag}}|{{ (tag.reference)|trim('\\', 'left') }}]] {% if tag.description|trim is not empty %}: {{ tag.description|trim('\\', 'left') }} {% endif %}
+{%- else -%}
+ {#{{ tag.description|trim('\\', 'left') }}#}
+{% endif %}
+{% endfor %}
+{% endfor %}
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/tag-synthesys.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/tag-synthesys.txt.twig
new file mode 100644
index 000000000..05b26087a
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/tag-synthesys.txt.twig
@@ -0,0 +1,56 @@
+{% if tag is not defined -%}
+ {# Do not display @api if @api-advanced is also present #}
+ {%- set tag = "api" -%}
+{%- endif %}
+
+{% if hidden_by is not defined -%}
+ {# Do not display @api if @api-advanced is also present #}
+ {%- set hidden_by = {"api" : "api-advanced"} -%}
+{%- endif %}
+
+
+
+{% for method in methods|sort_asc
+ if (method.visibility == 'public')
+ and (
+ method.tags[tag] is defined
+ and (
+ hidden_by[tag] is not defined or method.tags[hidden_by[tag]] is not defined
+ )
+ )
+%}
+{%- if loop.first %}
+{% if tag == 'api' %}
+===== API synthesis =====
+
+List of the public API methods.
+When manipulating {{ node.name }}, You can call those methods:
+
+{% elseif tag == 'api-advanced' %}
+===== Advanced API synthesis =====
+
+List of advanced API methods
+Beware they usage is recommended to advanced users only.
+
+{% elseif tag == 'overwritable-hook' %}
+===== overwritable-hook synthesis =====
+When inheriting from {{ node.name }},
+you can overwrite those methods in order to add custom logic:
+
+{% elseif tag == 'extension-hook' %}
+===== extension-hook synthesis =====
+
+When inheriting from {{ node.name }},
+you can extend the behaviour of iTop by implementing:
+
+{% endif %}
+{% endif %}
+{% set sanitizedMethod = method|trim('\\', 'left')|replace({(node.name~'::'): ''}) %}
+{% if '::' in sanitizedMethod -%}
+{%- if node.tags['phpdoc-tunning-exclude-inherited'] is not defined %}
+ * [[{{sanitizedMethod|replace({'::': '#'})|lower}}|↪{{sanitizedMethod}}]] — {{ method.summary|replace({"\n":""})|raw }}
+{% endif %}
+{%- else %}
+ * [[#{{sanitizedMethod}}|{{sanitizedMethod}}]] — {{ method.summary|replace({"\n":""})|raw }}
+{% endif %}
+{% endfor %}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/tags-with-description.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/tags-with-description.txt.twig
new file mode 100644
index 000000000..bd8e3b5d0
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/tags-with-description.txt.twig
@@ -0,0 +1,20 @@
+{% if title_level is not defined %}
+ {% set title_level = '==' %}
+{% endif %}
+
+
+{%- for tagName,tags in structure.tags if tagName in tagsWithDescription -%}
+ {%- for tag in tags -%}
+ {%- if tag.description is not empty -%}
+{%- if WRAP is defined -%}
+
+{%- endif -%}
+{{title_level}} {{ tagName }} {{title_level}}
+{{ tag.description|escape }}
+{%- if WRAP is defined -%}
+
+{%- endif -%}
+ {%- endif -%}
+ {%- endfor -%}
+{%- endfor -%}
+
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/tags.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/tags.txt.twig
new file mode 100644
index 000000000..008ffab56
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/tags.txt.twig
@@ -0,0 +1,22 @@
+{% if title_level is not defined %}
+ {% set title_level='=====' %}
+{% endif %}
+
+{% if blacklist is not defined %}
+ {% set blacklist =['link', 'see', 'abstract', 'example', 'method', 'property', 'property-read', 'property-write', 'package', 'subpackage', 'api', 'api-advanced', 'todo', 'code-example'] %}
+{% endif %}
+{% if hidden_by is not defined -%}
+ {# Do not display @api if @api-advanced is also present #}
+ {%- set hidden_by = {"api" : "api-advanced"} -%}
+{%- endif %}
+
+{#^ {% for tagName,tags in structure.tags if tagName not in blacklist -%}#}
+{#{{ tagName }} ^#}
+{#{%- endfor %}#}
+
+{% for tagName,tags in structure.tags if tagName not in blacklist and (hidden_by[tagName] is not defined or structure.tags[hidden_by[tagName]] is not defined) %}
+{%- if loop.first %}
+{{title_level}} Tags {{title_level}}
+{% endif %}
+^ {{ tagName }} | {% for tag in tags %}{{ tag.version ? tag.version ~ ' ' : '' }}{{ tag.description}}{% endfor %} |
+{% endfor %}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/used-by.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/used-by.txt.twig
new file mode 100644
index 000000000..e7d8d8c34
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/used-by.txt.twig
@@ -0,0 +1,24 @@
+{% if title_level is not defined %}
+ {% set title_level='' %}
+{% endif %}
+{% for tagName,tags in structure.tags if tagName in ['used-by'] %}
+{% if loop.first %}
+{{title_level}} Used by {{title_level}}
+{% endif %}
+{% for tag in tags %}
+{% if loop.length > 1 %} * {% endif %}{{ tag.reference ?: tag.link }} : {{ tag.description ?: tag.reference }}
+{% endfor %}
+{% endfor %}
+
+
+
+
+
+{#{% for tagName,tags in method.tags if tagName in ['uses'] %}#}
+ {#{% if loop.first %}#}
+ {#
Uses
#}
+ {#{% endif %}#}
+ {#{% for tag in tags %}#}
+ {#
{{ tag.reference|raw }}
#}
+ {#{% endfor %}#}
+{#{% endfor %}#}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/uses.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/uses.txt.twig
new file mode 100644
index 000000000..58e5b30b8
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/uses.txt.twig
@@ -0,0 +1,24 @@
+{% if title_level is not defined %}
+ {% set title_level='' %}
+{% endif %}
+{% for tagName,tags in structure.tags if tagName in ['uses'] %}
+{% if loop.first %}
+{{title_level}} Uses {{title_level}}
+{% endif %}
+{% for tag in tags %}
+{% if loop.length > 1 %} * {% endif %}{{ tag.reference ?: tag.link }} : {{ tag.description ?: tag.reference }}
+{% endfor %}
+{% endfor %}
+
+
+
+
+
+{#{% for tagName,tags in method.tags if tagName in ['uses'] %}#}
+ {#{% if loop.first %}#}
+ {#
Uses
#}
+ {#{% endif %}#}
+ {#{% for tag in tags %}#}
+ {#
{{ tag.reference|raw }}
#}
+ {#{% endfor %}#}
+{#{% endfor %}#}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/includes/wrap-tags.txt.twig b/.doc/phpdoc-templates/combodo-wiki/includes/wrap-tags.txt.twig
new file mode 100644
index 000000000..7419abf5b
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/includes/wrap-tags.txt.twig
@@ -0,0 +1,11 @@
+{% if wrap is not defined -%}
+ {% set wrap = 'notice' %}
+{%- endif -%}
+{% if hidden_by is not defined -%}
+ {# Do not display @api if @api-advanced is also present #}
+ {%- set hidden_by = {"api" : "api-advanced"} -%}
+{%- endif %}
+
+{%- for tagName,tags in structure.tags if tagName in wrapTags and (hidden_by[tagName] is not defined or structure.tags[hidden_by[tagName]] is not defined) %}
+ {{tagName}}
+{% endfor %}
diff --git a/.doc/phpdoc-templates/combodo-wiki/interface.txt.twig b/.doc/phpdoc-templates/combodo-wiki/interface.txt.twig
new file mode 100644
index 000000000..5bf639994
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/interface.txt.twig
@@ -0,0 +1,121 @@
+{% extends 'layout.txt.twig' %}
+
+{% block content %}
+[[start|🔙 Back]]
+
+{% if node.tags['internal'] is defined %}
+====== {{ node.name }} ======
+This interface is "internal", and thus is not documented!
+{% elseif node.tags['api'] is not defined and node.tags['api-advanced'] is not defined and node.tags['overwritable-hook'] is not defined and node.tags['extension-hook'] is not defined %}
+====== {{ node.name }} ======
+This interface is neither "api", "overwritable-hook" or "extension-hook", and thus is not documented!
+{% else %}
+
+====== {{ node.name }} ======
+
+{% if node.deprecated %}deprecated{% endif %}
+{% if node.abstract %}abstract{% endif %}
+{% if node.final %}final{% endif %}
+{% include 'includes/wrap-tags.txt.twig' with {structure:node, wrap: 'safety', wrapTags: ['api', 'api-advanced', 'overwritable-hook', 'extension-hook']} %}
+
+
+
+{% if node.deprecated %}
+=== **Deprecated**===
+//{{ node.tags.deprecated[0].description }}//
+{% endif %}
+
+
+== {{ node.summary|replace({"\n":""})|raw }} ==
+{{ node.description|markdown|raw }}
+
+
+{% include 'includes/code-examples.txt.twig' with {structure:node, title_level: '====='} %}
+
+
+{% set class = node.parent %}
+{% block hierarchy_element %}
+
+{% if class and class.name is defined and class.name|trim != '' %}
+==== parent ====
+{% set child = class %}
+{% set class = class.parent %}
+{{ block('hierarchy_element') }}
+[[{{ child.name }}|{{ child.name }}]]
+{% endif %}
+{% endblock %}
+
+
+{% for interface in node.interfaces|sort_asc %}
+{% if loop.first %}
+==== Implements ====
+{% endif %}
+{% if loop.length > 1 %} * {% endif %}{{ interface.fullyQualifiedStructuralElementName ?: interface }}
+{% endfor %}
+
+
+{% for trait in node.usedTraits|sort_asc %}
+{% if loop.first %}
+==== Uses traits ====
+{% endif %}
+{% if loop.length > 1 %} * {% endif %}{{ trait.fullyQualifiedStructuralElementName ?: trait }}
+{% endfor %}
+
+
+{% include 'includes/see-also.txt.twig' with {structure:node, title_level: '==='} %}
+
+{% include 'includes/tags.txt.twig' with {structure:node, title_level: '=====', blacklist: ['link', 'see', 'abstract', 'example', 'method', 'property', 'property-read', 'property-write', 'package', 'subpackage', 'phpdoc-tunning-exclude-inherited', 'api', 'api-advanced', 'overwritable-hook', 'extension-hook', 'copyright', 'license', 'code-example']} %}
+
+
+{% set methods = node.inheritedMethods.merge(node.methods) %}
+{% include 'includes/tag-synthesys.txt.twig' with {methods:methods, tag:'api'} %}
+{% include 'includes/tag-synthesys.txt.twig' with {methods:methods, tag:'api-advanced'} %}
+{% include 'includes/tag-synthesys.txt.twig' with {methods:methods, tag:'overwritable-hook'} %}
+{% include 'includes/tag-synthesys.txt.twig' with {methods:methods, tag:'extension-hook'} %}
+
+
+
+
+{% for method in methods|sort_asc if method.visibility == 'public' %}
+{%- if loop.first %}
+===== Public methods =====
+{% endif %}
+{{ block('method') }}
+{% endfor %}
+{% for method in methods|sort_asc if method.visibility == 'protected' %}
+{%- if loop.first %}
+===== Protected methods =====
+{% endif %}
+{{ block('method') }}
+{% endfor %}
+
+
+
+{% set constants = node.inheritedConstants.merge(node.constants) %}
+{% if constants|length > 0 %}
+===== Constants =====
+{% for constant in constants|sort_asc %}
+{{ block('constant') }}
+{% endfor %}
+{% endif %}
+
+
+{#{% set properties = node.inheritedProperties.merge(node.properties) %}#}
+{#{% for property in properties|sort_asc if property.visibility == 'public' %}#}
+{#{%- if loop.first %}#}
+{#===== Public properties =====#}
+{#{% endif %}#}
+{#{{ block('property') }}#}
+{#{% endfor %}#}
+{#{% for property in properties|sort_asc if property.visibility == 'protected' %}#}
+{#{%- if loop.first %}#}
+{#===== Protected properties =====#}
+{#{% endif %}#}
+{#{{ block('property') }}#}
+{#{% endfor %}#}
+
+
+{%- endif %} {#{% elseif node.tags['xxx'] is not defined and ... #}
+
+[[start|🔙 Back]]
+{% endblock %}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/layout.txt.twig b/.doc/phpdoc-templates/combodo-wiki/layout.txt.twig
new file mode 100644
index 000000000..7a2629d1d
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/layout.txt.twig
@@ -0,0 +1,5 @@
+{% use 'elements/constant.txt.twig' %}
+{% use 'elements/property.txt.twig' %}
+{% use 'elements/method.txt.twig' %}
+
+{% block content %}{% endblock %}
\ No newline at end of file
diff --git a/.doc/phpdoc-templates/combodo-wiki/namespace.txt.twig b/.doc/phpdoc-templates/combodo-wiki/namespace.txt.twig
new file mode 100644
index 000000000..3039693f8
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/namespace.txt.twig
@@ -0,0 +1,51 @@
+{% extends 'layout.txt.twig' %}
+
+{% block content %}
+{% set namespace = project.namespace %}
+{{ block('sidebarNamespaces') }}
+
+{#{{ node.parent|raw }}#}
+{#====== {{ node.parent.fullyQualifiedStructuralElementName }}{{ node.name }} ======#}
+
+{% if node.children|length > 0 %}
+=====Namespaces=====
+{% include 'includes/namespace-structure-toc.html.twig' with {structures: node.children} %}
+----
+{% endif %}
+
+{% if node.traits|length > 0 %}
+===== Traits =====
+{% include 'includes/namespace-structure-toc.html.twig' with {structures: node.traits} %}
+----
+{%- endif %}
+
+{% if node.interfaces|length > 0 %}
+===== Interfaces =====
+{% include 'includes/namespace-structure-toc.html.twig' with {structures: node.interfaces} %}
+----
+{% endif %}
+
+{% if node.classes|length > 0 %}
+===== Classes =====
+{% include 'includes/namespace-structure-toc.html.twig' with {structures: node.classes} %}
+----
+{% endif %}
+
+
+
+{#{% if node.constants|length > 0 %}#}
+{#===== Constants =====#}
+{#{% for constant in node.constants|sort_asc %}#}
+{# {{ block('constant') }}#}
+{#{% endfor %}#}
+{#{% endif %}#}
+
+{#{% if node.functions|length > 0 %}#}
+{#===== Functions =====#}
+
+{#{% for method in node.functions|sort_asc %}#}
+{# {{ block('method') }}#}
+{#{% endfor %}#}
+{#{% endif %}#}
+
+{% endblock %}
diff --git a/.doc/phpdoc-templates/combodo-wiki/reports/deprecated.html.twig b/.doc/phpdoc-templates/combodo-wiki/reports/deprecated.html.twig
new file mode 100644
index 000000000..d4f372389
--- /dev/null
+++ b/.doc/phpdoc-templates/combodo-wiki/reports/deprecated.html.twig
@@ -0,0 +1,49 @@
+
+====== Deprecated elements ======
+
+{#{% for element in project.indexes.elements if element.deprecated %}#}
+ {#{% if element.file.path != previousPath %}#}
+ {#
+ *
+ * @see #GetSynchroData
+ */
+ protected $m_aSynchroData = null;
protected $m_sHighlightCode = null;
protected $m_aCallbacks = array();
- // Use the MetaModel::NewObject to build an object (do we have to force it?)
+
+ /**
+ * DBObject constructor.
+ *
+ * You should preferably use MetaModel::NewObject() instead of this constructor.
+ * The whole collection of parameters is [*optional*] please refer to DBObjectSet::FromRow()
+ *
+ * @internal The availability of this method is not guaranteed in the long term, you should preferably use MetaModel::NewObject().
+ * @see MetaModel::NewObject()
+ *
+ * @param null|array $aRow If given : DBObjectSet::FromRow() will be used to fetch the object
+ * @param string $sClassAlias
+ * @param null|array $aAttToLoad
+ * @param null|array $aExtendedDataSpec
+ *
+ * @throws CoreException
+ */
public function __construct($aRow = null, $sClassAlias = '', $aAttToLoad = null, $aExtendedDataSpec = null)
{
if (!empty($aRow))
@@ -158,8 +202,10 @@ abstract class DBObject implements iDisplay
/**
* Update meta-attributes depending on the given attribute list
*
- * @param array|null $aAttCodes List of att codes
- *
+ * @internal
+ *
+ * @param array|null $aAttCodes List of att codes
+ *
* @throws \CoreException
*/
protected function UpdateMetaAttributes($aAttCodes = null)
@@ -178,20 +224,41 @@ abstract class DBObject implements iDisplay
}
}
- // Read-only <=> Written once (archive)
+ /**
+ * Mark the object as dirty
+ *
+ * Once dirty the object may be written to the DB, it is NOT possible to reload it
+ * or at least not possible to reload it the same way
+ *
+ * @internal
+ */
public function RegisterAsDirty()
{
- // While the object may be written to the DB, it is NOT possible to reload it
- // or at least not possible to reload it the same way
- $this->m_bDirty = true;
+ $this->m_bDirty = true;
}
+ /**
+ * Whether the object is already persisted in DB or not.
+ *
+ * @api
+ *
+ * @return bool
+ */
public function IsNew()
{
return (!$this->m_bIsInDB);
}
- // Returns an Id for memory objects
+ /**
+ * Returns an Id for memory objects
+ *
+ * @internal
+ *
+ * @param string $sClass
+ *
+ * @return int
+ * @throws CoreException
+ */
static protected function GetNextTempId($sClass)
{
$sRootClass = MetaModel::GetRootClass($sClass);
@@ -203,23 +270,53 @@ abstract class DBObject implements iDisplay
return (- self::$m_aMemoryObjectsByClass[$sRootClass]);
}
+ /**
+ * HTML String representation of the object
+ *
+ * Only a few meaningful information will be returned.
+ * This representation is for debugging purposes, and is subject to change.
+ * The returned string is raw HTML
+ *
+ * @return string
+ * @throws CoreException
+ */
public function __toString()
{
$sRet = '';
$sClass = get_class($this);
$sRootClass = MetaModel::GetRootClass($sClass);
$iPKey = $this->GetKey();
- $sFriendlyname = $this->Get('friendlyname');
+ $sFriendlyname = $this->GetAsHTML('friendlyname');
$sRet .= "$sClass::$iPKey ($sFriendlyname) \n";
return $sRet;
}
- // Restore initial values... mmmm, to be discussed
+ /**
+ * Alias of DBObject::Reload()
+ *
+ * Restore initial values
+ *
+ * @see Reload()
+ *
+ * @throws CoreException
+ */
public function DBRevert()
{
$this->Reload();
}
+ /**
+ * Is the current instance fully or partially loaded.
+ *
+ * This method compute the state in realtime.
+ * In almost every case it is preferable to use DBObject::m_bFullyLoaded.
+ *
+ * @internal
+ * @see m_bFullyLoaded
+ *
+ * @return bool
+ * @throws CoreException
+ */
protected function IsFullyLoaded()
{
foreach(MetaModel::ListAttributeDefs(get_class($this)) as $sAttCode=>$oAttDef)
@@ -234,10 +331,14 @@ abstract class DBObject implements iDisplay
}
/**
- * @param bool $bAllowAllData DEPRECATED: the reload must never fail!
+ * Reload the object from the DB.
+ *
+ * This is mostly used after a lazy load (automatically performed by the framework)
+ * This will erase any pending changes.
+ *
+ * @param bool $bAllowAllData @deprecated This parameter is ignored!!
*
* @throws CoreException
- * @internal
*/
public function Reload($bAllowAllData = false)
{
@@ -265,6 +366,20 @@ abstract class DBObject implements iDisplay
$this->m_aModifiedAtt = array();
}
+ /**
+ * Initialize the instance against a given structured array
+ *
+ * @internal
+ * @see GetExtendedData() extended data
+ *
+ * @param array $aRow an array under the form: ` => `
+ * @param string $sClassAlias if not null, it is preprended to the `` part of $aRow
+ * @param null|array $aAttToLoad List of attribute that will be fetched against the database anyway
+ * @param null|array $aExtendedDataSpec List of attribute that will be marked as DBObject::GetExtendedData()
+ *
+ * @return bool
+ * @throws CoreException
+ */
protected function FromRow($aRow, $sClassAlias = '', $aAttToLoad = null, $aExtendedDataSpec = null)
{
if (strlen($sClassAlias) == 0)
@@ -381,6 +496,18 @@ abstract class DBObject implements iDisplay
return $bFullyLoaded;
}
+ /**
+ * Protected raw Setter
+ *
+ * This method is an internal plumbing : it sets the value without doing any of the required processes.
+ * The exposed API Setter is DBObject::Set()
+ *
+ * @internal
+ * @see Set()
+ *
+ * @param string $sAttCode
+ * @param mixed $value
+ */
protected function _Set($sAttCode, $value)
{
$this->m_aCurrValues[$sAttCode] = $value;
@@ -388,6 +515,24 @@ abstract class DBObject implements iDisplay
unset($this->m_aModifiedAtt[$sAttCode]);
}
+
+ /**
+ * Attributes setter
+ *
+ * Set $sAttCode to $value.
+ * The value must be valid according to the type of attribute.
+ * The value will not be recorded into the DB until DBObject::DBWrite() is called.
+ *
+ * @api
+ * @see DBWrite()
+ *
+ * @param string $sAttCode
+ * @param mixed $value
+ *
+ * @return bool
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function Set($sAttCode, $value)
{
if ($sAttCode == 'finalclass')
@@ -475,6 +620,13 @@ abstract class DBObject implements iDisplay
}
/**
+ * Helper to set a value only if it is currently undefined
+ *
+ * Call Set() only of the internal representation of the attribute is null.
+ *
+ * @api
+ * @see Set()
+ *
* @param string $sAttCode
* @param mixed $value
*
@@ -493,6 +645,20 @@ abstract class DBObject implements iDisplay
}
}
+ /**
+ * Helper to set a value that fits the attribute max size
+ *
+ * compare $sValue against the field's max size in the database, and truncate it's ending in order to make it fit.
+ * If $sValue is short enough, nothing is done.
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ * @param string $sValue
+ *
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function SetTrim($sAttCode, $sValue)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
@@ -504,12 +670,40 @@ abstract class DBObject implements iDisplay
$this->Set($sAttCode, $sValue);
}
+ /**
+ * Get the label of an attribute.
+ *
+ * Shortcut to the field's AttributeDefinition->GetLabel()
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ *
+ * @return string
+ *
+ * @throws Exception
+ */
public function GetLabel($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAttDef->GetLabel();
}
+ /**
+ * Getter : get a value from the current object of from a related object
+ *
+ * Get the value of the attribute $sAttCode
+ * This call may involve an object reload if the object was not completely loaded (lazy loading)
+ *
+ * @api
+ *
+ * @param string $sAttCode Could be an extended attribute code in the form extkey_id->anotherkey_id->remote_attr
+ *
+ * @return mixed|string
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function Get($sAttCode)
{
if (($iPos = strpos($sAttCode, '->')) === false)
@@ -549,6 +743,18 @@ abstract class DBObject implements iDisplay
}
}
+ /**
+ * Getter : get values from the current object
+ *
+ * @internal
+ * @see Get
+ *
+ * @param string $sAttCode
+ *
+ * @return int|mixed|null
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetStrict($sAttCode)
{
if ($sAttCode == 'id')
@@ -636,6 +842,19 @@ abstract class DBObject implements iDisplay
return $value;
}
+ /**
+ * Get the value as it was before change with Set
+ *
+ * The original value vary according to the persisted state
+ * - not persisted: NULL
+ * - persisted: the "in DB" value
+ *
+ * @param string $sAttCode
+ *
+ * @return mixed|null the original value
+ *
+ * @throws CoreException
+ */
public function GetOriginal($sAttCode)
{
if (!array_key_exists($sAttCode, MetaModel::ListAttributeDefs(get_class($this))))
@@ -647,11 +866,17 @@ abstract class DBObject implements iDisplay
}
/**
- * Returns the default value of the $sAttCode. By default, returns the default value of the AttributeDefinition.
- * Overridable.
+ * Returns the default value of the $sAttCode.
+ *
+ * Returns the default value of the given attribute.
+ *
+ * @internal
+ *
+ * @param string $sAttCode
*
- * @param $sAttCode
* @return mixed
+ *
+ * @throws Exception
*/
public function GetDefaultValue($sAttCode)
{
@@ -661,6 +886,10 @@ abstract class DBObject implements iDisplay
/**
* Returns data loaded by the mean of a dynamic and explicit JOIN
+ *
+ * @internal
+ *
+ * @return array|null
*/
public function GetExtendedData()
{
@@ -668,8 +897,16 @@ abstract class DBObject implements iDisplay
}
/**
- * Set the HighlightCode if the given code has a greater rank than the current HilightCode
+ * Set the HighlightCode
+ *
+ * Switch to $sCode if it has a greater rank than the current code
+ *
+ * @internal
+ * @used-by DBObject::ComputeHighlightCode()
+ * @see m_sHighlightCode
+ *
* @param string $sCode
+ *
* @return void
*/
protected function SetHighlightCode($sCode)
@@ -693,13 +930,29 @@ abstract class DBObject implements iDisplay
/**
* Get the current HighlightCode
- * @return string The Hightlight code (null if none set, meaning rank = 0)
+ *
+ * @internal
+ * @used-by DBObject::ComputeHighlightCode()
+ *
+ * @return string|null The Hightlight code (null if none set, meaning rank = 0)
*/
protected function GetHighlightCode()
{
return $this->m_sHighlightCode;
}
-
+
+ /**
+ * Compute the highlightCode
+ *
+ * @example When TTR, then TTR of a UserRequest is greater thant a defined scale, the item is highlighted in the listings
+ *
+ * @interal
+ *
+ * @return string|null The Hightlight code (null if none set, meaning rank = 0)
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
protected function ComputeHighlightCode()
{
// First if the state defines a HiglightCode, apply it
@@ -725,15 +978,23 @@ abstract class DBObject implements iDisplay
return $this->GetHighlightCode();
}
- /**
- * Updates the value of an external field by (re)loading the object
- * corresponding to the external key and getting the value from it
- *
- * UNUSED ?
- *
- * @param string $sAttCode Attribute code of the external field to update
- * @return void
- */
+ /**
+ * Updates the value of an external field by (re)loading the object
+ * corresponding to the external key and getting the value from it
+ *
+ * UNUSED ?
+ *
+ * @internal
+ * @todo: check if this is dead code.
+ *
+ * @param string $sAttCode Attribute code of the external field to update
+ *
+ * @return void
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
protected function UpdateExternalField($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
@@ -755,9 +1016,10 @@ abstract class DBObject implements iDisplay
}
/**
- * Overridable callback, called by \DBObject::DoComputeValues
- *
- * @api
+ * Overridable callback
+ *
+ * @internal this method is elligible to the "overwritable-hook" tag. But it is willingly excluded.
+ * @used-by DoComputeValues()
*/
public function ComputeValues()
{
@@ -765,6 +1027,8 @@ abstract class DBObject implements iDisplay
/**
* Compute scalar attributes that depend on any other type of attribute
+ *
+ * if you want to customize this behaviour, overwrite @see ComputeValues()
*
* @throws \CoreException
* @throws \CoreUnexpectedValue
@@ -798,6 +1062,23 @@ abstract class DBObject implements iDisplay
$this->ComputeValues();
}
+ /**
+ * Get $sAttCode formatted as HTML
+ *
+ * The returned string is already escaped, and as such is protected against XSS
+ * The markup relies on a few assumptions (CSS) that could change without notice
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ * @param bool $bLocalize
+ *
+ * @return string
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws DictExceptionMissingString
+ */
public function GetAsHTML($sAttCode, $bLocalize = true)
{
$sClass = get_class($this);
@@ -827,6 +1108,20 @@ abstract class DBObject implements iDisplay
return $oAtt->GetAsHTML($this->Get($sAttCode), $this, $bLocalize);
}
+ /**
+ * Get the value as it must be in the edit areas (forms)
+ *
+ * Makes a raw text representation of the value.
+ *
+ * @internal
+ *
+ * @param string $sAttCode
+ *
+ * @return int|mixed|string
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetEditValue($sAttCode)
{
$sClass = get_class($this);
@@ -863,30 +1158,100 @@ abstract class DBObject implements iDisplay
return $sEditValue;
}
+ /**
+ * Get $sAttCode formatted as XML
+ *
+ * The returned value is a text that is suitable for insertion into an XML node.
+ * Depending on the type of attribute, the returned text is either:
+ * * A literal, with XML entities already escaped,
+ * * XML
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ * @param bool $bLocalize
+ *
+ * @return mixed
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetAsXML($sAttCode, $bLocalize = true)
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAtt->GetAsXML($this->Get($sAttCode), $this, $bLocalize);
}
+ /**
+ * Get $sAttCode formatted as CSV
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ * @param string $sSeparator
+ * @param string $sTextQualifier
+ * @param bool $bLocalize
+ * @param bool $bConvertToPlainText
+ *
+ * @return string
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetAsCSV($sAttCode, $sSeparator = ',', $sTextQualifier = '"', $bLocalize = true, $bConvertToPlainText = false)
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAtt->GetAsCSV($this->Get($sAttCode), $sSeparator, $sTextQualifier, $this, $bLocalize, $bConvertToPlainText);
}
+ /**
+ *
+ * @see GetAsHTML()
+ * @see GetOriginal()
+ *
+ * @param string $sAttCode
+ * @param bool $bLocalize
+ *
+ * @return string
+ * @throws CoreException
+ */
public function GetOriginalAsHTML($sAttCode, $bLocalize = true)
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAtt->GetAsHTML($this->GetOriginal($sAttCode), $this, $bLocalize);
}
+ /**
+ *
+ * @see GetAsXML()
+ * @see GetOriginal()
+ *
+ * @param string $sAttCode
+ * @param bool $bLocalize
+ *
+ * @return mixed
+ * @throws CoreException
+ */
public function GetOriginalAsXML($sAttCode, $bLocalize = true)
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
return $oAtt->GetAsXML($this->GetOriginal($sAttCode), $this, $bLocalize);
}
+ /**
+ *
+ * @see GetAsCSV()
+ * @see GetOriginal()
+ *
+ * @param string $sAttCode
+ * @param string $sSeparator
+ * @param string $sTextQualifier
+ * @param bool $bLocalize
+ * @param bool $bConvertToPlainText
+ *
+ * @return string
+ * @throws CoreException
+ */
public function GetOriginalAsCSV($sAttCode, $sSeparator = ',', $sTextQualifier = '"', $bLocalize = true, $bConvertToPlainText = false)
{
$oAtt = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
@@ -894,15 +1259,20 @@ abstract class DBObject implements iDisplay
}
/**
- * @param string $sObjClass
- * @param string $sObjKey
- * @param string $sHtmlLabel Label with HTML entities escaped (< escaped as <)
- * @param null $sUrlMakerClass
- * @param bool|true $bWithNavigationContext
- * @param bool|false $bArchived
- * @param bool|false $bObsolete
+ * Return an hyperlink pointing to <$sObjClass, $sObjKey>
+ *
+ * @internal
+ *
+ * @param string $sObjClass
+ * @param string $sObjKey
+ * @param string $sHtmlLabel Label with HTML entities escaped (< escaped as <)
+ * @param null|string $sUrlMakerClass if not null, the class must expose a public method ''MakeObjectUrl(string $sObjClass, string $sObjKey)''
+ * @param bool $bWithNavigationContext
+ * @param bool $bArchived
+ * @param bool $bObsolete
+ *
+ * @return string the HTML markup pointing to <$sObjClass, $sObjKey>
*
- * @return string
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \DictExceptionMissingString
@@ -978,12 +1348,19 @@ abstract class DBObject implements iDisplay
}
/**
+ * Return an hyperlink pointing to the current DBObject
+ *
+ * @api
+ *
* @param string $sUrlMakerClass
- * @param bool $bWithNavigationContext
+ * @param bool $bWithNavigationContext
* @param string $sLabel
*
* @return string
- * @throws \DictExceptionMissingString
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws DictExceptionMissingString
*/
public function GetHyperlink($sUrlMakerClass = null, $bWithNavigationContext = true, $sLabel = null)
{
@@ -995,7 +1372,14 @@ abstract class DBObject implements iDisplay
$bObsolete = $this->IsObsolete();
return self::MakeHyperLink(get_class($this), $this->GetKey(), $sLabel, $sUrlMakerClass, $bWithNavigationContext, $bArchived, $bObsolete);
}
-
+
+ /**
+ * @internal
+ *
+ * @param string $sClass
+ *
+ * @return mixed
+ */
public static function ComputeStandardUIPage($sClass)
{
static $aUIPagesCache = array(); // Cache to store the php page used to display each class of object
@@ -1012,22 +1396,58 @@ abstract class DBObject implements iDisplay
return $sPage;
}
+ /**
+ * @internal
+ *
+ * @return string
+ */
public static function GetUIPage()
{
return 'UI.php';
}
- // could be in the metamodel ?
+
+
+ /**
+ * Whether $value is valid as a primary key
+ *
+ * @internal
+ *
+ * @param string $value
+ *
+ * @return bool
+ */
public static function IsValidPKey($value)
{
+ // this function could be in the metamodel ?
return ((string)$value === (string)(int)$value);
}
+ /**
+ * Primary key Getter
+ *
+ * Get the id
+ *
+ * @api
+ *
+ * @return int|null
+ */
public function GetKey()
{
return $this->m_iKey;
}
+
+ /**
+ * Primary key Setter
+ * Usable only for not yet persisted DBObjects
+ *
+ * @internal
+ *
+ * @param int $iNewKey the desired identifier
+ *
+ * @throws CoreException
+ */
public function SetKey($iNewKey)
{
if (!self::IsValidPKey($iNewKey))
@@ -1041,11 +1461,18 @@ abstract class DBObject implements iDisplay
}
$this->m_iKey = $iNewKey;
}
- /**
- * Get the icon representing this object
- * @param boolean $bImgTag If true the result is a full IMG tag (or an emtpy string if no icon is defined)
- * @return string Either the full IMG tag ($bImgTag == true) or just the URL to the icon file
- */
+
+ /**
+ * Get the icon representing this object
+ *
+ * @api
+ *
+ * @param boolean $bImgTag If true the result is a full IMG tag (or an empty string if no icon is defined)
+ *
+ * @return string Either the full IMG tag ($bImgTag == true) or just the URL to the icon file
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetIcon($bImgTag = true)
{
$sCode = $this->ComputeHighlightCode();
@@ -1069,7 +1496,12 @@ abstract class DBObject implements iDisplay
}
/**
- * Get the name as defined in the dictionary
+ * Get the label of a class
+ *
+ * Returns the label as defined in the dictionary for the language of the current user
+ *
+ * @api
+ *
* @return string (empty for default name scheme)
*/
public static function GetClassName($sClass)
@@ -1079,7 +1511,12 @@ abstract class DBObject implements iDisplay
}
/**
- * Get the description as defined in the dictionary
+ * Get the description of a class
+ *
+ * Returns the label as defined in the dictionary for the language of the current user
+ *
+ * @internal
+ *
* @param string $sClass
*
* @return string
@@ -1091,7 +1528,9 @@ abstract class DBObject implements iDisplay
}
/**
- * Gets the name of an object in a safe manner for displaying inside a web page
+ * Helper to get the friendly name in a safe manner for displaying inside a web page
+ *
+ * @api
*
* @return string
* @throws \CoreException
@@ -1102,11 +1541,14 @@ abstract class DBObject implements iDisplay
}
/**
- * Gets the raw name of an object, this is not safe for displaying inside a web page
- * since the " < > characters are not escaped and the name may contain some XSS script
- * instructions.
+ * Helper to get the friendly name
+ *
+ * This is not safe for displaying inside a web page since the " < > characters are not escaped.
+ * In example, the name may contain some XSS script instructions.
* Use this function only for internal computations or for an output to a non-HTML destination
*
+ * @api
+ *
* @return string
* @throws \CoreException
*/
@@ -1116,9 +1558,12 @@ abstract class DBObject implements iDisplay
}
/**
+ * Helper to get the state
+ *
+ * @api
+ *
* @return mixed|string '' if no state attribute, object representing its value otherwise
* @throws \CoreException
- * @internal
*/
public function GetState()
{
@@ -1133,6 +1578,16 @@ abstract class DBObject implements iDisplay
}
}
+ /**
+ * Get the label of the current state
+ *
+ * @api
+ *
+ * @return mixed|string
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetStateLabel()
{
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
@@ -1147,6 +1602,15 @@ abstract class DBObject implements iDisplay
}
}
+ /**
+ * Get the description of the state
+ *
+ * @api
+ *
+ * @return mixed|string
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetStateDescription()
{
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
@@ -1162,9 +1626,9 @@ abstract class DBObject implements iDisplay
}
/**
- * Overridable - Define attributes read-only from the end-user perspective
- *
- * @return array List of attcodes
+ * Define attributes read-only from the end-user perspective
+ *
+ * @return array|null List of attcodes
*/
public static function GetReadOnlyAttributes()
{
@@ -1173,9 +1637,13 @@ abstract class DBObject implements iDisplay
/**
- * Overridable - Get predefined objects (could be hardcoded)
+ * Get predefined objects
+ *
* The predefined objects will be synchronized with the DB at each install/upgrade
- * As soon as a class has predefined objects, then nobody can create nor delete objects
+ * As soon as a class has predefined objects, then nobody can create nor delete objects
+ *
+ * @internal
+ *
* @return array An array of id => array of attcode => php value(so-called "real value": integer, string, ormDocument, DBObjectSet, etc.)
*/
public static function GetPredefinedObjects()
@@ -1184,17 +1652,19 @@ abstract class DBObject implements iDisplay
}
/**
+ * Get the flags for the given state
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic. If you do so, rely on the parent as a fallback if you have uncovered $sAttCode
+ *
* @param string $sAttCode $sAttCode The code of the attribute
- * @param array $aReasons To store the reasons why the attribute is read-only (info about the synchro replicas)
- * @param string $sTargetState The target state in which to evalutate the flags, if empty the current state will be
- * used
+ * @param array $aReasons To store the reasons why the attribute is read-only (info about the synchro replicas)
+ * @param string $sTargetState The target state in which to evalutate the flags, if empty the current state will be used
*
- * @return integer the binary combination of flags for the given attribute in the given state of the object
- * Values can be one of the OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY, ... (see define in metamodel.class.php)
+ * @return integer the binary combination of flags for the given attribute in the given state of the object.
+ * Values can be one of the OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY, ... (see define in metamodel.class.php)
+ *
* @throws \CoreException
*
- * @api
- *
* @see GetInitialStateAttributeFlags for creation
*/
public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
@@ -1232,12 +1702,18 @@ abstract class DBObject implements iDisplay
return $iFlags | $iSynchroFlags; // Combine both sets of flags
}
- /**
- * @param string $sAttCode
- * @param array $aReasons To store the reasons why the attribute is read-only (info about the synchro replicas)
- *
- * @throws \CoreException
- */
+ /**
+ * Whether the attribute is read-only
+ *
+ * @internal
+ *
+ * @param string $sAttCode
+ * @param array $aReasons To store the reasons why the attribute is read-only (info about the synchro replicas)
+ *
+ * @return int Values can be one of the OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY, ... (see define in metamodel.class.php)
+ *
+ * @throws \CoreException
+ */
public function IsAttributeReadOnlyForCurrentState($sAttCode, &$aReasons = array())
{
$iAttFlags = $this->GetAttributeFlags($sAttCode, $aReasons);
@@ -1248,11 +1724,17 @@ abstract class DBObject implements iDisplay
/**
* Returns the set of flags (OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY...)
* for the given attribute in a transition
- * @param $sAttCode string $sAttCode The code of the attribute
- * @param $sStimulus string The stimulus code to apply
- * @param $aReasons array To store the reasons why the attribute is read-only (info about the synchro replicas)
- * @param $sOriginState string The state from which to apply $sStimulus, if empty current state will be used
+ *
+ * @internal
+ *
+ * @param string $sAttCode $sAttCode The code of the attribute
+ * @param string $sStimulus The stimulus code to apply
+ * @param array|null $aReasons To store the reasons why the attribute is read-only (info about the synchro replicas)
+ * @param string $sOriginState The state from which to apply $sStimulus, if empty current state will be used
+ *
* @return integer Flags: the binary combination of the flags applicable to this attribute
+ * @throws ArchivedObjectException
+ * @throws CoreException
*/
public function GetTransitionFlags($sAttCode, $sStimulus, &$aReasons = array(), $sOriginState = '')
{
@@ -1287,9 +1769,13 @@ abstract class DBObject implements iDisplay
* Returns an array of attribute codes (with their flags) when $sStimulus is applied on the object in the $sOriginState state.
* Note: Attributes (and flags) from the target state and the transition are combined.
*
- * @param $sStimulus string
- * @param $sOriginState string Default is current state
+ * @internal
+ *
+ * @param string $sStimulus
+ * @param string $sOriginState Default is current state
+ *
* @return array
+ * @throws CoreException
*/
public function GetTransitionAttributes($sStimulus, $sOriginState = null)
{
@@ -1310,13 +1796,13 @@ abstract class DBObject implements iDisplay
* @param string $sAttCode The code of the attribute
* @param array $aReasons
*
- * @return integer The binary combination of the flags for the given attribute for the current state of the object
- * considered as an INITIAL state.
- * Values can be one of the OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY, ... (see define in metamodel.class.php)
+ * @overwritable-hook You can extend this method in order to provide your own logic
+ *
+ * @return integer The binary combination of the flags for the given attribute for the current state of the object considered as an INITIAL state.
+ * Values can be one of the OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY, ... (see define in metamodel.class.php)
+ *
* @throws \CoreException
*
- * @api
- *
* @see GetAttributeFlags when modifying the object
*/
public function GetInitialStateAttributeFlags($sAttCode, &$aReasons = array())
@@ -1333,15 +1819,17 @@ abstract class DBObject implements iDisplay
/**
* Check if the given (or current) value is suitable for the attribute
*
- * @param $sAttCode
- * @param boolean|string $value true if successfull, the error desciption otherwise
+ * @api
+ * @api-advanced
+ *
+ * @param string $sAttCode
+ * @param boolean|string $value true if successful, the error description otherwise
*
* @return bool|string
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
*
- * @internal
*/
public function CheckValue($sAttCode, $value = null)
{
@@ -1476,8 +1964,9 @@ abstract class DBObject implements iDisplay
/**
* check attributes together
*
- * @return bool
- * @api
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ *
+ * @return bool
*/
public function CheckConsistency()
{
@@ -1485,8 +1974,11 @@ abstract class DBObject implements iDisplay
}
/**
+ * @internal
+ *
* @throws \CoreException
* @throws \OQLException
+ *
* @since 2.6 N°659 uniqueness constraint
*/
protected function DoCheckUniqueness()
@@ -1524,11 +2016,13 @@ abstract class DBObject implements iDisplay
}
/**
+ *
+ * @internal
+ *
* @param string $sUniquenessRuleId
*
- * @return string dict key : Class:$sClassName/UniquenessRule:$sUniquenessRuleId
- * if none then will use Core:UniquenessDefaultError
- * Dictionary keys can contain "$this" placeholders
+ * @return string dict key : Class:$sClassName/UniquenessRule:$sUniquenessRuleId if none then will use Core:UniquenessDefaultError
+ * Dictionary keys can contain "$this" placeholders
*
* @since 2.6 N°659 uniqueness constraint
*/
@@ -1551,6 +2045,9 @@ abstract class DBObject implements iDisplay
}
/**
+ *
+ * @internal
+ *
* @param string $sUniquenessRuleId uniqueness rule ID
* @param array $aUniquenessRuleProperties uniqueness rule properties
*
@@ -1571,6 +2068,8 @@ abstract class DBObject implements iDisplay
}
/**
+ * @internal
+ *
* @param string $sUniquenessRuleId uniqueness rule ID
* @param array $aUniquenessRuleProperties uniqueness rule properties
*
@@ -1613,13 +2112,18 @@ abstract class DBObject implements iDisplay
/**
* Check integrity rules (before inserting or updating the object)
*
- * Errors should be inserted in {@link $m_aCheckIssues} and {@link $m_aCheckWarnings} arrays
- *
+ * **This method is not meant to be called directly, use DBObject::CheckToWrite()!**
+ * Errors should be inserted in $m_aCheckIssues and $m_aCheckWarnings arrays
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ * @see CheckToWrite()
+ * @see $m_aCheckIssues
+ * @see $m_aCheckWarnings
+ *
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
*
- * @api
*/
public function DoCheckToWrite()
{
@@ -1674,18 +2178,23 @@ abstract class DBObject implements iDisplay
}
/**
+ *
+ * @api
+ * @api-advanced
+ *
* @return array containing :
- *
- *
{@link $m_bCheckStatus}
- *
{@link $m_aCheckIssues}
- *
{@link $m_bSecurityIssue}
- *
+ * * $m_bCheckStatus
+ * * $m_aCheckIssues
+ * * $m_bSecurityIssue
*
+ * @see $m_bCheckStatus
+ * @see $m_aCheckIssues
+ * @see $m_bSecurityIssue
+ *
* @throws \ArchivedObjectException
* @throws \CoreException
* @throws \OQLException
*
- * @internal do not overwrite ! Use {@link DoCheckToWrite} instead
*/
final public function CheckToWrite()
{
@@ -1712,13 +2221,13 @@ abstract class DBObject implements iDisplay
return array($this->m_bCheckStatus, $this->m_aCheckIssues, $this->m_bSecurityIssue);
}
- // check if it is allowed to delete the existing object from the database
- // a displayable error is returned
/**
- * check if it is allowed to delete the existing object from the database
+ * Check if it is allowed to delete the existing object from the database
*
- * a displayable error is added in {@link $m_aDeleteIssues}
+ * an array of displayable error is added in {@link $m_aDeleteIssues}
*
+ * @internal
+ *
* @param \DeletionPlan $oDeletionPlan
*
* @throws \CoreException
@@ -1774,18 +2283,29 @@ abstract class DBObject implements iDisplay
}
}
- /**
- * @param \DeletionPlan $oDeletionPlan
- *
- * @return bool
- */
+ /**
+ * @internal
+ *
+ * @param \DeletionPlan $oDeletionPlan
+ *
+ * @return bool
+ * @throws CoreException
+ */
public function CheckToDelete(&$oDeletionPlan)
{
$this->MakeDeletionPlan($oDeletionPlan);
$oDeletionPlan->ComputeResults();
return (!$oDeletionPlan->FoundStopper());
- }
+ }
+ /**
+ * @internal
+ *
+ * @param array $aProposal
+ *
+ * @return array
+ * @throws Exception
+ */
protected function ListChangedValues(array $aProposal)
{
$aDelta = array();
@@ -1842,12 +2362,15 @@ abstract class DBObject implements iDisplay
return $aDelta;
}
- /**
- * List the attributes that have been changed
- *
- * @return array attname => currentvalue
- * @internal
- */
+ /**
+ * List the attributes that have been changed since the object has been loaded from the DB
+ *
+ * @api
+ * @api-advanced
+ *
+ * @return array attname => currentvalue
+ * @throws Exception
+ */
public function ListChanges()
{
if ($this->m_bIsInDB)
@@ -1860,7 +2383,14 @@ abstract class DBObject implements iDisplay
}
}
- // Tells whether or not an object was modified since last read (ie: does it differ from the DB ?)
+ /**
+ * Whether or not an object was modified since last read from the DB
+ * (ie: does it differ from the DB ?)
+ *
+ * @api
+ *
+ * @return bool
+ */
public function IsModified()
{
$aChanges = $this->ListChanges();
@@ -1868,7 +2398,9 @@ abstract class DBObject implements iDisplay
}
/**
- * @param \DBObject $oSibling
+ * Whether or not $oSibling is equal to the current DBObject
+ *
+ * @param DBObject $oSibling
*
* @return bool
*/
@@ -1909,8 +2441,8 @@ abstract class DBObject implements iDisplay
/**
* Used only by insert, Meant to be overloaded
- *
- * @api
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
*/
protected function OnObjectKeyReady()
{
@@ -1919,8 +2451,9 @@ abstract class DBObject implements iDisplay
/**
* used both by insert/update
*
+ * @internal
+ *
* @throws \CoreException
- * @internal
*/
private function DBWriteLinks()
{
@@ -1939,8 +2472,9 @@ abstract class DBObject implements iDisplay
/**
* Used both by insert/update
*
+ * @internal
+ *
* @throws \CoreException
- * @internal
*/
private function WriteExternalAttributes()
{
@@ -1955,15 +2489,26 @@ abstract class DBObject implements iDisplay
}
}
- // Note: this is experimental - it was designed to speed up the setup of iTop
- // Known limitations:
- // - does not work with multi-table classes (issue with the unique id to maintain in several tables)
- // - the id of the object is not updated
+
+ /**
+ * Note: this is experimental - it was designed to speed up the setup of iTop
+ * Known limitations:
+ * - does not work with multi-table classes (issue with the unique id to maintain in several tables)
+ * - the id of the object is not updated
+ *
+ * @internal
+ * @experimental
+ */
static public final function BulkInsertStart()
{
self::$m_bBulkInsert = true;
- }
+ }
+ /**
+ *
+ * @internal
+ * @experimental
+ */
static public final function BulkInsertFlush()
{
if (!self::$m_bBulkInsert) return;
@@ -1986,13 +2531,14 @@ abstract class DBObject implements iDisplay
/**
* Persists new object in the DB
+ *
+ * @internal
*
- * @param $sTableClass
+ * @param string $sTableClass
*
* @return bool|int false if nothing to persist (no change), new key value otherwise
* @throws \CoreException
* @throws \MySQLException
- * @internal
*/
private function DBInsertSingleTable($sTableClass)
{
@@ -2077,6 +2623,8 @@ abstract class DBObject implements iDisplay
/**
* Persists object to new records in the DB
+ *
+ * @internal
*
* @return int key of the newly created object
* @throws \ArchivedObjectException
@@ -2087,7 +2635,6 @@ abstract class DBObject implements iDisplay
* @throws \MySQLException
* @throws \OQLException
*
- * @internal
*/
public function DBInsertNoReload()
{
@@ -2204,6 +2751,16 @@ abstract class DBObject implements iDisplay
return $this->m_iKey;
}
+ /**
+ * @internal
+ *
+ * @param array $aAuthorizedExtKeys
+ * @param array $aStatements
+ * @param string $sTableClass
+ *
+ * @throws CoreException
+ * @throws MySQLException
+ */
protected function MakeInsertStatementSingleTable($aAuthorizedExtKeys, &$aStatements, $sTableClass)
{
$sTable = MetaModel::DBGetTable($sTableClass);
@@ -2270,6 +2827,15 @@ abstract class DBObject implements iDisplay
$aStatements[] = "INSERT INTO `$sTable` (".join(",", $aFieldsToWrite).") VALUES (".join(", ", $aValuesToWrite).");";
}
+ /**
+ * @internal
+ *
+ * @param array $aAuthorizedExtKeys
+ * @param array $aStatements
+ *
+ * @throws CoreException
+ * @throws MySQLException
+ */
public function MakeInsertStatements($aAuthorizedExtKeys, &$aStatements)
{
$sClass = get_class($this);
@@ -2292,8 +2858,14 @@ abstract class DBObject implements iDisplay
}
}
- /**
+ /*
+ * Persist an object to the DB, for the first time
+ *
+ * @api
+ * @see DBWrite
+ *
* @return int|null inserted object key
+ *
* @throws \ArchivedObjectException
* @throws \CoreCannotSaveObjectException
* @throws \CoreException
@@ -2301,7 +2873,6 @@ abstract class DBObject implements iDisplay
* @throws \CoreWarning
* @throws \MySQLException
* @throws \OQLException
- * @internal
*/
public function DBInsert()
{
@@ -2309,21 +2880,64 @@ abstract class DBObject implements iDisplay
$this->Reload();
return $this->m_iKey;
}
-
+
+ /**
+ * @internal
+ *
+ * @param CMDBChange $oChange
+ *
+ * @return int|null
+ * @throws ArchivedObjectException
+ * @throws CoreCannotSaveObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws CoreWarning
+ * @throws MySQLException
+ * @throws OQLException
+ */
public function DBInsertTracked(CMDBChange $oChange)
{
CMDBObject::SetCurrentChange($oChange);
return $this->DBInsert();
}
+ /**
+ * @internal
+ *
+ * @param CMDBChange $oChange
+ *
+ * @return int
+ * @throws ArchivedObjectException
+ * @throws CoreCannotSaveObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws CoreWarning
+ * @throws MySQLException
+ * @throws OQLException
+ */
public function DBInsertTrackedNoReload(CMDBChange $oChange)
{
CMDBObject::SetCurrentChange($oChange);
return $this->DBInsertNoReload();
}
- // Creates a copy of the current object into the database
- // Returns the id of the newly created object
+ /**
+ * Creates a copy of the current object into the database
+ *
+ * @internal
+ *
+ * @param null $iNewKey
+ *
+ * @return int|null the id of the newly created object
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreCannotSaveObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws CoreWarning
+ * @throws MySQLException
+ * @throws OQLException
+ */
public function DBClone($iNewKey = null)
{
$this->m_bIsInDB = false;
@@ -2337,6 +2951,8 @@ abstract class DBObject implements iDisplay
* This function is automatically called after cloning an object with the "clone" PHP language construct
* The purpose of this method is to reset the appropriate attributes of the object in
* order to make sure that the newly cloned object is really distinct from its clone
+ *
+ * @internal
*/
public function __clone()
{
@@ -2348,9 +2964,13 @@ abstract class DBObject implements iDisplay
/**
* Update an object in DB
*
+ * @api
+ * @see DBWrite
+ *
* @return int object key
+ *
* @throws \CoreException
- * @throws \CoreCannotSaveObjectException if {@link CheckToWrite()} returns issues
+ * @throws \CoreCannotSaveObjectException if CheckToWrite() returns issues
*/
public function DBUpdate()
{
@@ -2539,7 +3159,17 @@ abstract class DBObject implements iDisplay
return $this->m_iKey;
}
-
+
+ /**
+ *
+ * @internal
+ *
+ * @param CMDBChange $oChange
+ *
+ * @return int
+ * @throws CoreCannotSaveObjectException
+ * @throws CoreException
+ */
public function DBUpdateTracked(CMDBChange $oChange)
{
CMDBObject::SetCurrentChange($oChange);
@@ -2548,8 +3178,11 @@ abstract class DBObject implements iDisplay
/**
* Make the current changes persistent - clever wrapper for Insert or Update
+ *
+ * @api
*
* @return int
+ *
* @throws \CoreCannotSaveObjectException
* @throws \CoreException
*/
@@ -2565,6 +3198,13 @@ abstract class DBObject implements iDisplay
}
}
+ /**
+ * @internal
+ *
+ * @param string $sTableClass
+ *
+ * @throws CoreException
+ */
private function DBDeleteSingleTable($sTableClass)
{
$sTable = MetaModel::DBGetTable($sTableClass);
@@ -2578,6 +3218,16 @@ abstract class DBObject implements iDisplay
CMDBSource::DeleteFrom($sDeleteSQL);
}
+ /**
+ * @internal
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws MySQLException
+ * @throws MySQLHasGoneAwayException
+ * @throws OQLException
+ */
protected function DBDeleteSingleObject()
{
if (!MetaModel::DBIsReadOnly())
@@ -2644,8 +3294,27 @@ abstract class DBObject implements iDisplay
}
}
- // Delete an object... and guarantee data integrity
- //
+ /**
+ * Delete an object
+ *
+ * Pior to the delete the object, it checks if this is feasible to guarantee the DB integrity.
+ * If so, it performs any required cleanup (delete other objects or reset external keys) in addition to the object deletion.
+ *
+ * @api
+ *
+ * @param null $oDeletionPlan Do not use: aims at dealing with recursion
+ *
+ * @return DeletionPlan The detailed description of cleanup operation that have been performed
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreCannotSaveObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws DeleteException
+ * @throws MySQLException
+ * @throws MySQLHasGoneAwayException
+ * @throws OQLException
+ */
public function DBDelete(&$oDeletionPlan = null)
{
static $iLoopTimeLimit = null;
@@ -2710,12 +3379,36 @@ abstract class DBObject implements iDisplay
return $oDeletionPlan;
}
+ /**
+ * @internal
+ *
+ * @param CMDBChange $oChange
+ * @param null $bSkipStrongSecurity
+ * @param null $oDeletionPlan
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreCannotSaveObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws DeleteException
+ * @throws MySQLException
+ * @throws MySQLHasGoneAwayException
+ * @throws OQLException
+ */
public function DBDeleteTracked(CMDBChange $oChange, $bSkipStrongSecurity = null, &$oDeletionPlan = null)
{
CMDBObject::SetCurrentChange($oChange);
$this->DBDelete($oDeletionPlan);
}
+ /**
+ * @internal
+ *
+ * @return array
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function EnumTransitions()
{
$sStateAttCode = MetaModel::GetStateAttributeCode(get_class($this));
@@ -2725,9 +3418,20 @@ abstract class DBObject implements iDisplay
return MetaModel::EnumTransitions(get_class($this), $sState);
}
- /**
- * Designed as an action to be called when a stop watch threshold times out
- */
+ /**
+ * Helper to reset a stop-watch
+ * Suitable for use as a lifecycle action
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ *
+ * @return bool
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function ResetStopWatch($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
@@ -2742,11 +3446,15 @@ abstract class DBObject implements iDisplay
}
/**
- * Designed as an action to be called when a stop watch threshold times out
- * or from within the framework
- * @param $sStimulusCode
- * @param bool|false $bDoNotWrite
+ * Apply a stimulus (workflow)
+ *
+ * @api
+ *
+ * @param string $sStimulusCode
+ * @param bool $bDoNotWrite
+ *
* @return bool
+ *
* @throws CoreException
* @throws CoreUnexpectedValue
*/
@@ -2884,7 +3592,11 @@ abstract class DBObject implements iDisplay
}
/**
- * Lifecycle action: Recover the default value (aka when an object is being created)
+ * Helper to recover the default value (aka when an object is being created)
+ * Suitable for use as a lifecycle action
+ *
+ * @api
+ *
*/
public function Reset($sAttCode)
{
@@ -2893,7 +3605,10 @@ abstract class DBObject implements iDisplay
}
/**
- * Lifecycle action: Copy an attribute to another
+ * Helper to copy the value of an attribute to another one
+ * Suitable for use as a lifecycle action
+ *
+ * @api
*/
public function Copy($sDestAttCode, $sSourceAttCode)
{
@@ -2901,18 +3616,38 @@ abstract class DBObject implements iDisplay
return true;
}
- /**
- * Lifecycle action: Set the current date/time for the given attribute
- */
+ /**
+ * Helper to set the current date/time for the given attribute
+ * Suitable for use as a lifecycle action
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ *
+ * @return bool
+ *
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function SetCurrentDate($sAttCode)
{
$this->Set($sAttCode, time());
return true;
}
- /**
- * Lifecycle action: Set the current logged in user for the given attribute
- */
+ /**
+ * Helper to set the current logged in user for the given attribute
+ * Suitable for use as a lifecycle action
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ *
+ * @return bool
+ *
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function SetCurrentUser($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
@@ -2936,9 +3671,19 @@ abstract class DBObject implements iDisplay
return true;
}
- /**
- * Lifecycle action: Set the current logged in CONTACT for the given attribute
- */
+ /**
+ * Helper to set the current logged in CONTACT for the given attribute
+ * Suitable for use as a lifecycle action
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ *
+ * @return bool
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function SetCurrentPerson($sAttCode)
{
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
@@ -2970,9 +3715,21 @@ abstract class DBObject implements iDisplay
return true;
}
- /**
- * Lifecycle action: Set the time elapsed since a reference point
- */
+ /**
+ * Helper to set the time elapsed since a reference point
+ * Suitable for use as a lifecycle action
+ *
+ * @api
+ *
+ * @param string $sAttCode
+ * @param string $sRefAttCode
+ * @param string|null $sWorkingTimeComputer
+ *
+ * @return bool
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public function SetElapsedTime($sAttCode, $sRefAttCode, $sWorkingTimeComputer = null)
{
if (is_null($sWorkingTimeComputer))
@@ -3006,28 +3763,51 @@ abstract class DBObject implements iDisplay
}
-
- /**
- * Create query parameters (SELECT ... WHERE service = :this->service_id)
- * to be used with the APIs DBObjectSearch/DBObjectSet
- *
- * Starting 2.0.2 the parameters are computed on demand, at the lowest level,
- * in VariableExpression::Render()
- */
+ /**
+ * Create query parameters (SELECT ... WHERE service = :this->service_id)
+ * to be used with the APIs DBObjectSearch/DBObjectSet
+ *
+ * Starting 2.0.2 the parameters are computed on demand, at the lowest level,
+ * in VariableExpression::Render()
+ *
+ * @internal
+ *
+ * @param string $sArgName
+ *
+ * @return array
+ */
public function ToArgsForQuery($sArgName = 'this')
{
return array($sArgName.'->object()' => $this);
}
- /**
- * Create template placeholders: now equivalent to ToArgsForQuery since the actual
- * template placeholders are computed on demand.
- */
+ /**
+ * Create template placeholders: now equivalent to ToArgsForQuery since the actual
+ * template placeholders are computed on demand.
+ *
+ * @internal
+ *
+ * @param string $sArgName
+ *
+ * @return array
+ */
public function ToArgs($sArgName = 'this')
{
return $this->ToArgsForQuery($sArgName);
}
+ /**
+ * Get various representations of the value, for insertion into a template (e.g. in Notifications)
+ *
+ * @internal
+ *
+ * @param string $sPlaceholderAttCode
+ *
+ * @return int|mixed|string|null
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws DictExceptionMissingString
+ */
public function GetForTemplate($sPlaceholderAttCode)
{
$ret = null;
@@ -3110,6 +3890,8 @@ abstract class DBObject implements iDisplay
* Associate a portal to a class that implements iDBObjectURLMaker,
* and which will be invoked with placeholders like $this->org_id->hyperlink(portal)$
*
+ * @internal
+ *
* @param string $sPortalId Identifies the portal. Conventions: the main portal is 'console', The user requests portal is 'portal'.
* @param string $sUrlMakerClass
*/
@@ -3119,55 +3901,56 @@ abstract class DBObject implements iDisplay
}
/**
- * Can be overloaded
- *
- * @api
+ * this method is called before the object is inserted into DB.
+ *
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
*/
protected function OnInsert()
{
}
- /**
- * Can be overloaded
- *
- * @api
- */
+ /**
+ * this method is called after the object is inserted into DB.
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ */
protected function AfterInsert()
{
}
- /**
- * Can be overloaded
- *
- * @api
- */
+ /**
+ * this method is called before the object is updated into DB.
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ */
protected function OnUpdate()
{
}
- /**
- * Can be overloaded
- *
- * @api
- */
+ /**
+ * this method is called after the object is updated into DB.
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ */
protected function AfterUpdate()
{
}
- /**
- * Can be overloaded
- *
- * @api
- */
+ /**
+ * this method is called before the object is deleted into DB.
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ */
protected function OnDelete()
{
}
- /**
- * Can be overloaded
- *
- * @api
- */
+ /**
+ * this method is called after the object is deleted into DB.
+ *
+ * @overwritable-hook You can extend this method in order to provide your own logic.
+ */
protected function AfterDelete()
{
}
@@ -3176,6 +3959,8 @@ abstract class DBObject implements iDisplay
/**
* Common to the recording of link set changes (add/remove/modify)
*
+ * @internal
+ *
* @param $iLinkSetOwnerId
* @param \AttributeLinkedSet $oLinkSet
* @param $sChangeOpClass
@@ -3285,11 +4070,17 @@ abstract class DBObject implements iDisplay
$this->RecordLinkSetListChange(true);
}
+ /**
+ * @internal
+ */
protected function RecordObjDeletion($objkey)
{
$this->RecordLinkSetListChange(false);
}
+ /**
+ * @internal
+ */
protected function RecordAttChanges(array $aValues, array $aOrigValues)
{
foreach(MetaModel::GetTrackForwardExternalKeys(get_class($this)) as $sExtKeyAttCode => $oLinkSet)
@@ -3335,23 +4126,38 @@ abstract class DBObject implements iDisplay
}
}
- // Return an empty set for the parent of all
- // May be overloaded.
- // Anyhow, this way of implementing the relations suffers limitations (not handling the redundancy)
- // and you should consider defining those things in XML.
+
+ /**
+ * implement relations
+ *
+ * Return an empty set for the parent of all
+ *
+ * this way of implementing the relations suffers limitations (not handling the redundancy)
+ * and you should consider defining those things in XML
+ *
+ * @internal
+ * @deprecated
+ */
public static function GetRelationQueries($sRelCode)
{
return array();
}
- // Reserved: do not overload
+ /**
+ * Reserved: do not overload
+ *
+ * @internal
+ */
public static function GetRelationQueriesEx($sRelCode)
{
return array();
}
/**
- * Will be deprecated soon - use GetRelatedObjectsDown/Up instead to take redundancy into account
+ * Use GetRelatedObjectsDown/Up instead to take redundancy into account
+ *
+ * @internal
+ * @deprecated
*/
public function GetRelatedObjects($sRelCode, $iMaxDepth = 99, &$aResults = array())
{
@@ -3412,17 +4218,20 @@ abstract class DBObject implements iDisplay
}
return $aResults;
}
-
- /**
- * Compute the "RelatedObjects" (forward or "down" direction) for the object
- * for the specified relation
- *
- * @param string $sRelCode The code of the relation to use for the computation
- * @param int $iMaxDepth Maximum recursion depth
- * @param boolean $bEnableReduncancy Whether or not to take into account the redundancy
- *
- * @return RelationGraph The graph of all the related objects
- */
+
+ /**
+ * Compute the "RelatedObjects" (forward or "down" direction) for the object
+ * for the specified relation
+ *
+ * @internal
+ *
+ * @param string $sRelCode The code of the relation to use for the computation
+ * @param int $iMaxDepth Maximum recursion depth
+ * @param bool $bEnableRedundancy
+ *
+ * @return RelationGraph The graph of all the related objects
+ * @throws CoreException
+ */
public function GetRelatedObjectsDown($sRelCode, $iMaxDepth = 99, $bEnableRedundancy = true)
{
$oGraph = new RelationGraph();
@@ -3430,17 +4239,20 @@ abstract class DBObject implements iDisplay
$oGraph->ComputeRelatedObjectsDown($sRelCode, $iMaxDepth, $bEnableRedundancy);
return $oGraph;
}
-
- /**
- * Compute the "RelatedObjects" (reverse or "up" direction) for the object
- * for the specified relation
- *
- * @param string $sRelCode The code of the relation to use for the computation
- * @param int $iMaxDepth Maximum recursion depth
- * @param boolean $bEnableReduncancy Whether or not to take into account the redundancy
- *
- * @return RelationGraph The graph of all the related objects
- */
+
+ /**
+ * Compute the "RelatedObjects" (reverse or "up" direction) for the object
+ * for the specified relation
+ *
+ * @internal
+ *
+ * @param string $sRelCode The code of the relation to use for the computation
+ * @param int $iMaxDepth Maximum recursion depth
+ * @param bool $bEnableRedundancy
+ *
+ * @return RelationGraph The graph of all the related objects
+ * @throws CoreException
+ */
public function GetRelatedObjectsUp($sRelCode, $iMaxDepth = 99, $bEnableRedundancy = true)
{
$oGraph = new RelationGraph();
@@ -3481,6 +4293,8 @@ abstract class DBObject implements iDisplay
}
/**
+ * @internal
+ *
* @param \DeletionPlan $oDeletionPlan
* @param array $aVisited
* @param int $iDeleteOption
@@ -3563,11 +4377,13 @@ abstract class DBObject implements iDisplay
}
/**
- * WILL DEPRECATED SOON
* Caching relying on an object set is not efficient since 2.0.3
* Use GetSynchroData instead
*
* Get all the synchro replica related to this object
+ *
+ * @internal
+ * @deprecated
*
* @return DBObjectSet Set with two columns: R=SynchroReplica S=SynchroDataSource
* @throws \OQLException
@@ -3581,11 +4397,13 @@ abstract class DBObject implements iDisplay
/**
* Get all the synchro data related to this object
+ *
+ * @internal
*
* @return array of data_source_id => array
- * 'source' => $oSource,
- * 'attributes' => array of $oSynchroAttribute
- * 'replica' => array of $oReplica (though only one should exist, misuse of the data sync can have this consequence)
+ * * 'source' => $oSource,
+ * * 'attributes' => array of $oSynchroAttribute
+ * * 'replica' => array of $oReplica (though only one should exist, misuse of the data sync can have this consequence)
* @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \MySQLException
@@ -3624,6 +4442,20 @@ abstract class DBObject implements iDisplay
return $this->m_aSynchroData;
}
+ /**
+ *
+ * @internal
+ *
+ * @param string $sAttCode
+ * @param array $aReason
+ *
+ * @return int
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ * @throws MySQLException
+ * @throws OQLException
+ */
public function GetSynchroReplicaFlags($sAttCode, &$aReason)
{
$iFlags = OPT_ATT_NORMAL;
@@ -3654,6 +4486,9 @@ abstract class DBObject implements iDisplay
}
/**
+ *
+ * @internal
+ *
* @return bool true if this object is used in a data synchro
* @throws \CoreException
* @throws \CoreUnexpectedValue
@@ -3694,12 +4529,26 @@ abstract class DBObject implements iDisplay
// Experimental iDisplay implementation
//
/////////////////////////////////////////////////////////////////////////
-
+
+ /**
+ * @internal
+ *
+ * @param string $sContextParam
+ *
+ * @return string|null
+ */
public static function MapContextParam($sContextParam)
{
return null;
}
-
+
+ /**
+ * @internal
+ *
+ * @return String
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function GetHilightClass()
{
$sCode = $this->ComputeHighlightCode();
@@ -3714,6 +4563,16 @@ abstract class DBObject implements iDisplay
return HILIGHT_CLASS_NONE;
}
+ /**
+ * @internal
+ *
+ * @param WebPage $oPage
+ * @param bool $bEditMode
+ *
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ * @throws DictExceptionMissingString
+ */
public function DisplayDetails(WebPage $oPage, $bEditMode = false)
{
$oPage->add('
');
@@ -3730,11 +4589,13 @@ abstract class DBObject implements iDisplay
$oPage->details($aValues);
}
-
+ /** @internal */
const CALLBACK_AFTERINSERT = 0;
/**
* Register a call back that will be called when some internal event happens
+ *
+ * @internal
*
* @param $iType string Any of the CALLBACK_x constants
* @param $callback callable Call specification like a function name, or array('', '') or array($object, '')
@@ -3755,12 +4616,18 @@ abstract class DBObject implements iDisplay
);
}
- /**
- * Computes a text-like fingerprint identifying the content of the object
- * but excluding the specified columns
- * @param $aExcludedColumns array The list of columns to exclude
- * @return string
- */
+ /**
+ * Computes a text-like fingerprint identifying the content of the object
+ * but excluding the specified columns
+ *
+ * @internal
+ *
+ * @param $aExcludedColumns array The list of columns to exclude
+ *
+ * @return string
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function Fingerprint($aExcludedColumns = array())
{
$sFingerprint = '';
@@ -3780,6 +4647,8 @@ abstract class DBObject implements iDisplay
/**
* Execute a set of scripted actions onto the current object
* See ExecAction for the syntax and features of the scripted actions
+ *
+ * @internal
*
* @param $aActions array of statements (e.g. "set(name, Made after $source->name$)")
* @param $aSourceObjects array of Alias => Context objects (Convention: some statements require the 'source' element
@@ -3831,6 +4700,8 @@ abstract class DBObject implements iDisplay
/**
* Helper to copy an attribute between two objects (in memory)
* Originally designed for ExecAction()
+ *
+ * @internal
*
* @param \DBObject $oSourceObject
* @param $sSourceAttCode
@@ -3906,6 +4777,9 @@ abstract class DBObject implements iDisplay
* - add_to_list (source_key_att, dest_att, lnk_att, lnk_att_value)
* - apply_stimulus (stimulus)
* - call_method (method_name)
+ *
+ *
+ * @internal
*
* @param $sVerb string Any of the verb listed above (e.g. "set")
* @param $aParams array of strings (e.g. array('name', 'copied from $source->name$')
@@ -4138,6 +5012,17 @@ abstract class DBObject implements iDisplay
}
}
+ /**
+ * Is the object archived
+ *
+ * @api
+ *
+ * @param string|null $sKeyAttCode
+ *
+ * @return bool
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function IsArchived($sKeyAttCode = null)
{
$bRet = false;
@@ -4149,6 +5034,15 @@ abstract class DBObject implements iDisplay
return $bRet;
}
+ /**
+ * Is the object obsolete
+ *
+ * @param string|null $sKeyAttCode
+ *
+ * @return bool
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function IsObsolete($sKeyAttCode = null)
{
$bRet = false;
@@ -4161,7 +5055,10 @@ abstract class DBObject implements iDisplay
}
/**
- * @param $bArchive
+ *
+ * @internal
+ *
+ * @param boolean $bArchive
* @throws Exception
*/
protected function DBWriteArchiveFlag($bArchive)
@@ -4207,6 +5104,9 @@ abstract class DBObject implements iDisplay
}
/**
+ *
+ * @internal
+ *
* Can be called to repair the database (tables consistency)
* The archive_date will be preserved
* @throws Exception
@@ -4218,6 +5118,11 @@ abstract class DBObject implements iDisplay
$this->m_aOrigValues['archive_flag'] = true;
}
+ /**
+ * @internal
+ *
+ * @throws Exception
+ */
public function DBUnarchive()
{
$this->DBWriteArchiveFlag(false);
@@ -4228,11 +5133,15 @@ abstract class DBObject implements iDisplay
}
-
- /**
- * @param string $sClass Needs to be an instanciable class
- * @returns $oObj
- **/
+ /**
+ * @internal
+ *
+ * @param string $sClass Needs to be an instanciable class
+ *
+ * @return DBObject
+ * @throws CoreException
+ * @throws CoreUnexpectedValue
+ */
public static function MakeDefaultInstance($sClass)
{
$sStateAttCode = MetaModel::GetStateAttributeCode($sClass);
@@ -4247,6 +5156,9 @@ abstract class DBObject implements iDisplay
/**
* Complete a new object with data from context
+ *
+ * @internal
+ *
* @param array $aContextParam Context used for creation form prefilling
*
*/
@@ -4256,6 +5168,9 @@ abstract class DBObject implements iDisplay
/**
* Complete an object after a state transition with data from context
+ *
+ * @internal
+ *
* @param array $aContextParam Context used for creation form prefilling
*
*/
@@ -4266,6 +5181,9 @@ abstract class DBObject implements iDisplay
/**
* Complete a filter ($aContextParam['filter']) data from context
* (Called on source object)
+ *
+ * @internal
+ *
* @param array $aContextParam Context used for creation form prefilling
*
*/
@@ -4275,6 +5193,9 @@ abstract class DBObject implements iDisplay
/**
* Prefill a creation / stimulus change / search form according to context, current state of an object, stimulus.. $sOperation
+ *
+ * @internal
+ *
* @param string $sOperation Operation identifier
* @param array $aContextParam Context used for creation form prefilling
*
diff --git a/core/dbobjectsearch.class.php b/core/dbobjectsearch.class.php
index d6e650bdc..002c643d8 100644
--- a/core/dbobjectsearch.class.php
+++ b/core/dbobjectsearch.class.php
@@ -17,9 +17,22 @@
// along with iTop. If not, see
//
-// Dev hack for disabling the some query build optimizations (Folding/Merging)
+/** @internal Dev hack for disabling some query build optimizations (Folding/Merging) */
define('ENABLE_OPT', true);
+/**
+ * A search over a DBObject
+ *
+ * This is the most common search cases, the other class representing a search is DBUnionSearch.
+ * For clarity purpose, since only the constructor vary between DBObjectSearch and DBUnionSearch, all the API is documented on the common ancestor: DBSearch
+ * Please refer to DBSearch's documentation
+ *
+ * @package iTopORM
+ * @phpdoc-tunning-exclude-inherited this tag prevent PHPdoc from displaying inherited methods. This is done in order to force the API doc. location into DBSearch only.
+ * @api
+ * @see DBSearch
+ * @see DBUnionSearch
+ */
class DBObjectSearch extends DBSearch
{
private $m_aClasses; // queried classes (alias => class name), the first item is the class corresponding to this filter (the rest is coming from subfilters)
@@ -29,11 +42,23 @@ class DBObjectSearch extends DBSearch
private $m_aPointingTo;
private $m_aReferencedBy;
- // By default, some information may be hidden to the current user
- // But it may happen that we need to disable that feature
+ /**
+ * @var bool whether or not some information should be hidden to the current user. Default to false == hide information.
+ * @see AllowAllData()
+ */
protected $m_bAllowAllData = false;
protected $m_bDataFiltered = false;
+ /**
+ * DBObjectSearch constructor.
+ *
+ * @api
+ *
+ * @param string $sClass
+ * @param string|null $sClassAlias
+ *
+ * @throws Exception
+ */
public function __construct($sClass, $sClassAlias = null)
{
parent::__construct();
@@ -524,7 +549,7 @@ class DBObjectSearch extends DBSearch
/**
* Specify a condition on external keys or link sets
* @param string $sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
- * Example: infra_list->ci_id->location_id->country
+ * Example: infra_list->ci_id->location_id->country
* @param $value
* @return void
* @throws \CoreException
@@ -2344,8 +2369,8 @@ class DBObjectSearch extends DBSearch
}
/**
- * Get the expression for the class and its subclasses (if finalclass = 'subclass' ...)
- * Simplifies the final expression by grouping classes having the same expression
+ * Get the expression for the class and its subclasses (if finalclass = 'subclass' ...)
+ * Simplifies the final expression by grouping classes having the same expression
* @param $sClass
* @param $sAttCode
* @return \FunctionExpression|mixed|null
diff --git a/core/dbobjectset.class.php b/core/dbobjectset.class.php
index 026789f57..564a93331 100644
--- a/core/dbobjectset.class.php
+++ b/core/dbobjectset.class.php
@@ -27,9 +27,13 @@ require_once('dbobjectiterator.php');
/**
- * A set of persistent objects, could be heterogeneous as long as the objects in the set have a common ancestor class
+ * A set of persistent objects
+ *
+ * Created against a DBObjectSearch with additional information not relevant for the DBObjectSearch (ie: order, limit, ...)
+ * This set could be heterogeneous as long as the objects in the set have a common ancestor class.
*
* @package iTopORM
+ * @api
*/
class DBObjectSet implements iDBObjectSetIterator
{
@@ -81,6 +85,8 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Create a new set based on a Search definition.
+ *
+ * @api
*
* @param DBSearch $oFilter The search filter defining the objects which are part of the set (multiple columns/objects per row are supported)
* @param array $aOrderBy Array of '[.]attcode' => bAscending
@@ -110,6 +116,9 @@ class DBObjectSet implements iDBObjectSetIterator
$this->m_oSQLResult = null;
}
+ /**
+ * @internal
+ */
public function __destruct()
{
if (is_object($this->m_oSQLResult))
@@ -119,6 +128,8 @@ class DBObjectSet implements iDBObjectSetIterator
}
/**
+ * @internal
+ *
* @return string
*
* @throws \Exception
@@ -145,6 +156,9 @@ class DBObjectSet implements iDBObjectSetIterator
return $sRet;
}
+ /**
+ * @internal
+ */
public function __clone()
{
$this->m_oFilter = $this->m_oFilter->DeepClone();
@@ -158,6 +172,7 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Called when unserializing a DBObjectSet
+ * @internal
*/
public function __wakeup()
{
@@ -168,18 +183,30 @@ class DBObjectSet implements iDBObjectSetIterator
$this->m_oSQLResult = null;
}
+ /**
+ * @internal
+ * @param $bShow
+ */
public function SetShowObsoleteData($bShow)
{
$this->m_oFilter->SetShowObsoleteData($bShow);
}
+ /**
+ * @internal
+ * @return bool
+ */
public function GetShowObsoleteData()
{
return $this->m_oFilter->GetShowObsoleteData();
}
/**
- * Specify the subset of attributes to load (for each class of objects) before performing the SQL query for retrieving the rows from the DB
+ * Specify the subset of attributes to load
+ * this subset is specified for each class of objects,
+ * this has to be done before the actual fetch.
+ *
+ * @api
*
* @param array $aAttToLoad Format: alias => array of attribute_codes
*
@@ -262,6 +289,8 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Create a set (in-memory) containing just the given object
*
+ * @internal
+ *
* @param \DBobject $oObject
*
* @return \DBObjectSet The singleton set
@@ -278,6 +307,8 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Create an empty set (in-memory), for the given class (and its subclasses) of objects
*
+ * @internal
+ *
* @param string $sClass The class (or an ancestor) for the objects to be added in this set
*
* @return \DBObjectSet The empty set
@@ -297,6 +328,8 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Create a set (in-memory) with just one column (i.e. one object per row) and filled with the given array of objects
*
+ * @internal
+ *
* @param string $sClass The class of the objects (must be a common ancestor to all objects in the set)
* @param array $aObjects The list of objects to add into the set
*
@@ -314,9 +347,11 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Create a set in-memory with several classes of objects per row (with one alias per "column")
*
- * Limitation:
+ * **Limitation:**
* The filter/OQL query representing such a set can not be rebuilt (only the first column will be taken into account)
*
+ * @internal
+ *
* @param array $aClasses Format: array of (alias => class)
* @param array $aObjects Format: array of (array of (classalias => object))
*
@@ -345,6 +380,9 @@ class DBObjectSet implements iDBObjectSetIterator
}
/**
+ *
+ * @internal
+ *
* @param $oObject
* @param string $sLinkSetAttCode
* @param string $sExtKeyToRemote
@@ -371,11 +409,15 @@ class DBObjectSet implements iDBObjectSetIterator
}
/**
+ * Fetch all as array of DBObject
+ *
* Note: After calling this method, the set cursor will be at the end of the set. You might want to rewind it.
*
+ * @api
+ *
* @param bool $bWithId
*
- * @return array
+ * @return DBObject[]
*
* @throws \Exception
* @throws \CoreException
@@ -401,7 +443,14 @@ class DBObjectSet implements iDBObjectSetIterator
}
/**
- * @return array
+ * Fetch all as a structured array
+ *
+ * Unlike ToArray, ToArrayOfValues return the objects as an array.
+ * Only the scalar values will be presents (see AttributeDefinition::IsScalar())
+ *
+ * @api
+ *
+ * @return array[]
*
* @throws \Exception
* @throws \CoreException
@@ -773,6 +822,7 @@ class DBObjectSet implements iDBObjectSetIterator
* May actually perform the SQL query SELECT COUNT... if the set was not previously loaded, or loaded with a
* SetLimit
*
+ * @api
* @return int The total number of rows for this set.
*
* @throws \CoreException
@@ -796,11 +846,13 @@ class DBObjectSet implements iDBObjectSetIterator
return $this->m_iNumTotalDBRows + count($this->m_aAddedObjects); // Does it fix Trac #887 ??
}
- /** Check if the count exceeds a given limit
+ /**
+ * Check if the count exceeds a given limit
+ *
* @param $iLimit
*
* @return bool
- *
+ *
* @throws \CoreException
* @throws \MissingQueryArgument
* @throws \MySQLException
@@ -831,11 +883,13 @@ class DBObjectSet implements iDBObjectSetIterator
return ($iCount > $iLimit);
}
- /** Count only up to the given limit
+ /**
+ * Count only up to the given limit
+ *
* @param $iLimit
*
* @return int
- *
+ *
* @throws \CoreException
* @throws \MissingQueryArgument
* @throws \MySQLException
@@ -877,9 +931,11 @@ class DBObjectSet implements iDBObjectSetIterator
}
/**
- * Fetch the object (with the given class alias) at the current position in the set and move the cursor to the next position.
+ * Fetch an object (with the given class alias) at the current position in the set and move the cursor to the next position.
*
- * @param string $sRequestedClassAlias The class alias to fetch (if there are several objects/classes per row)
+ * @api
+ *
+ * @param string $sRequestedClassAlias The class alias to fetch (defaults to the first selected class)
*
* @return \DBObject The fetched object or null when at the end
*
@@ -933,6 +989,8 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Fetch the whole row of objects (if several classes have been specified in the query) and move the cursor to the next position
*
+ * @api
+ *
* @return array An associative with the format 'classAlias' => $oObj representing the current row of the set. Returns null when at the end.
*
* @throws \CoreException
@@ -981,8 +1039,10 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Position the cursor (for iterating in the set) to the first position (equivalent to Seek(0))
- *
- * @throws \Exception
+ *
+ * @api
+ *
+ * @throws \Exception
*/
public function Rewind()
{
@@ -1200,9 +1260,9 @@ class DBObjectSet implements iDBObjectSetIterator
* @param \DBObjectSet $oObjectSet
*
* @return \DBObjectSet The "delta" set.
- *
- * @throws \Exception
- * @throws \CoreException
+ *
+ * @throws \Exception
+ * @throws \CoreException
*/
public function CreateDelta(DBObjectSet $oObjectSet)
{
@@ -1445,6 +1505,8 @@ class DBObjectSet implements iDBObjectSetIterator
/**
* Helper function to perform a custom sort of a hash array
+ *
+ * @internal
*/
function HashCountComparison($a, $b) // Sort descending on 'count'
{
@@ -1464,6 +1526,11 @@ function HashCountComparison($a, $b) // Sort descending on 'count'
* LIMITATIONS:
* - only DBObjectSets with one column (i.e. one class of object selected) are supported
* - the first set must be the one loaded from the database
+ *
+ * @internal
+ *
+ * @package iTopORM
+ *
*/
class DBObjectSetComparator
{
@@ -1508,6 +1575,8 @@ class DBObjectSetComparator
/**
* Builds the lists of fingerprints and initializes internal structures, if it was not already done
*
+ * @internal
+ *
* @throws \CoreException
*/
protected function ComputeFingerprints()
@@ -1557,6 +1626,9 @@ class DBObjectSetComparator
/**
* Tells if the sets are equivalent or not. Returns as soon as the first difference is found.
+ *
+ * @internal
+ *
* @return boolean true if the set have an equivalent content, false otherwise
*
* @throws \CoreException
@@ -1603,8 +1675,10 @@ class DBObjectSetComparator
/**
* Get the list of differences between the two sets. In ordeer to write back into the database only the minimum changes
* THE FIRST SET MUST BE THE ONE LOADED FROM THE DATABASE
- * Returns a hash: 'added' => DBObject(s), 'removed' => DBObject(s), 'modified' => DBObjects(s)
- * @return array
+ *
+ * @internal
+ *
+ * @return array 'added' => DBObject(s), 'removed' => DBObject(s), 'modified' => DBObjects(s)
*
* @throws \Exception
* @throws \CoreException
@@ -1659,7 +1733,9 @@ class DBObjectSetComparator
}
/**
- * Helpr to clone (in memory) an object and to apply to it the values taken from a second object
+ * Helper to clone (in memory) an object and to apply to it the values taken from a second object
+ *
+ * @internal
*
* @param \DBObject $oObjToClone
* @param \DBObject $oObjWithValues
@@ -1682,4 +1758,4 @@ class DBObjectSetComparator
}
return $oObj;
}
-}
\ No newline at end of file
+}
diff --git a/core/dbsearch.class.php b/core/dbsearch.class.php
index 9f22b796a..56f7ba8e0 100644
--- a/core/dbsearch.class.php
+++ b/core/dbsearch.class.php
@@ -22,24 +22,35 @@ require_once('dbunionsearch.class.php');
/**
* An object search
- *
+ *
+ * DBSearch provides an API that leverage the possibility to construct a search against iTop's persisted objects.
+ * In order to do so, it let you declare the classes you want to fetch, the conditions you want to apply, ...
+ *
* Note: in the ancient times of iTop, a search was named after DBObjectSearch.
- * When the UNION has been introduced, it has been decided to:
- * - declare a hierarchy of search classes, with two leafs :
- * - one class to cope with a single query (A JOIN B... WHERE...)
- * - and the other to cope with several queries (query1 UNION query2)
- * - in order to preserve forward/backward compatibility of the existing modules
- * - keep the name of DBObjectSearch even if it a little bit confusing
- * - do not provide a type-hint for function parameters defined in the modules
- * - leave the statements DBObjectSearch::FromOQL in the modules, though DBSearch is more relevant
+ * When the UNION has been introduced, it has been decided to:
+ * * declare a hierarchy of search classes : `DBObjectSearch` & `DBUnionSearch`
+ * * DBObjectSearch cope with single query (A JOIN B... WHERE...)
+ * * DBUnionSearch cope with several queries (query1 UNION query2)
+ * * in order to preserve forward/backward compatibility of the existing modules
+ * * keep the name of DBObjectSearch even if it a little bit confusing
+ * * do not provide a type-hint for function parameters defined in the modules
+ * * leave the statements DBObjectSearch::FromOQL in the modules, though DBSearch is more relevant
*
* @copyright Copyright (C) 2015-2017 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
+ *
+ *
+ * @package iTopORM
+ * @api
+ * @see DBObjectSearch::__construct()
+ * @see DBUnionSearch::__construct()
*/
abstract class DBSearch
{
+ /** @internal */
const JOIN_POINTING_TO = 0;
+ /** @internal */
const JOIN_REFERENCED_BY = 1;
protected $m_bNoContextParameters = false;
@@ -47,14 +58,23 @@ abstract class DBSearch
protected $m_bArchiveMode = false;
protected $m_bShowObsoleteData = true;
+ /**
+ * DBSearch constructor.
+ *
+ * @api
+ * @see DBSearch::FromOQL()
+ */
public function __construct()
{
$this->Init();
}
+ /**
+ * called by the constructor
+ * @internal Set the obsolete and archive modes to the default ones
+ */
protected function Init()
{
- // Set the obsolete and archive modes to the default ones
$this->m_bArchiveMode = utils::IsArchiveMode();
$this->m_bShowObsoleteData = true;
}
@@ -62,6 +82,8 @@ abstract class DBSearch
/**
* Perform a deep clone (as opposed to "clone" which does copy a reference to the underlying objects)
*
+ * @internal
+ *
* @return \DBSearch
**/
public function DeepClone()
@@ -69,22 +91,62 @@ abstract class DBSearch
return unserialize(serialize($this)); // Beware this serializes/unserializes the search and its parameters as well
}
+ /**
+ * whether or not some information should be hidden to the current user.
+ *
+ * @api
+ * @see IsAllDataAllowed()
+ *
+ * @return mixed
+ */
abstract public function AllowAllData();
+
+ /**
+ * Current state of AllowAllData
+ *
+ * @internal
+ * @see AllowAllData()
+ *
+ * @return mixed
+ */
abstract public function IsAllDataAllowed();
+ /**
+ * Should the archives be fetched
+ *
+ * @internal
+ *
+ * @param $bEnable
+ */
public function SetArchiveMode($bEnable)
{
$this->m_bArchiveMode = $bEnable;
}
+
+ /**
+ * @internal
+ * @return bool
+ */
public function GetArchiveMode()
{
return $this->m_bArchiveMode;
}
+ /**
+ * Should the obsolete data be fetched
+ *
+ * @internal
+ * @param $bShow
+ */
public function SetShowObsoleteData($bShow)
{
$this->m_bShowObsoleteData = $bShow;
}
+
+ /**
+ * @internal
+ * @return bool
+ */
public function GetShowObsoleteData()
{
if ($this->m_bArchiveMode || $this->IsAllDataAllowed())
@@ -99,14 +161,36 @@ abstract class DBSearch
return $bRet;
}
+ /**
+ * @internal
+ */
public function NoContextParameters() {$this->m_bNoContextParameters = true;}
+
+ /**
+ * @internal
+ * @return bool
+ */
public function HasContextParameters() {return $this->m_bNoContextParameters;}
+ /**
+ * @internal
+ *
+ * @param $sPluginClass
+ * @param $sProperty
+ * @param $value
+ */
public function SetModifierProperty($sPluginClass, $sProperty, $value)
{
$this->m_aModifierProperties[$sPluginClass][$sProperty] = $value;
}
+ /**
+ * @internal
+ *
+ * @param $sPluginClass
+ *
+ * @return array|mixed
+ */
public function GetModifierProperties($sPluginClass)
{
if (array_key_exists($sPluginClass, $this->m_aModifierProperties))
@@ -119,18 +203,44 @@ abstract class DBSearch
}
}
+ /**
+ * @internal
+ * @param $sAlias
+ *
+ * @return mixed
+ */
abstract public function GetClassName($sAlias);
+
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function GetClass();
+
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function GetClassAlias();
/**
- * Change the class (only subclasses are supported as of now, because the conditions must fit the new class)
- * Defaults to the first selected class (most of the time it is also the first joined class
- */
+ * Change the class
+ *
+ * Defaults to the first selected class (most of the time it is also the first joined class
+ * only subclasses are supported as of now, because the conditions must fit the new class
+ *
+ * @internal
+ */
abstract public function ChangeClass($sNewClass, $sAlias = null);
+
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function GetSelectedClasses();
/**
+ * @internal
* @param array $aSelectedClasses array of aliases
* @throws CoreException
*/
@@ -139,64 +249,207 @@ abstract class DBSearch
/**
* Change any alias of the query tree
*
+ * @internal
+ *
* @param $sOldName
* @param $sNewName
* @return bool True if the alias has been found and changed
*/
abstract public function RenameAlias($sOldName, $sNewName);
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function IsAny();
+ /**
+ * @deprecated use ToOQL() instead
+ * @internal
+ * @return string
+ */
public function Describe(){return 'deprecated - use ToOQL() instead';}
+ /**
+ * @deprecated use ToOQL() instead
+ * @internal
+ * @return string
+ */
public function DescribeConditionPointTo($sExtKeyAttCode, $aPointingTo){return 'deprecated - use ToOQL() instead';}
+ /**
+ * @deprecated use ToOQL() instead
+ * @internal
+ * @return string
+ */
public function DescribeConditionRefBy($sForeignClass, $sForeignExtKeyAttCode){return 'deprecated - use ToOQL() instead';}
+ /**
+ * @deprecated use ToOQL() instead
+ * @internal
+ * @return string
+ */
public function DescribeConditionRelTo($aRelInfo){return 'deprecated - use ToOQL() instead';}
+ /**
+ * @deprecated use ToOQL() instead
+ * @internal
+ * @return string
+ */
public function DescribeConditions(){return 'deprecated - use ToOQL() instead';}
+ /**
+ * @deprecated use ToOQL() instead
+ * @internal
+ * @return string
+ */
public function __DescribeHTML(){return 'deprecated - use ToOQL() instead';}
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function ResetCondition();
+
+ /**
+ * add $oExpression as a OR
+ *
+ * @api
+ * @see DBSearch::AddConditionExpression()
+ *
+ * @param Expression $oExpression
+ *
+ * @return mixed
+ */
abstract public function MergeConditionExpression($oExpression);
+
+ /**
+ * add $oExpression as a AND
+ *
+ * @api
+ * @see DBSearch::MergeConditionExpression()
+ *
+ * @param Expression $oExpression
+ *
+ * @return mixed
+ */
abstract public function AddConditionExpression($oExpression);
+
+ /**
+ * Condition on the friendlyname
+ *
+ * Restrict the query to only the corresponding selected class' friendlyname
+ *
+ * @internal
+ *
+ * @param string $sName the desired friendlyname
+ *
+ * @return mixed
+ */
abstract public function AddNameCondition($sName);
+
+ /**
+ * Add a condition
+ *
+ * This is the simplest way to express a AND condition. For complex use cases, use MergeConditionExpression or AddConditionExpression instead
+ *
+ * @api
+ *
+ * @param string $sFilterCode
+ * @param mixed $value
+ * @param string $sOpCode operator to use : '=' (default), '!=', 'IN', 'NOT IN'
+ *
+ * @throws \CoreException
+ *
+ */
abstract public function AddCondition($sFilterCode, $value, $sOpCode = null);
/**
* Specify a condition on external keys or link sets
- * @param sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
+ *
+ * @internal
+ *
+ * @param string $sAttSpec Can be either an attribute code or extkey->[sAttSpec] or linkset->[sAttSpec] and so on, recursively
* Example: infra_list->ci_id->location_id->country
- * @param value The value to match (can be an array => IN(val1, val2...)
+ * @param mixed $value The value to match (can be an array => IN(val1, val2...)
* @return void
*/
abstract public function AddConditionAdvanced($sAttSpec, $value);
+
+ /**
+ * @internal
+ *
+ * @param string $sFullText
+ *
+ * @return mixed
+ */
abstract public function AddCondition_FullText($sFullText);
/**
+ * Perform a join, the remote class being matched by the mean of its primary key
+ *
+ * The join is performed
+ * * from the searched class, based on the $sExtKeyAttCode attribute
+ * * against the oFilter searched class, based on its primary key
+ * Note : if several classes have already being joined (SELECT a join b ON...), the first joined class (a in the example) is considered as being the searched class.
+ *
+ * @api
+ * @see AddCondition_ReferencedBy()
+ *
* @param DBObjectSearch $oFilter
- * @param $sExtKeyAttCode
- * @param int $iOperatorCode
- * @param null $aRealiasingMap array of => , for each alias that has changed
+ * @param string $sExtKeyAttCode
+ * @param int $iOperatorCode the comparison operator to use. For the list of all possible values, see the constant defined in core/oql/oqlquery.class.inc.php
+ * @param array|null $aRealiasingMap array of => , for each alias that has changed in the newly attached oFilter (in case of collisions between the two filters)
+ *
* @throws CoreException
* @throws CoreWarning
*/
abstract public function AddCondition_PointingTo(DBObjectSearch $oFilter, $sExtKeyAttCode, $iOperatorCode = TREE_OPERATOR_EQUALS, &$aRealiasingMap = null);
/**
+ * Inverse operation of AddCondition_PointingTo
+ *
+ * The join is performed
+ * * from the olFilter searched class, based on the $sExtKeyAttCode attribute
+ * * against the searched class, based on its primary key
+ * Note : if several classes have already being joined (SELECT a join b ON...), the first joined class (a in the example) is considered as being the searched class.
+ *
+ *
+ * @api
+ * @see AddCondition_PointingTo()
+ *
* @param DBObjectSearch $oFilter
* @param $sForeignExtKeyAttCode
* @param int $iOperatorCode
- * @param null $aRealiasingMap array of => , for each alias that has changed
+ * @param array|null $aRealiasingMap array of => , for each alias that has changed in the newly attached oFilter (in case of collisions between the two filters)
*/
abstract public function AddCondition_ReferencedBy(DBObjectSearch $oFilter, $sForeignExtKeyAttCode, $iOperatorCode = TREE_OPERATOR_EQUALS, &$aRealiasingMap = null);
+ /**
+ * Filter the result
+ *
+ * The filter is performed by returning only the values in common with the given $oFilter
+ * The impact on the resulting query performance/viability can be significant.
+ *
+ * @internal
+ *
+ * @param DBSearch $oFilter
+ *
+ * @return mixed
+ */
abstract public function Intersect(DBSearch $oFilter);
- /**
- * @param DBSearch $oFilter
- * @param integer $iDirection
- * @param string $sExtKeyAttCode
- * @param integer $iOperatorCode
- * @param array &$RealisasingMap Map of aliases from the attached query, that could have been renamed by the optimization process
- * @return DBSearch
- */
+ /**
+ * Perform a join
+ *
+ * The join is performed against $oFilter selected class using $sExtKeyAttCode of the current selected class
+ *
+ * @internal
+ *
+ * @param DBSearch $oFilter The join is performed against $oFilter selected class
+ * @param integer $iDirection can be either DBSearch::JOIN_POINTING_TO or DBSearch::JOIN_REFERENCED_BY
+ * @param string $sExtKeyAttCode The join is performed against $sExtKeyAttCode wetheir it is compared aginst the current DBSearch or $oFilter depend of $iDirection
+ * @param integer $iOperatorCode See DBSearch::AddCondition_PointingTo()
+ * @param array|null $aRealiasingMap Map of aliases from the attached query, that could have been renamed by the optimization process
+ *
+ * @return DBSearch
+ * @throws CoreException
+ * @throws CoreWarning
+ */
public function Join(DBSearch $oFilter, $iDirection, $sExtKeyAttCode, $iOperatorCode = TREE_OPERATOR_EQUALS, &$aRealiasingMap = null)
{
$oSourceFilter = $this->DeepClone();
@@ -231,21 +484,68 @@ abstract class DBSearch
return $oRet;
}
+ /**
+ * Set the internal params.
+ *
+ * If any params pre-existed, they are lost.
+ *
+ * @internal
+ *
+ * @param mixed[string] $aParams array of mixed params index by string name
+ *
+ * @return mixed
+ */
abstract public function SetInternalParams($aParams);
+
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function GetInternalParams();
+
+ /**
+ * @internal
+ *
+ * @param bool $bExcludeMagicParams
+ *
+ * @return mixed
+ */
abstract public function GetQueryParams($bExcludeMagicParams = true);
+
+ /**
+ * @internal
+ * @return mixed
+ */
abstract public function ListConstantFields();
/**
- * Turn the parameters (:xxx) into scalar values in order to easily
- * serialize a search
+ * Turn the parameters (:xxx) into scalar values
+ *
+ * The goal is to easily serialize a search
*
+ * @internal
+ *
* @param array $aArgs
*
* @return string
*/
abstract public function ApplyParameters($aArgs);
+ /**
+ * Convert a query to a string representation
+ *
+ * This operation can be revert back to a DBSearch using DBSearch::unserialize()
+ *
+ * @api
+ * @see DBSearch::unserialize()
+ *
+ * @param bool $bDevelopParams
+ * @param array $aContextParams
+ *
+ * @return false|string
+ * @throws ArchivedObjectException
+ * @throws CoreException
+ */
public function serialize($bDevelopParams = false, $aContextParams = array())
{
$aQueryParams = $this->GetQueryParams();
@@ -293,6 +593,10 @@ abstract class DBSearch
}
/**
+ * Convert a serialized query back to an instance of DBSearch
+ *
+ * @api
+ *
* @param string $sValue Serialized OQL query
*
* @return \DBSearch
@@ -336,11 +640,13 @@ abstract class DBSearch
/**
* Create a new DBObjectSearch from $oSearch with a new alias $sAlias
*
- * Note : This has not be tested with UNION queries.
+ * @internal Note : This has not be tested with UNION queries.
*
* @param DBSearch $oSearch
- * @param string $sAlias
+ * @param string $sAlias
+ *
* @return DBObjectSearch
+ * @throws CoreException
*/
static public function CloneWithAlias(DBSearch $oSearch, $sAlias)
{
@@ -349,12 +655,37 @@ abstract class DBSearch
return $oSearchWithAlias;
}
+ /**
+ * Convert the DBSearch to an OQL representation
+ *
+ * @api
+ * @see DBSearch::FromOQL()
+ *
+ * @param bool $bDevelopParams
+ * @param null $aContextParams
+ * @param bool $bWithAllowAllFlag
+ *
+ * @return mixed
+ */
abstract public function ToOQL($bDevelopParams = false, $aContextParams = null, $bWithAllowAllFlag = false);
static protected $m_aOQLQueries = array();
- // Do not filter out depending on user rights
- // In particular when we are currently in the process of evaluating the user rights...
+ /**
+ * FromOQL with AllowAllData enabled
+ *
+ * The goal is to not filter out depending on user rights.
+ * In particular when we are currently in the process of evaluating the user rights...
+ *
+ * @internal
+ * @see DBSearch::FromOQL()
+ *
+ * @param string $sQuery
+ * @param null $aParams
+ *
+ * @return DBSearch
+ * @throws OQLException
+ */
static public function FromOQL_AllData($sQuery, $aParams = null)
{
$oRes = self::FromOQL($sQuery, $aParams);
@@ -363,9 +694,19 @@ abstract class DBSearch
}
/**
- * @param string $sQuery
- * @param array $aParams
- * @return self
+ * Create a new DBSearch from the given OQL.
+ *
+ * This is the simplest way to create a DBSearch.
+ * For almost every cases, this is the easiest way.
+ *
+ * @api
+ * @see DBSearch::ToOQL()
+ *
+ * @param string $sQuery The OQL to convert to a DBSearch
+ * @param mixed[string] $aParams array of params index by name
+ *
+ * @return DBObjectSearch|DBUnionSearch
+ *
* @throws OQLException
*/
static public function FromOQL($sQuery, $aParams = null)
@@ -442,14 +783,20 @@ abstract class DBSearch
}
/**
+ * Fetch the result has an array structure.
+ *
* Alternative to object mapping: the data are transfered directly into an array
* This is 10 times faster than creating a set of objects, and makes sense when optimization is required
+ * But this speed comes at the cost of not obtaining the easy to manipulates DBObject instances but simple array structure.
+ *
+ * @internal
*
- * @param array $aColumns
+ * @param array $aColumns The columns you'd like to fetch.
* @param array $aOrderBy Array of '[.]attcode' => bAscending
* @param array $aArgs
*
* @return array|void
+ *
* @throws \CoreException
* @throws \MissingQueryArgument
* @throws \MySQLException
@@ -506,7 +853,11 @@ abstract class DBSearch
protected static $m_aQueryStructCache = array();
- /** Generate a Group By SQL request from a search
+ /**
+ * Generate a Group By SQL query from the current search
+ *
+ * @internal
+ *
* @param array $aArgs
* @param array $aGroupByExpr array('alias' => Expression)
* @param bool $bExcludeNullValues
@@ -514,7 +865,9 @@ abstract class DBSearch
* @param array $aOrderBy array('alias' => bool) true = ASC false = DESC
* @param int $iLimitCount
* @param int $iLimitStart
+ *
* @return string SQL query generated
+ *
* @throws Exception
*/
public function MakeGroupByQuery($aArgs, $aGroupByExpr, $bExcludeNullValues = false, $aSelectExpr = array(), $aOrderBy = array(), $iLimitCount = 0, $iLimitStart = 0)
@@ -590,6 +943,10 @@ abstract class DBSearch
/**
+ * Generate a SQL query from the current search
+ *
+ * @internal
+ *
* @param array|hash $aOrderBy Array of '[.]attcode' => bAscending
* @param array $aArgs
* @param null $aAttToLoad
@@ -684,9 +1041,33 @@ abstract class DBSearch
return $sRes;
}
+ /**
+ * @internal
+ * @return mixed
+ */
protected abstract function IsDataFiltered();
+
+ /**
+ * @internal
+ * @return mixed
+ */
protected abstract function SetDataFiltered();
+ /**
+ * @internal
+ *
+ * @param $aOrderBy
+ * @param $aArgs
+ * @param $aAttToLoad
+ * @param $aExtendedDataSpec
+ * @param $iLimitCount
+ * @param $iLimitStart
+ * @param $bGetCount
+ * @param null $aGroupByExpr
+ * @param null $aSelectExpr
+ *
+ * @return mixed
+ */
protected function GetSQLQuery($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $aGroupByExpr = null, $aSelectExpr = null)
{
$oSearch = $this;
@@ -727,18 +1108,46 @@ abstract class DBSearch
return $oSQLQuery;
}
+ /**
+ * @internal
+ *
+ * @param $aAttToLoad
+ * @param $bGetCount
+ * @param null $aGroupByExpr
+ * @param null $aSelectedClasses
+ * @param null $aSelectExpr
+ *
+ * @return mixed
+ */
public abstract function GetSQLQueryStructure(
$aAttToLoad, $bGetCount, $aGroupByExpr = null, $aSelectedClasses = null, $aSelectExpr = null
);
/**
+ * Get the current search conditions
+ *
+ * @internal
+ * @see DBSearch $m_oSearchCondition
+ *
* @return \Expression
*/
public abstract function GetCriteria();
+ /**
+ * Shortcut to add efficient IN condition
+ *
+ * @internal
+ *
+ * @param $sFilterCode
+ * @param $aValues
+ * @param bool $bPositiveMatch if true a `IN` is performed, if false, a `NOT IN` is performed
+ *
+ * @return mixed
+ */
public abstract function AddConditionForInOperatorUsingParam($sFilterCode, $aValues, $bPositiveMatch = true);
/**
+ * @internal
* @return string a unique param name
*/
protected function GenerateUniqueParamName() {
@@ -759,36 +1168,78 @@ abstract class DBSearch
protected static $m_bIndentQueries = false;
protected static $m_bOptimizeQueries = false;
+ /**
+ * @internal
+ */
public static function StartDebugQuery()
{
$aBacktrace = debug_backtrace();
self::$m_bDebugQuery = true;
}
+
+ /**
+ * @internal
+ */
public static function StopDebugQuery()
{
self::$m_bDebugQuery = false;
}
-
+
+ /**
+ * @internal
+ *
+ * @param bool $bEnabled
+ * @param bool $bUseAPC
+ * @param int $iTimeToLive
+ */
public static function EnableQueryCache($bEnabled, $bUseAPC, $iTimeToLive = 3600)
{
self::$m_bQueryCacheEnabled = $bEnabled;
self::$m_bUseAPCCache = $bUseAPC;
self::$m_iQueryCacheTTL = $iTimeToLive;
}
+
+ /**
+ * @internal
+ * @param $bEnabled
+ */
public static function EnableQueryTrace($bEnabled)
{
self::$m_bTraceQueries = $bEnabled;
}
+
+ /**
+ * @internal
+ * @param $bEnabled
+ */
public static function EnableQueryIndentation($bEnabled)
{
self::$m_bIndentQueries = $bEnabled;
}
+
+ /**
+ * @internal
+ * @param $bEnabled
+ */
public static function EnableOptimizeQuery($bEnabled)
{
self::$m_bOptimizeQueries = $bEnabled;
}
-
+ /**
+ * @internal
+ *
+ * @param $aOrderBy
+ * @param $aArgs
+ * @param $aAttToLoad
+ * @param $aExtendedDataSpec
+ * @param $iLimitCount
+ * @param $iLimitStart
+ * @param $bGetCount
+ * @param $sSql
+ *
+ * @throws MySQLException
+ */
protected function AddQueryTraceSelect($aOrderBy, $aArgs, $aAttToLoad, $aExtendedDataSpec, $iLimitCount, $iLimitStart, $bGetCount, $sSql)
{
if (self::$m_bTraceQueries)
@@ -808,7 +1259,16 @@ abstract class DBSearch
self::AddQueryTrace($aQueryData, $sOql, $sSql);
}
}
-
+
+ /**
+ * @internal
+ *
+ * @param $aArgs
+ * @param $aGroupByExpr
+ * @param $sSql
+ *
+ * @throws MySQLException
+ */
protected function AddQueryTraceGroupBy($aArgs, $aGroupByExpr, $sSql)
{
if (self::$m_bTraceQueries)
@@ -824,6 +1284,15 @@ abstract class DBSearch
}
}
+ /**
+ * @internal
+ *
+ * @param $aQueryData
+ * @param $sOql
+ * @param $sSql
+ *
+ * @throws MySQLException
+ */
protected static function AddQueryTrace($aQueryData, $sOql, $sSql)
{
if (self::$m_bTraceQueries)
@@ -854,6 +1323,9 @@ abstract class DBSearch
}
}
+ /**
+ * @internal
+ */
public static function RecordQueryTrace()
{
if (!self::$m_bTraceQueries)
@@ -914,6 +1386,10 @@ abstract class DBSearch
file_put_contents($sAllQueries, $sLog);
}
+ /**
+ * @internal
+ * @param $value
+ */
protected static function DbgTrace($value)
{
if (!self::$m_bDebugQuery)
@@ -949,7 +1425,9 @@ abstract class DBSearch
/**
* Experimental!
- * todo: implement the change tracking
+ * @todo implement the change tracking
+ *
+ * @internal
*
* @param $bArchive
* @throws Exception
@@ -1025,6 +1503,9 @@ abstract class DBSearch
}
}
+ /**
+ * @internal
+ */
public function UpdateContextFromUser()
{
$this->SetShowObsoleteData(utils::ShowObsoleteData());
diff --git a/core/dbunionsearch.class.php b/core/dbunionsearch.class.php
index 32721c45e..dada399a9 100644
--- a/core/dbunionsearch.class.php
+++ b/core/dbunionsearch.class.php
@@ -18,10 +18,21 @@
/**
- * A union of DBObjectSearches
+ * A union of DBObjectSearches
+ *
+ * This search class represent an union over a collection of DBObjectSearch.
+ * For clarity purpose, since only the constructor vary between DBObjectSearch and DBUnionSearch, all the API is documented on the common ancestor: DBSearch
+ * Please refer to DBSearch's documentation
*
* @copyright Copyright (C) 2015-2017 Combodo SARL
* @license http://opensource.org/licenses/AGPL-3.0
+ *
+ *
+ * @package iTopORM
+ * @phpdoc-tunning-exclude-inherited this tag prevent PHPdoc from displaying inherited methods. This is done in order to force the API doc. location into DBSearch only.
+ * @api
+ * @see DBSearch
+ * @see DBObjectSearch
*/
class DBUnionSearch extends DBSearch
@@ -29,6 +40,15 @@ class DBUnionSearch extends DBSearch
protected $aSearches; // source queries
protected $aSelectedClasses; // alias => classes (lowest common ancestors) computed at construction
+ /**
+ * DBUnionSearch constructor.
+ *
+ * @api
+ *
+ * @param $aSearches
+ *
+ * @throws CoreException
+ */
public function __construct($aSearches)
{
if (count ($aSearches) == 0)
diff --git a/core/metamodel.class.php b/core/metamodel.class.php
index c37083da1..0fcfc383c 100644
--- a/core/metamodel.class.php
+++ b/core/metamodel.class.php
@@ -97,8 +97,9 @@ define('MYSQL_ENGINE', 'innodb');
/**
- * (API) The objects definitions as well as their mapping to the database
+ * The objects definitions as well as their mapping to the database
*
+ * @api
* @package iTopORM
*/
abstract class MetaModel
@@ -1233,6 +1234,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
*
* @return array
@@ -1285,9 +1287,12 @@ abstract class MetaModel
}
/**
- * @param string $sClass
- * @param string $sAttCode
- * @param bool $bExtended
+ * Check it the given attribute exists in the specified class
+ *
+ * @api
+ * @param string $sClass Class name
+ * @param string $sAttCode Attribute code
+ * @param bool $bExtended Allow the extended syntax: extkey_id->remote_attcode
*
* @return bool
* @throws \Exception
@@ -1341,6 +1346,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
*
@@ -1356,6 +1362,9 @@ abstract class MetaModel
}
/**
+ * Check if the given class name is actually a persistent class
+ *
+ * @api
* @param string $sClass
*
* @return bool
@@ -1630,17 +1639,20 @@ abstract class MetaModel
/**
* array of ("classname" => array filterdef)
*
+ * @deprecated
* @var array
*/
private static $m_aFilterDefs = array();
/**
* array of ("classname" => array of ("attcode"=>"sourceclass"))
*
+ * @deprecated
* @var array
*/
private static $m_aFilterOrigins = array();
/**
+ * @deprecated
* @param string $sClass
*
* @return mixed
@@ -1653,6 +1665,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
*
@@ -1670,6 +1683,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
*
@@ -1688,6 +1702,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
*
@@ -1705,6 +1720,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
*
@@ -1722,6 +1738,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
*
@@ -1740,6 +1757,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sClass
* @param string $sFilterCode
* @param string $sOpCode
@@ -1759,6 +1777,7 @@ abstract class MetaModel
}
/**
+ * @deprecated
* @param string $sFilterCode
*
* @return string
@@ -1856,7 +1875,7 @@ abstract class MetaModel
private static $m_aRelationInfos = array();
/**
- * TO BE DEPRECATED: use EnumRelationsEx instead
+ * @deprecated Use EnumRelationsEx instead
*
* @param string $sClass
*
@@ -6643,12 +6662,13 @@ abstract class MetaModel
}
/**
- * Search for the specified class and id.
+ * Instantiate an object already persisted to the Database.
*
+ * @api
* @param string $sClass
* @param int $iKey id value of the object to retrieve
* @param bool $bMustBeFound see throws ArchivedObjectException
- * @param bool $bAllowAllData if true then no rights filtering
+ * @param bool $bAllowAllData if true then user rights will be bypassed - use with care!
* @param null $aModifierProperties
*
* @return DBObject|null null if : (the object is not found) or (archive mode disabled and object is archived and
@@ -6859,8 +6879,11 @@ abstract class MetaModel
}
/**
- * @param string $sClass
- * @param array|null $aValues array of attcode => value
+ * Instantiate a persistable object (not yet persisted)
+ *
+ * @api
+ * @param string $sClass A persistable class
+ * @param array|null $aValues array of attcode => attribute value to preset
*
* @return DBObject
* @throws \CoreException
@@ -6905,6 +6928,8 @@ abstract class MetaModel
* @todo: protect it against forbidden usages (in such a case, delete objects one by one)
*
* @param \DBObjectSearch $oFilter
+ * @deprecated
+ * @experimental
*
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
@@ -6922,6 +6947,8 @@ abstract class MetaModel
* @param DBObjectSearch $oFilter
* @param array $aValues array of attcode => value
*
+ * @deprecated
+ * @experimental
* @return int Modified objects
* @throws \MySQLException
* @throws \MySQLHasGoneAwayException
diff --git a/Jenkinsfile b/jenkinsfile
similarity index 100%
rename from Jenkinsfile
rename to jenkinsfile
diff --git a/phpdoc.dist.xml b/phpdoc.dist.xml
deleted file mode 100644
index f095b5c9b..000000000
--- a/phpdoc.dist.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- /var/www/doc-extensions
-
-
- /var/www/doc-extensions
-
-
- /home/romain/itop-trunk/application/applicationextension.inc.php
-
-
diff --git a/readme.md b/readme.md
new file mode 100644
index 000000000..112ff6114
--- /dev/null
+++ b/readme.md
@@ -0,0 +1,140 @@
+