Doctrine\ODM\PHPCR\NodeTypeRegistrator::registerNodeTypes PHP 메소드

registerNodeTypes() 공개 메소드

Register the system node types on the given session.
public registerNodeTypes ( PHPCR\SessionInterface $session )
$session PHPCR\SessionInterface
    public function registerNodeTypes(SessionInterface $session)
    {
        $cnd = <<<CND
// register phpcr_locale namespace
<{$this->localeNamespace}='{$this->localeNamespaceUri}'>
// register phpcr namespace
<{$this->phpcrNamespace}='{$this->phpcrNamespaceUri}'>
[phpcr:managed]
mixin
- phpcr:class (STRING)
- phpcr:classparents (STRING) multiple
CND;
        $nodeTypeManager = $session->getWorkspace()->getNodeTypeManager();
        $nodeTypeManager->registerNodeTypesCnd($cnd, true);
    }

Usage Example

예제 #1
0
 private function loadPhpcrOdm()
 {
     $this['psi_content_type.storage.doctrine.phpcr_odm.property_encoder'] = function ($container) {
         return new PropertyEncoder('psict', 'https://github.com/psiphp/content-type');
     };
     $this['psi_content_type.storage.doctrine.phpcr_odm.field_mapper'] = function ($container) {
         return new FieldMapper($container['psi_content_type.storage.doctrine.phpcr_odm.property_encoder'], $container['psi_content_type.field_loader']);
     };
     $this['psi_content_type.storage.doctrine.phpcr_odm.collection_updater'] = function ($container) {
         return new CollectionIdentifierUpdater($container['psi_content_type.metadata.factory'], $container['psi_content_type.storage.doctrine.phpcr_odm.property_encoder']);
     };
     $this['doctrine_phpcr.document_manager'] = function ($container) {
         $registerNodeTypes = false;
         // automatically setup the schema if the db doesn't exist yet.
         if (!file_exists($container['config']['db_path'])) {
             if (!file_exists($dir = dirname($container['config']['db_path']))) {
                 mkdir($dir);
             }
             $connection = $container['dbal.connection'];
             $schema = new RepositorySchema();
             foreach ($schema->toSql($connection->getDatabasePlatform()) as $sql) {
                 $connection->exec($sql);
             }
             $registerNodeTypes = true;
         }
         // register the phpcr session
         $factory = new RepositoryFactoryDoctrineDBAL();
         $repository = $factory->getRepository(['jackalope.doctrine_dbal_connection' => $container['dbal.connection']]);
         $session = $repository->login(new SimpleCredentials(null, null), 'default');
         if ($registerNodeTypes) {
             $typeRegistrator = new NodeTypeRegistrator();
             $typeRegistrator->registerNodeTypes($session);
             $ctTypeRegistrator = new CtNodeTypeRegistrator($container['psi_content_type.storage.doctrine.phpcr_odm.property_encoder']);
             $ctTypeRegistrator->registerNodeTypes($session);
         }
         // annotation driver
         $annotationDriver = new AnnotationDriver($container['annotation_reader'], [__DIR__ . '/../../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Document', __DIR__ . '/Example']);
         $xmlDriver = new XmlDriver([__DIR__ . '/mappings']);
         $annotationDriver = new AnnotationDriver($container['annotation_reader'], [__DIR__ . '/../../vendor/doctrine/phpcr-odm/lib/Doctrine/ODM/PHPCR/Document', __DIR__ . '/Example']);
         $chain = new MappingDriverChain();
         $chain->addDriver($annotationDriver, 'Psi\\Bridge\\ContentType\\Doctrine\\PhpcrOdm\\Tests\\Functional\\Example');
         $chain->addDriver($xmlDriver, 'Psi\\Component\\ContentType\\Tests\\Functional\\Example\\Model');
         $chain->addDriver($annotationDriver, 'Doctrine');
         $config = new Configuration();
         $config->setMetadataDriverImpl($chain);
         $manager = DocumentManager::create($session, $config);
         $manager->getEventManager()->addEventSubscriber(new MetadataSubscriber($container['psi_content_type.metadata.factory'], $container['psi_content_type.field_loader'], $container['psi_content_type.storage.doctrine.phpcr_odm.field_mapper']));
         $manager->getEventManager()->addEventSubscriber(new CollectionSubscriber($container['psi_content_type.metadata.factory'], $container['psi_content_type.storage.doctrine.phpcr_odm.property_encoder']));
         return $manager;
     };
 }
All Usage Examples Of Doctrine\ODM\PHPCR\NodeTypeRegistrator::registerNodeTypes
NodeTypeRegistrator