Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonata Page Bundle 4 #1440

Merged
merged 2 commits into from
Dec 15, 2022
Merged

Conversation

eerison
Copy link
Contributor

@eerison eerison commented Oct 4, 2022

@github-actions
Copy link

github-actions bot commented Oct 4, 2022

Thanks for the PR 😍

How to test these changes in your application

  1. Define the SYMFONY_ENDPOINT environment variable:

    # On Unix-like (BSD, Linux and macOS)
    export SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1440/index.json
    # On Windows
    SET SYMFONY_ENDPOINT=https://raw.githubusercontent.com/symfony/recipes-contrib/flex/pull-1440/index.json
  2. Install the package(s) related to this recipe:

    composer req 'symfony/flex:^1.16'
    composer req 'sonata-project/page-bundle:^4.0'
  3. Don't forget to unset the SYMFONY_ENDPOINT environment variable when done:

    # On Unix-like (BSD, Linux and macOS)
    unset SYMFONY_ENDPOINT
    # On Windows
    SET SYMFONY_ENDPOINT=

Diff between recipe versions

In order to help with the review stage, I'm in charge of computing the diff between the various versions of patched recipes.
I'm going keep this comment up to date with any updates of the attached patch.

sonata-project/page-bundle

3.9 vs 4.0
diff --git a/sonata-project/page-bundle/3.9/config/packages/sonata_page.yaml b/sonata-project/page-bundle/4.0/config/packages/sonata_page.yaml
index 6268a933..a8991ddc 100644
--- a/sonata-project/page-bundle/3.9/config/packages/sonata_page.yaml
+++ b/sonata-project/page-bundle/4.0/config/packages/sonata_page.yaml
@@ -1,16 +1,15 @@
 sonata_block:
-    context_manager: sonata.page.block.context_manager
     default_contexts: [sonata_page_bundle]
 
 sonata_admin:
     assets:
         extra_javascripts:
-            - bundles/sonatapage/sonata-page.back.min.js
+            - bundles/sonatapage/app.js
         extra_stylesheets:
-            - bundles/sonatapage/sonata-page.back.min.css
+            - bundles/sonatapage/app.css
 
+# https://docs.sonata-project.org/projects/SonataPageBundle/en/4.x/reference/advanced_configuration/
 sonata_page:
-    slugify_service: sonata.page.slugify.cocur
     multisite: host
     use_streamed_response: false
 
@@ -33,6 +32,7 @@ sonata_page:
     ignore_uri_patterns:
         - ^/admin\/   # ignore admin route, ie route containing 'admin'
 
+    #https://docs.sonata-project.org/projects/SonataPageBundle/en/4.x/reference/page_composer/
     default_template: default
     templates:
         default:
@@ -74,9 +74,3 @@ sonata_page:
     catch_exceptions:
         not_found: [404]    # render 404 page with "not_found" key (name generated: _page_internal_error_{key})
         fatal:     [500]    # so you can use the same page for different http errors or specify specific page for each error
-
-    class:
-        page: 'App\Entity\SonataPagePage'
-        snapshot: 'App\Entity\SonataPageSnapshot'
-        block: 'App\Entity\SonataPageBlock'
-        site: 'App\Entity\SonataPageSite'
diff --git a/sonata-project/page-bundle/3.9/config/routes/sonata_page.yaml b/sonata-project/page-bundle/4.0/config/routes/sonata_page.yaml
index 764a52b0..f824032f 100644
--- a/sonata-project/page-bundle/3.9/config/routes/sonata_page.yaml
+++ b/sonata-project/page-bundle/4.0/config/routes/sonata_page.yaml
@@ -1,11 +1,3 @@
-#sonata_page_api:
-#    resource: '@SonataPageBundle/Resources/config/routing/api.xml'
-#    prefix: /
-
-#sonata_page_cache:
-#    resource: '@SonataPageBundle/Resources/config/routing/cache.xml'
-#    prefix: /
-
 sonata_page_exceptions:
     resource: '@SonataPageBundle/Resources/config/routing/exceptions.xml'
     prefix: /
