Gets an array of handled codes

@return array
18981
public function getHandledCodes()
    {
        return array(
            self::CODE_PENDING                     => 'pending',
            self::CODE_ERROR                       => 'error',
            self::CODE_SUCCESS                     => 'success',
            self::CODE_UNAUTHORIZED_EMAIL          => 'unauthorized email',
            self::CODE_EMAIL_ALREADY_EXIST         => 'email already exist',
            self::CODE_UNAUTHORIZED_OPTOUT_EMAIL   => 'unauthorized optout email',
            self::CODE_UNAUTHORIZED_OPTOUT_MOBILE  => 'unauthorized optout mobile',
            self::CODE_ERROR_ON_INTEREST_TO_ADD    => 'error on interest to add',
            self::CODE_ERROR_ON_INTEREST_TO_DELETE => 'error on interest to delete',
        );
    }
587356
protected function _handlers()
    {
        $gmstrtotime = function ($value) {
            $TZ = date_default_timezone_get();
            if ($TZ === 'UTC') {
                return strtotime($value);
            }
            date_default_timezone_set('UTC');
            $time = strtotime($value);
            date_default_timezone_set($TZ);
            return $time;
        };

        return [
            'array' => [
                'object' => function($value, $column) {
                    return $value->to('array', $column);
                },
                'string' => function($value, $column) {
                    return (string) $value;
                },
                'integer' => function($value, $column) {
                    return (int) $value;
                },
                'float' => function($value, $column) {
                    return (float) $value;
                },
                'date' => function($value, $column) {
                    return $this->convert('array', 'datetime', $value, ['format' => 'Y-m-d']);
                },
                'datetime' => function($value, $column) use ($gmstrtotime) {
                    $column += ['format' => 'Y-m-d H:i:s'];
                    $format = $column['format'];
                    if ($value instanceof DateTime) {
                        return $value->format($format);
                    }
                    return gmdate($format, is_numeric($value) ? $value : $gmstrtotime($value));
                },
                'boolean' => function($value, $column) {
                    return $value;
                },
                'null' => function($value, $column) {
                    return;
                },
                'json' => function($value, $column) {
                    return is_array($value) ? $value : $value->to('array', $column);
                }
            ],
            'cast' => [
                'object' => function($value, $column, $options) {
                    return is_array($value) ? new Document([
                        'schema' => $options['schema'] ?? null,
                        'basePath' => $options['basePath'] ?? null,
                        'data' => $value
                    ]) : $value;
                },
                'string' => function($value, $column, $options) {
                    return (string) $value;
                },
                'integer' => function($value, $column, $options) {
                    return (integer) $value;
                },
                'float'   => function($value, $column, $options) {
                    return (float) $value;
                },
                'decimal' => function($value, $column, $options) {
                    $column += ['precision' => 2, 'decimal' => '.', 'separator' => ''];
                    return number_format($value, $column['precision'], $column['decimal'], $column['separator']);
                },
                'boolean' => function($value, $column, $options) {
                    return !!$value;
                },
                'date'    => function($value, $column, $options) {
                    return $this->convert('cast', 'datetime', $value, ['format' => 'Y-m-d'], $options);
                },
                'datetime'    => function($value, $column, $options) use ($gmstrtotime) {
                    $column += ['format' => 'Y-m-d H:i:s'];
                    if ($value instanceof DateTime) {
                        return $value;
                    }
                    $timestamp = is_numeric($value) ? $value : $gmstrtotime($value);
                    if ($timestamp < 0 || $timestamp === false) {
                        return;
                    }
                    return DateTime::createFromFormat("!{$column['format']}", gmdate($column['format'], $timestamp), new DateTimeZone('UTC'));
                },
                'null'    => function($value, $column, $options) {
                    return null;
                },
                'json' => function($value, $column, $options) {
                    return is_string($value) ? json_decode($value, true) : $value;
                }
            ]
        ];
    }
