{"id":16150250,"url":"https://github.com/zapalm/prestashop-helpers","last_synced_at":"2025-03-18T18:33:49.170Z","repository":{"id":46342021,"uuid":"143726865","full_name":"zapalm/prestashop-helpers","owner":"zapalm","description":"Helper classes for Prestashop CMS.","archived":false,"fork":false,"pushed_at":"2024-04-10T10:17:39.000Z","size":148,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T00:47:52.204Z","etag":null,"topics":["hacktoberfest","helpers","php","php-library","prestashop"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zapalm.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null},"funding":{"patreon":"zapalm"}},"created_at":"2018-08-06T12:40:41.000Z","updated_at":"2023-08-14T09:46:23.000Z","dependencies_parsed_at":"2024-04-10T10:51:19.484Z","dependency_job_id":null,"html_url":"https://github.com/zapalm/prestashop-helpers","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapalm%2Fprestashop-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapalm%2Fprestashop-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapalm%2Fprestashop-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapalm%2Fprestashop-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zapalm","download_url":"https://codeload.github.com/zapalm/prestashop-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221715979,"owners_count":16868648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest","helpers","php","php-library","prestashop"],"created_at":"2024-10-10T00:48:12.075Z","updated_at":"2024-10-27T18:15:58.337Z","avatar_url":"https://github.com/zapalm.png","language":"PHP","funding_links":["https://patreon.com/zapalm"],"categories":[],"sub_categories":[],"readme":"# Helper classes for PrestaShop CMS\nFull documented helper classes for PrestaShop CMS (8, 1.7, 1.6, 1.5).\nWith these helpers some programming tasks becomes more simple and done faster.\n[The library homepage][5].\n\n**Helper list:**\n- ArrayHelper\n- BackendHelper\n- DateHelper\n- DiagnosticHelper\n- FileHelper\n- FormHelper\n- HtaccessHelper\n- LogHelper\n- ModuleHelper\n- ObjectHelper\n- SecurityHelper\n- StringHelper\n- TranslateHelper\n- UrlHelper\n- ValidateHelper\n- ProductHelper\n\n**Controller list:**\n- BaseModuleFrontController.php\n- AjaxModuleFrontController.php\n\n**Component list:**\n- Cache\n- QualityService\n- Autoloader (used Composer that goes to boot)\n\n## Examples\nEvery method and class is full documented, so here are several examples, i.e. just a one for each class. \n\n**ArrayHelper**, indexing an array.\n~~~\n$array = [\n    ['id' =\u003e '123', 'data' =\u003e 'abc'],\n    ['id' =\u003e '345', 'data' =\u003e 'def'],\n];\n$result = ArrayHelper::index($array, 'id');\n// The result is:\n// [\n//     '123' =\u003e ['id' =\u003e '123', 'data' =\u003e 'abc'],\n//     '345' =\u003e ['id' =\u003e '345', 'data' =\u003e 'def'],\n// ]\n~~~ \n\n**FormHelper**, generating a source array for a `select` element. \n~~~\n$array = [\n    ['123' =\u003e 'abc'],\n    ['345' =\u003e 'def'],\n];\n$result = FormHelper::generateList($array);\n// The result is:\n// [\n//     ['id' =\u003e '123', 'name' =\u003e 'abc'],\n//     ['id' =\u003e '345', 'name' =\u003e 'def']\n// ]\n\n// The usage in a form definition:\narray(\n    'type'    =\u003e 'select',\n    'label'   =\u003e 'Example',\n    'name'    =\u003e 'example',\n    'options' =\u003e array(\n        'query' =\u003e $result,\n        'id'    =\u003e 'id',\n        'name'  =\u003e 'name',\n    ),\n)\n~~~\n\n**LogHelper**, logging an error in a module.\n~~~\npublic function example() {\n    $this-\u003elog('An error occupied.');\n}\npublic function log($messages, $level = AbstractLogger::WARNING) {\n    LogHelper::log($messages, $level, $this-\u003ename, $this-\u003eid);\n}\n~~~\n\n**DiagnosticHelper**, checking if a method is overridden.\n~~~\nif (DiagnosticHelper::isMethodOverridden('AddressController', 'init')) {\n    $this-\u003e_errors[] = $this-\u003el('The AddressController::init() already overridden.');\n}\n~~~\n\n**AjaxModuleFrontController**, creating a simple Ajax controller for a module.\n~~~\nclass ExampleAjaxModuleFrontController extends AjaxModuleFrontController {\n    protected function actionSave() {\n        $this-\u003eajaxResponse-\u003eresult  = true;\n        $this-\u003eajaxResponse-\u003emessage = 'Success!';\n    }\n}\n// The output result is:\n// {\"result\":true,\"data\":null,\"html\":\"\",\"message\":\"Success!\",\"errors\":[]}\n~~~\n\n**ModuleHelper**, getting an instance of a module by given directory path.\n~~~\n$path   = '/var/www/prestashop/modules/homecategoriez/classes'; \n$module = ModuleHelper::getInstanceByPath($path); /** @var HomeCategoriez $module The instance of the module: HomeCategoriez */\n~~~\n\n**FileHelper**, getting a real maximum file size that can be uploaded to a site.\n~~~\n$sizeInBytes = FileHelper::getFileSizeUploadLimit();\n~~~\n\n**Cache component**, caching a DB query result. \n~~~\npublic function getAllCustomers() {\n    $cacheKey = CacheProvider::getKeyName(__METHOD__);\n\n    $data = CacheProvider::getInstance()-\u003eget($cacheKey);\n    if (false === $data) {\n        $data = Db::getInstance()-\u003eexecuteS('SELECT * FROM ps_customer', true, false);\n        CacheProvider::getInstance()-\u003eset($cacheKey, $data, 60 * 60 * 24);\n    }\n\n    return $data;\n}\n~~~\n\n**Autoloader**, using Composer's autoloader to automatically load PHP classes, for example, *in a module* by adding classmap to your `composer.json` file.\n~~~\n\"autoload\": {\n  \"classmap\": [\n    \"classes/\",\n    \"interfaces/\"\n  ]\n}\n~~~\n\n## Installation\nAdd the dependency directly to your `composer.json` file:\n```\n\"repositories\": [\n  {\n    \"type\": \"vcs\",\n    \"url\": \"https://github.com/zapalm/prestashop-helpers\"\n  }\n],\n\"require\": {\n  \"php\": \"\u003e=5.5\",\n  \"zapalm/prestashop-helpers\": \"dev-master\"\n},\n```\n\n## How to help the project grow and get updates\nGive the **star** to the project. That's all! :)\n\n## Contributing to the code\n\n### Requirements for code contributors\n\nContributors **must** follow the following rules:\n\n* **Make your Pull Request on the *dev* branch**, NOT the *master* branch.\n* Do not update a helper version number.\n* Follow [PSR coding standards][1].\n\n### Process in details for code contributors\n\nContributors wishing to edit the project's files should follow the following process:\n\n1. Create your GitHub account, if you do not have one already.\n2. Fork the project to your GitHub account.\n3. Clone your fork to your local machine.\n4. Create a branch in your local clone of the project for your changes.\n5. Change the files in your branch. Be sure to follow [the coding standards][1].\n6. Push your changed branch to your fork in your GitHub account.\n7. Create a pull request for your changes **on the *dev* branch** of the project.\n   If you need help to make a pull request, read the [GitHub help page about creating pull requests][4].\n8. Wait for the maintainer to apply your changes.\n\n**Do not hesitate to create a pull request if even it's hard for you to apply the coding standards.**\n\n[1]: https://www.php-fig.org/psr/\n[4]: https://help.github.com/articles/about-pull-requests/\n[5]: https://prestashop.modulez.ru/en/tools-scripts/53-helper-classes-for-prestashop.html","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapalm%2Fprestashop-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzapalm%2Fprestashop-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapalm%2Fprestashop-helpers/lists"}