PHPackages                             lolautruche/sqliimport - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. lolautruche/sqliimport

ActiveEzpublish-legacy-extension

lolautruche/sqliimport
======================

eZ Publish legacy extension for importing external content

v1.3.0(10y ago)219.2k↓50%22[3 PRs](https://github.com/lolautruche/sqliimport/pulls)2GPL-2.0PHP

Since Nov 28Pushed 8y ago5 watchersCompare

[ Source](https://github.com/lolautruche/sqliimport)[ Packagist](https://packagist.org/packages/lolautruche/sqliimport)[ RSS](/packages/lolautruche-sqliimport/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (8)Used By (2)

SQLIImport for eZ Publish documentation
=======================================

[](#sqliimport-for-ez-publish-documentation)

[![https://github.com/lolautruche/SQLIImport/raw/master/doc/images/sqli_logo.jpg](https://github.com/lolautruche/SQLIImport/raw/master/doc/images/sqli_logo.jpg)](https://github.com/lolautruche/SQLIImport/raw/master/doc/images/sqli_logo.jpg)

author:Jérôme Vieilledentversion:1.2Date:2010/09/26Table of contents

- [1 PRESENTATION](#presentation)
    - [1.1 LICENCE](#licence)
    - [1.2 CREDITS](#credits)
- [2 USAGE](#usage)
    - [2.1 Immediate &amp; Scheduled](#immediate-scheduled)
        - [2.1.1 Immediate](#immediate)
        - [2.1.2 Scheduled](#scheduled)
    - [2.2 Runtime Options](#runtime-options)
    - [2.3 Import Interruption](#import-interruption)
        - [2.3.1 From admin interface](#from-admin-interface)
        - [2.3.2 From CLI](#from-cli)
- [3 CLI SCRIPT](#cli-script)
- [4 PERFORMANCE SETTINGS](#performance-settings)
    - [4.1 ViewCaching](#viewcaching)
    - [4.2 ObjectIndexing](#objectindexing)
    - [4.3 Content objects update](#content-objects-update)
        - [4.3.1 Datatypes for which a specific diff handler is provided :](#datatypes-for-which-a-specific-diff-handler-is-provided)
- [5 HANDLER DEVELOPMENT](#handler-development)
    - [5.1 Simplified content API](#simplified-content-api)
        - [5.1.1 Options](#options)
            - [5.1.1.1 SQLIContentOptions](#sqlicontentoptions)
            - [5.1.1.2 SQLIContentPublishOptions](#sqlicontentpublishoptions)
    - [5.2 Source Handlers](#source-handlers)
- [6 DIFF HANDLER DEVELOPMENT](#diff-handler-development)

[1 PRESENTATION](#id1)
----------------------

[](#1presentation)

SQLIImport is an extension allowing to import external content in eZ Publish. It provides a framework for content manipulation and a simple interface for developing import handlers, so as a GUI to administrate your imports in the admin interface Import handlers are classes you need to develop in order to process external data (XML, CSV, ...) and import it into eZ Publish (see [Handler Development](#handler-development) section).

### [1.1 LICENCE](#id2)

[](#11licence)

This eZ Publish extension is provided *as is*, in GPL v2 (see LICENCE).

### [1.2 CREDITS](#id3)

[](#12credits)

This extension has been written by [Jérôme Vieilledent](http://share.ez.no/community/profile/11256) and sponsored by [SQLi](http://www.sqli.com/eng).

Oracle adaptation has been made by [Simone Tellini](http://tellini.info/).

[2 USAGE](#id4)
---------------

[](#2usage)

You can manage your imports via the admin interface. After installing *SQLIImport*, a new **Import Management** tab appears (you'll need to have access to *sqliimport* module or to simply be administrator to be able to see it from eZ Publish 4.3). Click on it to start managing your imports :

[![https://github.com/lolautruche/SQLIImport/raw/master/doc/images/admin_importlist.jpg](https://github.com/lolautruche/SQLIImport/raw/master/doc/images/admin_importlist.jpg)](https://github.com/lolautruche/SQLIImport/raw/master/doc/images/admin_importlist.jpg)Imports list

### [2.1 Immediate &amp; Scheduled](#id5)

[](#21immediate--scheduled)

There are two types of imports :- Immediate
- Scheduled

Each import is stored in the database as pending and awaits for the cronjob to process it. Pending imports can be cancelled while the cronjob has not processed it.

#### [2.1.1 Immediate](#id6)

[](#211immediate)

Immediate imports are *one-shot*, meaning that they will not repeat in time, contrary to scheduled imports. To add an immediate import, click on *Request a new immediate import* in the left menu. Choose your import handler and eventually add options (see [Runtime Options](#runtime-options) section below).

#### [2.1.2 Scheduled](#id7)

[](#212scheduled)

Scheduled imports will be launched at chosen *start date*. They can be one-shot (Frequency = none) or recurring. You can add a label to the scheduled import and deactivate it :

[![https://github.com/lolautruche/SQLIImport/raw/master/doc/images/admin_addscheduled.jpg](https://github.com/lolautruche/SQLIImport/raw/master/doc/images/admin_addscheduled.jpg)](https://github.com/lolautruche/SQLIImport/raw/master/doc/images/admin_addscheduled.jpg)Add scheduled import form

To add a scheduled import, go to *Scheduled import(s)* by clicking the link in the left menu, and click *Add a scheduled import*. Choose your import handler and eventually add options (see [Runtime Options](#runtime-options) section below).

### [2.2 Runtime Options](#id8)

[](#22runtime-options)

If your import handler supports **Runtime options** (see [Handler Development](#handler-development) section), you can add them from the admin interface. You can only add one option per line with format **optionName=optionValue**. Options will be passed to the import handler at runtime (in the handler constructor).

### [2.3 Import Interruption](#id9)

[](#23import-interruption)

Running imports are safely interruptable from the admin interface or from the CLI.

#### [2.3.1 From admin interface](#id10)

[](#231from-admin-interface)

From the import list, you can interrupt a running import by clicking the **Interrupt** link of the import. Please note that you will need to have access to the *manageimports* policy function for the current import handler.

#### [2.3.2 From CLI](#id11)

[](#232from-cli)

From version 1.2.0, SQLI Import catches *SIGTERM* and *SIGINT* signals. This is made possible thanks to [PCNTL extension](http://php.net/pcntl) (won't work on Windows). You can thus safely interrupt a running import with **kill** command :

```
kill -2
kill -15
```

Please note that **kill -9** (*SIGKILL*) signal cannot be caught, so always prefer using SIGTERM (**kill -15**) or SIGINT (**kill -2**). You can also ask for import interruption by pressing **Ctrl+C**, which sends a *SIGINT* signal.

[3 CLI SCRIPT](#id12)
---------------------

[](#3cli-script)

SQLIImport provides both a cronjob and a *regular* CLI script. The cronjob is used to process imports added from the admin interface (immediate and scheduled). The regular CLI script can be used to trigger a quick one shot import, without having to go into the admin interface.

**Usage :** php extension/sqliimport/bin/php/sqlidoimport.php \[OPTION\]...

**Options :**--source-handlers=VALUE Comma separated source handlers identifiers. If not provided, all source handlers will be processed.--list-source-handlers Lists all available handlers--options=VALUE Options for import handlers. Should be something like --options="handler1::foo=bar,foo2=baz|handler2::someoption=biz"[4 PERFORMANCE SETTINGS](#id13)
-------------------------------

[](#4performance-settings)

Several *performance settings* are set in **sqliimport.ini** configuration file. For more details, read the inline comments in the INI file.

### [4.1 ViewCaching](#id14)

[](#41viewcaching)

View caching is disabled by default for performance reasons. It's disabled only for the import script. ViewCache is cleared once import has been done, via *sqliimport\_cleanup* cronjob (launched after *sqliimport\_run*)

### [4.2 ObjectIndexing](#id15)

[](#42objectindexing)

Same as for ViewCaching above. Import will be much faster with ObjectIndexing set to disabled. Will just activate site.ini SearchSettings.DelayedIndexing for current import script. Content objects will be indexed once import has been done, via *sqliimport\_cleanup* cronjob.

### [4.3 Content objects update](#id16)

[](#43content-objects-update)

If bundled content manipulation framework is used, the system will do comparisons in order to check if it is really necessary to create a new content object version. By default it compares the string representation of each attribute content, but the diff system is extendable. It is thus possible to define new diff handlers for each datatype.

For more information, please read the [DIFF HANDLER DEVELOPMENT](#diff-handler-development) section.

#### [4.3.1 Datatypes for which a specific diff handler is provided :](#id17)

[](#431datatypes-for-which-a-specific-diff-handler-is-provided-)

> - ezimage
> - ezbinaryfile

[5 HANDLER DEVELOPMENT](#id18)
------------------------------

[](#5handler-development)

To import external content into eZ Publish with SQLIImport, you need to develop a handler that *understands*the external source (whatever it is) and maps it with your eZ Publish content structure.

Developing an import handler is fairly easy. You just need to create a PHP class that extends **SQLIImportAbstractHandler**and implements **ISQLIImportHandler**. You will also need to declare it in an override of **sqliimport.ini** by creating a dedicated section (please read inline INI comments for further details).

[![https://github.com/lolautruche/SQLIImport/raw/master/doc/uml/ImportHandlers.png](https://github.com/lolautruche/SQLIImport/raw/master/doc/uml/ImportHandlers.png)](https://github.com/lolautruche/SQLIImport/raw/master/doc/uml/ImportHandlers.png)UML diagram for import handlers

**Handler method call order :**- *\_\_construct()* - You'll need to call the parent constructor in it
- *initialize()* - Main method called to init your handler. Here you may read your external data source
- *getProcessLength()* - Get the number of iterations needed to complete the process
- *getHandlerName()*
- *getHandlerIdentifier()*
- *getNextRow()* - Must return next row to process or *false* when import process is finished for the handler
- *process()* - Called in a loop mastered by *getNextRow()*. Result of *getNextRow* is passed to this method
- *getProgressionNotes()* - Called inside the loop, after process()
- *cleanup()* Final method called at the end of the handler process

A full working example is provided (**SQLIRSSImportHandler**). Check it to understand the mechanism.

Note that all configuration set in your INI handler block in *sqliimport.ini* will be available in your handler in **$this-&gt;handlerConfArray**.

### [5.1 Simplified content API](#id19)

[](#51simplified-content-api)

A framework is provided to manage eZ Publish content without hassle (please read examples in the API doc) :

```