1275335
public function getHandlers()
    {
        $filters = &gplcart_static('filter.handlers');

        if (isset($filters)) {
            return $filters;
        }

        $filters = array();
        $this->hook->attach('filter.handlers', $filters, $this);

        foreach ($filters as $id => &$filter) {
            $filter['filter_id'] = $id;
            $filter += array(
                'role_id' => array(),
                'status' => true,
                'module' => null
            );
        }

        return $filters;
    }
906021
public function getHandlers()
    {
        $handlers = &gplcart_static('install.handlers');

        if (isset($handlers)) {
            return $handlers;
        }

        $handlers = array();
        $this->hook->attach('install.handlers', $handlers, $this);

        foreach ($handlers as $id => &$handler) {

            if (empty($handler['module'])) {
                unset($handlers[$id]);
                continue;
            }

            $info = $this->module->getInfo($handler['module']);

            if (empty($info['type']) || $info['type'] !== 'installer') {
                unset($handlers[$id]);
                continue;
            }

            $handler['id'] = $id;
            $handler['weight'] = isset($handler['weight']) ? $handler['weight'] : 0;
        }

        $handlers = array_merge($handlers, $this->getDefaultHandler());
        gplcart_array_sort($handlers);
        return $handlers;
    }
798135
public function getErrors()
	{
		if ($msg = $this->options->message) {
			$errors[] = $msg;
		} else {

			$messages = $this->messages();
			foreach ($this->errors as $code) {
				$errors[] = $messages[$code];
			}
		}

		return $errors;
	}
1132034
public function __toArray()
    {
        $result = [];
        if ($this->status !== null) {
            $result['status'] = $this->status;
        }
        if ($this->code !== null) {
            $result['code'] = $this->code;
        }
        if ($this->title !== null) {
            $result['title'] = $this->title;
        }
        return $result;
    }
23693
public function isOk()
    {
        $codes = [
            static::STATUS_OK,
            static::STATUS_CREATED,
            static::STATUS_ACCEPTED,
            static::STATUS_NON_AUTHORITATIVE_INFORMATION,
            static::STATUS_NO_CONTENT
        ];

        return in_array($this->code, $codes);
    }
561174
public function asArray()
    {
        $error = $this->error;
        if ($error->has()) {
            $o = [
                'error' => true,
                'errors' => [],
                'htmlErrorIndexes' => [],
            ];
            $index = 0;
            foreach ($error->getList() as $error) {
                $o['errors'][] = (string) $error;
                if ($error instanceof HtmlAwareErrorInterface && $error->messageContainsHtml()) {
                    $o['htmlErrorIndexes'][] = $index;
                }
                ++$index;
            }
            if (empty($o['htmlErrorIndexes'])) {
                unset($o['htmlErrorIndexes']);
            }

            return $o;
        }
    }
1192184
public function getAvailable(): array
    {
        $result = [];

        $dbLanguages = $this->find('list', ['keyField' => 'code', 'valueField' => 'name'])
                            ->where(['trashed IS' => null])
                            ->toArray();
        $supportedLanguages = $this->getSupported();
        $result = array_diff_assoc($supportedLanguages, $dbLanguages);

        return $result;
    }
397078
public static function getHandlers()
    {
        $handlers = array();
        $handlerList = self::getHandlerList();
        $cacheHash = md5( serialize( $handlerList ) );
        
        if ( isset( $GLOBALS['eZHTTPCacheManager_' . $cacheHash] ) )
            return $GLOBALS['eZHTTPCacheManager_' . $cacheHash];
        
        foreach ( $handlerList as $handler )
        {
            $object = new $handler;
            if ( $object instanceof eZHTTPCacheManagerInterface )
                $handlers[] = $object;
        }
        
        $GLOBALS['eZHTTPCacheManager_' . $cacheHash] = $handlers;
        
        return $handlers;
    }
383082
public function getStores()
	{
		$handlers = scandir(
			dirname(__FILE__).DS.'storage',
			SCANDIR_SORT_DESCENDING
		);

		$handlers = preg_grep('/^([^.])/', $handlers);

		$exclude = array(
			'abstract.php',
			'exception.php',
			'interface.php'
		);

		$handlers = array_diff($handlers, $exclude);

		$names = array();

		foreach ($handlers as $handler) {
			if (strpos($handler, '.php')) {
				$name = substr($handler, 0, strrpos($handler, '.'));
				if ($this->getService('com:sessions.storage.'.$name)->test()){
					$names[] = $name;
				}
			}
		}

		return $names;
	}
