pandawan-technology/neo4j-fixtures-bundle

允许将Neo4j数据固定文件加载到您的Symfony应用程序中

dev-master / 1.0.x-dev 2016-05-10 09:05 UTC

This package is auto-updated.

Last update: 2024-09-20 07:33:17 UTC


README

允许将固定文件加载到您的Neo4j图数据库中的Symfony组件

安装

将组件作为需求添加

composer require pandawan-technology/neo4j-fixtures-bundle

在您的app/AppKernel.php文件中启用它

<?php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = [
            // ... my bundles
            new PandawanTechnology\Neo4jFixturesBundle\PandawanTechnologyNeo4jFixturesBundle(),
        ];
        
        return $bundles;
    }
}

使用

基本

默认情况下,组件将在您注册的组件中搜索DataFixtures/Neo4j目录。这些文件必须实现PandawanTechnology\Neo4jDataFixtures\Neo4jFixtureInterface接口,并推荐扩展PandawanTechnology\Neo4jDataFixtures\AbstractNeo4jFixture

<?php
// src/AppBundle/DataFixtures/Neo4j/LoadUserData.php
namespace AppBundle\DataFixtures\Neo4j;

use GraphAware\Common\Connection\ConnectionInterface;
use PandawanTechnology\Neo4jDataFixtures\AbstractNeo4jFixture;

class LoadUserData extends AbstractNeo4jFixture
{
    /**
     * @inheritDoc
     */
    public function load(ConnectionInterface $connection)
    {
        // ... statements here
    }
}

有关更多信息,请参阅Pandawan Technology Neo4j Data Fixtures库文档

高级

如果您需要使用容器中的第三方服务,您可以实现ContainerAwareInterface

<?php
// src/AppBundle/DataFixtures/Neo4j/LoadUserData.php
namespace AppBundle\DataFixtures\Neo4j;

use GraphAware\Common\Connection\ConnectionInterface;
use PandawanTechnology\Neo4jDataFixtures\AbstractNeo4jFixture;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

class LoadUserData extends AbstractNeo4jFixture implements ContainerAwareInterface
{
    private $container;
    
    /**
     * @inheritDoc
     */
    public function setContainer(ContainerInterface $container = null)
    {
        $this->container = $container;
    }
    
    /**
     * @inheritDoc
     */
    public function load(ConnectionInterface $connection)
    {
        // ... statements here
    }
}

有关更多信息,您可以查看Pandawan Technology Neo4j Data Fixtures库的README文件