diff --git a/sonata-project/page-bundle/4.0/post-install.txt b/sonata-project/page-bundle/4.0/post-install.txt
new file mode 100644
index 00000000..51058e42
--- /dev/null
+++ b/sonata-project/page-bundle/4.0/post-install.txt
@@ -0,0 +1,13 @@
+ * Your Page is almost ready:
+    1. Generate a migration for Sonata Page Database php bin/console doctrine:migrations:diff
+        
+            If you use Doctrine Attribute Reference, You must change Sonata Entities generated in Entity folder.
+            You can check more details at https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/attributes-reference.html
+
+            You can also use Rector to refactor, check more details at https://getrector.org/blog/how-to-upgrade-annotations-to-attributes
+        
+    2. Apply the migration generated php bin/console doctrine:migrations:migrate --no-interaction
+    3. Create your first site: bin/console sonata:page:create-site --enabled --name=localhost --locale=- --host=localhost --relativePath=- --enabledFrom=now --enabledTo=- --default
+        After you generate your site, You will see few commands to execute to have your Site ready.
+
+  * Read the documentation at https://docs.sonata-project.org/projects/SonataPageBundle/en/4.x/
diff --git a/sonata-project/page-bundle/3.9/src/Entity/SonataPageBlock.php b/sonata-project/page-bundle/4.0/src/Entity/SonataPageBlock.php
index 417e8b47..b7144825 100644
--- a/sonata-project/page-bundle/3.9/src/Entity/SonataPageBlock.php
+++ b/sonata-project/page-bundle/4.0/src/Entity/SonataPageBlock.php
@@ -5,13 +5,11 @@ declare(strict_types=1);
 namespace App\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
-use JMS\Serializer\Annotation as Serializer;
 use Sonata\PageBundle\Entity\BaseBlock;
 
 /**
  * @ORM\Entity
  * @ORM\Table(name="page__block")
- * @ORM\HasLifecycleCallbacks
  */
 class SonataPageBlock extends BaseBlock
 {
@@ -19,63 +17,8 @@ class SonataPageBlock extends BaseBlock
      * @ORM\Id
      * @ORM\Column(type="integer")
      * @ORM\GeneratedValue(strategy="AUTO")
-     * // Serializer\Groups(groups={"sonata_api_read","sonata_api_write","sonata_search"})
      *
      * @var int
      */
     protected $id;
-
-    /**
-     * @ORM\OneToMany(
-     *     targetEntity="App\Entity\SonataPageBlock",
-     *     mappedBy="parent", cascade={"remove", "persist"}, orphanRemoval=true
-     * )
-     * @ORM\OrderBy({"position"="ASC"})
-     *
-     * @var SonataPageBlock[]
-     */
-    protected $children;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPageBlock",
-     *     inversedBy="children"
-     * )
-     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPageBlock
-     */
-    protected $parent;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPagePage",
-     *     inversedBy="blocks", cascade={"persist"}
-     * )
-     * @ORM\JoinColumn(name="page_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPagePage
-     */
-    protected $page;
-
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * @ORM\PrePersist
-     */
-    public function prePersist(): void
-    {
-        parent::prePersist();
-    }
-
-    /**
-     * @ORM\PreUpdate
-     */
-    public function preUpdate(): void
-    {
-        parent::preUpdate();
-    }
 }
diff --git a/sonata-project/page-bundle/3.9/src/Entity/SonataPagePage.php b/sonata-project/page-bundle/4.0/src/Entity/SonataPagePage.php
index b9f2fbdd..eed26221 100644
--- a/sonata-project/page-bundle/3.9/src/Entity/SonataPagePage.php
+++ b/sonata-project/page-bundle/4.0/src/Entity/SonataPagePage.php
@@ -5,13 +5,11 @@ declare(strict_types=1);
 namespace App\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