360017
public function getItemsWithUnhandledErrors()
    {
        $list = [];
        foreach ($this->getItems() as $item) {
            if ($item->hasUnhandledError()) {
                $list[] = $item;
            }
        }

        return $list;
    }
962091
public function statusCodes(): array
    {
        return array_map(
                function($status)
                {
                    return new Status($status->getCode(), $status->getDescription());
                },
                $this->annotations->named('Status')
        );
    }
1126217
public function toArray(): array
    {
        $payload = [
            'code' => $this->getCode()
        ];

        if (! empty($this->getMessage())) {
            $payload['message'] = $this->getMessage();
        }

        if (! empty($this->getError())) {
            $payload['error'] = $this->getError();
        }

        if (! empty($this->getData())) {
            $payload['data'] = $this->getData();
        }

        if (! empty($this->getOptions())) {
            $payload += $this->getOptions();
        }

        return $payload;
    }
526912
public function getHandlers()
    {
        $handlers = &gplcart_static('mail.handlers');

        if (isset($handlers)) {
            return $handlers;
        }

        $handlers = (array) gplcart_config_get(GC_FILE_CONFIG_MAIL);
        $this->hook->attach('mail.handlers', $handlers, $this);
        return $handlers;
    }
1007924
public function all()
    {
        $all = [];

        foreach ($this->style as $style) {
            $all = array_merge($all, $this->convertToCodes($style->all()));
        }

        return $all;
    }
