From 270f9770081e7f0c5a03f729395fd9554379688e Mon Sep 17 00:00:00 2001 From: Yorkie Chadwick Date: Tue, 5 Nov 2019 16:47:43 +0100 Subject: [PATCH] add networking/init-cms-bundle recipe --- .../config/packages/networking_init_cms.yaml | 97 +++++++++++++ .../config/routes/networking_init_cms.yaml | 3 + networking/init-cms-bundle/4.0/manifest.json | 17 +++ .../init-cms-bundle/4.0/post-install.txt | 18 +++ .../4.0/serializer/Entity.Page.yaml | 77 ++++++++++ .../init-cms-bundle/4.0/src/Entity/Page.php | 132 ++++++++++++++++++ .../init-cms-bundle/4.0/src/Entity/User.php | 40 ++++++ 7 files changed, 384 insertions(+) create mode 100644 networking/init-cms-bundle/4.0/config/packages/networking_init_cms.yaml create mode 100644 networking/init-cms-bundle/4.0/config/routes/networking_init_cms.yaml create mode 100644 networking/init-cms-bundle/4.0/manifest.json create mode 100644 networking/init-cms-bundle/4.0/post-install.txt create mode 100644 networking/init-cms-bundle/4.0/serializer/Entity.Page.yaml create mode 100644 networking/init-cms-bundle/4.0/src/Entity/Page.php create mode 100644 networking/init-cms-bundle/4.0/src/Entity/User.php diff --git a/networking/init-cms-bundle/4.0/config/packages/networking_init_cms.yaml b/networking/init-cms-bundle/4.0/config/packages/networking_init_cms.yaml new file mode 100644 index 00000000..52963c15 --- /dev/null +++ b/networking/init-cms-bundle/4.0/config/packages/networking_init_cms.yaml @@ -0,0 +1,97 @@ +imports: + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/doctrine.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/fos_ck_editor.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/fos_user.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/mopa_bootstrap.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/oneup_flysystem.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/oneup_uploader.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_admin.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_block.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_core.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_doctrine_admin.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_formatter.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_media.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_notification.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/sonata_user.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/stof_doctrine_extensions.yaml" } + - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/symfony_cmf_routing_extra.yaml" } +# Default security configuration +# - { resource: "@NetworkingInitCmsBundle/Resources/config/cms/security.yaml" } + +# Set templating to twig. FOSUserBundle requires templating to be setup +framework: + templating: { engines: ['twig'] } + +# Set up the serializer to read config file for App Page and User entities +jms_serializer: + metadata: + directories: + NetworkingSonataMediaBundle: + namespace_prefix: "Sonata\\MediaBundle" + path: "@NetworkingInitCmsBundle/Resources/config/serializer" + app: + namespace_prefix: "App" + path: "%kernel.project_dir%/config/serializer" + +# Translation bundle configuration, swap environment variables if mange_locales_only option set to false +lexik_translation: + fallback_locale: '%env(LOCALE)%' # (required) default locale to use + managed_locales: [ '%env(LOCALE)%'] # !IMPORTANT: Change to strings and not environment variables + resources_registration: + type: all # all | files | database + managed_locales_only: false # set to true to only include managed_locales + + +networking_init_cms: + # Set a cookie in the fronted end for language. If disabled, the URL will be prefixed with the locale + allow_locale_cookie: true + + # Simple php based cache for caching the rendered HTML in the frontend + cache: + activate: true #default false + cache_time: 86400 #default value + cache_service_class: 'Networking\InitCmsBundle\Lib\PhpCache' #default value + + # Show admin toolbar when in the frontend + admin_toolbar: + toolbar: true #Default is activated + position: 'top' #Choices are 'top' or 'bottom' + translation_fallback_route: 'initcms_404' #Default fallback to 404 page + no_translation_template: '@NetworkingInitCms/no_translation_found.html.twig' # + 404_template: '@NetworkingInitCms/error_404.html.twig' #Fallback to a 404 page included + # Tag tree for use in the media manager + show_tag_tree: true #Default is true + multiple_media_tags: true #Default is true + + # Language set up, label is used in the default frontend language switcher menu + languages: + - {label: 'Deutsch', locale: 'de'} + - {label: 'English', locale: 'en'} + + # Add content types here + content_types: + - { name: 'Text' , class: 'Networking\InitCmsBundle\Entity\Text'} + - { name: 'Gallery Viewer' , class: 'Networking\InitCmsBundle\Entity\GalleryView'} + + # Classes to be used for the page and user entities + class: + page: "App\\Entity\\Page" + user: "App\\Entity\\User" + + # Default template settings to get you started + templates: + 'app_single_column': + template: "@NetworkingInitCms/sandbox/page/one_column.html.twig" + name: "Single Column" + icon: "bundles/networkinginitcms/img/template_header_one_column.png" + zones: + - { name: header, class: 'col-md-12' } + - { name: main_content, class: 'col-md-12'} + 'app_two_column': + template: "@NetworkingInitCms/sandbox/page/two_column.html.twig" + name: "Two Column" + icon: "bundles/networkinginitcms/img/template_header_two_column.png" + zones: + - { name: header , class: 'col-md-12'} + - { name: left , class: 'col-md-3'} + - { name: right , class: 'col-md-9'} diff --git a/networking/init-cms-bundle/4.0/config/routes/networking_init_cms.yaml b/networking/init-cms-bundle/4.0/config/routes/networking_init_cms.yaml new file mode 100644 index 00000000..66940470 --- /dev/null +++ b/networking/init-cms-bundle/4.0/config/routes/networking_init_cms.yaml @@ -0,0 +1,3 @@ +networking_init_cms: + resource: "@NetworkingInitCmsBundle/Resources/config/routing/routing.yaml" + prefix: / diff --git a/networking/init-cms-bundle/4.0/manifest.json b/networking/init-cms-bundle/4.0/manifest.json new file mode 100644 index 00000000..b5b084e0 --- /dev/null +++ b/networking/init-cms-bundle/4.0/manifest.json @@ -0,0 +1,17 @@ +{ + "bundles": { + "Networking\\InitCmsBundle\\NetworkingInitCmsBundle": ["all"] + }, + "copy-from-recipe": { + "config/": "%CONFIG_DIR%/", + "serializer/": "%CONFIG_DIR%/serializer/", + "src/": "%SRC_DIR%/" + }, + "env": { + "LOCALE": "en" + }, + "composer-scripts": { + "ckeditor:install --clear=drop": "symfony-cmd", + "assets:install %PUBLIC_DIR%": "symfony-cmd" + } +} diff --git a/networking/init-cms-bundle/4.0/post-install.txt b/networking/init-cms-bundle/4.0/post-install.txt new file mode 100644 index 00000000..96a5f7a1 --- /dev/null +++ b/networking/init-cms-bundle/4.0/post-install.txt @@ -0,0 +1,18 @@ + + What's next? + + + * The InitCmsBundle imports many configuration files, such as doctrine.yaml, security.yaml etc. In order + to ensure your app will work please do the following: + 1. Check that all files imported via the networking_init_cms.yaml file are not overwritten with a similar + configuration file in your /config/packages folder. !IMPORTANT the doctrine.yaml and security.yaml must be either + deleted, or configured along the lines of the provided default doctrine and security configs provided in the + bundle + 2. Check that the Page and User entities were copied to the correct entity folder, and are configured correctly + 3. Clear the cache again so that the new config files are loaded correctly. + 4. Back up your database. + 5. Update your database bin/console doctrine:schema:update or using the doctrine migrate commands + 6. Use the command networking:initcms:install to install setup the DB install fixtures and create a superuser admin + 7. OR you can use the networking:initcms:data-setup if you just want to install the data structure and fixtures + 8. Enable or copy the security configuration file that is commented out in the networking_init_cms.yaml file + 9. Set up your managed languages for the lexik translation bundle diff --git a/networking/init-cms-bundle/4.0/serializer/Entity.Page.yaml b/networking/init-cms-bundle/4.0/serializer/Entity.Page.yaml new file mode 100644 index 00000000..86f06af2 --- /dev/null +++ b/networking/init-cms-bundle/4.0/serializer/Entity.Page.yaml @@ -0,0 +1,77 @@ +App\Entity\Page: + properties: + id: + type: integer + createdAt: + type: DateTime + updatedAt: + type: DateTime + pageName: + type: string + metaTitle: + type: string + url: + type: string + path: + type: string + level: + type: integer + metaKeyword: + type: string + metaDescription: + type: string + parent: + accessor: + getter: convertParentToInteger + type: integer + alias: + accessor: + getter: convertAliasToInteger + type: integer + parents: + accessor: + getter: convertParentsToArray + type: array + children: + accessor: + getter: convertChildrenToIntegerArray + type: array + allChildren: + exclude: true + layoutBlock: + type: ArrayCollection + menuItem: + exclude: true + accessor: + getter: prepareMenuItemsForSerialization + type: ArrayCollection + isHome: + type: boolean + status: + type: string + visibility: + type: string + activeFrom: + type: DateTime + activeTo: + type: DateTime + locale: + type: string + translations: + accessor: + getter: convertTranslationsToIntegerArray + type: array + originals: + accessor: + getter: convertOriginalsToIntegerArray + type: array + snapshots: + exclude: true + snapshotClassType: + type: string + oldTitle: + exclude: true + tags: + exclude: true + contentRoute: + exclude: true diff --git a/networking/init-cms-bundle/4.0/src/Entity/Page.php b/networking/init-cms-bundle/4.0/src/Entity/Page.php new file mode 100644 index 00000000..cb6786e3 --- /dev/null +++ b/networking/init-cms-bundle/4.0/src/Entity/Page.php @@ -0,0 +1,132 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace App\Entity; + +use Doctrine\Common\Collections\ArrayCollection; +use Gedmo\Mapping\Annotation as Gedmo; +use Networking\InitCmsBundle\Entity\BasePage; +use Doctrine\ORM\Mapping as ORM; +use Networking\InitCmsBundle\Model\ContentRoute; + +/** + * + * @author Yorkie Chadwick + * + * @ORM\Entity + * @ORM\Table(name="page", + * uniqueConstraints={@ORM\UniqueConstraint(name="path_idx", columns={ + * "path", "locale" + * })} + * ) + * @ORM\HasLifecycleCallbacks() + */ +class Page extends BasePage{ + + /** + * @var integer $id + * + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue(strategy="IDENTITY") + */ + protected $id; + + /** + * @var ContentRoute + * @ORM\OneToOne( + * targetEntity = "Networking\InitCmsBundle\Entity\ContentRoute", + * cascade={"remove", "persist"} + * ) + * @ORM\JoinColumn(name="content_route_id", referencedColumnName="id") + */ + protected $contentRoute; + + /** + * @ORM\OneToMany(targetEntity="Networking\InitCmsBundle\Entity\LayoutBlock", + * mappedBy="page", + * cascade={"remove", "persist"}, + * orphanRemoval=true + * ) + * @ORM\OrderBy({"sortOrder" = "ASC"}) + */ + protected $layoutBlock; + + /** + * @ORM\OneToMany(targetEntity="Networking\InitCmsBundle\Entity\MenuItem", + * mappedBy="page", + * cascade={"remove"}, + * orphanRemoval=true + * ) + */ + protected $menuItem; + + /** + * @ORM\OneToMany(targetEntity="Networking\InitCmsBundle\Entity\PageSnapshot", + * mappedBy="page", + * cascade={"remove"}, + * orphanRemoval=true + * ) + * @ORM\OrderBy({"version" = "DESC"}) + */ + protected $snapshots; + + /** + * @ORM\OneToMany(targetEntity="App\Entity\Page", + * mappedBy="parent" + * ) + */ + protected $children; + + /** + * @var Page + * @ORM\ManyToOne(targetEntity="App\Entity\Page" ) + * @ORM\JoinColumn(name="alias_id", referencedColumnName="id", onDelete="SET NULL") + */ + protected $alias; + + /** + * @var Page + * @ORM\ManyToOne(targetEntity="App\Entity\Page", inversedBy="children", cascade="persist" ) + * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="SET NULL") + * @Gedmo\TreeParent + */ + protected $parent; + + /** + * @var ArrayCollection $originals + * @ORM\ManyToMany( + * targetEntity="App\Entity\Page", + * inversedBy="translations", + * cascade={"persist"} + * ) + * @ORM\JoinTable( + * name="page_translation", + * joinColumns={ + * @ORM\JoinColumn(name="translation_id", referencedColumnName="id") + * }, + * inverseJoinColumns={ + * @ORM\JoinColumn(name="original_id", referencedColumnName="id") + * } + * ) + */ + protected $originals; + + /** + * @var ArrayCollection $translations + * @ORM\ManyToMany( + * targetEntity="App\Entity\Page", + * mappedBy="originals", + * cascade={"persist"} + * ) + */ + protected $translations; +} diff --git a/networking/init-cms-bundle/4.0/src/Entity/User.php b/networking/init-cms-bundle/4.0/src/Entity/User.php new file mode 100644 index 00000000..81045b68 --- /dev/null +++ b/networking/init-cms-bundle/4.0/src/Entity/User.php @@ -0,0 +1,40 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + + +namespace App\Entity; + +use Networking\InitCmsBundle\Entity\BaseUser; +use Doctrine\ORM\Mapping as ORM; + +/** + * User + * + * @ORM\Table(name="fos_user_user") + * @ORM\Entity() + */ +class User extends BaseUser{ + + /** + * @var int + * + * @ORM\Column(name="id", type="integer") + * @ORM\Id + * @ORM\GeneratedValue(strategy="AUTO") + */ + protected $id; + + /** + * @var \Networking\InitCmsBundle\Model\AdminSettings + * @ORM\Column(name="admin_settings", type="object", nullable=true) + */ + protected $adminSettings; + +}