Documentation

Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract
in package

Table of Contents

Constants

CHARS_DIGITS  : mixed = '0123456789'
CHARS_LOWERS  : mixed = 'abcdefghijklmnopqrstuvwxyz'
CHARS_PASSWORD_DIGITS  : mixed = '23456789'
CHARS_PASSWORD_LOWERS  : mixed = 'abcdefghjkmnpqrstuvwxyz'
CHARS_PASSWORD_SPECIALS  : mixed = '!$*-.=?@_'
CHARS_PASSWORD_UPPERS  : mixed = 'ABCDEFGHJKLMNPQRSTUVWXYZ'
CHARS_SPECIALS  : mixed = '!$*+-.=?@^_|~'
CHARS_UPPERS  : mixed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
DIVIDE_EPSILON  : mixed = 10000
Const for correct dividing decimal values
XML_PATH_CACHE_BETA_TYPES  : mixed = 'global/cache/betatypes'
XML_PATH_DEFAULT_COUNTRY  : mixed = 'general/country/default'
XML_PATH_DEV_ALLOW_IPS  : mixed = 'dev/restrict/allow_ips'
XML_PATH_ENCRYPTION_MODEL  : mixed = 'global/helpers/core/encryption_model'
XML_PATH_EU_COUNTRIES_LIST  : mixed = 'general/country/eu_countries'
XML_PATH_MERCHANT_COUNTRY_CODE  : mixed = 'general/store_information/merchant_country'
Config paths to merchant country code and merchant VAT number
XML_PATH_MERCHANT_VAT_NUMBER  : mixed = 'general/store_information/merchant_vat_number'
XML_PATH_PROTECTED_FILE_EXTENSIONS  : mixed = 'general/file/protected_extensions'

Properties

$_allowedFormats  : mixed
$_encryptor  : Mage_Core_Model_Encryption
$_layout  : Mage_Core_Model_Layout
Layout model object
$_moduleName  : string
Helper module name
$_request  : Mage_Core_Controller_Request_Http
Request object
$modulesDisabled  : array<string|int, mixed>
$symfonyValidator  : ValidatorInterface|null
Symfony validator instance

Methods

