├── Makefile ├── composer.json ├── phpunit.xml.dist ├── src ├── CmfContentBundle.php ├── Controller │ └── ContentController.php ├── DependencyInjection │ ├── CmfContentExtension.php │ ├── Compiler │ │ └── ValidationPass.php │ └── Configuration.php ├── Doctrine │ └── Phpcr │ │ ├── StaticContent.php │ │ └── StaticContentBase.php ├── Model │ ├── StaticContent.php │ └── StaticContentBase.php └── Resources │ ├── config │ ├── doctrine-model │ │ ├── StaticContent.phpcr.xml │ │ └── StaticContentBase.phpcr.xml │ ├── doctrine-phpcr │ │ ├── StaticContent.phpcr.xml │ │ └── StaticContentBase.phpcr.xml │ ├── persistence-phpcr.xml │ ├── schema │ │ └── content-1.0.xsd │ ├── services.xml │ └── validation-phpcr.xml │ ├── meta │ └── LICENSE │ └── rdf-mappings │ └── Symfony.Cmf.Bundle.ContentBundle.Doctrine.Phpcr.StaticContent.xml └── tests ├── Fixtures ├── App │ ├── DataFixtures │ │ └── Phpcr │ │ │ └── LoadContentData.php │ ├── Kernel.php │ └── config │ │ ├── bundles.php │ │ ├── cmf_content.yml │ │ ├── config.php │ │ └── routing.php └── config │ ├── config1.xml │ ├── config2.xml │ └── config3.xml ├── Functional └── Doctrine │ └── Phpcr │ └── StaticContentTest.php └── Unit └── DependencyInjection └── XmlSchemaTest.php /Makefile: -------------------------------------------------------------------------------- 1 | ####################################################### 2 | # DO NOT EDIT THIS FILE! # 3 | # # 4 | # It's auto-generated by symfony-cmf/dev-kit package. # 5 | ####################################################### 6 | 7 | ############################################################################ 8 | # This file is part of the Symfony CMF package. # 9 | # # 10 | # (c) 2011-2017 Symfony CMF # 11 | # # 12 | # For the full copyright and license information, please view the LICENSE # 13 | # file that was distributed with this source code. # 14 | ############################################################################ 15 | 16 | TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin 17 | CONSOLE=${TESTING_SCRIPTS_DIR}/console 18 | VERSION=dev-master 19 | ifdef BRANCH 20 | VERSION=dev-${BRANCH} 21 | endif 22 | PACKAGE=symfony-cmf/content-bundle 23 | export KERNEL_CLASS=Symfony\Cmf\Bundle\ContentBundle\Tests\Fixtures\App\Kernel 24 | list: 25 | @echo 'test: will run all tests' 26 | @echo 'unit_tests: will run unit tests only' 27 | @echo 'functional_tests_phpcr: will run functional tests with PHPCR' 28 | 29 | @echo 'test_installation: will run installation test' 30 | include ${TESTING_SCRIPTS_DIR}/make/unit_tests.mk 31 | include ${TESTING_SCRIPTS_DIR}/make/functional_tests_phpcr.mk 32 | include ${TESTING_SCRIPTS_DIR}/make/test_installation.mk 33 | 34 | .PHONY: test 35 | test: unit_tests functional_tests_phpcr 36 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "symfony-cmf/content-bundle", 3 | "type": "symfony-bundle", 4 | "description": "Symfony CMF Content Bundle", 5 | "keywords": [ 6 | "Symfony CMF" 7 | ], 8 | "homepage": "http://cmf.symfony.com", 9 | "license": "MIT", 10 | "authors": [ 11 | { 12 | "name": "Symfony CMF Community", 13 | "homepage": "https://github.com/symfony-cmf/ContentBundle/contributors" 14 | } 15 | ], 16 | "require": { 17 | "php": "^7.1", 18 | "symfony/framework-bundle": "^2.8 || ^3.3 || ^4.0", 19 | "symfony/templating": "^2.8 || ^3.3 || ^4.0", 20 | "symfony/twig-bundle": "^2.8 || ^3.3 || ^4.0", 21 | "symfony/validator": "^2.8 || ^3.3 || ^4.0", 22 | "symfony-cmf/core-bundle": "^2.1", 23 | "symfony-cmf/menu-bundle": "^2.1", 24 | "symfony-cmf/routing-bundle": "^2.1" 25 | }, 26 | "require-dev": { 27 | "doctrine/phpcr-odm": "^1.4|^2.0", 28 | "symfony-cmf/testing": "^2.1.11", 29 | "symfony/phpunit-bridge": "^4.2.2" 30 | }, 31 | "suggest": { 32 | "friendsofsymfony/rest-bundle": "Improved handling for different output formats", 33 | "doctrine/phpcr-odm": "To persist content with the PHP content repository", 34 | "doctrine/phpcr-bundle": "To integrate PHPCR-ODM with Symfony", 35 | "symfony-cmf/sonata-admin-integration-bundle": "To provide admin interfaces for the content" 36 | }, 37 | "autoload": { 38 | "psr-4": { 39 | "Symfony\\Cmf\\Bundle\\ContentBundle\\": "src/" 40 | } 41 | }, 42 | "autoload-dev": { 43 | "psr-4": { 44 | "Symfony\\Cmf\\Bundle\\ContentBundle\\Tests\\": "tests/" 45 | } 46 | }, 47 | "extra": { 48 | "branch-alias": { 49 | "dev-master": "2.1-dev" 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | ./tests/Functional 10 | 11 | 12 | 13 | ./tests/Unit 14 | 15 | 16 | 17 | 18 | 19 | . 20 | 21 | *Bundle.php 22 | Resources/ 23 | Admin/ 24 | tests/ 25 | vendor/ 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/CmfContentBundle.php: -------------------------------------------------------------------------------- 1 | addCompilerPass(new ValidationPass()); 24 | 25 | if (class_exists('Doctrine\Bundle\PHPCRBundle\DependencyInjection\Compiler\DoctrinePhpcrMappingsPass')) { 26 | $container->addCompilerPass( 27 | DoctrinePhpcrMappingsPass::createXmlMappingDriver( 28 | [ 29 | realpath(__DIR__.'/Resources/config/doctrine-model') => 'Symfony\Cmf\Bundle\ContentBundle\Model', 30 | realpath(__DIR__.'/Resources/config/doctrine-phpcr') => 'Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr', 31 | ], 32 | ['cmf_content.persistence.phpcr.manager_name'], 33 | 'cmf_content.backend_type_phpcr', 34 | ['CmfContentBundle' => 'Symfony\Cmf\Bundle\ContentBundle\Doctrine\Phpcr'] 35 | ) 36 | ); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Controller/ContentController.php: -------------------------------------------------------------------------------- 1 | templating = $templating; 63 | $this->defaultTemplate = $defaultTemplate; 64 | $this->viewHandler = $viewHandler; 65 | $this->twig = $twig; 66 | } 67 | 68 | /** 69 | * Render the provided content. 70 | * 71 | * When using the publish workflow, enable the publish_workflow.request_listener 72 | * of the core bundle to have the contentDocument as well as the route 73 | * checked for being published. 74 | * We don't need an explicit check in this method. 75 | * 76 | * @param Request $request 77 | * @param object $contentDocument 78 | * @param string $template Symfony path of the template to render 79 | * the content document. If omitted, the 80 | * default template is used 81 | * 82 | * @return Response 83 | */ 84 | public function indexAction(Request $request, $contentDocument, $template = null) 85 | { 86 | $contentTemplate = $template ?: $this->defaultTemplate; 87 | 88 | $contentTemplate = str_replace( 89 | ['{_format}', '{_locale}'], 90 | [$request->getRequestFormat(), $request->getLocale()], 91 | $contentTemplate 92 | ); 93 | 94 | $params = $this->getParams($request, $contentDocument); 95 | 96 | return $this->renderResponse($contentTemplate, $params); 97 | } 98 | 99 | protected function renderResponse($contentTemplate, $params) 100 | { 101 | if ($this->viewHandler) { 102 | if (1 === count($params)) { 103 | $templateVar = key($params); 104 | $params = reset($params); 105 | } 106 | $view = $this->getView($params); 107 | if (isset($templateVar)) { 108 | $view->setTemplateVar($templateVar); 109 | } 110 | $view->setTemplate($contentTemplate); 111 | 112 | return $this->viewHandler->handle($view); 113 | } 114 | 115 | if (is_null($this->templating)) { 116 | $response = new Response(); 117 | $response->setContent($this->twig->render($contentTemplate, $params)); 118 | } else { 119 | $response = $this->templating->renderResponse($contentTemplate, $params); 120 | } 121 | 122 | return $response; 123 | } 124 | 125 | /** 126 | * Prepare the REST View to render the response in the correct format. 127 | * 128 | * @param array $params 129 | * 130 | * @return View 131 | */ 132 | protected function getView($params) 133 | { 134 | return new View($params); 135 | } 136 | 137 | /** 138 | * Determine the parameters for rendering the template. 139 | * 140 | * This is mainly meant as a possible extension point in a custom 141 | * controller. 142 | * 143 | * @param Request $request 144 | * @param object $contentDocument 145 | * 146 | * @return array 147 | */ 148 | protected function getParams(Request $request, $contentDocument) 149 | { 150 | return [ 151 | 'cmfMainContent' => $contentDocument, 152 | ]; 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /src/DependencyInjection/CmfContentExtension.php: -------------------------------------------------------------------------------- 1 | processConfiguration(new Configuration(), $configs); 24 | 25 | $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 26 | $loader->load('services.xml'); 27 | 28 | if ($config['persistence']['phpcr']['enabled']) { 29 | $this->loadPhpcr($config['persistence']['phpcr'], $loader, $container); 30 | } 31 | 32 | if (isset($config['default_template'])) { 33 | $container->setParameter($this->getAlias().'.default_template', $config['default_template']); 34 | } 35 | } 36 | 37 | public function loadPhpcr(array $config, XmlFileLoader $loader, ContainerBuilder $container) 38 | { 39 | $container->setParameter($this->getAlias().'.backend_type_phpcr', true); 40 | 41 | $keys = [ 42 | 'manager_name', 43 | 'content_basepath', 44 | ]; 45 | 46 | foreach ($keys as $key) { 47 | $container->setParameter($this->getAlias().'.persistence.phpcr.'.$key, $config[$key]); 48 | } 49 | 50 | $loader->load('persistence-phpcr.xml'); 51 | } 52 | 53 | /** 54 | * Returns the base path for the XSD files. 55 | * 56 | * @return string The XSD base path 57 | */ 58 | public function getXsdValidationBasePath() 59 | { 60 | return __DIR__.'/../Resources/config/schema'; 61 | } 62 | 63 | public function getNamespace() 64 | { 65 | return 'http://cmf.symfony.com/schema/dic/content'; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/DependencyInjection/Compiler/ValidationPass.php: -------------------------------------------------------------------------------- 1 | 21 | */ 22 | class ValidationPass implements CompilerPassInterface 23 | { 24 | public function process(ContainerBuilder $container) 25 | { 26 | if ($container->hasParameter('cmf_content.backend_type_phpcr')) { 27 | $container 28 | ->getDefinition('validator.builder') 29 | ->addMethodCall('addXmlMappings', [[__DIR__.'/../../Resources/config/validation-phpcr.xml']]); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | root('cmf_content') 24 | ->children() 25 | ->scalarNode('default_template')->end() 26 | ->arrayNode('persistence') 27 | ->addDefaultsIfNotSet() 28 | ->children() 29 | ->arrayNode('phpcr') 30 | ->addDefaultsIfNotSet() 31 | ->canBeEnabled() 32 | ->children() 33 | ->scalarNode('manager_name')->defaultNull()->end() 34 | ->scalarNode('content_basepath')->defaultValue('/cms/content')->end() 35 | ->end() 36 | ->end() 37 | ->end() 38 | ->end() 39 | ->end() 40 | ; 41 | 42 | return $treeBuilder; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Doctrine/Phpcr/StaticContent.php: -------------------------------------------------------------------------------- 1 | parent = $parent; 50 | } 51 | 52 | /** 53 | * {@inheritdoc} 54 | */ 55 | public function getParentDocument() 56 | { 57 | return $this->parent; 58 | } 59 | 60 | /** 61 | * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface 62 | * @see setParentDocument 63 | */ 64 | public function setParent($parent) 65 | { 66 | @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 3.0. Use setParentDocument() instead.', E_USER_DEPRECATED); 67 | 68 | return $this->setParentDocument($parent); 69 | } 70 | 71 | /** 72 | * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface 73 | * @see getParentDocument 74 | */ 75 | public function getParent() 76 | { 77 | @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 3.0. Use getParentDocument() instead.', E_USER_DEPRECATED); 78 | 79 | return $this->getParentDocument(); 80 | } 81 | 82 | public function getName() 83 | { 84 | return $this->name; 85 | } 86 | 87 | public function setName($name) 88 | { 89 | $this->name = $name; 90 | } 91 | 92 | /** 93 | * Get the underlying PHPCR node of this document. 94 | * 95 | * @return NodeInterface 96 | */ 97 | public function getNode() 98 | { 99 | return $this->node; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/Doctrine/Phpcr/StaticContentBase.php: -------------------------------------------------------------------------------- 1 | parent = $parent; 47 | } 48 | 49 | /** 50 | * {@inheritdoc} 51 | */ 52 | public function getParentDocument() 53 | { 54 | return $this->parent; 55 | } 56 | 57 | /** 58 | * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface 59 | * @see setParentDocument 60 | */ 61 | public function setParent($parent) 62 | { 63 | @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 3.0. Use setParentDocument() instead.', E_USER_DEPRECATED); 64 | 65 | return $this->setParentDocument($parent); 66 | } 67 | 68 | /** 69 | * @deprecated For BC with the PHPCR-ODM 1.4 HierarchyInterface 70 | * @see getParentDocument 71 | */ 72 | public function getParent() 73 | { 74 | @trigger_error('The '.__METHOD__.'() method is deprecated and will be removed in version 3.0. Use getParentDocument() instead.', E_USER_DEPRECATED); 75 | 76 | return $this->getParentDocument(); 77 | } 78 | 79 | public function getName() 80 | { 81 | return $this->name; 82 | } 83 | 84 | public function setName($name) 85 | { 86 | $this->name = $name; 87 | } 88 | 89 | /** 90 | * Get the underlying PHPCR node of this document. 91 | * 92 | * @return NodeInterface 93 | */ 94 | public function getNode() 95 | { 96 | return $this->node; 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/Model/StaticContent.php: -------------------------------------------------------------------------------- 1 | routes = new ArrayCollection(); 101 | $this->menuNodes = new ArrayCollection(); 102 | } 103 | 104 | /** 105 | * {@inheritdoc} 106 | */ 107 | public function getLocale() 108 | { 109 | return $this->locale; 110 | } 111 | 112 | /** 113 | * {@inheritdoc} 114 | */ 115 | public function setLocale($locale) 116 | { 117 | $this->locale = $locale; 118 | } 119 | 120 | /** 121 | * Get the tags set on this content. 122 | * 123 | * @return string[] 124 | */ 125 | public function getTags() 126 | { 127 | return $this->tags; 128 | } 129 | 130 | /** 131 | * Set the tags of this content as an array of strings. 132 | * 133 | * @param string[] $tags 134 | */ 135 | public function setTags($tags) 136 | { 137 | $this->tags = $tags; 138 | } 139 | 140 | /** 141 | * @return BlockInterface 142 | */ 143 | public function getAdditionalInfoBlock() 144 | { 145 | return $this->additionalInfoBlock; 146 | } 147 | 148 | /** 149 | * Set the additional info block for this content. Usually you want this to 150 | * be a container block in order to be able to add several blocks. 151 | * 152 | * @param BlockInterface $block must be persistable through cascade by the 153 | * persistence layer 154 | */ 155 | public function setAdditionalInfoBlock($block) 156 | { 157 | $this->additionalInfoBlock = $block; 158 | } 159 | 160 | /** 161 | * {@inheritdoc} 162 | */ 163 | public function setPublishable($publishable) 164 | { 165 | return $this->publishable = (bool) $publishable; 166 | } 167 | 168 | /** 169 | * {@inheritdoc} 170 | */ 171 | public function isPublishable() 172 | { 173 | return $this->publishable; 174 | } 175 | 176 | /** 177 | * {@inheritdoc} 178 | */ 179 | public function getPublishStartDate() 180 | { 181 | return $this->publishStartDate; 182 | } 183 | 184 | /** 185 | * {@inheritdoc} 186 | */ 187 | public function setPublishStartDate(\DateTime $publishStartDate = null) 188 | { 189 | $this->publishStartDate = $publishStartDate; 190 | } 191 | 192 | /** 193 | * {@inheritdoc} 194 | */ 195 | public function getPublishEndDate() 196 | { 197 | return $this->publishEndDate; 198 | } 199 | 200 | /** 201 | * {@inheritdoc} 202 | */ 203 | public function setPublishEndDate(\DateTime $publishEndDate = null) 204 | { 205 | $this->publishEndDate = $publishEndDate; 206 | } 207 | 208 | /** 209 | * Get the application information associated with this document. 210 | * 211 | * @return array 212 | */ 213 | public function getExtras() 214 | { 215 | return $this->extras; 216 | } 217 | 218 | /** 219 | * Get a single application information value. 220 | * 221 | * @param string $name 222 | * @param string|null $default 223 | * 224 | * @return string|null the value at $name if set, null otherwise 225 | */ 226 | public function getExtra($name, $default = null) 227 | { 228 | return isset($this->extras[$name]) ? $this->extras[$name] : $default; 229 | } 230 | 231 | /** 232 | * Set the application information. 233 | * 234 | * @param array $extras 235 | * 236 | * @return StaticContent - this instance 237 | */ 238 | public function setExtras(array $extras) 239 | { 240 | $this->extras = $extras; 241 | 242 | return $this; 243 | } 244 | 245 | /** 246 | * Set a single application information value. 247 | * 248 | * @param string $name 249 | * @param string $value the new value, null removes the entry 250 | * 251 | * @return StaticContent - this instance 252 | */ 253 | public function setExtra($name, $value) 254 | { 255 | if (is_null($value)) { 256 | unset($this->extras[$name]); 257 | } else { 258 | $this->extras[$name] = $value; 259 | } 260 | 261 | return $this; 262 | } 263 | 264 | /** 265 | * {@inheritdoc} 266 | */ 267 | public function addRoute($route) 268 | { 269 | $this->routes->add($route); 270 | } 271 | 272 | /** 273 | * {@inheritdoc} 274 | */ 275 | public function removeRoute($route) 276 | { 277 | $this->routes->removeElement($route); 278 | } 279 | 280 | /** 281 | * {@inheritdoc} 282 | */ 283 | public function getRoutes() 284 | { 285 | return $this->routes; 286 | } 287 | 288 | /** 289 | * {@inheritdoc} 290 | */ 291 | public function addMenuNode(NodeInterface $menu) 292 | { 293 | $this->menuNodes->add($menu); 294 | } 295 | 296 | /** 297 | * {@inheritdoc} 298 | */ 299 | public function removeMenuNode(NodeInterface $menu) 300 | { 301 | $this->menuNodes->removeElement($menu); 302 | } 303 | 304 | /** 305 | * {@inheritdoc} 306 | */ 307 | public function getMenuNodes() 308 | { 309 | return $this->menuNodes; 310 | } 311 | } 312 | -------------------------------------------------------------------------------- /src/Model/StaticContentBase.php: -------------------------------------------------------------------------------- 1 | id = $id; 39 | } 40 | 41 | /** 42 | * @return mixed 43 | */ 44 | public function getId() 45 | { 46 | return $this->id; 47 | } 48 | 49 | /** 50 | * @return string 51 | */ 52 | public function getTitle() 53 | { 54 | return $this->title; 55 | } 56 | 57 | /** 58 | * @param string $title 59 | */ 60 | public function setTitle($title) 61 | { 62 | $this->title = $title; 63 | } 64 | 65 | /** 66 | * @return string 67 | */ 68 | public function getBody() 69 | { 70 | return $this->body; 71 | } 72 | 73 | /** 74 | * @param string $body 75 | */ 76 | public function setBody($body) 77 | { 78 | $this->body = $body; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/Resources/config/doctrine-model/StaticContent.phpcr.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Resources/config/doctrine-model/StaticContentBase.phpcr.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Resources/config/doctrine-phpcr/StaticContent.phpcr.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Resources/config/doctrine-phpcr/StaticContentBase.phpcr.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/Resources/config/persistence-phpcr.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | CmfContentBundle 9 | 10 | %cmf_content.persistence.phpcr.content_basepath% 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Resources/config/schema/content-1.0.xsd: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Resources/config/services.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | null 7 | 8 | 9 | 10 | 11 | 12 | 13 | %cmf_content.default_template% 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Resources/config/validation-phpcr.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /src/Resources/meta/LICENSE: -------------------------------------------------------------------------------- 1 | Symfony Cmf Content Bundle 2 | 3 | The MIT License 4 | 5 | Copyright (c) 2011-2017 Symfony CMF 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /src/Resources/rdf-mappings/Symfony.Cmf.Bundle.ContentBundle.Doctrine.Phpcr.StaticContent.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tests/Fixtures/App/DataFixtures/Phpcr/LoadContentData.php: -------------------------------------------------------------------------------- 1 | getPhpcrSession(), '/test'); 25 | $root = $manager->find(null, '/test'); 26 | 27 | $contentRoot = new Generic(); 28 | $contentRoot->setNodename('contents'); 29 | $contentRoot->setParent($root); 30 | $manager->persist($contentRoot); 31 | 32 | $content = new StaticContent(); 33 | $content->setName('content-1'); 34 | $content->setTitle('Content 1'); 35 | $content->setBody('Content 1'); 36 | $content->setParentDocument($contentRoot); 37 | $manager->persist($content); 38 | 39 | $content = new StaticContent(); 40 | $content->setName('content-2'); 41 | $content->setTitle('Content 2'); 42 | $content->setBody('Content 2'); 43 | $content->setParentDocument($contentRoot); 44 | $manager->persist($content); 45 | 46 | $manager->flush(); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/Fixtures/App/Kernel.php: -------------------------------------------------------------------------------- 1 | requireBundleSets([ 22 | 'default', 23 | 'phpcr_odm', 24 | ]); 25 | 26 | $contents = require $this->getKernelDir().'/config/bundles.php'; 27 | foreach ($contents as $class => $envs) { 28 | if (isset($envs['all']) || isset($envs[$this->environment])) { 29 | if (!class_exists($class)) { 30 | throw new \InvalidArgumentException(sprintf( 31 | 'Bundle class "%s" does not exist.', 32 | $class 33 | )); 34 | } 35 | 36 | $this->requiredBundles[$class] = new $class(); 37 | } 38 | } 39 | } 40 | 41 | public function registerContainerConfiguration(LoaderInterface $loader) 42 | { 43 | $loader->load($this->getKernelDir().'/config/config.php'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tests/Fixtures/App/config/bundles.php: -------------------------------------------------------------------------------- 1 | ['phpcr' => true], 20 | CmfContentBundle::class => ['phpcr' => true], 21 | CmfRoutingBundle::class => ['phpcr' => true], 22 | CmfMenuBundle::class => ['phpcr' => true], 23 | CmfCoreBundle::class => ['phpcr' => true], 24 | ]; 25 | -------------------------------------------------------------------------------- /tests/Fixtures/App/config/cmf_content.yml: -------------------------------------------------------------------------------- 1 | cmf_core: 2 | multilang: 3 | locales: ['en', 'de', 'fr'] 4 | 5 | cmf_routing: 6 | dynamic: 7 | enabled: true 8 | persistence: 9 | phpcr: ~ 10 | 11 | cmf_content: 12 | persistence: 13 | phpcr: 14 | content_basepath: /test/contents 15 | -------------------------------------------------------------------------------- /tests/Fixtures/App/config/config.php: -------------------------------------------------------------------------------- 1 | setParameter('cmf_testing.bundle_fqn', 'Symfony\Cmf\Bundle\ContentBundle'); 13 | $loader->import(CMF_TEST_CONFIG_DIR.'/default.php'); 14 | $loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php'); 15 | $loader->import(__DIR__.'/cmf_content.yml'); 16 | -------------------------------------------------------------------------------- /tests/Fixtures/App/config/routing.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /tests/Fixtures/config/config2.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/Fixtures/config/config3.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /tests/Functional/Doctrine/Phpcr/StaticContentTest.php: -------------------------------------------------------------------------------- 1 | db('PHPCR')->createTestNode(); 22 | $this->dm = $this->db('PHPCR')->getOm(); 23 | $this->base = $this->dm->find(null, '/test'); 24 | } 25 | 26 | public function testStaticContent() 27 | { 28 | $data = [ 29 | 'name' => 'test-node', 30 | 'title' => 'test-title', 31 | 'body' => 'test-body', 32 | 'publishable' => false, 33 | 'publishStartDate' => new \DateTime('2013-06-18'), 34 | 'publishEndDate' => new \DateTime('2013-06-18'), 35 | ]; 36 | 37 | $content = new StaticContent(); 38 | $refl = new \ReflectionClass($content); 39 | 40 | $content->setParentDocument($this->base); 41 | 42 | foreach ($data as $key => $value) { 43 | $refl = new \ReflectionClass($content); 44 | $prop = $refl->getProperty($key); 45 | $prop->setAccessible(true); 46 | $prop->setValue($content, $value); 47 | } 48 | 49 | $this->dm->persist($content); 50 | $this->dm->flush(); 51 | $this->dm->clear(); 52 | 53 | $content = $this->dm->find(null, '/test/test-node'); 54 | 55 | $this->assertNotNull($content); 56 | 57 | foreach ($data as $key => $value) { 58 | $prop = $refl->getProperty($key); 59 | $prop->setAccessible(true); 60 | $v = $prop->getValue($content); 61 | 62 | if (!is_object($value)) { 63 | $this->assertEquals($value, $v); 64 | } 65 | } 66 | 67 | // test publish start and end 68 | $publishStartDate = $content->getPublishStartDate(); 69 | $publishEndDate = $content->getPublishEndDate(); 70 | 71 | $this->assertInstanceOf('\DateTime', $publishStartDate); 72 | $this->assertInstanceOf('\DateTime', $publishEndDate); 73 | $this->assertEquals($data['publishStartDate']->format('Y-m-d'), $publishStartDate->format('Y-m-d')); 74 | $this->assertEquals($data['publishEndDate']->format('Y-m-d'), $publishEndDate->format('Y-m-d')); 75 | 76 | // test multi-lang 77 | $content->setLocale('fr'); 78 | $this->dm->persist($content); 79 | $this->dm->flush(); 80 | $this->dm->clear(); 81 | 82 | $content = $this->dm->findTranslation(null, '/test/test-node', 'fr'); 83 | $this->assertEquals('fr', $content->getLocale()); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /tests/Unit/DependencyInjection/XmlSchemaTest.php: -------------------------------------------------------------------------------- 1 | assertSchemaAcceptsXml($xmlFiles, __DIR__.'/../../../src/Resources/config/schema/content-1.0.xsd'); 29 | } 30 | } 31 | --------------------------------------------------------------------------------