<div class="home__favorite"> 
  <div class="home__favorite-inner"> 
 
    {% if is_granted('ROLE_USER') %} 
    {#{% if app.user is not empty and app.user.CustomerFavoriteProducts is not empty and app.user.CustomerFavoriteProducts|length > 0 %}#} 
 
        <h2> 
          見たい授業<span>見たい授業に登録した授業動画一覧</span> 
        </h2> 
 
        <ul class="home__favorite-list"> 
          {% set FavoriteProductMaxCnt = FavoriteProductMaxCnt ?? 6 %} 
          {% set displayedCnt = 0 %} 
          {% for FavoriteProduct in app.user.CustomerFavoriteProducts %} 
            {% set Product = FavoriteProduct.Product %} 
            {% set productClass = Product.ProductClasses.get(0) %} 
            {% set videoContent = productClass.ProductClassContent.get(0) %} 
            {% if videoContent is not empty %} 
              {% set anker = url('video/{product_id}/content/{content_id}', {'product_id': Product.id, 'content_id': videoContent.Content.id}) %} 
            {% else %} 
              {% set anker = url('product_detail', {id: Product.id}) %} 
            {% endif %} 
         
            {% set isFavorite = repository('Eccube\\Entity\\CustomerFavoriteProduct').isFavorite(app.user, Product) %} 
            {% set ProductWords = Product.search_word|split(',') %} 
            {% if displayedCnt < FavoriteProductMaxCnt %} 
              {% set displayedCnt = displayedCnt + 1 %} 
              <li class="home__favorite-item"> 
                <div class="home__favorite-item-inner"> 
                  <div class="home__favorite-img-wrapper"> 
                    <a href="{{ anker }}"> 
                      {% if Product.ProductImage is defined and Product.ProductImage is not empty %} 
                        <img src="{{ asset(Product.ProductImage.get(0), 'save_image') }}" alt="{{ Product.name|trans }}" /> 
                      {% else %} 
                        <img src="{{ asset(''|no_image_product, 'save_image') }}" alt="" /> 
                      {% endif %} 
                    </a> 
                  </div> 
                  <div class="home__favorite-text-wrapper"> 
                    <a href="{{ anker }}" class="home__favorite-title">{{ Product.name|trans }}</a> 
                    <ul class="home__favorite-keyword-list"> 
                      {% for word in ProductWords %} 
                        {% if word is not empty %} 
                        <li class="mod_movie-keyword-item"> 
                          <span>{{ word|trans }}</span> 
                        </li> 
                        {% endif %} 
                      {% endfor %} 
                    </ul> 
                    <div class="home__favorite-btn-wrapper"> 
                      <div class="mod_movie-btn-favorite {{ (isFavorite == 1) ? 'favorite__del': 'favorite__add' }}" data-pid="{{ Product.id }}"> 
                        {#{% if isFavorite %}#} 
                        {#<form action="{{ url('refine_delete_favorite', {id: Product.id}) }}" method="post">#} 
                        {#  <input type="submit" value="{{ '見たい授業'|trans }}" />#} 
                        {#</form>#} 
                        {#{% else %}#} 
                        {#<form action="{{ url('product_add_favorite', {id: Product.id}) }}" method="post">#} 
                        {#  <input type="submit" value="{{ '見たい授業'|trans }}" />#} 
                        {#</form>#} 
                        {#{% endif %}#} 
                        <input type="button" class="favorite-btn" value="{{ '見たい授業'|trans }}" /> 
         
                      </div> 
                      <a href="{{ anker }}" class="home__favorite-btn-watch"><span>{{ '見る'|trans }}</span></a> 
                    </div> 
                  </div> 
                </div> 
              </li> 
            {% endif %} 
          {% endfor %} 
        </ul> 
 
        <div class="home__favorite-btn-more"> 
          <a href="{{ url('product_list') }}">{{ '動画をもっと見る'|trans }}</a> 
        </div> 
 
    {% else %} 
        <a href="{{ url('user_data', {'route':'about'}) }}"> 
            <img src="{{ asset('assets/images/common/favorite_blank_bannar.jpg', 'user_data') }}" alt="50代から始める認知症予防 健康まぁじゃんTVとは" /> 
        </a> 
    {% endif %} 
  </div> 
</div>