133033
public function getFunctions()
    {
        $stmts = [];
        $stmts['drop/function/slugify'] = 'DROP FUNCTION IF EXISTS `slugify`';
        $stmts['create/function/slugify'] = <<< ENDQ
        CREATE FUNCTION `slugify` (dirty_string VARCHAR(255))
        RETURNS VARCHAR(255) CHARSET latin1
        DETERMINISTIC
        BEGIN
            DECLARE x, y , z INT;
            DECLARE temp_string, new_string VARCHAR(255);
            DECLARE is_allowed BOOL;
            DECLARE c, check_char VARCHAR(1);

            SET temp_string = LOWER(dirty_string);

            SET temp_string = REPLACE(temp_string, '&', ' and ');

            SELECT temp_string REGEXP('[^a-z0-9\-]+') INTO x;
            IF x = 1 THEN
                SET z = 1;
                WHILE z <= CHAR_LENGTH(temp_string) DO
                    SET c = SUBSTRING(temp_string, z, 1);
                    SET is_allowed = FALSE;
                    IF !((ascii(c) = 45) or (ascii(c) >= 48 and ascii(c) <= 57) or (ascii(c) >= 97 and ascii(c) <= 122)) THEN
                        SET temp_string = REPLACE(temp_string, c, '-');
                    END IF;
                    SET z = z + 1;
                END WHILE;
            END IF;

            SELECT temp_string REGEXP("^-|-$|'") INTO x;
            IF x = 1 THEN
                SET temp_string = REPLACE(temp_string, "'", '');
                SET z = CHAR_LENGTH(temp_string);
                SET y = CHAR_LENGTH(temp_string);
                Dash_check: WHILE z > 1 DO
                    IF STRCMP(SUBSTRING(temp_string, -1, 1), '-') = 0 THEN
                        SET temp_string = SUBSTRING(temp_string,1, y-1);
                        SET y = y - 1;
                    ELSE
                        LEAVE Dash_check;
                    END IF;
                    SET z = z - 1;
                END WHILE;
            END IF;

            REPEAT
                SELECT temp_string REGEXP("--") INTO x;
                IF x = 1 THEN
                    SET temp_string = REPLACE(temp_string, "--", "-");
                END IF;
            UNTIL x <> 1 END REPEAT;

            IF LOCATE('-', temp_string) = 1 THEN
                SET temp_string = SUBSTRING(temp_string, 2);
            END IF;

            RETURN temp_string;
        END        
ENDQ;

        $stmts['drop/function/strip_tags'] = 'DROP FUNCTION IF EXISTS `strip_tags`';
        $stmts['create/function/strip_tags'] = <<< 'ENDQ'
        CREATE FUNCTION strip_tags( DIRTY VARCHAR(3000) )
        RETURNS VARCHAR(3000) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci
        DETERMINISTIC 
        BEGIN
          DECLARE iStart, iEnd, iLength int;
            WHILE LOCATE( '<', DIRTY ) > 0 And LOCATE( '>', DIRTY, LOCATE( '<', DIRTY )) > 0 DO
              BEGIN
                SET iStart = LOCATE( '<', DIRTY ), iEnd = LOCATE( '>', DIRTY, LOCATE('<', DIRTY ));
                SET iLength = ( iEnd - iStart) + 1;
                IF iLength > 0 THEN
                  BEGIN
                    SET DIRTY = INSERT( DIRTY, iStart, iLength, '');
                  END;
                END IF;
              END;
            END WHILE;
            RETURN DIRTY;
        END;
ENDQ;

        $stmts['drop/function/delete_double_spaces'] = 'DROP FUNCTION IF EXISTS `delete_double_spaces`';
        $stmts['create/function/delete_double_spaces'] = <<< 'ENDQ'
        CREATE FUNCTION delete_double_spaces ( title VARCHAR(3000) )
        RETURNS VARCHAR(3000) CHARSET utf8mb4 COLLATE utf8mb4_unicode_ci 
        DETERMINISTIC
        BEGIN
            DECLARE result VARCHAR(3000);
            SET result = REPLACE( title, '  ', ' ' );
            WHILE (result <> title) DO 
                SET title = result;
                SET result = REPLACE( title, '  ', ' ' );
            END WHILE;
            RETURN result;
        END;
ENDQ;

        $stmts['drop/function/get_searchable_reference'] = 'DROP FUNCTION IF EXISTS `get_searchable_reference`';
        $stmts['create/function/get_searchable_reference'] = <<< 'ENDQ'
        CREATE FUNCTION `get_searchable_reference` (`in_str` VARCHAR(2048)) 
        RETURNS VARCHAR(2048) CHARSET utf8mb4
        DETERMINISTIC        
        BEGIN
            /*
              This function escape a string from any non alphanumeric chars (A_Z0_9)
              to get a searchable reference. Also try to remove any first 
              non-significative zero.

              FOR example 'BA-0114-22' -> 'BA11422'  

            */    
            DECLARE out_str VARCHAR(2048) DEFAULT '';
            DECLARE c VARCHAR(1) DEFAULT '';
            DECLARE prev_c VARCHAR(1) DEFAULT '';
            DECLARE pointer INT DEFAULT 1;

            IF ISNULL(in_str) THEN
                RETURN NULL;
            ELSE
                WHILE pointer <= LENGTH(in_str) DO
                    SET c = UPPER(MID(in_str, pointer, 1));

                    -- TAKE ONLY [A-Z0-9] characters
                    IF  ((ASCII(c) > 64 AND ASCII(c) < 92) or (ASCII(c) > 47 AND ASCII(c) < 58))
                    THEN
                        -- IF A NUMBER, try to get rid of non-significave numbers
                        IF (ASCII(c) > 47 AND ASCII(c) < 58)
                        THEN 
                            -- IF C is a zero and PREVIOUS CHARACTER IS NUMERIC
                            IF (c = 0 and NOT (ASCII(prev_c) > 47 AND ASCII(prev_c) < 58))
                            THEN
                                -- NOTHING
                                SET c = c;
                            ELSE
                                SET out_str = CONCAT(out_str, c);
                            END IF;
                        ELSE 
                            SET out_str = CONCAT(out_str, c);
                        END IF;
                    END IF;
                    SET prev_c = c;
                    SET pointer = pointer + 1;
                END WHILE;
            END IF;

            RETURN UPPER(out_str);
        END;
ENDQ;

        return $stmts;
    }