oefenweb/cakephp-edexml

An Edexml parser / validator Plugin for CakePHP

Installs: 17 469

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 3

Forks: 3

Open Issues: 1

Type:cakephp-plugin

v3.0.2 2020-03-03 09:47 UTC

This package is auto-updated.

Last update: 2024-10-29 04:36:23 UTC


README

Build Status PHP 7 ready Coverage Status Packagist downloads Code Climate Scrutinizer Code Quality

Requirements

  • CakePHP 2.9.0 or greater.
  • PHP 7.0.0 or greater.

Installation

Clone/Copy the files in this directory into app/Plugin/Edexml

Configuration

Ensure the plugin is loaded in app/Config/bootstrap.php by calling:

CakePlugin::load('Edexml');

Usage

Validating Edexml file upload from a controller

First include the plugin model in your controller:

public $uses = ['Edexml.Edexml'];

Validate Edexml file:

$this->Edexml->saveAll($this->request->data, ['validate' => 'only']);

And in the corresponding view:

echo $this->Form->create('Edexml.Edexml', ['type' => 'file']);
echo $this->Form->input('file', ['type' => 'file']);
echo $this->Form->end(__('Submit'));

Parse Edexml file to a normalized array

First include the plugin model in your controller:

public $uses = ['Edexml.Edexml'];

Convert the Edexml file:

$filename = $this->request->data('Edexml.file.tmp_name');
$data = $this->Edexml->parseToArray($filename);
$data = $this->Edexml->convert($data);