public function testAddNodeTypes()
 {
     $workspace = $this->session->getWorkspace();
     $ntm = $workspace->getNodeTypeManager();
     $template = $ntm->createNodeTypeTemplate();
     $template->setName('phpcr:article');
     $propertyDefs = $template->getPropertyDefinitionTemplates();
     $propertyTemplate = $ntm->createPropertyDefinitionTemplate();
     $propertyTemplate->setName('headline');
     $propertyTemplate->setRequiredType(\PHPCR\PropertyType::STRING);
     $propertyDefs[] = $propertyTemplate;
     $childDefs = $template->getNodeDefinitionTemplates();
     $nodeTemplate = $ntm->createNodeDefinitionTemplate();
     $nodeTemplate->setName('article_content');
     $nodeTemplate->setDefaultPrimaryTypeName('nt:unstructured');
     $nodeTemplate->setMandatory(true);
     $childDefs[] = $nodeTemplate;
     $ntm->registerNodeTypes(array($template), true);
     $def = $ntm->getNodeType('phpcr:article');
     $this->assertEquals("phpcr:article", $def->getName());
     $this->assertEquals(1, count($def->getDeclaredPropertyDefinitions()));
     $this->assertEquals(1, count($def->getDeclaredChildNodeDefinitions()));
 }
 /**
  * {@inheritdoc}
  */
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $srcLocale = $input->getArgument('srcLocale');
     $destLocale = $input->getArgument('destLocale');
     $overwrite = $input->getOption('overwrite');
     $dryRun = $input->getOption('dry-run');
     $this->session = $this->getContainer()->get('doctrine_phpcr')->getManager()->getPhpcrSession();
     $this->queryManager = $this->session->getWorkspace()->getQueryManager();
     $this->languageNamespace = $this->getContainer()->getParameter('sulu.content.language.namespace');
     $this->snippetRepository = $this->getContainer()->get('sulu_snippet.repository');
     $this->contentMapper = $this->getContainer()->get('sulu.content.mapper');
     $this->output = $output;
     $this->copyNodes($srcLocale, $destLocale, $overwrite);
     if (false === $dryRun) {
         $this->output->writeln('<info>Saving ...</info>');
         $this->session->save();
         $this->output->writeln('<info>Done</info>');
     } else {
         $this->output->writeln('<info>Dry run complete</info>');
     }
 }
Example #3
0
 /**
  * Initialize basic information common to nodes and properties
  *
  * @param FactoryInterface $factory       the object factory
  * @param string           $path          The normalized and absolute path to this item
  * @param Session          $session
  * @param ObjectManager    $objectManager
  * @param boolean          $new           can be set to true to tell the object that it has
  *      been created locally
  */
 protected function __construct(FactoryInterface $factory, $path, Session $session, ObjectManager $objectManager, $new = false)
 {
     $this->factory = $factory;
     $this->valueConverter = $this->factory->get('PHPCR\\Util\\ValueConverter');
     $this->session = $session;
     $this->objectManager = $objectManager;
     $this->setState($new ? self::STATE_NEW : self::STATE_CLEAN);
     if (!$new && $session->getRepository()->getDescriptor(RepositoryInterface::OPTION_TRANSACTIONS_SUPPORTED)) {
         if ($session->getWorkspace()->getTransactionManager()->inTransaction()) {
             // properly set previous state in case we get into a rollback
             $this->savedState = self::STATE_CLEAN;
         }
     }
     $this->setPath($path);
 }