gmoigneu/laravel-jackrabbit

Laravel 5.x 包,提供Jackrabbit后端功能以及Doctrine-PHPCR-ODM映射

dev-master 2015-11-08 16:10 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:42:21 UTC


README

Laravel 5.x 包,提供Jackrabbit后端功能以及Doctrine-PHPCR-ODM映射。

先决条件

  • Apache Sling 7 或 Apache Jackrabbit 2.3.6+

Jackalope 目前不能与 Jackrabbit Oak 一起使用,因此不在 Apache Sling 8 中

Maven 仓库上下载 Sling Launchpad 7。

更多信息请访问

安装

composer require gmoigneu/laravel-jackrabbit

配置

发布配置文件并使用您的Jackrabbit详细信息编辑它

php artisan vendor:publish

使用方法

JCR会话

// Init session
$session = \App::make('phpcr.session');

// Save a new testNode
$rootNode = $session->getNode("/");
$testNode = $rootNode->addNode("testNode");
$session->save();

// Get the newly created node
$testNode = $session->getNode("/testNode");
dd($testNode);

文档管理器

创建一个新的模型

<?php namespace App\Models;

use Doctrine\ODM\PHPCR\Mapping\Annotations as PHPCR;

/**
 * @PHPCR\Document(referenceable=true)
 */
class Post
{

    /**
     * @PHPCR\Uuid()
     */
    protected $uuid;

    /**
     * @PHPCR\Id()
     */
    protected $slug;

    /**
     * @PHPCR\ParentDocument()
     */
    protected $parent;

    /**
     * @PHPCR\NodeName
     */
    protected $title;

    public function setParent($parent)
    {
        $this->parent = $parent;
        return $this;
    }

    public function setTitle($title)
    {
        $this->title = $title;
        return $this;
    }

    public function getTitle()
    {
        return $this->title;
    }

}

使用以下方式注册您的新的类型

$ php artisan doctrine:phpcr:register-system-node-types                                                                     
Successfully registered system node types.

在任何您想要使用模型的地方使用它

// Get the document manager
$dm = \App::make('phpcr.manager');

// Get the root node
$root = $dm->find(null, '/');

// Create a post
$post = new Post();
$post->setParent($root);
$post->setTitle('Example Post');

$dm->persist($post);
$dm->flush();

$post = $dm->find(null, 'Example Post');
dd($post);

鸣谢

基于 Workers 的工作