__()  : string
Translate
assocToXml()  : SimpleXMLElement
Transform an assoc array to SimpleXMLElement object Array has some limitations. Appropriate exceptions will be thrown
copyFieldset()  : bool
Copy data from object|array to object|array containing fields from fieldset matching an aspect.
currency()  : mixed
Convert and format price value for current application store
currencyByStore()  : mixed
Convert and format price value for specified store
decrypt()  : string
Decrypt data using application key
encrypt()  : string
Encrypt data using application key
encryptIdempotent()  : string
Idempotent encryption: decrypts first to get plaintext, then encrypts.
escapeHtml()  : ($data is array ? ?string[] : ?string)
Escape html entities
escapeScriptIdentifiers()  : string
Remove `javascript:`, `vbscript:`, `data:` words from the string.
escapeSpecial()  : string
Remove `\t`,`\n`,`\r`,`\0`,`\x0B:` symbols from the string.
escapeUrl()  : string
Escape html entities in url
filter()  : mixed
Filter value using specified filter type
filterAlnum()  : string
Keep only alphanumeric characters (a-z, A-Z, 0-9)
filterAlpha()  : string
Keep only alphabetic characters (a-z, A-Z)
filterDigits()  : string
Keep only digits (0-9)
filterEmail()  : string
Sanitize email address by removing invalid characters
filterFloat()  : float
Extract float from value, keeping digits, +/-, and decimal point
filterInt()  : int
Extract integer from value, removing all non-digit characters except +/-
filterStripTags()  : string
Remove HTML and PHP tags, optionally allowing specific tags
filterUrl()  : string
Sanitize URL by removing invalid characters
formatCurrency()  : string
Format and convert currency using current store option
formatDate()  : string
Format date for display using the store's locale and timezone.
formatPrice()  : string
Formats price
formatTime()  : string
Format time using current locale options
formatTimezoneDate()  : string
Format date for display using the store's locale and timezone.
getCacheBetaTypes()  : array<string|int, mixed>
Get information about available cache beta types
getCacheTypes()  : array<string|int, mixed>
Get information about available cache types
getDefaultCountry()  : string
Return default country code
getEncryptor()  : Mage_Core_Model_Encryption
getEscapedCSVData()  : array<string|int, mixed>
Escaping CSV-data
getExactDivision()  : float|int
Returns the floating point remainder (modulo) of the division of the arguments
getHash()  : string
Generate salted hash from password
getHashPassword()  : string
Generate password hash for user
getHoneypotFieldHtml()  : string
Visually-hidden honeypot trap field markup, ready to echo inside a `<form>`.
getHoneypotFieldName()  : string
Per-install hidden trap field name for honeypot anti-spam.
getIconSvg()  : string
Get SVG icon content
getLayout()  : Mage_Core_Model_Layout
Retrieve layout model object
getMailerDsn()  : string
getMailTransport()  : TransportInterface|null
getMerchantCountryCode()  : string
Retrieve merchant country code
getMerchantVatNumber()  : string
Retrieve merchant VAT number
getProtectedFileExtensions()  : array<string|int, mixed>
Return list with protected file extensions
getRandomString()  : string
getStoreId()  : int
Retrieve store identifier
getVersionHash()  : int
Get encryption method depending on the presence of the function - password_hash.
hasTags()  : bool
Check for tags in multidimensional arrays
ipRateLimiter()  : RateLimiter|null
Config-governed IP limiter (system/rate_limit/*). Returns null when rate limiting is disabled or the client IP is unknown; callers treat null as "not limited".
isCountryInEU()  : bool
Check whether specified country is in EU countries list
isDevAllowed()  : bool
isFormKeyEnabled()  : bool
isHoneypotTriggered()  : bool
Honeypot check: returns true when the request body contains a non-empty value in the install-specific trap field returned by `getHoneypotFieldName()`.
isModuleEnabled()  : bool
Check is module exists and enabled in global config.
isModuleOutputEnabled()  : bool
Check whether the module output is enabled in Configuration
isValid()  : bool
Generic validation method that returns boolean result using Symfony constraints
isValidDate()  : bool
Check if date format is valid using Symfony Date constraint
isValidDateTime()  : bool
Check if datetime format is valid using Symfony DateTime constraint
isValidEmail()  : bool
Check if email address is valid using Symfony Email constraint
isValidIp()  : bool
Check if value is a valid IP address (IPv4 or IPv6)
isValidLength()  : bool
Check if string length is valid using Symfony Length constraint
isValidNotBlank()  : bool
Check if value is not blank using Symfony NotBlank constraint
isValidRange()  : bool
Check if numeric value is in valid range using Symfony Range constraint
isValidRegex()  : bool
Check if string matches regex pattern using Symfony Regex constraint
isValidUrl()  : bool
Check if URL format is valid using Symfony Url constraint
jsonDecode()  : mixed
Decodes the given $encodedValue string which is encoded in the JSON format
jsonEncode()  : string
Encode the mixed $valueToEncode into the JSON format
jsQuoteEscape()  : ($data is array ? string[] : string)
Escape quotes in java script
packageInstallWarning()  : string
Return a "⚠️ Install <package>" hint when the given Composer package isn't installed, or '' when it is. Used by system-config sources that surface optional dependencies inline (SMTP transports, AI providers).
quoteEscape()  : string
Escape quotes inside html attributes Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)
rateLimiter()  : RateLimiter
Rate limiter scoped to the request client. Core resolves the identity (IP/session) from $scope, so callers never read the remote address or session id themselves. $namespace separates one feature's budget from another's. A non-positive $maxAttempts disables it.
rateLimiterBy()  : RateLimiter
Rate limiter keyed by a caller-owned domain value (email, store id, order reference) rather than by request identity. The caller passes a value it already holds; nothing is read from the request. A non-positive $maxAttempts disables it.
recryptTable()  : bool
Re-encrypt columns in a table using batched queries to avoid memory exhaustion.
removeAccents()  : false|string
removeTags()  : string
Remove html tags, but leave "<" and ">" signs
setLayout()  : Mage_Core_Helper_Abstract
Declare layout
stripTags()  : string
Wrapper for standard strip_tags() function with extra functionality for html entities
translateArray()  : array<string|int, mixed>
Translate array
tryDecrypt()  : string|null
Attempt to decrypt data, returning null on failure instead of logging exceptions.
unEscapeCSVData()  : mixed
UnEscapes CSV data
uniqHash()  : string
Generate a hash from unique ID
urlDecode()  : string
base64_decode() for URLs decoding
urlDecodeAndEscape()  : string
base64_decode() and escape quotes in url
urlEncode()  : string
base64_encode() for URLs encoding
validateDecryptTable()  : array<int, array{table: string, primary_key: mixed, column: string}>
Validate that all encrypted values in a table can be decrypted successfully.
validateHash()  : bool
validateKey()  : bool
xmlToAssoc()  : array<string|int, mixed>
Transform SimpleXMLElement to associative array SimpleXMLElement must be conform structure, generated by assocToXml()
_cleanCache()  : Mage_Core_Helper_Abstract
Cleaning cache
_getModuleName()  : string
Retrieve helper module name
_getRequest()  : Mage_Core_Controller_Request_Http
Retrieve request object
_getUrl()  : string
Retrieve url
_loadCache()  : mixed
Loading cache data
_removeCache()  : Mage_Core_Helper_Abstract
Removing cache
_saveCache()  : Mage_Core_Helper_Abstract
Saving cache
resolveRateLimitIdentity()  : string
_assocToXml()  : SimpleXMLElement
Function, that actually recursively transforms array to xml
getSymfonyValidator()  : ValidatorInterface
Get Symfony validator instance

Constants

CHARS_DIGITS

public mixed CHARS_DIGITS = '0123456789'

CHARS_LOWERS

public mixed CHARS_LOWERS = 'abcdefghijklmnopqrstuvwxyz'

CHARS_PASSWORD_DIGITS

public mixed CHARS_PASSWORD_DIGITS = '23456789'

CHARS_PASSWORD_LOWERS

public mixed CHARS_PASSWORD_LOWERS = 'abcdefghjkmnpqrstuvwxyz'

CHARS_PASSWORD_SPECIALS

public mixed CHARS_PASSWORD_SPECIALS = '!$*-.=?@_'

CHARS_PASSWORD_UPPERS

public mixed CHARS_PASSWORD_UPPERS = 'ABCDEFGHJKLMNPQRSTUVWXYZ'

CHARS_SPECIALS

public mixed CHARS_SPECIALS = '!$*+-.=?@^_|~'

CHARS_UPPERS

public mixed CHARS_UPPERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

DIVIDE_EPSILON

Const for correct dividing decimal values

public mixed DIVIDE_EPSILON = 10000

XML_PATH_CACHE_BETA_TYPES

public mixed XML_PATH_CACHE_BETA_TYPES = 'global/cache/betatypes'

XML_PATH_DEFAULT_COUNTRY

public mixed XML_PATH_DEFAULT_COUNTRY = 'general/country/default'

XML_PATH_DEV_ALLOW_IPS

public mixed XML_PATH_DEV_ALLOW_IPS = 'dev/restrict/allow_ips'

XML_PATH_ENCRYPTION_MODEL

public mixed XML_PATH_ENCRYPTION_MODEL = 'global/helpers/core/encryption_model'

XML_PATH_EU_COUNTRIES_LIST

public mixed XML_PATH_EU_COUNTRIES_LIST = 'general/country/eu_countries'

XML_PATH_MERCHANT_COUNTRY_CODE

Config paths to merchant country code and merchant VAT number

public mixed XML_PATH_MERCHANT_COUNTRY_CODE = 'general/store_information/merchant_country'

XML_PATH_MERCHANT_VAT_NUMBER

public mixed XML_PATH_MERCHANT_VAT_NUMBER = 'general/store_information/merchant_vat_number'

XML_PATH_PROTECTED_FILE_EXTENSIONS

public mixed XML_PATH_PROTECTED_FILE_EXTENSIONS = 'general/file/protected_extensions'

Properties

$_allowedFormats

protected mixed $_allowedFormats = [\Mage_Core_Model_Locale::FORMAT_TYPE_FULL, \Mage_Core_Model_Locale::FORMAT_TYPE_LONG, \Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, \Mage_Core_Model_Locale::FORMAT_TYPE_SHORT]

$_moduleName

Helper module name

protected string $_moduleName = 'Mage_Core'

$modulesDisabled

protected array<string|int, mixed> $modulesDisabled = []

$symfonyValidator

Symfony validator instance

private static ValidatorInterface|null $symfonyValidator = \null

Methods

__()

Translate

public __() : string
Return values
string

assocToXml()

Transform an assoc array to SimpleXMLElement object Array has some limitations. Appropriate exceptions will be thrown

public assocToXml(array<string|int, mixed> $array[, string $rootName = '_' ]) : SimpleXMLElement
Parameters
$array : array<string|int, mixed>
$rootName : string = '_'
Tags
throws
Exception
Return values
SimpleXMLElement

copyFieldset()

Copy data from object|array to object|array containing fields from fieldset matching an aspect.

public copyFieldset(string $fieldset, string $aspect, array<string|int, mixed>|DataObject $source, array<string|int, mixed>|DataObject $target[, string $root = 'global' ]) : bool

Contents of $aspect are a field name in target object or array. If '*' - will be used the same name as in the source object or array.

Parameters
$fieldset : string
$aspect : string
$source : array<string|int, mixed>|DataObject
$target : array<string|int, mixed>|DataObject
$root : string = 'global'
Return values
bool

currency()

Convert and format price value for current application store

public static currency(float $value[, bool $format = true ][, bool $includeContainer = true ]) : mixed
Parameters
$value : float
$format : bool = true
$includeContainer : bool = true

currencyByStore()

Convert and format price value for specified store

public static currencyByStore(float $value[, int|Mage_Core_Model_Store $store = null ][, bool $format = true ][, bool $includeContainer = true ]) : mixed
Parameters
$value : float
$store : int|Mage_Core_Model_Store = null
$format : bool = true
$includeContainer : bool = true

decrypt()

Decrypt data using application key

public decrypt(string|null $data) : string
Parameters
$data : string|null
Return values
string

encrypt()

Encrypt data using application key

public encrypt(string $data) : string
Parameters
$data : string
Return values
string

encryptIdempotent()

Idempotent encryption: decrypts first to get plaintext, then encrypts.

public encryptIdempotent(string $data) : string

Safe to call on both plaintext and already-encrypted values.

Parameters
$data : string
Return values
string

escapeHtml()

Escape html entities

public escapeHtml(null|string|array<string|int, string> $data[, null|array<string|int, string> $allowedTags = null ]) : ($data is array ? ?string[] : ?string)
Parameters
$data : null|string|array<string|int, string>
$allowedTags : null|array<string|int, string> = null
Return values
($data is array ? ?string[] : ?string)

escapeScriptIdentifiers()

Remove `javascript:`, `vbscript:`, `data:` words from the string.

public escapeScriptIdentifiers(string $data) : string
Parameters
$data : string
Return values
string

escapeSpecial()

Remove `\t`,`\n`,`\r`,`\0`,`\x0B:` symbols from the string.

public escapeSpecial(string $data) : string
Parameters
$data : string
Return values
string

escapeUrl()

Escape html entities in url

public escapeUrl(string $data) : string
Parameters
$data : string
Return values
string

filter()

Filter value using specified filter type

public filter(mixed $value, string $filter, mixed ...$args) : mixed
Parameters
$value : mixed
$filter : string
$args : mixed

filterAlnum()

Keep only alphanumeric characters (a-z, A-Z, 0-9)

public filterAlnum(mixed $value[, bool $allowWhitespace = false ]) : string
Parameters
$value : mixed
$allowWhitespace : bool = false
Return values
string

filterAlpha()

Keep only alphabetic characters (a-z, A-Z)

public filterAlpha(mixed $value) : string
Parameters
$value : mixed
Return values
string

filterDigits()

Keep only digits (0-9)

public filterDigits(mixed $value) : string
Parameters
$value : mixed
Return values
string

filterEmail()

Sanitize email address by removing invalid characters

public filterEmail(mixed $value) : string
Parameters
$value : mixed
Return values
string

filterFloat()

Extract float from value, keeping digits, +/-, and decimal point

public filterFloat(mixed $value) : float
Parameters
$value : mixed
Return values
float

filterInt()

Extract integer from value, removing all non-digit characters except +/-

public filterInt(mixed $value) : int
Parameters
$value : mixed
Return values
int

filterStripTags()

Remove HTML and PHP tags, optionally allowing specific tags

public filterStripTags(mixed $value[, array<string|int, mixed>|string|null $allowedTags = null ]) : string
Parameters
$value : mixed
$allowedTags : array<string|int, mixed>|string|null = null
Return values
string

filterUrl()

Sanitize URL by removing invalid characters

public filterUrl(mixed $value) : string
Parameters
$value : mixed
Return values
string

formatCurrency()

Format and convert currency using current store option

public formatCurrency(float $value[, bool $includeContainer = true ]) : string
Parameters
$value : float
$includeContainer : bool = true
Return values
string

formatDate()

Format date for display using the store's locale and timezone.

public formatDate([string|int|DateTimeInterface|null $date = null ][, string $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT ][, bool $withTime = false ]) : string

Produces locale-aware output (e.g. "April 16, 2026" in en_US, "16 avril 2026" in fr_FR). For machine-readable formats, use DateTime::format() directly instead.

Parameters
$date : string|int|DateTimeInterface|null = null

If empty, return current datetime.

$format : string = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT

See Mage_Core_Model_Locale::FORMAT_TYPE_* constants

$withTime : bool = false

Whether to include time

Return values
string

formatPrice()

Formats price

public formatPrice(float $price[, bool $includeContainer = true ]) : string
Parameters
$price : float
$includeContainer : bool = true
Return values
string

formatTimezoneDate()

Format date for display using the store's locale and timezone.

public formatTimezoneDate([string|int|DateTimeInterface|null $date = null ][, string $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT ][, bool $withTime = false ][, bool $useTimezone = true ]) : string

Produces locale-aware output (e.g. "April 16, 2026" in en_US, "16 avril 2026" in fr_FR). For machine-readable formats, use DateTime::format() directly instead.

Parameters
$date : string|int|DateTimeInterface|null = null

The date to format. Can be:

  • null: Uses current time
  • int: Unix timestamp (assumes UTC)
  • string: Date string (e.g., "2025-08-01 09:24:18")
  • DateTimeInterface: Existing DateTime/DateTimeImmutable object
$format : string = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT

Display format constant:

  • FORMAT_TYPE_SHORT: Brief format (e.g., "8/1/25")
  • FORMAT_TYPE_MEDIUM: Standard format (e.g., "Aug 1, 2025")
  • FORMAT_TYPE_LONG: Detailed format (e.g., "August 1, 2025")
  • FORMAT_TYPE_FULL: Complete format (e.g., "Thursday, August 1, 2025")
$withTime : bool = false

Whether to include time in the output

  • true: "Aug 1, 2025, 10:24:18 AM"
  • false: "Aug 1, 2025"
$useTimezone : bool = true

Whether to convert the date to store timezone

  • true: Converts from UTC to store timezone before formatting
  • false: Formats the date in its current timezone (typically UTC)
Return values
string

Formatted date string according to locale settings

getCacheBetaTypes()

Get information about available cache beta types

public getCacheBetaTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getCacheTypes()

Get information about available cache types

public getCacheTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getEscapedCSVData()

Escaping CSV-data

public getEscapedCSVData(array<string|int, mixed> $data) : array<string|int, mixed>

Security enhancement for CSV data processing by Excel-like applications.

Parameters
$data : array<string|int, mixed>
Tags
see
https://bugzilla.mozilla.org/show_bug.cgi?id=1054702
Return values
array<string|int, mixed>

getExactDivision()

Returns the floating point remainder (modulo) of the division of the arguments

public getExactDivision(float|int $dividend, float|int $divisor) : float|int
Parameters
$dividend : float|int
$divisor : float|int
Return values
float|int

getHash()

Generate salted hash from password

public getHash(string $password[, string|int|bool $salt = false ]) : string
Parameters
$password : string
$salt : string|int|bool = false
Return values
string

getHashPassword()

Generate password hash for user

public getHashPassword(string $password[, mixed $salt = false ]) : string
Parameters
$password : string
$salt : mixed = false
Return values
string

getHoneypotFieldHtml()

Visually-hidden honeypot trap field markup, ready to echo inside a `<form>`.

public getHoneypotFieldHtml() : string

Renders the install-specific field from getHoneypotFieldName() so every caller emits an identical, correctly-named trap. The enable/disable toggle stays the caller's concern: gate this behind your own module setting.

Return values
string

getHoneypotFieldName()

Per-install hidden trap field name for honeypot anti-spam.

public getHoneypotFieldName() : string

Derived deterministically from the encryption key, so the same install always returns the same name (frontend can cache it), and different installs return different names (so a bot that scrapes one Maho install can't blanket-target all of them).

Defeats random spambot armies. For targeted attackers (who can scrape the rendered form), pair with captcha.

Return values
string

getIconSvg()

Get SVG icon content

public getIconSvg(string $name[, string $variant = 'outline' ][, string $role = 'none' ]) : string
Parameters
$name : string

Icon name (e.g., 'circle-x', 'plus', etc.)

$variant : string = 'outline'

Icon variant: 'outline' or 'filled'

$role : string = 'none'

ARIA role, see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles

Return values
string

SVG icon HTML or empty string if not found

getMailerDsn()

public getMailerDsn() : string
Return values
string

getMailTransport()

public getMailTransport() : TransportInterface|null
Return values
TransportInterface|null

getMerchantCountryCode()

Retrieve merchant country code

public getMerchantCountryCode([Mage_Core_Model_Store|string|int|null $store = null ]) : string
Parameters
$store : Mage_Core_Model_Store|string|int|null = null
Return values
string

getProtectedFileExtensions()

Return list with protected file extensions

public getProtectedFileExtensions([Mage_Core_Model_Store|string|int $store = null ]) : array<string|int, mixed>
Parameters
$store : Mage_Core_Model_Store|string|int = null
Return values
array<string|int, mixed>

getRandomString()

public getRandomString(int $len[, string|null $chars = null ]) : string
Parameters
$len : int
$chars : string|null = null
Return values
string

hasTags()

Check for tags in multidimensional arrays

public hasTags(string|array<string|int, mixed> $data[, array<string|int, mixed> $arrayKeys = [] ][, bool $skipTags = true ]) : bool
Parameters
$data : string|array<string|int, mixed>
$arrayKeys : array<string|int, mixed> = []

keys of the array being checked that are excluded and included in the check

$skipTags : bool = true

skip transferred array keys, if false then check only them

Return values
bool

ipRateLimiter()

Config-governed IP limiter (system/rate_limit/*). Returns null when rate limiting is disabled or the client IP is unknown; callers treat null as "not limited".

public ipRateLimiter() : RateLimiter|null
Return values
RateLimiter|null

isCountryInEU()

Check whether specified country is in EU countries list

public isCountryInEU(string $countryCode[, null|int $storeId = null ]) : bool
Parameters
$countryCode : string
$storeId : null|int = null
Return values
bool

isFormKeyEnabled()

public isFormKeyEnabled() : bool

since 25.5.0

Return values
bool

isHoneypotTriggered()

Honeypot check: returns true when the request body contains a non-empty value in the install-specific trap field returned by `getHoneypotFieldName()`.

public isHoneypotTriggered(array<string|int, mixed> $body) : bool

The enable/disable toggle is the caller's concern: gate this call behind your own module setting. Works for any request shape that exposes form data as an array, so it's usable from web controllers ($request->getPost()) and API processors (decoded JSON body) alike.

Parameters
$body : array<string|int, mixed>
Return values
bool

isModuleEnabled()

Check is module exists and enabled in global config.

public isModuleEnabled([string $moduleName = null ]) : bool
Parameters
$moduleName : string = null

the full module name, example Mage_Core

Return values
bool

isModuleOutputEnabled()

Check whether the module output is enabled in Configuration

public isModuleOutputEnabled([string $moduleName = null ]) : bool
Parameters
$moduleName : string = null

Full module name

Return values
bool

isValid()

Generic validation method that returns boolean result using Symfony constraints

public isValid(mixed $value, mixed $constraint) : bool
Parameters
$value : mixed
$constraint : mixed
Return values
bool

isValidDate()

Check if date format is valid using Symfony Date constraint

public isValidDate(string $date) : bool
Parameters
$date : string
Return values
bool

isValidDateTime()

Check if datetime format is valid using Symfony DateTime constraint

public isValidDateTime(string $datetime) : bool
Parameters
$datetime : string
Return values
bool

isValidEmail()

Check if email address is valid using Symfony Email constraint

public isValidEmail(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isValidIp()

Check if value is a valid IP address (IPv4 or IPv6)

public isValidIp(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isValidLength()

Check if string length is valid using Symfony Length constraint

public isValidLength(string $value[, int|null $min = null ][, int|null $max = null ]) : bool
Parameters
$value : string
$min : int|null = null
$max : int|null = null
Return values
bool

isValidNotBlank()

Check if value is not blank using Symfony NotBlank constraint

public isValidNotBlank(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

isValidRange()

Check if numeric value is in valid range using Symfony Range constraint

public isValidRange(mixed $value[, int|float|null $min = null ][, int|float|null $max = null ]) : bool
Parameters
$value : mixed
$min : int|float|null = null
$max : int|float|null = null
Return values
bool

isValidRegex()

Check if string matches regex pattern using Symfony Regex constraint

public isValidRegex(string $value, string $pattern) : bool
Parameters
$value : string
$pattern : string
Return values
bool

isValidUrl()

Check if URL format is valid using Symfony Url constraint

public isValidUrl(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

jsonDecode()

Decodes the given $encodedValue string which is encoded in the JSON format

public jsonDecode(string $encodedValue[, bool $associative = true ]) : mixed

switch added to prevent exceptions in json_decode

Parameters
$encodedValue : string
$associative : bool = true

When true, JSON objects will be returned as associative arrays

Tags
throws
JsonException

jsonEncode()

Encode the mixed $valueToEncode into the JSON format

public jsonEncode(mixed $valueToEncode) : string
Parameters
$valueToEncode : mixed
Tags
throws
JsonException
Return values
string

packageInstallWarning()

Return a "⚠️ Install <package>" hint when the given Composer package isn't installed, or '' when it is. Used by system-config sources that surface optional dependencies inline (SMTP transports, AI providers).

public packageInstallWarning(string $package[, string $separator = ' ' ]) : string
Parameters
$package : string
$separator : string = ' '

string inserted before the warning - " " for dropdown labels, "
" for heading rows.

Return values
string

quoteEscape()

Escape quotes inside html attributes Use $addSlashes = false for escaping js that inside html attribute (onClick, onSubmit etc)

public quoteEscape(string $data[, bool $addSlashes = false ]) : string
Parameters
$data : string
$addSlashes : bool = false
Return values
string

rateLimiter()

Rate limiter scoped to the request client. Core resolves the identity (IP/session) from $scope, so callers never read the remote address or session id themselves. $namespace separates one feature's budget from another's. A non-positive $maxAttempts disables it.

public rateLimiter(string $namespace, int $maxAttempts, int $windowSeconds[, RateLimitScope $scope = RateLimitScope::Client ]) : RateLimiter
Parameters
$namespace : string
$maxAttempts : int
$windowSeconds : int
$scope : RateLimitScope = RateLimitScope::Client
Return values
RateLimiter

rateLimiterBy()

Rate limiter keyed by a caller-owned domain value (email, store id, order reference) rather than by request identity. The caller passes a value it already holds; nothing is read from the request. A non-positive $maxAttempts disables it.

public rateLimiterBy(string $namespace, string $value, int $maxAttempts, int $windowSeconds) : RateLimiter
Parameters
$namespace : string
$value : string
$maxAttempts : int
$windowSeconds : int
Return values
RateLimiter

recryptTable()

Re-encrypt columns in a table using batched queries to avoid memory exhaustion.

public recryptTable(string $table, string $primaryKey, array<string|int, string> $columns, callable $encryptCallback, callable $decryptCallback[, int $batchSize = 1000 ][, OutputInterface|null $output = null ]) : bool
Parameters
$table : string
$primaryKey : string
$columns : array<string|int, string>
$encryptCallback : callable
$decryptCallback : callable
$batchSize : int = 1000
$output : OutputInterface|null = null
Return values
bool

removeAccents()

public removeAccents(string $string[, bool $german = false ]) : false|string
Parameters
$string : string
$german : bool = false
Return values
false|string

removeTags()

Remove html tags, but leave "<" and ">" signs

public removeTags(string $html) : string
Parameters
$html : string
Return values
string

stripTags()

Wrapper for standard strip_tags() function with extra functionality for html entities

public stripTags(string $data[, null|string|array<string|int, string> $allowableTags = null ][, bool $escape = false ]) : string
Parameters
$data : string
$allowableTags : null|string|array<string|int, string> = null
$escape : bool = false
Return values
string

translateArray()

Translate array

public translateArray([mixed $arr = [] ]) : array<string|int, mixed>

@param array $arr

Parameters
$arr : mixed = []
Return values
array<string|int, mixed>

tryDecrypt()

Attempt to decrypt data, returning null on failure instead of logging exceptions.

public tryDecrypt(string|null $data) : string|null

Useful when the value may or may not be encrypted.

Parameters
$data : string|null
Return values
string|null

unEscapeCSVData()

UnEscapes CSV data

public unEscapeCSVData(mixed $data) : mixed
Parameters
$data : mixed
Return values
mixed

array

uniqHash()

Generate a hash from unique ID

public uniqHash([string $prefix = '' ]) : string
Parameters
$prefix : string = ''
Return values
string

urlDecode()

base64_decode() for URLs decoding

public urlDecode(mixed $url) : string

@param string $url

Parameters
$url : mixed
Return values
string

urlDecodeAndEscape()

base64_decode() and escape quotes in url

public urlDecodeAndEscape(mixed $url) : string

@param string $url

Parameters
$url : mixed
Return values
string

urlEncode()

base64_encode() for URLs encoding

public urlEncode(mixed $url) : string

@param string $url

Parameters
$url : mixed
Return values
string

validateDecryptTable()

Validate that all encrypted values in a table can be decrypted successfully.

public validateDecryptTable(string $table, string $primaryKey, array<string|int, string> $columns, callable $decryptCallback[, int $batchSize = 1000 ]) : array<int, array{table: string, primary_key: mixed, column: string}>

Returns an array of failures (empty array = all good).

Parameters
$table : string
$primaryKey : string
$columns : array<string|int, string>
$decryptCallback : callable
$batchSize : int = 1000
Return values
array<int, array{table: string, primary_key: mixed, column: string}>

validateHash()

public validateHash(string $password, string $hash) : bool
Parameters
$password : string
$hash : string
Tags
throws
Exception
Return values
bool

validateKey()

public validateKey(string $key) : bool
Parameters
$key : string
Return values
bool

xmlToAssoc()

Transform SimpleXMLElement to associative array SimpleXMLElement must be conform structure, generated by assocToXml()

public xmlToAssoc(SimpleXMLElement $xml) : array<string|int, mixed>
Parameters
$xml : SimpleXMLElement
Return values
array<string|int, mixed>

_getModuleName()

Retrieve helper module name

protected _getModuleName() : string
Return values
string

_getUrl()

Retrieve url

protected _getUrl(string $route[, array<string|int, mixed> $params = [] ]) : string
Parameters
$route : string
$params : array<string|int, mixed> = []
Return values
string

_loadCache()

Loading cache data

protected _loadCache(string $id) : mixed
Parameters
$id : string

_saveCache()

Saving cache

protected _saveCache(mixed $data, string $id[, array<string|int, mixed> $tags = [] ][, null|false|int $lifeTime = false ]) : Mage_Core_Helper_Abstract
Parameters
$data : mixed
$id : string
$tags : array<string|int, mixed> = []
$lifeTime : null|false|int = false
Return values
Mage_Core_Helper_Abstract

_assocToXml()

Function, that actually recursively transforms array to xml

private _assocToXml(array<string|int, mixed> $array, string $rootName, SimpleXMLElement &$xml) : SimpleXMLElement
Parameters
$array : array<string|int, mixed>
$rootName : string
$xml : SimpleXMLElement
Tags
throws
Exception
Return values
SimpleXMLElement

getSymfonyValidator()

Get Symfony validator instance

private getSymfonyValidator() : ValidatorInterface
Return values
ValidatorInterface
On this page

Search results