├── tests
├── Fixtures
│ ├── App
│ │ ├── var
│ │ │ └── .gitempty
│ │ ├── templates
│ │ │ ├── form.html.twig
│ │ │ └── foo.html
│ │ ├── config
│ │ │ ├── twig.yaml
│ │ │ ├── framework.yaml
│ │ │ ├── routes
│ │ │ │ ├── routes.yaml
│ │ │ │ └── web_profiler.yaml
│ │ │ ├── services.yaml
│ │ │ ├── config.php
│ │ │ ├── routing.php
│ │ │ ├── web_profiler.yaml
│ │ │ ├── bundles.php
│ │ │ └── doctrine.yaml
│ │ ├── bin
│ │ │ └── console
│ │ ├── Kernel.php
│ │ ├── Controller
│ │ │ └── TestController.php
│ │ ├── Document
│ │ │ ├── ReferrerDocument.php
│ │ │ └── TestDocument.php
│ │ └── DataFixtures
│ │ │ └── PHPCR
│ │ │ └── LoadData.php
│ └── fixtures
│ │ └── config
│ │ ├── multiple.yml
│ │ ├── multiple.xml
│ │ ├── multiple.php
│ │ ├── single.yml
│ │ ├── single.php
│ │ └── single.xml
├── phpcr_odm_doctrine_dbal.sh
├── Web
│ └── WebProfilerTest.php
├── Functional
│ ├── Initializer
│ │ └── GenericInitializerTest.php
│ ├── Command
│ │ └── NodeDumpCommandTest.php
│ ├── BaseTestCase.php
│ └── Form
│ │ ├── ChoiceList
│ │ └── PhpcrOdmQueryBuilderLoaderTest.php
│ │ └── Type
│ │ └── DocumentTypeTest.php
└── Unit
│ ├── Form
│ ├── DataTransformer
│ │ ├── PHPCRNodeToUuidTransformerTest.php
│ │ ├── DocumentToPathTransformerTest.php
│ │ └── PHPCRNodeToPathTransformerTest.php
│ └── Type
│ │ ├── PathTypeTest.php
│ │ └── PHPCRReferenceTypeTest.php
│ ├── DependencyInjection
│ └── Compiler
│ │ └── InitializerPassTest.php
│ ├── Initializer
│ ├── GenericInitializerTest.php
│ └── InitializerManagerTest.php
│ └── EventListener
│ └── LocaleListenerTest.php
├── src
├── Resources
│ ├── meta
│ │ ├── approval_LGPL-to-MIT
│ │ │ ├── Stof.eml
│ │ │ ├── ruian.eml
│ │ │ ├── request.eml
│ │ │ ├── bergie.eml
│ │ │ ├── treffynnon.eml
│ │ │ ├── lsmith77.eml
│ │ │ └── uwej711.eml
│ │ └── LICENSE
│ ├── config
│ │ ├── jackalope_doctrine_dbal-commands.xml
│ │ ├── jackrabbit-commands.xml
│ │ ├── jackalope_doctrine_dbal.xml
│ │ ├── odm_multilang.xml
│ │ ├── jackalope.xml
│ │ ├── phpcr.xml
│ │ ├── commands.xml
│ │ └── odm.xml
│ └── views
│ │ └── Collector
│ │ └── icon.svg
├── Initializer
│ ├── SessionAwareInitializerInterface.php
│ ├── InitializerInterface.php
│ ├── GenericInitializer.php
│ └── InitializerManager.php
├── Migrator
│ ├── MigratorInterface.php
│ └── AbstractMigrator.php
├── Mapping
│ └── Driver
│ │ ├── XmlDriver.php
│ │ └── YamlDriver.php
├── DependencyInjection
│ └── Compiler
│ │ ├── MigratorPass.php
│ │ └── InitializerPass.php
├── Validator
│ └── Constraints
│ │ ├── ValidPhpcrOdm.php
│ │ └── ValidPhpcrOdmValidator.php
├── DataCollector
│ └── StopWatchLogger.php
├── EventListener
│ ├── JackalopeDoctrineDbalSchemaListener.php
│ └── LocaleListener.php
├── ManagerRegistryInterface.php
├── Form
│ ├── DoctrinePHPCRExtension.php
│ ├── Type
│ │ ├── PathType.php
│ │ ├── DocumentType.php
│ │ └── PHPCRReferenceType.php
│ ├── DataTransformer
│ │ ├── DocumentToPathTransformer.php
│ │ ├── PHPCRNodeToPathTransformer.php
│ │ └── PHPCRNodeToUuidTransformer.php
│ └── ChoiceList
│ │ └── PhpcrOdmQueryBuilderLoader.php
├── Command
│ ├── WorkspaceListCommand.php
│ ├── NodeMoveCommand.php
│ ├── NodeTouchCommand.php
│ ├── WorkspaceCreateCommand.php
│ ├── NodeRemoveCommand.php
│ ├── NodesUpdateCommand.php
│ ├── NodeTypeListCommand.php
│ ├── WorkspaceExportCommand.php
│ ├── WorkspaceImportCommand.php
│ ├── WorkspacePurgeCommand.php
│ ├── WorkspaceQueryCommand.php
│ ├── WorkspaceDeleteCommand.php
│ ├── NodeDumpCommand.php
│ ├── RepositoryInitCommand.php
│ ├── NodeTypeRegisterCommand.php
│ ├── DoctrineCommandHelper.php
│ ├── MigratorMigrateCommand.php
│ └── PhpcrShellCommand.php
├── OptionalCommand
│ ├── ODM
│ │ ├── DocumentMigrateClassCommand.php
│ │ ├── InfoDoctrineCommand.php
│ │ ├── DocumentConvertTranslationCommand.php
│ │ └── VerifyUniqueNodeTypesMappingCommand.php
│ └── Jackalope
│ │ ├── JackrabbitCommand.php
│ │ └── InitDoctrineDbalCommand.php
├── CacheWarmer
│ └── UniqueNodeTypeCacheWarmer.php
├── DataFixtures
│ └── PHPCRExecutor.php
├── ManagerRegistry.php
└── Test
│ └── RepositoryManager.php
├── .gitignore
├── doc
├── index.rst
└── events.rst
├── .styleci.yml
├── .doctrine-project.json
├── .php-cs-fixer.dist.php
├── phpstan.neon.dist
├── UPGRADE-2.4.md
├── phpunit.xml.dist
├── LICENSE
├── .github
└── workflows
│ ├── static.yml
│ └── test-application.yaml
├── README.md
└── composer.json
/tests/Fixtures/App/var/.gitempty:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/templates/form.html.twig:
--------------------------------------------------------------------------------
1 | {{ form(form) }}
2 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/twig.yaml:
--------------------------------------------------------------------------------
1 | twig:
2 | default_path: '%kernel.project_dir%/templates'
3 |
--------------------------------------------------------------------------------
/src/Resources/meta/approval_LGPL-to-MIT/Stof.eml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doctrine/DoctrinePHPCRBundle/HEAD/src/Resources/meta/approval_LGPL-to-MIT/Stof.eml
--------------------------------------------------------------------------------
/src/Resources/meta/approval_LGPL-to-MIT/ruian.eml:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/doctrine/DoctrinePHPCRBundle/HEAD/src/Resources/meta/approval_LGPL-to-MIT/ruian.eml
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | composer.lock
2 | phpunit.xml
3 | !tests/Fixtures/App/var/.gitempty
4 | tests/Fixtures/App/var
5 | vendor
6 | .phpunit.result.cache
7 | .php-cs-fixer.cache
8 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/framework.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | secret: test
3 | property_access: ~
4 | test: ~
5 | form: ~
6 | router:
7 | resource: '%kernel.project_dir%/config/routing.php'
8 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/routes/routes.yaml:
--------------------------------------------------------------------------------
1 | phpcr_request:
2 | path: /phpcr_request
3 | defaults:
4 | _controller: Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Controller\TestController::phpcrRequest
5 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/services.yaml:
--------------------------------------------------------------------------------
1 | services:
2 | _defaults:
3 | public: false
4 | autowire: true
5 | autoconfigure: true
6 |
7 | Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Controller\TestController: ~
8 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/templates/foo.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Foo
6 |
7 |
8 | Foo
9 |
10 |
11 |
--------------------------------------------------------------------------------
/doc/index.rst:
--------------------------------------------------------------------------------
1 | DoctrinePHPCRBundle
2 | ===================
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | introduction
8 | models
9 | events
10 | forms
11 | fixtures_initializers
12 | multilang
13 | multiple_sessions
14 | configuration
15 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/config.php:
--------------------------------------------------------------------------------
1 | import(__DIR__.'/framework.yaml');
4 | $loader->import(__DIR__.'/doctrine.yaml');
5 | $loader->import(__DIR__.'/twig.yaml');
6 | $loader->import(__DIR__.'/services.yaml');
7 |
8 | $loader->import(__DIR__.'/web_profiler.yaml');
9 |
--------------------------------------------------------------------------------
/tests/phpcr_odm_doctrine_dbal.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | set -e
4 |
5 | DIR_NAME=`dirname $0`
6 | CONSOLE_DIR=$DIR_NAME"/../tests/Fixtures/App/bin"
7 |
8 | $CONSOLE_DIR"/console" doctrine:phpcr:init:dbal --drop --force
9 | $CONSOLE_DIR"/console" doctrine:phpcr:repository:init
10 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/routes/web_profiler.yaml:
--------------------------------------------------------------------------------
1 | web_profiler_wdt:
2 | resource: '@WebProfilerBundle/Resources/config/routing/wdt.xml'
3 | prefix: /_wdt
4 |
5 | web_profiler_profiler:
6 | resource: '@WebProfilerBundle/Resources/config/routing/profiler.xml'
7 | prefix: /_profiler
8 |
--------------------------------------------------------------------------------
/.styleci.yml:
--------------------------------------------------------------------------------
1 | preset: symfony
2 |
3 | risky: true
4 |
5 | enabled:
6 | - combine_consecutive_unsets
7 | - no_php4_constructor
8 | - no_useless_else
9 | - ordered_use
10 | - strict
11 | - php_unit_construct
12 |
13 | disabled:
14 | - single_line_class_definition
15 | - single_line_throw
16 |
--------------------------------------------------------------------------------
/.doctrine-project.json:
--------------------------------------------------------------------------------
1 | {
2 | "active": true,
3 | "name": "Doctrine PHPCR Bundle",
4 | "slug": "phpcr-bundle",
5 | "docsSlug": "doctrine-phpcr-bundle",
6 | "versions": [
7 | {
8 | "name": "3.x",
9 | "branchName": "3.x",
10 | "slug": "latest",
11 | "current": true
12 | }
13 | ]
14 | }
15 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/routing.php:
--------------------------------------------------------------------------------
1 | addCollection(
8 | $loader->import(__DIR__.'/routes/web_profiler.yaml')
9 | );
10 |
11 | $collection->addCollection(
12 | $loader->import(__DIR__.'/routes/routes.yaml')
13 | );
14 |
15 | return $collection;
16 |
--------------------------------------------------------------------------------
/src/Initializer/SessionAwareInitializerInterface.php:
--------------------------------------------------------------------------------
1 |
9 | */
10 | interface SessionAwareInitializerInterface
11 | {
12 | public function setSessionName(string $sessionName): void;
13 | }
14 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/web_profiler.yaml:
--------------------------------------------------------------------------------
1 | framework:
2 | profiler:
3 | enabled: true
4 | collect: false # Prevents slowing down the tests. The profiler needs
5 | # to be enabled selectively for each functional test.
6 | only_exceptions: false
7 |
8 | web_profiler:
9 | toolbar: true
10 |
11 | doctrine_phpcr:
12 | session:
13 | backend:
14 | profiling: true
15 |
--------------------------------------------------------------------------------
/.php-cs-fixer.dist.php:
--------------------------------------------------------------------------------
1 | in(__DIR__.'/src')
5 | ->in(__DIR__.'/tests')
6 | ->exclude(__DIR__.'/tests/Fixtures/App/var')
7 | ->name('*.php')
8 | ;
9 |
10 | $config = new PhpCsFixer\Config();
11 |
12 | return $config
13 | ->setRiskyAllowed(true)
14 | ->setRules([
15 | '@Symfony' => true,
16 | 'single_line_throw' => false,
17 | ])
18 | ->setFinder($finder)
19 | ;
20 |
--------------------------------------------------------------------------------
/src/Migrator/MigratorInterface.php:
--------------------------------------------------------------------------------
1 | ['all' => true],
5 | Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle::class => ['all' => true],
6 | Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
7 | Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true],
8 | Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
9 | Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['all' => true],
10 | ];
11 |
--------------------------------------------------------------------------------
/src/Migrator/AbstractMigrator.php:
--------------------------------------------------------------------------------
1 | session = $session;
17 | $this->output = $output;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Resources/config/jackalope_doctrine_dbal-commands.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/src/Resources/config/jackrabbit-commands.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 | %doctrine_phpcr.jackrabbit_jar%
10 | %doctrine_phpcr.workspace_dir%
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/Initializer/InitializerInterface.php:
--------------------------------------------------------------------------------
1 |
12 | */
13 | interface InitializerInterface
14 | {
15 | /**
16 | * This method should be used to establish the requisite structure needed
17 | * by the application or bundle of the content repository.
18 | */
19 | public function init(ManagerRegistryInterface $registry): void;
20 |
21 | /**
22 | * Return a name which can be used to identify this initializer.
23 | */
24 | public function getName(): string;
25 | }
26 |
--------------------------------------------------------------------------------
/src/Mapping/Driver/XmlDriver.php:
--------------------------------------------------------------------------------
1 |
12 | * @author Benjamin Eberlei
13 | */
14 | class XmlDriver extends BaseXmlDriver
15 | {
16 | public const DEFAULT_FILE_EXTENSION = '.phpcr.xml';
17 |
18 | public function __construct(array $prefixes, string $fileExtension = self::DEFAULT_FILE_EXTENSION)
19 | {
20 | $locator = new SymfonyFileLocator($prefixes, $fileExtension);
21 | parent::__construct($locator, $fileExtension);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/Mapping/Driver/YamlDriver.php:
--------------------------------------------------------------------------------
1 |
12 | * @author Benjamin Eberlei
13 | */
14 | class YamlDriver extends BaseYamlDriver
15 | {
16 | public const DEFAULT_FILE_EXTENSION = '.phpcr.yml';
17 |
18 | public function __construct(array $prefixes, string $fileExtension = self::DEFAULT_FILE_EXTENSION)
19 | {
20 | $locator = new SymfonyFileLocator($prefixes, $fileExtension);
21 | parent::__construct($locator, $fileExtension);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/DependencyInjection/Compiler/MigratorPass.php:
--------------------------------------------------------------------------------
1 | findTaggedServiceIds('doctrine_phpcr.migrator') as $id => $attributes) {
17 | $alias = $attributes[0]['alias'] ?? null;
18 | $migrators[$alias] = $id;
19 | }
20 |
21 | $container->setParameter('doctrine_phpcr.migrate.migrators', $migrators);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/bin/console:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env php
2 | getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'dev');
13 | $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(array('--no-debug', '')) && $env !== 'prod';
14 |
15 | if ($debug) {
16 | Debug::enable();
17 | }
18 |
19 | // must be placed after setting $env, because it's used in bootstrapping the
20 | // kernel
21 | $kernel = new Kernel($env, $debug);
22 | $application = new Application($kernel);
23 | $application->run($input);
24 |
--------------------------------------------------------------------------------
/src/Validator/Constraints/ValidPhpcrOdm.php:
--------------------------------------------------------------------------------
1 |
11 | */
12 | #[\Attribute(\Attribute::TARGET_CLASS)]
13 | class ValidPhpcrOdm extends Constraint
14 | {
15 | public string $message = 'This value should not be blank.';
16 |
17 | public string $service = 'doctrine_phpcr.odm.validator.valid_phpcr_odm';
18 |
19 | /**
20 | * The validator must be defined as a service with this name.
21 | */
22 | public function validatedBy(): string
23 | {
24 | return $this->service;
25 | }
26 |
27 | public function getTargets(): string
28 | {
29 | return self::CLASS_CONSTRAINT;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/UPGRADE-2.4.md:
--------------------------------------------------------------------------------
1 | UPGRADE FROM 2.x to 2.3
2 | =======================
3 |
4 | * [BC Break] In order to have compatibility with Symfony 6, return types have been added to the following methods:
5 | * `Doctrine\Bundle\PHPCRBundle\DependencyInjection\DoctrinePHPCRExtension::getMappingObjectDefaultName()`
6 | * `Doctrine\Bundle\PHPCRBundle\DependencyInjection\DoctrinePHPCRExtension::getMappingResourceConfigDirectory()`
7 | * `Doctrine\Bundle\PHPCRBundle\DependencyInjection\DoctrinePHPCRExtension::getMappingResourceExtension()`
8 | * `Doctrine\Bundle\PHPCRBundle\DependencyInjection\DoctrinePHPCRExtension::getObjectManagerElementName()`
9 | * `Doctrine\Bundle\PHPCRBundle\Form\ChoiceList\PhpcrOdmQueryBuilderLoader::getEntities`
10 | * `Doctrine\Bundle\PHPCRBundle\Form\ChoiceList\PhpcrOdmQueryBuilderLoader::getEntitiesByIds`
11 | * `Doctrine\Bundle\PHPCRBundle\Form\Type\DocumentType::getLoader`
12 |
--------------------------------------------------------------------------------
/phpunit.xml.dist:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 | ./tests
12 |
13 |
14 |
15 |
16 | src/
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/config/doctrine.yaml:
--------------------------------------------------------------------------------
1 | doctrine:
2 | dbal:
3 | driver: pdo_sqlite
4 | path: "%kernel.project_dir%/var/cache/app.sqlite"
5 | charset: UTF8
6 |
7 | doctrine_phpcr:
8 | session:
9 | backend:
10 | type: doctrinedbal
11 | parameters:
12 | jackalope.check_login_on_server: false
13 | workspace: default
14 | username: admin
15 | password: admin
16 |
17 | odm:
18 | auto_mapping: true,
19 | auto_generate_proxy_classes: "%kernel.debug%"
20 | locales:
21 | en: [de, fr]
22 | de: [en, fr]
23 | fr: [en, de]
24 | mappings:
25 | test_additional:
26 | type: attribute
27 | prefix: Doctrine\Bundle\PHPCRBundle\Tests\Fixtures\App\Document
28 | dir: "%kernel.project_dir%/Document"
29 | is_bundle: false
30 |
--------------------------------------------------------------------------------
/src/DataCollector/StopWatchLogger.php:
--------------------------------------------------------------------------------
1 |
10 | * @author Lukas Kahwe Smith
11 | */
12 | final class StopWatchLogger implements LoggerInterface
13 | {
14 | public function __construct(private ?Stopwatch $stopwatch = null)
15 | {
16 | }
17 |
18 | public function startCall($method, ?array $params = null, ?array $env = null): void
19 | {
20 | if (null !== $this->stopwatch) {
21 | $this->stopwatch->start('doctrine_phpcr', 'doctrine_phpcr');
22 | }
23 | }
24 |
25 | public function stopCall(): void
26 | {
27 | if (null !== $this->stopwatch) {
28 | $this->stopwatch->stop('doctrine_phpcr');
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/EventListener/JackalopeDoctrineDbalSchemaListener.php:
--------------------------------------------------------------------------------
1 |
16 | * @author Johannes M. Schmitt
17 | */
18 | class JackalopeDoctrineDbalSchemaListener
19 | {
20 | public function __construct(
21 | private RepositorySchema $schema,
22 | ) {
23 | }
24 |
25 | public function postGenerateSchema(GenerateSchemaEventArgs $args): void
26 | {
27 | $schema = $args->getSchema();
28 | $this->schema->addToSchema($schema);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/ManagerRegistryInterface.php:
--------------------------------------------------------------------------------
1 | .
18 |
--------------------------------------------------------------------------------
/src/Form/DoctrinePHPCRExtension.php:
--------------------------------------------------------------------------------
1 |
7 | *
8 | * For the full copyright and license information, please view the LICENSE
9 | * file that was distributed with this source code.
10 | */
11 |
12 | namespace Doctrine\Bundle\PHPCRBundle\Form;
13 |
14 | use Doctrine\Bundle\PHPCRBundle\ManagerRegistryInterface;
15 | use Symfony\Component\Form\AbstractExtension;
16 |
17 | class DoctrinePHPCRExtension extends AbstractExtension
18 | {
19 | private ManagerRegistryInterface $registry;
20 |
21 | public function __construct(ManagerRegistryInterface $registry)
22 | {
23 | $this->registry = $registry;
24 | }
25 |
26 | protected function loadTypes(): array
27 | {
28 | return [
29 | new Type\DocumentType($this->registry),
30 | ];
31 | }
32 |
33 | protected function loadTypeGuesser(): PhpcrOdmTypeGuesser
34 | {
35 | return new PhpcrOdmTypeGuesser($this->registry);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Resources/config/jackalope_doctrine_dbal.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) Doctrine Project
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining a copy of
4 | this software and associated documentation files (the "Software"), to deal in
5 | the Software without restriction, including without limitation the rights to
6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 | of the Software, and to permit persons to whom the Software is furnished to do
8 | so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all
11 | copies or substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 | SOFTWARE.
20 |
--------------------------------------------------------------------------------
/tests/Fixtures/fixtures/config/multiple.yml:
--------------------------------------------------------------------------------
1 | doctrine_phpcr:
2 | session:
3 | sessions:
4 | default:
5 | backend:
6 | type: jackrabbit
7 | url: http://a
8 | workspace: default
9 | username: admin
10 | password: admin
11 |
12 | website:
13 | backend:
14 | type: jackrabbit
15 | url: http://b
16 | workspace: website
17 | username: root
18 | password: root
19 | admin_username: admin
20 | admin_password: admin
21 | odm:
22 | auto_generate_proxy_classes: true
23 | document_managers:
24 | default:
25 | session: default
26 | mappings:
27 | SandboxMainBundle: ~
28 |
29 | website:
30 | session: website
31 | configuration_id: sandbox_magnolia.odm_configuration
32 | mappings:
33 | SandboxMagnoliaBundle: ~
34 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/Kernel.php:
--------------------------------------------------------------------------------
1 | environment;
13 | }
14 |
15 | public function getLogDir(): string
16 | {
17 | return __DIR__.'/var/log';
18 | }
19 |
20 | public function getProjectDir(): string
21 | {
22 | return __DIR__;
23 | }
24 |
25 | public function registerBundles(): iterable
26 | {
27 | $contents = require __DIR__.'/config/bundles.php';
28 | foreach ($contents as $class => $envs) {
29 | if (isset($envs['all']) || isset($envs[$this->environment])) {
30 | yield new $class();
31 | }
32 | }
33 | }
34 |
35 | public function registerContainerConfiguration(LoaderInterface $loader): void
36 | {
37 | $loader->load(__DIR__.'/config/config.php');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/tests/Web/WebProfilerTest.php:
--------------------------------------------------------------------------------
1 | enableProfiler();
19 |
20 | $client->request('GET', '/phpcr_request');
21 | $this->assertResponseSuccess($client->getResponse());
22 |
23 | $token = $client->getProfile()->getToken();
24 | $uri = str_replace('{token}', $token, $uri);
25 |
26 | $client->request('GET', $uri);
27 | $this->assertResponseSuccess($client->getResponse());
28 | }
29 |
30 | public function provideWebProfilerUris(): array
31 | {
32 | return [
33 | 'the default panel' => ['/_profiler/{token}'],
34 | 'the PHPCR panel' => ['/_profiler/{token}?panel=phpcr'],
35 | ];
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Resources/config/odm_multilang.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
8 |
9 |
11 | %doctrine_phpcr.odm.locales%
12 | %doctrine_phpcr.odm.default_locale%
13 |
14 |
15 |
17 |
18 |
19 | %doctrine_phpcr.odm.allowed_locales%
20 | %doctrine_phpcr.odm.locale_fallback%
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/src/Command/WorkspaceListCommand.php:
--------------------------------------------------------------------------------
1 | setName('doctrine:phpcr:workspace:list')
21 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
22 | ;
23 | }
24 |
25 | protected function execute(InputInterface $input, OutputInterface $output): int
26 | {
27 | DoctrineCommandHelper::setApplicationPHPCRSession(
28 | $this->getApplication(),
29 | $input->getOption('session'),
30 | true
31 | );
32 |
33 | return parent::execute($input, $output);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Command/NodeMoveCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class NodeMoveCommand extends BaseNodeMoveCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:node:move')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Command/NodeTouchCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class NodeTouchCommand extends BaseNodeTouchCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:node:touch')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Command/WorkspaceCreateCommand.php:
--------------------------------------------------------------------------------
1 | setName('doctrine:phpcr:workspace:create')
21 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
22 | ;
23 | }
24 |
25 | protected function execute(InputInterface $input, OutputInterface $output): int
26 | {
27 | DoctrineCommandHelper::setApplicationPHPCRSession(
28 | $this->getApplication(),
29 | $input->getOption('session'),
30 | true
31 | );
32 |
33 | return parent::execute($input, $output);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/Command/NodeRemoveCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class NodeRemoveCommand extends BaseNodeRemoveCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:node:remove')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Command/NodesUpdateCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class NodesUpdateCommand extends BaseNodesUpdateCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:nodes:update')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/Controller/TestController.php:
--------------------------------------------------------------------------------
1 | registry = $registry;
17 | }
18 |
19 | /**
20 | * Do a simple PHPCR request.
21 | */
22 | public function phpcrRequest(): Response
23 | {
24 | $dm = $this->registry->getManager();
25 |
26 | $document = $dm->find(null, '/foo');
27 |
28 | if (null !== $document) {
29 | $dm->remove($document);
30 | $dm->flush();
31 | }
32 |
33 | $document = new ReferrerDocument();
34 | $document->id = '/foo';
35 |
36 | $dm->persist($document);
37 | $dm->flush();
38 |
39 | return $this->render('foo.html');
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/Command/NodeTypeListCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class NodeTypeListCommand extends BaseTypeListCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:node-type:list')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session'),
32 | true
33 | );
34 |
35 | return parent::execute($input, $output);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Command/WorkspaceExportCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class WorkspaceExportCommand extends BaseWorkspaceExportCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:workspace:export')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Command/WorkspaceImportCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class WorkspaceImportCommand extends BaseWorkspaceImportCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:workspace:import')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Command/WorkspacePurgeCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class WorkspacePurgeCommand extends BaseWorkspacePurgeCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:workspace:purge')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/Command/WorkspaceQueryCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class WorkspaceQueryCommand extends BaseWorkspaceQueryCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:workspace:query')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session')
32 | );
33 |
34 | return parent::execute($input, $output);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/OptionalCommand/ODM/DocumentMigrateClassCommand.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | class DocumentMigrateClassCommand extends BaseDocumentMigrateClassCommand
15 | {
16 | protected function configure(): void
17 | {
18 | parent::configure();
19 |
20 | $this->addOption('dm', null, InputOption::VALUE_REQUIRED, 'The document manager to use for this command');
21 | }
22 |
23 | protected function execute(InputInterface $input, OutputInterface $output): int
24 | {
25 | $dmName = $input->getOption('dm'); // defaults to null
26 | DoctrineCommandHelper::setApplicationDocumentManager(
27 | $this->getApplication(),
28 | $dmName
29 | );
30 |
31 | return parent::execute($input, $output);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/Command/WorkspaceDeleteCommand.php:
--------------------------------------------------------------------------------
1 |
14 | */
15 | class WorkspaceDeleteCommand extends BaseWorkspaceDeleteCommand
16 | {
17 | protected function configure(): void
18 | {
19 | parent::configure();
20 |
21 | $this
22 | ->setName('doctrine:phpcr:workspace:delete')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | DoctrineCommandHelper::setApplicationPHPCRSession(
30 | $this->getApplication(),
31 | $input->getOption('session'),
32 | true
33 | );
34 |
35 | return parent::execute($input, $output);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Resources/views/Collector/icon.svg:
--------------------------------------------------------------------------------
1 |
4 |
--------------------------------------------------------------------------------
/.github/workflows/static.yml:
--------------------------------------------------------------------------------
1 | name: Static analysis
2 |
3 | on:
4 | push:
5 | branches:
6 | - '[0-9]+.x'
7 | - '[0-9]+.[0-9]+'
8 | - '[0-9]+.[0-9]+.x'
9 | pull_request:
10 |
11 | jobs:
12 | phpstan:
13 | name: PHPStan
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - name: Setup PHP
18 | uses: shivammathur/setup-php@v2
19 | with:
20 | php-version: '8.3'
21 | extensions: "curl,dom,json,xml,dom"
22 | coverage: none
23 |
24 | - name: Checkout code
25 | uses: actions/checkout@v3
26 |
27 | # have to install phpstan ourselves here, the phpstan-ga fails at composer install with weird errors
28 | - name: Install phpstan
29 | run: |
30 | composer require --no-update jackalope/jackalope-doctrine-dbal jackalope/jackalope-jackrabbit phpstan/phpstan
31 | composer update
32 |
33 | - name: PHPStan
34 | run: vendor/bin/phpstan analyze --no-progress
35 |
36 | php-cs-fixer:
37 | name: PHP-CS-Fixer
38 | runs-on: ubuntu-latest
39 |
40 | steps:
41 | - name: Checkout code
42 | uses: actions/checkout@v3
43 |
44 | - name: PHP-CS-Fixer
45 | uses: docker://oskarstark/php-cs-fixer-ga
46 | with:
47 | args: --dry-run --diff
48 |
--------------------------------------------------------------------------------
/src/DependencyInjection/Compiler/InitializerPass.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | final class InitializerPass implements CompilerPassInterface
15 | {
16 | public function process(ContainerBuilder $container): void
17 | {
18 | if (!$container->hasDefinition('doctrine_phpcr.initializer_manager')) {
19 | return;
20 | }
21 |
22 | $initializerManagerDef = $container->getDefinition('doctrine_phpcr.initializer_manager');
23 | $services = $container->findTaggedServiceIds('doctrine_phpcr.initializer');
24 |
25 | foreach ($services as $id => $attributes) {
26 | $priority = 0;
27 |
28 | if (isset($attributes[0]['priority'])) {
29 | $priority = $attributes[0]['priority'];
30 | }
31 |
32 | $initializerManagerDef->addMethodCall('addInitializer', [
33 | new Reference($id), $priority,
34 | ]);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/CacheWarmer/UniqueNodeTypeCacheWarmer.php:
--------------------------------------------------------------------------------
1 | registry = $registry;
21 | }
22 |
23 | /**
24 | * This cache warmer is optional as it is just for error
25 | * checking and reporting back to the user.
26 | */
27 | public function isOptional(): bool
28 | {
29 | return true;
30 | }
31 |
32 | public function warmUp(string $cacheDir, ?string $buildDir = null): array
33 | {
34 | $helper = new UniqueNodeTypeHelper();
35 |
36 | foreach ($this->registry->getManagers() as $documentManager) {
37 | $helper->checkNodeTypeMappings($documentManager);
38 | }
39 |
40 | return [];
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/tests/Functional/Initializer/GenericInitializerTest.php:
--------------------------------------------------------------------------------
1 | getContainer()->get('doctrine_phpcr');
21 | \assert($managerRegistry instanceof ManagerRegistryInterface);
22 | $dm = $managerRegistry->getManager();
23 |
24 | // The first run should create a node.
25 | $this->assertNull($dm->find(null, '/test/path'));
26 |
27 | $initializer->init($managerRegistry);
28 | $node = $dm->find(null, '/test/path');
29 | $this->assertNotNull($node);
30 |
31 | // The second run should not modify the existing node.
32 | $initializer->init($managerRegistry);
33 | $this->assertSame($node, $dm->find(null, '/test/path'));
34 |
35 | $managerRegistry->getConnection()->save();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/Form/Type/PathType.php:
--------------------------------------------------------------------------------
1 | registry = $registry;
19 | }
20 |
21 | public function getParent(): string
22 | {
23 | return method_exists(AbstractType::class, 'getBlockPrefix') ? TextType::class : 'text';
24 | }
25 |
26 | public function getBlockPrefix(): string
27 | {
28 | return 'phpcr_odm_path';
29 | }
30 |
31 | public function buildForm(FormBuilderInterface $builder, array $options): void
32 | {
33 | $dm = $this->registry->getManager($options['manager_name']);
34 | $transformer = new DocumentToPathTransformer($dm);
35 | $builder->addModelTransformer($transformer);
36 | }
37 |
38 | public function configureOptions(OptionsResolver $resolver): void
39 | {
40 | $resolver->setDefaults([
41 | 'manager_name' => null,
42 | ]);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DoctrinePHPCRBundle
2 |
3 | [](https://github.com/doctrine/DoctrinePHPCRBundle/actions)
4 | [](https://packagist.org/packages/doctrine/phpcr-bundle)
5 | [](https://packagist.org/packages/doctrine/phpcr-bundle)
6 |
7 | PHPCR & Doctrine PHPCR-ODM Bundle for the Symfony Framework.
8 |
9 | This bundle integrates PHP Content Repository implementations and the Doctrine PHPCR-ODM into Symfony.
10 |
11 | ## What is Doctrine PHPCR-ODM?
12 |
13 | The Doctrine Project is the home of a selected set of PHP libraries primarily focused on providing persistence
14 | services and related functionality. The PHPCR-ODM project provides an Object - Document Mapper built on top of
15 | the content repository standard PHPCR.
16 |
17 | It leverages the various features of PHPCR like references, children and parent relations and versioning and
18 | adds features of its own like multilanguage.
19 |
20 | ## Documentation
21 |
22 | For information on PHPCR-ODM, see [Doctrine Documentation](https://www.doctrine-project.org/projects/phpcr-odm.html),
23 | and [DoctrinePHPCRBundle](https://www.doctrine-project.org/projects/doctrine-phpcr-bundle.html).
24 |
25 | Read more about PHPCR, the storage layer behind PHPCR-ODM: [PHPCR documentation](https://phpcr.readthedocs.io/en/latest/).
26 |
--------------------------------------------------------------------------------
/src/OptionalCommand/ODM/InfoDoctrineCommand.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | class InfoDoctrineCommand extends BaseInfoDoctrineCommand
17 | {
18 | protected function configure(): void
19 | {
20 | parent::configure();
21 |
22 | $this
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The document manager to use for this command.', null)
24 | ->setHelp($this->getHelp().<<<'EOT'
25 |
26 | If you are using multiple document managers you can pick your choice with the
27 | --session option:
28 |
29 | php app/console doctrine:phpcr:mapping:info --session=default
30 | EOT
31 | );
32 | }
33 |
34 | protected function execute(InputInterface $input, OutputInterface $output): int
35 | {
36 | DoctrineCommandHelper::setApplicationDocumentManager(
37 | $this->getApplication(),
38 | $input->getOption('session')
39 | );
40 |
41 | return parent::execute($input, $output);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tests/Fixtures/fixtures/config/multiple.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
10 |
11 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
28 |
29 |
30 |
31 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/src/Form/DataTransformer/DocumentToPathTransformer.php:
--------------------------------------------------------------------------------
1 | dm = $dm;
16 | }
17 |
18 | /**
19 | * Transform a document into a path.
20 | *
21 | * @param object $document
22 | */
23 | public function transform(mixed $document): ?string
24 | {
25 | if (null === $document) {
26 | return null;
27 | }
28 |
29 | return $this->dm->getUnitOfWork()->getDocumentId($document);
30 | }
31 |
32 | /**
33 | * Transform a path to its corresponding PHPCR-ODM document.
34 | *
35 | * @param string $path phpcr path
36 | *
37 | * @return object|null returns the document or null if $path is empty
38 | */
39 | public function reverseTransform(mixed $path): ?object
40 | {
41 | if (!$path) {
42 | return null;
43 | }
44 |
45 | $document = $this->dm->find(null, $path);
46 |
47 | if (!$document) {
48 | throw new TransformationFailedException(sprintf('Could not transform path "%s" to document. Path not found.', $path));
49 | }
50 |
51 | return $document;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/DataFixtures/PHPCRExecutor.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | final class PHPCRExecutor extends AbstractExecutor
17 | {
18 | private BasePHPCRExecutor $wrappedExecutor;
19 |
20 | public function __construct(
21 | DocumentManagerInterface $dm,
22 | ?PHPCRPurger $purger = null,
23 | private ?InitializerManager $initializerManager = null,
24 | ) {
25 | parent::__construct($dm);
26 | $this->wrappedExecutor = new BasePHPCRExecutor($dm, $purger);
27 | }
28 |
29 | public function purge(): void
30 | {
31 | parent::purge();
32 |
33 | if ($this->initializerManager) {
34 | $this->initializerManager->setLoggingClosure($this->logger);
35 | $this->initializerManager->initialize();
36 | }
37 | }
38 |
39 | public function execute(array $fixtures, bool $append = false): void
40 | {
41 | $this->wrappedExecutor->execute($fixtures, $append);
42 | }
43 |
44 | public function getObjectManager(): DocumentManagerInterface
45 | {
46 | return $this->wrappedExecutor->getObjectManager();
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/tests/Fixtures/fixtures/config/multiple.php:
--------------------------------------------------------------------------------
1 | loadFromExtension('doctrine_phpcr', [
4 | 'session' => [
5 | 'sessions' => [
6 | 'default' => [
7 | 'backend' => [
8 | 'type' => 'jackrabbit',
9 | 'url' => 'http://a',
10 | ],
11 | 'workspace' => 'default',
12 | 'username' => 'admin',
13 | 'password' => 'admin',
14 | ],
15 | 'website' => [
16 | 'backend' => [
17 | 'type' => 'jackrabbit',
18 | 'url' => 'http://b',
19 | 'factory' => null,
20 | ],
21 | 'workspace' => 'website',
22 | 'username' => 'root',
23 | 'password' => 'root',
24 | 'admin_username' => 'admin',
25 | 'admin_password' => 'admin',
26 | ],
27 | ],
28 | ],
29 | 'odm' => [
30 | 'auto_generate_proxy_classes' => true,
31 | 'document_managers' => [
32 | 'default' => [
33 | 'session' => 'default',
34 | 'mappings' => [
35 | 'SandboxMainBundle' => null,
36 | ],
37 | ],
38 | 'website' => [
39 | 'session' => 'website',
40 | 'configuration_id' => 'sandbox_magnolia.odm_configuration',
41 | 'mappings' => [
42 | 'SandboxMagnoliaBundle' => null,
43 | ],
44 | ],
45 | ],
46 | ],
47 | ]);
48 |
--------------------------------------------------------------------------------
/src/OptionalCommand/ODM/DocumentConvertTranslationCommand.php:
--------------------------------------------------------------------------------
1 |
15 | */
16 | class DocumentConvertTranslationCommand extends BaseDocumentConvertTranslationCommand
17 | {
18 | protected function configure(): void
19 | {
20 | parent::configure();
21 |
22 | $this
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The document manager to use for this command.', null)
24 | ->setHelp($this->getHelp().<<<'EOT'
25 |
26 | If you are using multiple document managers you can pick your choice with the
27 | --session option:
28 |
29 | php app/console doctrine:phpcr:document:convert-translation --session=default
30 | EOT
31 | );
32 | }
33 |
34 | protected function execute(InputInterface $input, OutputInterface $output): int
35 | {
36 | DoctrineCommandHelper::setApplicationDocumentManager(
37 | $this->getApplication(),
38 | $input->getOption('session')
39 | );
40 |
41 | return parent::execute($input, $output);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tests/Fixtures/fixtures/config/single.yml:
--------------------------------------------------------------------------------
1 | doctrine_phpcr:
2 | session:
3 | backend:
4 | type: jackrabbit
5 | url: http://localhost:8080/server/
6 | logging: true
7 | profiling: true
8 |
9 | parameters:
10 | jackalope.factory: Jackalope\Factory
11 | jackalope.check_login_on_server: false
12 | jackalope.disable_stream_wrapper: false
13 | jackalope.auto_lastmodified: true
14 | jackalope.default_header: 'X-ID: %serverid%'
15 | jackalope.jackrabbit_expect: true
16 | workspace: default
17 | username: admin
18 | password: admin
19 | options:
20 | jackalope.fetch_depth: 1
21 | odm:
22 | configuration_id: ~
23 | auto_mapping: true
24 | mappings:
25 | test:
26 | mapping: true
27 | type: ~
28 | dir: ~
29 | prefix: ~
30 | is_bundle: ~
31 | auto_generate_proxy_classes: true
32 | proxy_dir: /doctrine/PHPCRProxies
33 | proxy_namespace: PHPCRProxies
34 |
35 | metadata_cache_driver:
36 | type: array
37 |
38 | locales:
39 | en: [de, fr]
40 | de: [en, fr]
41 | fr: [en, de]
42 | locale_fallback: hardcoded
43 | default_locale: fr
44 |
45 | jackrabbit_jar: /path/to/jackrabbit.jar
46 | dump_max_line_length: 20
47 | manager_registry_service_id: my_phpcr_registry
48 |
--------------------------------------------------------------------------------
/src/OptionalCommand/ODM/VerifyUniqueNodeTypesMappingCommand.php:
--------------------------------------------------------------------------------
1 | setName('doctrine:phpcr:mapping:verify-unique-node-types')
22 | ->setDescription('Verify that documents claiming to have unique node types are truly unique')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ->setHelp(<<<'EOT'
25 | The %command.name% command checks all mapped PHPCR-ODM documents
26 | and verifies that any claiming to use unique node types are truly unique.
27 | EOT
28 | );
29 | }
30 |
31 | protected function execute(InputInterface $input, OutputInterface $output): int
32 | {
33 | DoctrineCommandHelper::setApplicationDocumentManager(
34 | $this->getApplication(),
35 | $input->getOption('session')
36 | );
37 |
38 | return parent::execute($input, $output);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/Form/Type/DocumentType.php:
--------------------------------------------------------------------------------
1 |
13 | */
14 | class JackrabbitCommand extends BaseJackrabbitCommand
15 | {
16 | private const NAME = 'doctrine:phpcr:jackrabbit';
17 |
18 | public function __construct(
19 | private ?string $jackrabbitJar,
20 | private ?string $workspaceDir,
21 | ) {
22 | parent::__construct(self::NAME);
23 | }
24 |
25 | protected function configure(): void
26 | {
27 | parent::configure();
28 |
29 | $this
30 | ->setName(self::NAME)
31 | ->setHelp(<<<'EOF'
32 | The doctrine:phpcr:jackrabbit command allows to have a minimal control on the Jackrabbit server from within a
33 | Symfony 2 command.
34 |
35 | If the jackrabbit_jar option is set, it will be used as the Jackrabbit server jar file.
36 | Otherwise, you will have to set the doctrine_phpcr.jackrabbit_jar config parameter to a valid Jackrabbit
37 | server jar file.
38 | EOF
39 | )
40 | ;
41 | }
42 |
43 | protected function execute(InputInterface $input, OutputInterface $output): int
44 | {
45 | $this->setJackrabbitPath($this->jackrabbitJar);
46 | $this->setWorkspaceDir($this->workspaceDir);
47 |
48 | return parent::execute($input, $output);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/tests/Functional/Command/NodeDumpCommandTest.php:
--------------------------------------------------------------------------------
1 | getRepositoryManager();
17 | $repositoryManager->loadFixtures([LoadData::class]);
18 | }
19 |
20 | public function testMaxLineLengthOptionIsAppliedSuccessfully(): void
21 | {
22 | $application = new Application(self::$kernel);
23 |
24 | $command = $application->find('doctrine:phpcr:node:dump');
25 | $commandTester = new CommandTester($command);
26 | $commandTester->execute([
27 | 'command' => $command->getName(),
28 | '--props' => true,
29 | '--max_line_length' => 120,
30 | 'identifier' => '/test/doc-very-long',
31 | ]);
32 |
33 | $output = $commandTester->getDisplay();
34 | $this->assertMatchesRegularExpression('/^\s+ - \s+ text \s+ = \s+ .{120} \.\.\.$/mx', $output);
35 |
36 | $commandTester->execute([
37 | 'command' => $command->getName(),
38 | '--props' => true,
39 | '--max_line_length' => 20,
40 | 'identifier' => '/test/doc-very-long',
41 | ]);
42 |
43 | $output = $commandTester->getDisplay();
44 | $this->assertMatchesRegularExpression('/^\s+ - \s+ text \s+ = \s+ .{20} \.\.\.$/mx', $output);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Form/DataTransformer/PHPCRNodeToPathTransformer.php:
--------------------------------------------------------------------------------
1 | session = $session;
18 | }
19 |
20 | /**
21 | * Transform a node into a path.
22 | *
23 | * @param NodeInterface|null $node
24 | *
25 | * @return string|null the path to the node or null if $node is null
26 | *
27 | * @throws UnexpectedTypeException if given value is not a NodeInterface
28 | */
29 | public function transform($node): ?string
30 | {
31 | if (null === $node) {
32 | return null;
33 | }
34 |
35 | if (!$node instanceof NodeInterface) {
36 | throw new UnexpectedTypeException($node, NodeInterface::class);
37 | }
38 |
39 | return $node->getPath();
40 | }
41 |
42 | /**
43 | * Transform a path to its corresponding PHPCR node.
44 | *
45 | * @param string $path phpcr path
46 | *
47 | * @return NodeInterface|null returns the node or null if $path is empty
48 | *
49 | * @throws ItemNotFoundException if node for a non-empty $path is not found
50 | */
51 | public function reverseTransform($path): ?NodeInterface
52 | {
53 | if (!$path) {
54 | return null;
55 | }
56 |
57 | return $this->session->getNode($path);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/Form/DataTransformer/PHPCRNodeToUuidTransformer.php:
--------------------------------------------------------------------------------
1 | session = $session;
18 | }
19 |
20 | /**
21 | * Transform a node into a uuid.
22 | *
23 | * @param NodeInterface|null $node
24 | *
25 | * @return string|null the uuid to the node or null if $node is null
26 | *
27 | * @throws UnexpectedTypeException if given value is not a NodeInterface
28 | */
29 | public function transform($node): ?string
30 | {
31 | if (null === $node) {
32 | return null;
33 | }
34 |
35 | if (!$node instanceof NodeInterface) {
36 | throw new UnexpectedTypeException($node, NodeInterface::class);
37 | }
38 |
39 | return $node->getIdentifier();
40 | }
41 |
42 | /**
43 | * Transform a uuid to its corresponding PHPCR node.
44 | *
45 | * @param string $id uuid
46 | *
47 | * @return NodeInterface|null returns the node or null if the $id is empty
48 | *
49 | * @throws ItemNotFoundException if node for a non-empty $id is not found
50 | */
51 | public function reverseTransform($id): ?NodeInterface
52 | {
53 | if (!$id) {
54 | return null;
55 | }
56 |
57 | return $this->session->getNodeByIdentifier($id);
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/tests/Functional/BaseTestCase.php:
--------------------------------------------------------------------------------
1 | getContainer()) {
18 | self::$kernel->boot();
19 | }
20 | $container = self::getTestContainer();
21 |
22 | return new RepositoryManager($container->get('doctrine_phpcr'), $container->get('doctrine_phpcr.initializer_manager'));
23 | }
24 |
25 | protected function assertResponseSuccess(Response $response): void
26 | {
27 | libxml_use_internal_errors(true);
28 |
29 | $dom = new \DOMDocument();
30 | $dom->loadHTML($response->getContent());
31 |
32 | $xpath = new \DOMXPath($dom);
33 | $result = $xpath->query('//div[contains(@class,"text-exception")]/h1');
34 | $exception = null;
35 | if ($result->length) {
36 | $exception = $result->item(0)->nodeValue;
37 | }
38 |
39 | $this->assertEquals(200, $response->getStatusCode(), $exception ? 'Exception: "'.$exception.'"' : '');
40 | }
41 |
42 | protected static function getTestContainer(): ContainerInterface
43 | {
44 | if (!self::$kernel) {
45 | self::bootKernel();
46 | }
47 | if (!self::$kernel->getContainer()) {
48 | self::$kernel->boot();
49 | }
50 |
51 | return self::getContainer();
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/OptionalCommand/Jackalope/InitDoctrineDbalCommand.php:
--------------------------------------------------------------------------------
1 | setName('doctrine:phpcr:init:dbal')
23 | ->addOption('session', null, InputOption::VALUE_REQUIRED, 'The session to use for this command')
24 | ;
25 | }
26 |
27 | protected function execute(InputInterface $input, OutputInterface $output): int
28 | {
29 | $application = $this->getApplication();
30 | if (!$application instanceof Application) {
31 | throw new \InvalidArgumentException('Expected to find '.Application::class.' but got '.
32 | ($application ? \get_class($application) : null));
33 | }
34 |
35 | $sessionName = $input->getOption('session');
36 | if (empty($sessionName)) {
37 | $container = $application->getKernel()->getContainer();
38 | $sessionName = $container->getParameter('doctrine_phpcr.default_session');
39 | }
40 |
41 | DoctrineCommandHelper::setApplicationConnection($application, $sessionName);
42 |
43 | return parent::execute($input, $output);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/Resources/meta/approval_LGPL-to-MIT/request.eml:
--------------------------------------------------------------------------------
1 | Message-ID: <4FFD76C2.3040806@liip.ch>
2 | Date: Wed, 11 Jul 2012 14:51:14 +0200
3 | From: David Buchmann
4 | User-Agent: Mozilla/5.0 (X11; Linux i686; rv:13.0) Gecko/20120615 Thunderbird/13.0.1
5 | MIME-Version: 1.0
6 | To: Christophe Coevoet ,
7 | Florent Cailhol ,
8 | Henri Bergius ,
9 | Julien 'ruian' Galenski ,
10 | Lukas Kahwe Smith ,
11 | Simon Holywell ,
12 | =?ISO-8859-15?Q?Uwe_J=E4ger?=
13 | Subject: please confirm doctrine phpcr bundle license change to MIT
14 | X-Enigmail-Version: 1.4.2
15 | Content-Type: text/plain; charset=ISO-8859-15
16 | Content-Transfer-Encoding: 7bit
17 |
18 | -----BEGIN PGP SIGNED MESSAGE-----
19 | Hash: SHA1
20 |
21 | hi,
22 |
23 | as the doctrine phpcr bundle was not covered in the switch of doctrine
24 | to MIT [1] i wanted to ask all of you as the contributers to the
25 | bundle if you are ok with switching the bundle license to MIT as well.
26 |
27 | please just reply to this email if it is ok.
28 |
29 | you can see your contributions on the github page
30 | https://github.com/doctrine/DoctrinePHPCRBundle/graphs/contributors
31 |
32 | @stof: github does not show you because the only commit you have was a
33 | merge commit. i still include you for completeness and because i am
34 | not a lawyer :-)
35 |
36 | cheers,david
37 |
38 | [1] http://dlm.beberlei.de/licenses/projects
39 | - --
40 | Liip AG // Agile Web Development // T +41 26 422 25 11
41 | CH-1700 Fribourg // PGP 0xA581808B // www.liip.ch
42 |
43 | -----BEGIN PGP SIGNATURE-----
44 | Version: GnuPG v1.4.11 (GNU/Linux)
45 | Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
46 |
47 | iEYEARECAAYFAk/9dr0ACgkQqBnXnqWBgIuNoQCfVOaJ1KAV+9uBM1OCo3Dh/LwD
48 | ILQAn0IZ8C++sO40auTEZfGOUTa5stxV
49 | =h+Mh
50 | -----END PGP SIGNATURE-----
51 |
--------------------------------------------------------------------------------
/tests/Unit/Form/DataTransformer/PHPCRNodeToUuidTransformerTest.php:
--------------------------------------------------------------------------------
1 | session = $this->createMock(SessionInterface::class);
31 | $this->transformer = new PHPCRNodeToUuidTransformer($this->session);
32 | $this->node = $this->createMock(Node::class);
33 | }
34 |
35 | public function testTransform(): void
36 | {
37 | $this->node->expects($this->once())
38 | ->method('getIdentifier')
39 | ->willReturn('/asd');
40 | $res = $this->transformer->transform($this->node);
41 | $this->assertEquals('/asd', $res);
42 | }
43 |
44 | public function testReverseTransform(): void
45 | {
46 | $this->session->expects($this->once())
47 | ->method('getNodeByIdentifier')
48 | ->with('/asd')
49 | ->willReturn($this->node);
50 |
51 | $res = $this->transformer->reverseTransform('/asd');
52 | $this->assertSame($this->node, $res);
53 | }
54 |
55 | public function testReverseTransformEmpty(): void
56 | {
57 | $this->session->expects($this->never())
58 | ->method('getNodeByIdentifier');
59 | $res = $this->transformer->reverseTransform('');
60 | $this->assertNull($res);
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/tests/Fixtures/App/Document/ReferrerDocument.php:
--------------------------------------------------------------------------------
1 | documents = new ArrayCollection();
39 | $this->testDocuments = new ArrayCollection();
40 | }
41 |
42 | public function addDocument($doc): void
43 | {
44 | $this->documents->add($doc);
45 | }
46 |
47 | public function getSingle()
48 | {
49 | return $this->single;
50 | }
51 |
52 | public function getTestDocument()
53 | {
54 | return $this->testDocument;
55 | }
56 |
57 | /**
58 | * @return Collection