-use JMS\Serializer\Annotation as Serializer;
 use Sonata\PageBundle\Entity\BasePage;
 
 /**
  * @ORM\Entity
  * @ORM\Table(name="page__page")
- * @ORM\HasLifecycleCallbacks
  */
 class SonataPagePage extends BasePage
 {
@@ -19,95 +17,8 @@ class SonataPagePage extends BasePage
      * @ORM\Id
      * @ORM\Column(type="integer")
      * @ORM\GeneratedValue(strategy="AUTO")
-     * // Serializer\Groups(groups={"sonata_api_read","sonata_api_write","sonata_search"})
      *
      * @var int
      */
     protected $id;
-
-    /**
-     * @ORM\OneToMany(
-     *     targetEntity="App\Entity\SonataPagePage",
-     *     mappedBy="parent", cascade={"persist"}, orphanRemoval=false
-     * )
-     * @ORM\OrderBy({"position"="ASC"})
-     *
-     * @var SonataPagePage[]
-     */
-    protected $children;
-
-    /**
-     * @ORM\OneToMany(
-     *     targetEntity="App\Entity\SonataPageBlock",
-     *     mappedBy="page", cascade={"remove", "persist", "refresh", "merge", "detach"}, orphanRemoval=false
-     * )
-     * @ORM\OrderBy({"position"="ASC"})
-     *
-     * @var SonataPageBlock[]
-     */
-    protected $blocks;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPageSite",
-     *     cascade={"persist"}
-     * )
-     * @ORM\JoinColumn(name="site_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPageSite
-     */
-    protected $site;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPagePage",
-     *     inversedBy="children", cascade={"persist"}
-     * )
-     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPagePage
-     */
-    protected $parent;
-
-    /**
-     * @ORM\OneToMany(
-     *     targetEntity="App\Entity\SonataPagePage",
-     *     mappedBy="target", orphanRemoval=false
-     * )
-     *
-     * @var SonataPagePage[]
-     */
-    protected $sources;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPagePage",
-     *     inversedBy="sources", cascade={"persist"}
-     * )
-     * @ORM\JoinColumn(name="target_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPagePage
-     */
-    protected $target;
-
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * @ORM\PrePersist
-     */
-    public function prePersist(): void
-    {
-        parent::prePersist();
-    }
-
-    /**
-     * @ORM\PreUpdate
-     */
-    public function preUpdate(): void
-    {
-        parent::preUpdate();
-    }
 }
diff --git a/sonata-project/page-bundle/3.9/src/Entity/SonataPageSite.php b/sonata-project/page-bundle/4.0/src/Entity/SonataPageSite.php
index 9d2b688a..7a195aac 100644
--- a/sonata-project/page-bundle/3.9/src/Entity/SonataPageSite.php
+++ b/sonata-project/page-bundle/4.0/src/Entity/SonataPageSite.php
@@ -5,13 +5,11 @@ declare(strict_types=1);
 namespace App\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
-use JMS\Serializer\Annotation as Serializer;
 use Sonata\PageBundle\Entity\BaseSite;
 
 /**
  * @ORM\Entity
  * @ORM\Table(name="page__site")
- * @ORM\HasLifecycleCallbacks
  */
 class SonataPageSite extends BaseSite
 {
@@ -19,30 +17,8 @@ class SonataPageSite extends BaseSite
      * @ORM\Id
      * @ORM\Column(type="integer")
      * @ORM\GeneratedValue(strategy="AUTO")
-     * \\ Serializer\Groups(groups={"sonata_api_read","sonata_api_write","sonata_search"})
      *
      * @var int
      */
     protected $id;
-
-    public function getId()
-    {
-        return $this->id;
-    }
-
-    /**
-     * @ORM\PrePersist
-     */
-    public function prePersist(): void
-    {
-        parent::prePersist();
-    }
-
-    /**
-     * @ORM\PreUpdate
-     */
-    public function preUpdate(): void
-    {
-        parent::preUpdate();
-    }
 }
diff --git a/sonata-project/page-bundle/3.9/src/Entity/SonataPageSnapshot.php b/sonata-project/page-bundle/4.0/src/Entity/SonataPageSnapshot.php
index 9560a863..bbd3637d 100644
--- a/sonata-project/page-bundle/3.9/src/Entity/SonataPageSnapshot.php
+++ b/sonata-project/page-bundle/4.0/src/Entity/SonataPageSnapshot.php
@@ -5,7 +5,6 @@ declare(strict_types=1);
 namespace App\Entity;
 
 use Doctrine\ORM\Mapping as ORM;
-use JMS\Serializer\Annotation as Serializer;
 use Sonata\PageBundle\Entity\BaseSnapshot;
 
 /**
@@ -22,36 +21,8 @@ class SonataPageSnapshot extends BaseSnapshot
      * @ORM\Id
      * @ORM\Column(type="integer")
      * @ORM\GeneratedValue(strategy="AUTO")
-     * // Serializer\Groups(groups={"sonata_api_read","sonata_api_write","sonata_search"})
      *
      * @var int
      */
     protected $id;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPageSite",
