frekel / cakephp-edexml

An Edexml parser / validator Plugin for CakePHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Edexml plugin for CakePHP

Build Status PHP 7 ready Coverage Status Packagist downloads Code Climate

Requirements

  • CakePHP 2.6.0 or greater.
  • PHP 5.4.16 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 = array('Edexml.Edexml');

Validate Edexml file:

$this->Edexml->saveAll($this->request->data, array('validate' => 'only'))

And in the corresponding view:

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

Parse Edexml file to a normalized array

First include the plugin model in your controller:

public $uses = array('Edexml.Edexml');

Convert the Edexml file:

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

About

An Edexml parser / validator Plugin for CakePHP

License:MIT License


Languages

Language:PHP 100.0%