定制 comsa/sulu-google-reviews-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

comsa/sulu-google-reviews-bundle

Composer 安装命令:

composer require comsa/sulu-google-reviews-bundle

包简介

Sulu bundle to make a connection to the google API and get reviews for your business.

README 文档

README

composer require comsa/facebook-bundle

Setup

Read the following documentation and check if all requirements are met:

  1. https://developers.google.com/my-business/content/prereqs
  2. https://developers.google.com/my-business/content/basic-setup
  3. https://developers.google.com/my-business/content/review-data

Execute:

php bin/console doctrine:schema:update -f

Add the following code to src/DataFixtures/AppFixtures.php:

<?php

namespace App\DataFixtures;

use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use Comsa\SuluGoogleReviewsBundle\DataFixtures\AppSeed as SuluGoogleReviewsAppSeed;

class AppFixtures extends Fixture implements DependentFixtureInterface
{
    public function load(ObjectManager $manager)
    {
    }

    public function getDependencies(): array
    {
        return [
            SuluGoogleReviewsAppSeed::class
        ];
    }
}

Execute:

php bin/console doctrine:fixtures:load --append

Configure Sulu

in config/routes_admin.yaml:

sulu_comsa_google_reviews_admin:
  type: rest
  resource: "@SuluGoogleReviewsBundle/Resources/config/routes/admin.yaml"
  prefix: /admin/google/api

Google Reviews Block Template:

<?xml version="1.0" ?>
<type name="google_reviews" xmlns="http://schemas.sulu.io/template/template"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xsi:schemaLocation="http://schemas.sulu.io/template/template http://schemas.sulu.io/template/template-1.0.xsd">
    <meta>
        <title lang="en">Reviews</title>
        <title lang="nl">Recensies</title>
    </meta>
    <properties>
        <property name="loadType" type="single_select">
            <meta>
                <title lang="en">How do you want to load the reviews?</title>
                <title lang="nl">Hoe wil je de recensies ophalen?</title>
            </meta>

            <params>
                <param name="default_value" value="dynamically"/>

                <param name="values" type="collection">
                    <param name="dynamic">
                        <meta>
                            <title lang="en">Dynamically</title>
                            <title lang="nl">Dynamisch</title>
                        </meta>
                    </param>

                    <param name="static">
                        <meta>
                            <title lang="en">Static reviews</title>
                            <title lang="nl">Vaste recensies</title>
                        </meta>
                    </param>
                </param>
            </params>
        </property>

        <property name="review_selection" type="review_selection" visibleCondition="__parent.loadType == 'static'">
            <meta>
                <title lang="en">Reviews</title>
                <title lang="nl">Recensies</title>
            </meta>
        </property>

        <property name="min_rating" type="single_select" colspan="6" visibleCondition="__parent.loadType == 'dynamic'">
            <meta>
                <title lang="en">Minimum Rating</title>
                <title lang="nl">Minimum Beroordeling</title>
            </meta>

            <params>
                <param name="default_value" value="THREE"/>

                <param name="values" type="collection">
                    <param name="ONE">
                        <meta>
                            <title>1</title>
                        </meta>
                    </param>
                    <param name="TWO">
                        <meta>
                            <title>2</title>
                        </meta>
                    </param>
                    <param name="THREE">
                        <meta>
                            <title>3</title>
                        </meta>
                    </param>
                    <param name="FOUR">
                        <meta>
                            <title>4</title>
                        </meta>
                    </param>
                    <param name="FIVE">
                        <meta>
                            <title>5</title>
                        </meta>
                    </param>
                </param>
            </params>
        </property>
        <property name="amount" type="number" colspan="6" visibleCondition="__parent.loadType == 'dynamic'">
            <meta>
                <title lang="en">Amount of reviews</title>
                <title lang="nl">Aantal recensies</title>
            </meta>
            <params>
                <param name="min" value="0" />
            </params>
        </property>

        <xi:include href="includes/width.xml"/>
    </properties>
</type>

Settings

Settings can be found in the Sulu admin environment. There you can enter your account, location and client url.

Frontend

Google Reviews Template example:

{% if block.loadType == "static" %}
  {% set reviews = block.review_selection %}
{% else %}
  {% set reviews = parse_review_widget(block.amount, app.request.locale, block.min_rating) %}
{% endif %}

<div class="google-reviews">
  <div class="row">
    {% for review in reviews %}
      <div class="col-md-4 my-3">
        <div class="card" style="height: 25rem;">
          <div class="card-title text-center w-100 pt-3">
            {% if review.profilePhoto %}
              <img src="{{ review.profilePhoto }}" alt="{{ review.reviewer }}" title="{{ review.reviewer }}" class="card-img-top img-fluid w-25">
            {% endif %}
          </div>
          <div class="card-body text-center">
            <h3>
              {{ review.reviewer }}
            </h3>
            <div class="d-flex w-100 justify-content-center">
              {% set imgs = get_star_rating(review.starRating) %}
              {% for img in imgs %}
                {{ img|raw }}
              {% endfor %}
            </div>
            <div class="mt-3">
              {% if review.comment %}
                {{ review.comment }}
              {% endif %}
            </div>
          </div>
        </div>
      </div>
    {% endfor %}
  </div>
</div>

Commands

Get reviews:

php bin/console comsa:import:google-reviews

comsa/sulu-google-reviews-bundle 适用场景与选型建议

comsa/sulu-google-reviews-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 comsa/sulu-google-reviews-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 comsa/sulu-google-reviews-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 comsa/sulu-google-reviews-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-13