-     *     cascade={"persist"}
-     * )
-     * @ORM\JoinColumn(name="site_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPageSite
-     */
-    protected $site;
-
-    /**
-     * @ORM\ManyToOne(
-     *     targetEntity="App\Entity\SonataPagePage",
-     *     cascade={"persist"}
-     * )
-     * @ORM\JoinColumn(name="page_id", referencedColumnName="id", onDelete="CASCADE")
-     *
-     * @var SonataPagePage
-     */
-    protected $page;
-
-    public function getId()
-    {
-        return $this->id;
-    }
 }

@eerison eerison marked this pull request as ready for review October 4, 2022 13:45
@eerison eerison closed this Oct 4, 2022
@eerison eerison reopened this Oct 4, 2022
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 4, 2022 13:53
auto-merge was automatically disabled October 6, 2022 07:21

Head branch was pushed to by a user without write access

@eerison eerison force-pushed the sonata-page_bundle_4 branch from 3923c8c to 1cfac61 Compare October 6, 2022 07:21
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 6, 2022 07:22
@eerison
Copy link
Contributor Author

eerison commented Oct 6, 2022

Hey @jordisala1991

for page bundle works I need to add SonataDoctrineOrmAdminBundle

https://docs.sonata-project.org/projects/SonataPageBundle/en/4.x/reference/installation/

do you know anyway to check if this dependency was added if not ask if the user wants to install?

@eerison eerison requested a review from jordisala1991 October 6, 2022 07:41
@VincentLanglet
Copy link
Contributor

Hey @jordisala1991

for page bundle works I need to add SonataDoctrineOrmAdminBundle

https://docs.sonata-project.org/projects/SonataPageBundle/en/4.x/reference/installation/

do you know anyway to check if this dependency was added if not ask if the user wants to install?

IMHO, it's the user job to require DoctrineORM so you don't need anything else.

@eerison eerison closed this Oct 13, 2022
auto-merge was automatically disabled October 13, 2022 14:57

Pull request was closed

@eerison eerison reopened this Oct 13, 2022
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 13, 2022 14:57
VincentLanglet
VincentLanglet previously approved these changes Oct 13, 2022
jordisala1991
jordisala1991 previously approved these changes Oct 20, 2022
auto-merge was automatically disabled October 26, 2022 07:50

Head branch was pushed to by a user without write access

@eerison eerison dismissed stale reviews from jordisala1991 and VincentLanglet via 3dc3174 October 26, 2022 07:50
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 26, 2022 07:50
auto-merge was automatically disabled October 26, 2022 07:52

Head branch was pushed to by a user without write access

@eerison eerison force-pushed the sonata-page_bundle_4 branch from 3dc3174 to b5ae694 Compare October 26, 2022 07:52
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 26, 2022 07:52
@eerison eerison marked this pull request as draft October 26, 2022 08:08
auto-merge was automatically disabled October 26, 2022 08:08

Pull request was converted to draft

@eerison eerison force-pushed the sonata-page_bundle_4 branch 4 times, most recently from 6d599c4 to 25874df Compare October 26, 2022 08:31
@eerison eerison marked this pull request as ready for review October 26, 2022 08:36
@eerison eerison force-pushed the sonata-page_bundle_4 branch from 25874df to 969b323 Compare October 26, 2022 08:36
@symfony-recipes-bot symfony-recipes-bot enabled auto-merge (squash) October 26, 2022 08:37
@eerison
Copy link
Contributor Author

eerison commented Oct 26, 2022

Screenshot 2022-10-26 at 09 59 04

Hey @VincentLanglet and @jordisala1991 , after the user install Sonata Page bundle, it'll be the next steps to execute to have this working! What do you think?

@VincentLanglet
Copy link
Contributor

That's nice, let see if someone can merge this

@eerison
Copy link
Contributor Author

eerison commented Oct 26, 2022

Screenshot 2022-10-26 at 10 39 54

The current one :D

@eerison
Copy link
Contributor Author

eerison commented Dec 2, 2022

@jordisala1991 could you give your approval again pleases 🙏

@VincentLanglet
Copy link
Contributor

@jordisala1991 could you give your approval again pleases 🙏

He's really busy atm ; and the approval will not really help moving this PR forward.
I think you just need someone with the rights to merge PR in this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants