Plugin architecture for external datasource

Hi guys,

we use an external tool with an own mysql data table to manage and create our job offers.
Now I want to create a plugin to connect to this data.

Our neos website should dynamically list all active job offers and our candidates should be able to apply for this jobs with a neos form. We need a interface to read and write data.

  1. Is there an existing plugin/controller which can read and write from/to an external data source?

  2. Would it be better to create a neos nodetype and feed the neos database from the external tool?
    Maybe this could be much faster, because neos could cache the data?!

I look forward to your expert advice and suggestions!

Flow use Doctrine, so you create your own database connection directly with doctrine. No problem to use external datasource.

I depend a lots of factors. The synchronization process can add a lots of complexity, but then you can configure a more fine grained caching mechanism in Neos … performance can be better (but if your external service is fast enough, it should be ok to call it directly, and cache stuff on the Neos is needed only)

Personally, I will go with the most simple solution (calling the external service via Doctrine) and then iterate over when needed if you have performance issues.

1 Like

I stuck at the momement and need a little help.

I created a flow package and it´ s active.

My settings.yaml has the connection paramaters for the external database.

Neos:
  Flow:
    persistence:
     backendOptions:
      driver: 'pdo_mysql'
      dbname: 'dbname'
      user: 'dbuser'
      password: 'dbpassword'
      host: 'dbhost'

Now I started to add the domain model, repository and and a cli-command controller, cause I want to see some output at the console.

But I can´ t see any connection at the target server, even if I run a database query. Shouldn´` t I see the connection anyway cause it´ is persistant?
How would you implement a little database connection test?

Thanks, and greetings
Andy

Today I found the doctrine example code in \Neos\Packages\Libraries\gedmo\doctrine-extensions\ folder.

The example console connection workes fine.

I was able to do a reverse engineering and generate the orm mapping of the existing database.
(http://symfony.com/doc/current/doctrine/reverse_engineering.html)

But now I get an exception"No identifier/primary key specified for Entity “XXX\Career\Domain\Model\Joboffers” sub class of “XXX\Career\Domain\Model\Joboffers_Original”. Every Entity must have an identifier/primary key."

But there is one specified!?

<?php

namespace XXX\Career\Domain\Model;

use Doctrine\ORM\Mapping as ORM;

/**
 *
 * @ORM\Entity
 * @ORM\Table(name="joboffers", indexes={@ORM\Index(name="fk_JobOffers_JobOffers_TextInterest1_idx", columns={"JobOffers_TextInterest_JobOffers_TextInterest_ID"}), @ORM\Index(name="fk_JobOffers_JobOffers_TextOurOffer1_idx", columns={"JobOffers_TextOurOffer_JobOffers_TextOurOffer_ID"})})
 * 
 */
class Joboffers
{
    /**
     * @var integer $jobofferId
     *
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     * @ORM\Column(name="JobOffer_ID", type="integer", nullable=false)
     */
    private $jobofferId;

    /**
     * @var string $jobofferNumber
     *
     * @ORM\Column(name="JobOffer_Number", type="string", length=100, nullable=true)
     */
    private $jobofferNumber;

    /**
     * @var string $jobofferTitel
     *
     * @ORM\Column(name="JobOffer_Titel", type="string", length=255, nullable=true)
     */
    private $jobofferTitel;

    /**
     * @var Date $jobofferCreationdate
     *
     * @ORM\Column(name="JobOffer_CreationDate", type="date", nullable=true)
     */
    private $jobofferCreationdate;

    /**
     * @var text $jobofferTasks
     *
     * @ORM\Column(name="JobOffer_Tasks", type="text", length=65535, nullable=true)
     */
    private $jobofferTasks;

    /**
     * @var text $jobofferProfil
     *
     * @ORM\Column(name="JobOffer_Profil", type="text", length=65535, nullable=true)
     */
    private $jobofferProfil;

    /**
     * @var string $jobofferStatus
     *
     * @ORM\Column(name="JobOffer_Status", type="string", nullable=true)
     */
    private $jobofferStatus;

    /**
     * @var JoboffersTextinterest
     *
     * @ORM\ManyToOne(targetEntity="JoboffersTextinterest")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="JobOffers_TextInterest_JobOffers_TextInterest_ID", referencedColumnName="JobOffers_TextInterest_ID")
     * })
     */
    private $joboffersTextinterestJoboffersTextinterest;

    /**
     * @var JoboffersTextouroffer
     *
     * @ORM\ManyToOne(targetEntity="JoboffersTextouroffer")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="JobOffers_TextOurOffer_JobOffers_TextOurOffer_ID", referencedColumnName="JobOffers_TextOurOffer_ID")
     * })
     */
    private $joboffersTextourofferJoboffersTextouroffer;


}

The problem is solved.

The variables have to be protected not private.

I had to do add a lot of other things for the data mapping.
The relations (ManyToOne and OneToMany, remove the indices and I added all requiered Getters + Setters).

Now I realized that flow can only have 1 persistent data connection. So I have to implement the doctrine connection by myself. Correct?

Or is it possible to switch the data connection for a plugin with the settings config? I don´t need both at the same time…

All the “magic” (migration, …) is only available to the main Flow DB connection. So if you use an other DB connection, you need to use DQL or SQL to query this db.

Thanks for the answer.

I have integrated my own doctrine EntityManager with its own connection and can do queries now within the flow controller.
My own entity classes have to be excluded from flow in order that flow don` t read the orm annotations.

As result of my queries I get arrays with doctrine objects back to flow.

For example for jobplaces I get:

object(Entity\Jobplaces)#3070 (2) {
  ["jobplacesId":protected]=>
  int(2)
  ["jobplacesName":protected]=>
  string(14) "Raum Stuttgart"
}

Is there an easy way to map those objects to flow?